If it is realistic, it can be cute small improvement.
(map (lambda()(print $idx)) '(1 2 7)) ; 127
How about $idx for map?
-
- Posts: 388
- Joined: Thu May 08, 2008 1:24 am
- Location: Croatia
- Contact:
It would be more idiomatic for $idx to be the position of the current item in the list.
Anyway, it isn't necessary. Use dolist for that.
Code: Select all
(map (fn (x) (list $idx x)) '(1 2 3)) => '((0 1) (1 2) (2 3))
-
- Posts: 388
- Joined: Thu May 08, 2008 1:24 am
- Location: Croatia
- Contact:
Yes, you are right about $idx as position on the list. I was not focused. True, it is not necessary, but it is still small improvement which could provide similar advantage to $idx in other loops, isn't it - if its implementation is equally (time, space, implementation effort) cheap.Jeff wrote:It would be more idiomatic for $idx to be the position of the current item in the list.
Anyway, it isn't necessary. Use dolist for that.Code: Select all
(map (fn (x) (list $idx x)) '(1 2 3)) => '((0 1) (1 2) (2 3))