[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Re: setf'able?

William James

1/22/2016 8:52:00 AM

Pierre Mai wrote:

> (defmacro for-each* (bindings &body body)
> "FOR-EACH* ({(Var Sequence)}+) Declaration* Form*
> Loops over body with the symbols `var' bound to each element of the
> corresponding sequences. The variables are bound in parallel.
> Returns nil."
> (loop for (var seq) in bindings
> collect var into var-list
> collect seq into seq-list
> finally
> (return
> `(map nil (function (lambda (,@var-list) ,@body)) ,@seq-list))))
>
> #|
> ;;; Examples:
>
> * (for-each (x (list 'a 'b 'c)) (print x))
> A
> B
> C
> NIL
> * (for-each* ((x (list 1 2 3)) (y (vector 3 2 1))) (print (+ x y)))
> 4
> 4
> 4
> NIL

MatzLisp (Ruby):

[1,2,3].zip([3,2,1]){|x,y| p x+y}
4
4
4

--
[A]n unholy alliance of leftists, capitalists, and Zionist supremacists has
schemed to promote immigration and miscegenation with the deliberate aim of
breeding us out of existence in our own homelands.... [T]he real aim stays the
same: the biggest genocide in human history.... --- Nick Griffin
(https://www.youtube.com/watch?v=K...)