• Re: Ex. 3.5 in ACL

    From B. Pym@Nobody447095@here-nor-there.org to comp.lang.lisp,comp.lang.scheme on Tue Jun 10 08:06:01 2025
    From Newsgroup: comp.lang.lisp

    B. Pym wrote:

    Zachary Beane wrote:

    (defun mapcar-pos+ (list)
    (let ((i -1))
    (mapcar #'(lambda (elt) (+ elt (incf i)))

    Truly abysmal ignorance or willful stupidity.

    The #' is redundant.


    iteration:

    (defun pos+ (lst)
    (setf acc NIL)
    (setf i 0)
    (dolist (obj lst)
    ; i know, instead of append, i could do a cons and reverse afterwards...
    (progn (setf acc (append acc (list (+ obj i))))
    (setf i (+ i 1))))
    acc)

    I'd prefer LOOP here:

    (defun loop-pos+ (list)
    (loop for i from 0
    for elt in list
    collect (+ elt i)))

    Gauche Scheme:


    (map + '(200 300 400) (lrange 0))

    (200 301 402)


    --- Synchronet 3.21d-Linux NewsLink 1.2