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

    From Hen Hanna@21:1/5 to All on Thu Aug 25 09:01:36 2022
    (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))

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Duffy@21:1/5 to Hen Hanna on Thu Aug 25 23:26:33 2022
    Hen Hanna <henhanna@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).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Hen Hanna@21:1/5 to David Duffy on Wed Sep 7 11:09:50 2022
    On Thursday, August 25, 2022 at 4:26:38 PM UTC-7, David Duffy wrote:
    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).


    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)