William James
4/2/2015 5:23:00 PM
Pascal Costanza wrote:
> David Sletten wrote:
> > Jonathon McKitrick wrote:
> >
> >> I keep saying to myself, 'A-ha! Here's a chance to try a different
> >> variation of mapping.' Then I go to the Hyperspec again, and find
> >> that... once again... it boils down to mapcar.
> >>
> >> The problems I am solving are not that complex at the mapping level.
> >> But I'd be interested in seeing some examples that are more than just
> >> theory, and show uses for the others.
> >>
> >
> > I searched through my code and the only non-contrived use of the rarer
> > maps I found was this:
> > (defun sublists (l)
> > (maplist #'identity l))
> >
> > I suppose nowadays I probably lean towards using LOOP for all but
> > straightforward MAPCAR situations:
> > (defun sublists (l)
> > (loop for cons on l by #'cdr collect cons))
>
> (loop for cons on l collect cons) is sufficient here.
Gauche Scheme:
(use srfi-1)
(pair-fold-right cons '() '(2 3 4))
===>
((2 3 4) (3 4) (4))
For Racket, make this change:
(require srfi/1)
For Larceny, make this change:
(require 'srfi-1)