[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Question about data structures
From: |
divoplade |
Subject: |
Re: Question about data structures |
Date: |
Sun, 22 Nov 2020 20:45:05 +0100 |
User-agent: |
Evolution 3.34.2 |
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))
- Question about data structures, Zelphir Kaltstahl, 2020/11/22
- Re: Question about data structures, Tim Van den Langenbergh, 2020/11/22
- Re: Question about data structures, Taylan Kammer, 2020/11/22
- Re: Question about data structures, Neil Jerram, 2020/11/23
- Re: Question about data structures, Dr. Arne Babenhauserheide, 2020/11/23