[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.lisp

Re: LOOP blows!

William James

1/7/2016 11:50:00 PM

Kaz Kylheku wrote:

> (loop for i from 5 downto 2
> appending (loop for j below i collect j))

Output:

(0 1 2 3 4 0 1 2 3 0 1 2 0 1)


Gauche Scheme:

(use srfi-42 :only (list-ec))
(list-ec
(:range i 5 1 -1)
(:range j i)
j)

===>
(0 1 2 3 4 0 1 2 3 0 1 2 0 1)


MatzLisp (Ruby):

5.downto(2).flat_map{|i| i.times.to_a}
==>[0, 1, 2, 3, 4, 0, 1, 2, 3, 0, 1, 2, 0, 1]


--
If the Union was formed by the accession of States, then the
Union may be dissolved by the secession of States.
--- Daniel Webster, U.S. Senate, February 15, 1833