• Re: concentric loops

    From B. Pym@21:1/5 to Peter Seibel on Thu Sep 12 04:41:56 2024
    XPost: comp.lang.scheme

    Peter Seibel wrote:

    ( 11 12 13 21 22 23 31 32 33)

    I know that in CL plus is replaced by +, but how can I
    handle the mapcar inside the mapcan?

    (loop for x from 10 to 30 by 10 nconcing
    (loop for y from 1 to 3 collect (+ x y)))

    Gauche Scheme

    (use srfi-42) ; list-ec

    (list-ec (:range x 10 31 10) (:range y 1 4) (+ x y))

    ===>
    (11 12 13 21 22 23 31 32 33)

    Shorter:

    (list-ec (: x 10 31 10) (: y 1 4) (+ x y))

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to B. Pym on Thu Sep 12 12:26:44 2024
    XPost: comp.lang.scheme

    On 2024-09-12, B. Pym <[email protected]> wrote:
    Peter Seibel wrote:

    ( 11 12 13 21 22 23 31 32 33)

    I know that in CL plus is replaced by +, but how can I
    handle the mapcar inside the mapcan?

    (loop for x from 10 to 30 by 10 nconcing
    (loop for y from 1 to 3 collect (+ x y)))

    Gauche Scheme

    (use srfi-42) ; list-ec

    (list-ec (:range x 10 31 10) (:range y 1 4) (+ x y))


    (11 12 13 21 22 23 31 32 33)

    Shorter:

    (list-ec (: x 10 31 10) (: y 1 4) (+ x y))

    TXR Lisp:

    [maprod + (range 10 31 10) 1..4]
    (11 12 13 21 22 23 31 32 33)

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @[email protected]

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From B. Pym@21:1/5 to Peter Seibel on Sat Aug 23 11:22:55 2025
    Peter Seibel wrote:

    ( 11 12 13 21 22 23 31 32 33)

    I know that in CL plus is replaced by +, but how can I
    handle the mapcar inside the mapcan?

    (loop for x from 10 to 30 by 10 nconcing
    (loop for y from 1 to 3 collect (+ x y)))

    Using "do" instead of "loop" makes the solution shorter.

    Gauche Scheme

    (do ((x 30 (- x 10))
    (r () (append (map (pa$ + x) (iota 3 1)) r)))
    ((= x 0) r))

    (11 12 13 21 22 23 31 32 33)

    --
    [T]he problem is that lispniks are as cultish as any other devout group and basically fall down frothing at the mouth if they see [heterodoxy].
    --- Kenny Tilton
    The good news is, it's not Lisp that sucks, but Common Lisp. --- Paul Graham

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