• Re: distinction?

    From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp on Sun Jun 22 21:15:07 2025
    From Newsgroup: comp.lang.lisp

    B. Pym wrote:

    Kent M. Pitman wrote:

    Even non-programmers know
    what it means to say "For every setting at the table, make sure the napkin is arranged right".

    This can be expressed functionally in Scheme using map (like mapcar in CL).
    It's not necessary to use iteration.

    But MAP is not good for expressing "For every number from 0 to 9, make sure
    it appears on the phone dial" because Scheme does not provide an object over which one can "map" numeric ranges, as CL's LOOP does.

    Gauche Scheme:

    (define phone-dial '(0 1 2 3 4 5 6 7 8 9))

    (every (cut member <> phone-dial) (iota 10))
    ===>
    (9)

    (every (cut member <> phone-dial) '(2 6 8 22))
    ===>
    #f

    (find (lambda(x) (not (member x phone-dial))) '(2 6 8 22))
    ===>
    22

    (use srfi-1)

    (lset-difference = '(2 6 8 22) phone-dial)
    ===>
    (22)


    Using "is":

    (every (is member phone-dial) (iota 10))


    Given:

    (define is
    (case-lambda
    [(x) (lambda(y) (equal? y x))]
    [(pred x) (lambda(y) (pred y x))]
    [(key pred x) (lambda(y) (pred (key y) x))]))

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp on Thu Jun 26 20:24:59 2025
    From Newsgroup: comp.lang.lisp

    B. Pym wrote:

    Kent M. Pitman wrote:

    I guess my point is that some things "feel" recursive and should be expressed
    recursively. But some things "feel" iterative, and I don't see anything wrong
    with:

    (loop for entry in some-list
    for name = (person-name entry)
    for age = (person-age entry)
    collect (list name age))

    Abysmal.

    (map
    (lambda (entry) (list (person-name entry) (person-age entry)))
    some-list)

    Is it true that users of CL inspired the making of
    the movie "Idiocracy"?


    --- Synchronet 3.21d-Linux NewsLink 1.2