John Connors wrote:
Yet Another Noob Question.
What are the characteristics of each implementation?
How can I tell which I should be writing in what context...
(defun find-indicies (lst tst)
(let ((li 0))
(labels ((qpred (a)
(incf li)
(if (funcall tst a)
(1- li)
nil)))
(remove nil (mapcar #'qpred lst)))))
(defun find-indices (lst tst)
(loop
for el in lst
counting t into index
if (funcall tst el)
collect index))
You are allergic to loop
(defun find-indices (list test)
(loop for element in list
for index from 1
when (funcall test element) collect index))
John Connors wrote:
Yet Another Noob Question.
What are the characteristics of each implementation?
How can I tell which I should be writing in what context...
(defun find-indicies (lst tst)
(let ((li 0))
(labels ((qpred (a)
(incf li)
(if (funcall tst a)
(1- li)
nil)))
(remove nil (mapcar #'qpred lst)))))
(defun find-indices (lst tst)
(loop
for el in lst
counting t into index
if (funcall tst el)
collect index))
You are allergic to loop
(defun find-indices (list test)
(loop for element in list
for index from 1
when (funcall test element) collect index))
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 388 |
Nodes: | 16 (2 / 14) |
Uptime: | 09:58:59 |
Calls: | 8,221 |
Files: | 13,122 |
Messages: | 5,872,631 |