1

This is a Code, which 'removes' duplicates:

(define (positions list)
   (sort (foldl (lambda (x y) (if (not (member? x y)) (append (list x) y) y)) empty list) <))

When I tested this:

(positions (list 3 4 4 5 8 9 4 1 2 9))

I get an error function call: expected function, given: (list 3 4 4 5 8 9 4 1 2 9)

But when I replace (list x) with (cons x '()) it works. Why? Aren't both the same?

jdoe
  • 57
  • 4

0 Answers0