Jochen wrote:
This ...
CL-USER 1 > (loop for i for j in '(a b c) collect (cons i j))
((0 . A) (1 . B) (2 . C))
works perfectly on LispWorks, but not with SBCL
FOR is an unknown keyword in FOR or AS clause in LOOP.
I found a way around it 'for i from 0' but am not sure if there is another smarter way to achieve this.
I think the canonical way would be
(loop for i upfrom 0
for j in '(a b c)
collect (cons i j))
newLISP
(map (curry list $idx) '(a b c))
((0 a) (1 b) (2 c))
Jochen wrote:
This ...
CL-USER 1 > (loop for i for j in '(a b c) collect (cons i j))
((0 . A) (1 . B) (2 . C))
works perfectly on LispWorks, but not with SBCL
FOR is an unknown keyword in FOR or AS clause in LOOP.
I found a way around it 'for i from 0' but am not sure if there is
another smarter way to achieve this.
I think the canonical way would be
(loop for i upfrom 0
for j in '(a b c)
collect (cons i j))
((0 . A) (1 . B) (2 . C))
((0 . A) (1 . B))
((0 . A) (1 . B) (2 . C))
((9 . A) (8 . B) (7 . C))
Jochen wrote:
This ...
CL-USER 1 > (loop for i for j in '(a b c) collect (cons i j))
((0 . A) (1 . B) (2 . C))
works perfectly on LispWorks, but not with SBCL
FOR is an unknown keyword in FOR or AS clause in LOOP.
I found a way around it 'for i from 0' but am not sure if there is another smarter way to achieve this.
I think the canonical way would be
(loop for i upfrom 0
for j in '(a b c)
collect (cons i j))
CL-USER 1 > (loop for i for j in '(a b c) collect (cons i j))
((0 . A) (1 . B) (2 . C))
and, do you really like that code? is it readable?
if I encounter such stuff, i'd yell "WTF??".
I found a way around it 'for i from 0'
as others have noted, canonic way is to use upfrom. for i upfrom 0.
perfectly readable and makes sense for anybody, even if they do not know the language.
Jochen wrote:
This ...
CL-USER 1 > (loop for i for j in '(a b c) collect (cons i j))
((0 . A) (1 . B) (2 . C))
works perfectly on LispWorks, but not with SBCL
FOR is an unknown keyword in FOR or AS clause in LOOP.
I found a way around it 'for i from 0' but am not sure if there is another smarter way to achieve this.
I think the canonical way would be
(loop for i upfrom 0
for j in '(a b c)
collect (cons i j))
newLISP
(map (curry list $idx) '(a b c))
((0 a) (1 b) (2 c))
3. Loop is very powerful, granted, and many people are trying to
argue that "you can do so much with loop that it's unreadable."
This is not an argument.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 65 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 03:11:48 |
| Calls: | 862 |
| Files: | 1,311 |
| D/L today: |
10 files (20,373K bytes) |
| Messages: | 264,422 |