Groups | Search | Server Info | Login | Register


Groups > comp.lang.scheme > #6521

Re: Lis(t|p) comprehensions

From "B. Pym" <Nobody447095@here-nor-there.org>
Newsgroups comp.lang.lisp, comp.lang.scheme
Subject Re: Lis(t|p) comprehensions
Date 2025-07-19 04:18 +0000
Organization A noiseless patient Spider
Message-ID <105f6a5$2i8cc$1@dont-email.me> (permalink)

Cross-posted to 2 groups.

Show all headers | View raw


Frank Buss wrote:

> joswig@corporate-world.lisp.de wrote:
> 
> > For combinations of this kind of stuff I really prefer the functional
> > approach:
> > CL-USER 5 > (remove-if-not 'oddp '(1 2 3))
> > (1 3)
> 
> I know it is possible, but I'm not sure aboout how to write the following
> with a functional approach:
> 
> > (loop for i from 1 to 10 collect (loop for j from 1 to i collect j))
> ((1) (1 2) (1 2 3) (1 2 3 4) (1 2 3 4 5) (1 2 3 4 5 6) (1 2 3 4 5 6 7) (1 2
> 3 4 5 6 7 8) (1 2 3 4 5 6 7 8 9) (1 2 3 4 5 6 7 8 9 10))

Is "map" functional enough?

Gauche Scheme:

(map (cut  iota <> 1) (iota 10 1))

  ===>
((1) (1 2) (1 2 3) (1 2 3 4) (1 2 3 4 5) (1 2 3 4 5 6)
 (1 2 3 4 5 6 7) (1 2 3 4 5 6 7 8) (1 2 3 4 5 6 7 8 9)
 (1 2 3 4 5 6 7 8 9 10))


-- 
[T]he problem is that lispniks are as cultish as any other devout group and
basically fall down frothing at the mouth if they see [heterodoxy].
  --- Kenny Tilton
The good news is, it's not Lisp that sucks, but Common Lisp. --- Paul Graham

Back to comp.lang.scheme | Previous | Next | Find similar


Thread

Re: Lis(t|p) comprehensions "B. Pym" <Nobody447095@here-nor-there.org> - 2025-07-19 04:18 +0000

csiph-web