[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: A critic of Guido's blog on Python's lambda

William James

10/26/2015 6:34:00 PM

Bill Atkins wrote:

> The cool thing about ITERATE is that it lets you express looping
> concepts in a language designed explicitly for such a purpose, e.g.
>
> (iter (for x in '(1 3 3))
> (summing x)) => 7

Why do you have to come up with a name for the elements?
Wouldn't it be easier just to say "Add up the elements"?

Gauche Scheme:

(fold + 0 '(1 3 3))
===>
7


> (iter (for x in '(1 -3 2))
> (finding x maximizing (abs x))) => -3

(use gauche.collection :only (find-max))
(find-max '(1 -3 2) :key abs)
===>
-3


Portable Standard Lisp:

(load useful)

(for (in x '(1 -3 2))
(maximal x (abs x)))
===>
-3

>
> (iter (for x in '(a b c 1 d 3 e))
> (when (symbolp x)
> (collect x))) => (a b c d e)

Why do you have to come up with a name for the elements?
Wouldn't it be easier to say "Keep only the symbols"?

(filter symbol? '(a b c 1 d 3 e))
===>
(a b c d e)

--
They [the Puritans] bored holes through Quakers' tongues with red-hot irons at
Boston, drowned the Baptists at Salem, stripped women and tied them to cart
tails, and whipped them from Boston to Dedham.
--- The Old Guard, March 1863, p. 59
1 Answer

William James

10/29/2015 3:51:00 PM

0

WJ wrote:

> > (iter (for x in '(1 -3 2))
> > (finding x maximizing (abs x))) => -3
>
> (use gauche.collection :only (find-max))
> (find-max '(1 -3 2) :key abs)
> ===>
> -3
>
>
> Portable Standard Lisp:
>
> (load useful)
>
> (for (in x '(1 -3 2))
> (maximal x (abs x)))
> ===>
> -3

MatzLisp (Ruby):

[1,-3,2].max_by &:abs

--
[T]he two races, equally free, cannot live under the same government.
--- Thomas Jefferson