[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: implementing Haskell style flip for Lisp

William James

3/27/2015 4:09:00 AM

> > How does Haskell code typically use the flip code?? I am
> > not sure of its applicable use.
>
> Here's an example,
> CL-USER> (mapcar (bind (flip #'-) 2) (enum-from-to 2 12))
> (0 1 2 3 4 5 6 7 8 9 10)
>
>
> (defun enum-from-to (lo hi)
> (loop for x from lo to hi collect x))
>
> (defun bind (f &rest bound-args)
> #'(lambda (&rest args)
> (apply f (append bound-args args))))
>
> (defun flip (f)
> #'(lambda (&rest args)
> (apply f (reverse args))))

Gauche Scheme:

(map (cut - <> 2) (iota 11 2))

===>
(0 1 2 3 4 5 6 7 8 9 10)


Racket:

(require srfi/26) ; cut
(map (cut - <> 2) (range 2 13))
===>
'(0 1 2 3 4 5 6 7 8 9 10)

Another way:

(map (curryr - 2) (range 2 13))
===>
'(0 1 2 3 4 5 6 7 8 9 10)
1 Answer

yansimon52

11/26/2013 12:36:00 AM

0

Tos lazy bump juzt know how to swallow up other ppl properties wit strong arm tactic...how they swallow the Sime Darby grp....how they dominated genting casino operation...thru a newly formed company known as Resort World....knowing those yearly profits are considered as "haram"....but these allah ppl dont give a dam...they say when come to haram money or fucking tos babi eating chinese chick...allah can wait! They already swallow-up some of robert kwok biz interest.