[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: Yet another Smalltalk or Lisp discussion (Windows Centric

William James

4/12/2015 9:55:00 PM

Rob Warnock wrote:

> | Put it like this. If Lisp had (mabe it has, for all I know)
> | a simple and clear syntax for indicating deferred evaluation...
> +---------------
>
> You mean like these?
>
> > (defmacro thunk (&body body) `(lambda () ,@body))
>
> THUNK
> > (defmacro fn (args &body body) `(lambda ,args ,@body))
>
> FN
> > (mapcar (fn (x y) (+ x y)) '(1 2 3 4) '(0 5 10 15))
>
> (1 7 13 19)
> >

Guache Scheme:

(map (^(x y) (+ (* x y) (/ x y))) '(2 3 4) '(7 8 9))

===>
(100/7 195/8 328/9)


>
> Or if you *insist* on getting all "syntaxy":
>
> > (mapcar #$(+ $1 $2) '(1 2 3 4) '(0 5 10 15))
>
> (1 7 13 19)

(map (cut / 288 <> <>) '(2 3 4) '(7 8 9))
===>
(144/7 12 8)

To use cut in Racket:

(require srfi/26)