• Re: Looping over array.

    From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp,comp.lang.scheme on Sat Jul 5 13:51:29 2025
    From Newsgroup: comp.lang.scheme

    Christopher Browne wrote:

    (loop with array = #(1 4 9 16 "Foo" "Bar" 'frobozz |Bogomatic|)
    for i across array
    for j from 0 by 1
    do
    (format t "Element ~D is ~A~%" j i))
    Element 0 is 1
    Element 1 is 4
    Element 2 is 9
    Element 3 is 16
    Element 4 is Foo
    Element 5 is Bar
    Element 6 is 'FROBOZZ
    Element 7 is Bogomatic

    We can make it shorter by using a Lispy language instead of CL.

    Gauche Scheme

    (use srfi-43) ;; vector-for-each

    (vector-for-each
    (cut print "Element " <> " is " <>)
    #(1 4 9 16 "Foo" "Bar" 'frobozz |Bogomatic|))

    Element 0 is 1
    Element 1 is 4
    Element 2 is 9
    Element 3 is 16
    Element 4 is Foo
    Element 5 is Bar
    Element 6 is 'frobozz
    Element 7 is Bogomatic


    Another vector library.

    (use scheme.vector)

    (vector-for-each-with-index
    (cut print "Element " <> " is " <>)
    #(1 4 9 16 "Foo" "Bar" 'frobozz |Bogomatic|))
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Schol-R-LEA@alicetrillianosako@gmail.com to comp.lang.scheme on Sat Jul 5 10:44:26 2025
    From Newsgroup: comp.lang.scheme

    B. Pym, I am confused. Is your goal to promote Scheme, or to mock the
    Scheme community by making us look petulant and spiteful? Because if
    your goal is the former, well, you are doing an excellent job of the latter.

    B. Pym:
    Christopher Browne wrote:

    (loop with array = #(1 4 9 16 "Foo" "Bar" 'frobozz |Bogomatic|)
    for i across array
    for j from 0 by 1
    do
    (format t "Element ~D is ~A~%" j i))
    Element 0 is 1
    Element 1 is 4
    Element 2 is 9
    Element 3 is 16
    Element 4 is Foo
    Element 5 is Bar
    Element 6 is 'FROBOZZ
    Element 7 is Bogomatic

    We can make it shorter by using a Lispy language instead of CL.

    Gauche Scheme

    (use srfi-43) ;; vector-for-each

    (vector-for-each
    (cut print "Element " <> " is " <>)
    #(1 4 9 16 "Foo" "Bar" 'frobozz |Bogomatic|))

    Element 0 is 1
    Element 1 is 4
    Element 2 is 9
    Element 3 is 16
    Element 4 is Foo
    Element 5 is Bar
    Element 6 is 'frobozz
    Element 7 is Bogomatic


    Another vector library.

    (use scheme.vector)

    (vector-for-each-with-index
    (cut print "Element " <> " is " <>)
    #(1 4 9 16 "Foo" "Bar" 'frobozz |Bogomatic|))

    --- Synchronet 3.21a-Linux NewsLink 1.2