[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: LAMBDA abbreviations

William James

7/26/2015 6:55:00 PM

Rob Warnock wrote:

> Heh! Funny you should mention. The most successful (so far) of
> my many attempts at coming up with a usable reader macro shorthand
> for LAMBDA provides implicitly-declared parameters with names of
> $1, $2, &c., like a shell script. [The choice of "#$" as the reader
> macro is supposed to be a reminder of that.] It's too ugly and
> non-standard for code you might ever want to release to others,
> but on the other hand it's sometimes kinda convenient if you're
> just messing around interactively:
>
> > (mapcar #$(* $1 3) '(1 8 4 2))
> (3 24 12 6)

Gauche Scheme:

gosh> (map (cut * 3 <>) '(1 8 4 2))
(3 24 12 6)
gosh> (map (pa$ * 3) '(1 8 4 2))
(3 24 12 6)

> > (mapcar #$(cons $2 (1+ $1)) '(1 8 4 2) '(bill joe sally ted))
> ((BILL . 2) (JOE . 9) (SALLY . 5) (TED . 3))
> > (remove-if #$(char= #\L (char (symbol-name $1) 2))
> '(bill joe sally ted))
> (JOE TED)
> >
>
>
> -Rob
>
> p.s. Another flavor I tried, but never found as convenient
> [since you still have to type the whole parameter list] was:
>
> > (mapcar #[(x y) (cons y (1+ x))] '(1 8 4 2) '(bill joe sally ted))
> ((BILL . 2) (JOE . 9) (SALLY . 5) (TED . 3))

gosh> (map (^(x y) (cons y (+ 1 x))) '(1 8 4 2) '(bill joe sally ted))
((bill . 2) (joe . 9) (sally . 5) (ted . 3))

--
As more and more power gravitates in the capital, the more vital it becomes for
the corporate America to secure its interests by corrupting that seat of power.
www.kolumbus.fi/aquilon/america-middle-class-and-the-end-of-growth.htm
1 Answer

William James

5/28/2016 6:55:00 AM

0

WJ wrote:

> > p.s. Another flavor I tried, but never found as convenient
> > [since you still have to type the whole parameter list] was:
> >
> > > (mapcar #[(x y) (cons y (1+ x))] '(1 8 4 2) '(bill joe sally ted))
> > ((BILL . 2) (JOE . 9) (SALLY . 5) (TED . 3))
>
> gosh> (map (^(x y) (cons y (+ 1 x))) '(1 8 4 2) '(bill joe sally ted))
> ((bill . 2) (joe . 9) (sally . 5) (ted . 3))

OCaml:

List.map2 (fun n s -> s,n+1) [1;8;4;2] ["bill";"joe";"sally";"ted"] ;;

[("bill", 2); ("joe", 9); ("sally", 5); ("ted", 3)]

--
In Sweden one liberal newspaper editor responded to the latest polling triumphs
by the ... Sweden Democrats party by saying that he would be happy to flood
Sweden with Islamic State fighters to punish the ... electorate for voting
for the Sweden Democrats.... [M]ost media in Sweden is Jewish-owned...
theoccidentalobserver.net/2015/11/douglas-murrays-warning-to-the-jewish-community