Kaz Kylheku
10/26/2015 8:48:00 PM
On 2015-10-26, WJ <w_a_x_man@yahoo.com> wrote:
> Pascal Bourguignon wrote:
>
>> Let's say we want a function that takes a list ( ... i ...) of numbers
>> as argument and return a form like:
>>
>> (list (+ 3 4) ... (+ i i) ... (- 4 3))
>>
>> How can we write such a function?
>>
>> (defun fun-test-2 (list)
>> (append
>> (list (quote list) (quote (+ 3 4)))
>> (mapcar (lambda (i) (list (quote +) i i)) list)
>> (list (quote (- 4 3)))))
>>
>> Let's try it:
>>
>> (fun-test-2 '(10 20 30 40 50))
>> --> (LIST (+ 3 4) (+ 10 10) (+ 20 20) (+ 30 30) (+ 40 40) (+ 50 50) (- 4 3))
>
> Gauche Scheme:
>
> (define (fun-test-2 items)
> `(list (+ 3 4) ,@(map (^x (list '+ x x)) items) (- 4 3)))
Reminds me of the time, not so long ago, you posted:
Gauche Scheme:
(dotimes ...)
Nope, no quasiquotes or dotimes in Common Lisp.
ISTR that your (dotimes ...) form executed vebatim in a CL listener.
By the way, what is wrong with `(list + ,x ,x)? It's shorter by character
count 'n' everything.