• Re: help me with starting this in files

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

    Pascal Bourguignon wrote:

    muhaid@gmail.com writes:
    Write Lisp functions to do the following.


    ;; 5.(10) Write a function f that takes a list and returns a list where
    ;; each element (symbol, number, or list) e of the original list is
    ;; changed to (e dot). For example, (f '(a (b) c)) return ((a dot)
    ;; ((b) dot) (c dot)). Note that you only need one statement in f and it
    ;; has to use mapcar and lambda (for an anonymous function you have to
    ;; define).

    (defun f (l)
    (loop for e in l collect (list e 'dot) into res
    finally (return (mapcar (lambda (x) x) res))))

    Gauche Scheme

    (map (lambda(x) (list x 'dot)) '(a (b) c))

    ===>
    ((a dot) ((b) dot) (c dot))

    Shorter:

    (map (^x (list x 'dot)) '(a (b) c))

    Another way:

    (map (cut list <> 'dot) '(a (b) c))
    --
    [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 (05 Dec 2004)
    --- Synchronet 3.21a-Linux NewsLink 1.2