Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #318: Your EMAIL is now being delivered by the USPS.


comp / comp.lang.lisp / Re: how to map a variable to a list?

SubjectAuthor
o Re: how to map a variable to a list?steve

1
Subject: Re: how to map a variable to a list?
From: steve
Newsgroups: comp.lang.lisp
Organization: 
Date: Fri, 19 Apr 2024 22:14 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!border-3.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 19 Apr 2024 22:14:19 +0000
From: sgonedes1977@gmail.com (steve)
Newsgroups: comp.lang.lisp
Subject: Re: how to map a variable to a list?
References: <u111j3$26d7d$1@dont-email.me> <O5sf1cOqAlzNMgIN7@bongo-ra.co>
Date: Fri, 19 Apr 2024 18:14:18 -0400
Message-ID: <87bk6580g5.fsf@gmail.com>
Organization: 
User-Agent: Gnus/5.13 (Gnus v5.13)
Cancel-Lock: sha1:XjtrKL89Hub9zVcBHOPnwsx9eI8=
MIME-Version: 1.0
Content-Type: text/plain
Lines: 45
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-sICnUAArwJ/MxVMfoyuZS7cuTSMStYwcSbWTBUCpxxPNZgVqNBuNkS61LKMcc9hWsjvaRR8T8X3iexw!Gp9D4L2r+9lBAHJ/8ZJHzKfkuXM1OozhRT1W7fbYQknR4A==
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
View all headers

Spiros Bousbouras <spibou@gmail.com> writes:

< On Mon, 10 Apr 2023 21:05:23 +0800
< Jinsong Zhao <jszhao@yeah.net> wrote:
>> Hi there,
>>
>> In the following code example,
>>
>> (defun a-test (lst)
>> (let ((a (elt lst 0))
>> (b (elt lst 1))
>> (c (elt lst 2)))
>> (+ a (- c b))))
>>
>> How to map local variable a, b, and c to the elements of lst? In my
>> actual code, the lst have 12 elements, and I have 12 named local
>> variables that appeared in the body with high frequency.

< Why is the above code not satisfactory ?

no idea, works for me.

(defun a-test (lst)
(let ((a (pop lst))
(b (pop lst))
(c (pop lst)))
(+ a (- c b))))

(a-test '(3 5 7))

(defun a-test2 (lst)
(let ((a (elt lst 0))
(b (elt lst 1))
(c (elt lst 2)))
(+ a (- c b))))

(a-test2 '(1 4 7))

show the code? might be helpful. 12 variables can be done with reduce
mapcar, depending on the operation.

1

rocksolid light 0.9.8
clearnet tor