William James
12/1/2015 7:11:00 AM
WJ wrote:
> Erik Naggum wrote:
>
> > > Is there any function or macro defined by Common Lisp that does the
> > > following?
> > :
> > > Here is its fictional documentation:
> > >
> > > (map-by VARLIST LIST &rest BODY)
> > >
> > > A macro returning a list created by binding successive N elements of LIST
> > > to the symbols in VARLIST (where N is the length of VARLIST) and
> > > executing BODY each time around. The return value of BODY is used as each
> > > element of the return list.
> >
> > the much undeservedly maligned extended LOOP macro does this for me
> > whenever I need the above, which is only when processing property lists:
> >
> > (loop
> > for (key value) on <plist> by #'cddr
> > collect (<whatever> key value))
Ocaml:
let rec loop = function
k::v::rest -> k+v :: loop rest
| x -> x
in loop [2;20;3;30];;
===>
[22; 33]
--
[Y]ou can never fix a decaying empire; the empire can only fall when the time
comes. You cannot fix the empire by sending good and honest men to the capital,
because the simple logic of the system corrupts everyone along the way.
www.kolumbus.fi/aquilon/america-middle-class-and-the-end-of-growth.htm