Hello Zelphir!

Le dimanche 22 novembre 2020 à 19:48 +0100, Zelphir Kaltstahl a écrit :
> However, when I use the list in
> reverse and ever need to output the lines in the list in their
> original
> order, I would first need to `reverse` the list again.
There is a "reverse" function; you could implement it yourself as a
tail-recursive function if you wanted (it's currently implemented in C,
so my guess is it's even more efficient). You don't need vectors for
that.

(define (my-reverse-aux accumulation list)
  (if (null? list)
      accumulation
      (my-reverse-aux (cons (car list) accumulation) (cdr list))))

(define (my-reverse list)
  (my-reverse-aux '() list))

(my-reverse '(a b c d e f g h))


Reply via email to