[plt-scheme] mreverse!

From: Eli Barzilay (eli at barzilay.org)
Date: Sat Jan 24 16:22:46 EST 2009

On Jan 24, praimon wrote:
> Okay, so I definitely don't understand the point of mreverse!
> How is it different from
> (define mreverse!
>     (lambda (l)
>       (let ([rev (mreverse l)])
>         (set-mcdr! l null)
>         rev)))

You need to see the structure of all pairs in the list.  Try this

  (define d (mcons 4 '()))
  (define c (mcons 3 d))
  (define b (mcons 2 c))
  (define a (mcons 1 b))

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.