Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Good news. Ten weeks from Friday will be a pretty good day.


comp / comp.lang.lisp / Re: [Newbie] passing keyword argument

SubjectAuthor
* Re: [Newbie] passing keyword argumentB. Pym
`- Re: [Newbie] passing keyword argumentKaz Kylheku

1
Subject: Re: [Newbie] passing keyword argument
From: B. Pym
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Thu, 18 Jul 2024 07:39 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: [Newbie] passing keyword argument
Date: Thu, 18 Jul 2024 07:39:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <v7agr4$2am53$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Injection-Date: Thu, 18 Jul 2024 09:39:18 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="8e507d2f4c44ea84c4d5df38107e66f0";
logging-data="2447523"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18rrqCjtZJCHVppeVCV7u2/"
User-Agent: XanaNews/1.18.1.6
Cancel-Lock: sha1:t02RkFAsVr3VaRK4j6F8FPZkHYo=
View all headers

Carl Taylor wrote:

> Here's a LOOP version of an index constructor.
>
> (defun make-index-list (obj seq &key (test #'eql))
> (loop for p = (position obj seq :test test :start (if p (1+ p) 0))
> while p
> collect p))
>
> (compile *)
>
> CL-USER 18 >
> (make-index-list
> '(0 1)
> '(a (6 2 z) (0 1) (1 2 3 4) (q w e r t y) (0 1) (foo) bar)
> :test #'equal)
>
> (2 5)

Gauche Scheme

(define (make-index-list obj seq :optional (test equal?))
(filter-map
(lambda(x i) (and (test obj x) i))
seq
(lrange 0)))

(make-index-list
'(0 1)
'(a (6 2 z) (0 1) (1 2 3 4) (q w e r t y) (0 1) (foo) bar))

===>
(2 5)

Subject: Re: [Newbie] passing keyword argument
From: Kaz Kylheku
Newsgroups: comp.lang.lisp
Organization: A noiseless patient Spider
Date: Fri, 19 Jul 2024 17:25 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 643-408-1753@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.lisp
Subject: Re: [Newbie] passing keyword argument
Date: Fri, 19 Jul 2024 17:25:45 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <20240719102409.76@kylheku.com>
References: <v7agr4$2am53$1@dont-email.me>
Injection-Date: Fri, 19 Jul 2024 19:25:45 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="329fa895c5d6908477a80b789f62a073";
logging-data="3237795"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mxuqx6FyjA0jpWnfjqvXYFB2nxi6opME="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:gfBlvT0S+LauKWcER029KxtdCsU=
View all headers

On 2024-07-18, B. Pym <Nobody447095@here-nor-there.org> wrote:
> Carl Taylor wrote:
>
>> Here's a LOOP version of an index constructor.
>>
>> (defun make-index-list (obj seq &key (test #'eql))
>> (loop for p = (position obj seq :test test :start (if p (1+ p) 0))
>> while p
>> collect p))
>>
>> (compile *)
>>
>> CL-USER 18 >
>> (make-index-list
>> '(0 1)
>> '(a (6 2 z) (0 1) (1 2 3 4) (q w e r t y) (0 1) (foo) bar)
>> :test #'equal)
>>
>> (2 5)
>
> Gauche Scheme
>
> (define (make-index-list obj seq :optional (test equal?))
> (filter-map
> (lambda(x i) (and (test obj x) i))
> seq
> (lrange 0)))
>
> (make-index-list
> '(0 1)
> '(a (6 2 z) (0 1) (1 2 3 4) (q w e r t y) (0 1) (foo) bar))
>
> ===>
> (2 5)

This is the TXR Lisp interactive listener of TXR 295.
Quit with :quit or Ctrl-D on an empty line. Ctrl-X ? for cheatsheet.
TXR's no-spray organic production means every bug is carefully removed by hand.
1> (where (op equal '(0 1)) '(a (6 2 z) (0 1) (1 2 3 4)
(q w e r t y) (0 1) (foo) bar))
(2 5)

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

1

rocksolid light 0.9.8
clearnet tor