[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

returning a freshly allocated list?

According to the specification, merge should return a *freshly* *allocated* list as its result.

But the reference implementation is:
(define (merge a b less? . opt-key)
  (define key (if (null? opt-key) identity (car opt-key)))
  (cond ((null? a) b)
	((null? b) a)...which is trying to avoid allocating as much as possible.

Solution: either remove the "freshly allocated" requirement in the specification, or to use (map identity lst) where needed in the reference implementation.