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