Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #191: Just type 'mv * /dev/null'.


comp / comp.lang.lisp / Re: YANQ - When to map, when to iterate, when to recurse? And why CLOS?

SubjectAuthor
o Re: YANQ - When to map, when to iterate, when to recurse? And why CLOS?B. Pym

1
Subject: Re: YANQ - When to map, when to iterate, when to recurse? And why CLOS?
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Mon, 19 Aug 2024 07:20 UTC
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Nobody447095@here-nor-there.org (B. Pym)
Newsgroups: comp.lang.lisp
Subject: Re: YANQ - When to map, when to iterate, when to recurse? And why CLOS?
Date: Mon, 19 Aug 2024 07:20:00 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <v9urmt$2pj9b$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Mon, 19 Aug 2024 09:20:01 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="9810b1c7a97d7b87e5fd6bb09612219a";
logging-data="2936107"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/pNC3KwPynJ6p88Cn4Vmcs"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:uAYJvW447I16mcH1AU5HDILkZwQ=
View all headers

Wade Humeniuk wrote:

> 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))

newLISP

(define (find-indices lst test)
(index test lst))

(find-indices '(200 209 250 257 260 263) odd?)
===>
(1 3 5)

1

rocksolid light 0.9.8
clearnet tor