Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 23 |
Nodes: | 6 (0 / 6) |
Uptime: | 52:39:54 |
Calls: | 583 |
Files: | 1,139 |
D/L today: |
179 files (27,921K bytes) |
Messages: | 111,617 |
Kenny Tilton wrote:
KMP: The example you cite is quite simplistic.....snip...A
loop like this:
(loop for x from 0
for y in some-list
when (good-result? y)
collect (list x y))
is easy to write and maintain, and much easier to explain than the equivalent, but more Lispy:
(do ((x 0 (+ x 1))
(y-list some-list (cdr y-list))
(result '()))
((null y-list) ;; [fixed]
(nreverse result))
(let ((y (first y-list)))
(when (good-result? y)
(push (list x y) result))))
Ugh. Howse about:
(let ((goody-pos -1)
goodies)
(dolist (it some-list (nreverse goodies))
(incf goody-pos)
(when (good-result? it)
(push (list goody-pos it) goodies))))
perhaps i will be swayed someday by the charms of loop, but i gotta
tell you, i just don't get it. is loop for people who can't read lisp? can't be, lisp is easier to read than loop. stumped.
Gauche Scheme:
(use gauche.collection) ;; size-of
(filter-map
(lambda (x i)
(and (> (size-of x) 1) (list i x)))
'("a" "or" "I" "can" "o" "burn")
(liota))
===>
((1 "or") (3 "can") (5 "burn"))