Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

(list-ref list k) ------- ( 0-index awkwardness)

19 views
Skip to first unread message

Hen Hanna

unread,
Aug 25, 2022, 12:01:39 PM8/25/22
to
(list-ref list k) ------- ( 0-index awkwardness) , R7RS

(i guess this problem is the same with Common Lisp's Nth and Elt.)

in the following code ,
--- Print the 10th element (in the list),
--- Print the 20th element,
--- Print the 30th element,
--- Print the 40th element,
--- Print the 50th element

came out a bit awkward.... How do ppl usually deal with it ?


________________
(define (print x) (write x) (newline))

(define a '(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50))

(print a) (print (length a))
(print (list-ref a 9))
(print (list-ref a 19))
(print (list-ref a 29))
(print (list-ref a 39))
(print (list-ref a 49))

David Duffy

unread,
Aug 25, 2022, 7:26:38 PM8/25/22
to
Hen Hanna <henh...@gmail.com> wrote:
> (list-ref list k) ------- ( 0-index awkwardness) , R7RS
> (i guess this problem is the same with Common Lisp's Nth and Elt.)
> in the following code ,
> --- Print the 10th element (in the list),
> --- Print the 20th element,
see Xlispstat list-select and Lisp-Stat select (and iota).

Hen Hanna

unread,
Sep 7, 2022, 2:09:52 PM9/7/22
to
thanks.... i often don't use Iota because it's not in R7RS proper

https://quickref.common-lisp.net/lisp-stat.html

Lisp-Stat seems to be a library for Common Lisp

0 new messages