Rocksolid Light

Welcome to Rocksolid Light

mail  files  register  newsreader  groups  login

Message-ID:  

GIVE: Support the helpless victims of computer error.


devel / comp.lang.lisp / Can someone help me fix a basic recursive function

SubjectAuthor
* Can someone help me fix a basic recursive functionME Jones
+* Re: Can someone help me fix a basic recursive functionST
|`- Re: Can someone help me fix a basic recursive functionSpiros Bousbouras
+* Re: Can someone help me fix a basic recursive functionPaul Rubin
|+- Re: Can someone help me fix a basic recursive functionSpiros Bousbouras
|`- Re: Can someone help me fix a basic recursive functionBen Bacarisse
+- Re: Can someone help me fix a basic recursive functionSpiros Bousbouras
`- Re: Can someone help me fix a basic recursive functionTom Russ

1
Can someone help me fix a basic recursive function

<d088e62b-7798-4d56-b8c2-5de08acc10e8n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3441&group=comp.lang.lisp#3441

  copy link   Newsgroups: comp.lang.lisp
X-Received: by 2002:a0c:ecc8:0:b0:4c6:91f9:9dff with SMTP id o8-20020a0cecc8000000b004c691f99dffmr3776191qvq.103.1669091528574;
Mon, 21 Nov 2022 20:32:08 -0800 (PST)
X-Received: by 2002:a05:6830:2b2b:b0:66c:52d6:50c8 with SMTP id
l43-20020a0568302b2b00b0066c52d650c8mr11583714otv.200.1669091528336; Mon, 21
Nov 2022 20:32:08 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.lisp
Date: Mon, 21 Nov 2022 20:32:08 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=67.185.73.248; posting-account=z6W7sQoAAADU1WINpl0JBaSWNNUw5WQ0
NNTP-Posting-Host: 67.185.73.248
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d088e62b-7798-4d56-b8c2-5de08acc10e8n@googlegroups.com>
Subject: Can someone help me fix a basic recursive function
From: markjones@shawday.com (ME Jones)
Injection-Date: Tue, 22 Nov 2022 04:32:08 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1456
 by: ME Jones - Tue, 22 Nov 2022 04:32 UTC

Hello,
I am trying to create the following recursive function:

Example: (doubleodd '(1 2 3 4 5)) -> (2 2 6 4 10)

(defun doubleodd (list)
(when list
(if (oddp (car list)) (setf (car list) (* (car list) 2)))
(doubleodd (cdr list))
)
)

When i evaluate i am not getting back a list and it's missing some values in the list. What am i doing wrong?

(doubleodd '(1 2 3 4 5))

evaluates to:
26410
NIL

Thank you for your help.
Mark

Re: Can someone help me fix a basic recursive function

<tlho6p$1i0r$1@dont-email.me>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3442&group=comp.lang.lisp#3442

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: usenet.233ph@slmail.me (ST)
Newsgroups: comp.lang.lisp
Subject: Re: Can someone help me fix a basic recursive function
Date: Tue, 22 Nov 2022 05:54:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <tlho6p$1i0r$1@dont-email.me>
References: <d088e62b-7798-4d56-b8c2-5de08acc10e8n@googlegroups.com>
Reply-To: usenet.233ph@slmail.me
Injection-Date: Tue, 22 Nov 2022 05:54:33 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="8b16de5e26c04878815b3f92ec50420f";
logging-data="51227"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/6bHHwzmYjREILLWsq86aF9hMko7LksK4="
User-Agent: slrn/1.0.3 (Darwin)
Cancel-Lock: sha1:JVh7yVDp5GovtUiT5dX/i8SVk50=
 by: ST - Tue, 22 Nov 2022 05:54 UTC

On 2022-11-22, ME Jones <markjones@shawday.com> wrote:
> Hello,
> I am trying to create the following recursive function:
>
> Example: (doubleodd '(1 2 3 4 5)) -> (2 2 6 4 10)
>
> (defun doubleodd (list)
> (when list
> (if (oddp (car list)) (setf (car list) (* (car list) 2)))
> (doubleodd (cdr list))
> )
> )
>
> When i evaluate i am not getting back a list and it's missing some values in the list. What am i doing wrong?

(defun doubleodd (l)
(if (null l)
nil
(if (oddp (car l))
(cons (* 2 (car l)) (doubleodd (cdr l)))
(cons (car l) (doubleodd (cdr l))))))

In a recursive function with a list, 2 important things to remember:

you apply the function on the car of the list then your recursive call
goes on the cdr.

Once the list is null, you return a nil to end the recursion.

Lisp is mostly a functional language, avoid the usage of (setf) inside
a function unless it's to change the value of a lexical
variable. Otherwise, you function is called destructive.

2 books to read absolutely to understand Lisp and its philosophy:

Ansi Common Lisp
On Lisp

Both from Paul Graham. The second one is not printed anymore, but
available at low cost from lulu.com

>
> (doubleodd '(1 2 3 4 5))
>
> evaluates to:
> 26410
> NIL
>
> Thank you for your help.
> Mark

Re: Can someone help me fix a basic recursive function

<8735ab1iqf.fsf@nightsong.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3443&group=comp.lang.lisp#3443

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: no.email@nospam.invalid (Paul Rubin)
Newsgroups: comp.lang.lisp
Subject: Re: Can someone help me fix a basic recursive function
Date: Tue, 22 Nov 2022 00:44:24 -0800
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <8735ab1iqf.fsf@nightsong.com>
References: <d088e62b-7798-4d56-b8c2-5de08acc10e8n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="81d9dc1e7acd10ee3590cb89caced2c3";
logging-data="72442"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19OY01/Uthok3kn3GEXFwb8"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:6Ph251AFp6hG0pZKmcJOuMmowQU=
sha1:y6uKLFY11ltURDM/+hF+4JWaHU4=
 by: Paul Rubin - Tue, 22 Nov 2022 08:44 UTC

ME Jones <markjones@shawday.com> writes:
> I am trying to create the following recursive function:
> Example: (doubleodd '(1 2 3 4 5)) -> (2 2 6 4 10)

I would first break this out into a function that conditionally doubles
a single number:

(defun double-odd-1 (n)
(cond ((oddp n) (+ n n))
(t n)))

and then a tail-recursive function that applies DOUBLE-ODD-1 to each
element of a list, consing it up into a new list that is in reverse
order. Then, at the end, reverse the new list "in place" using
nreverse:

(defun double-odd (xs &optional acc)
(defun f (n) (+ n n))
(cond ((null xs) (nreverse acc))
(t (double-odd (cdr xs) (cons (double-odd-1 (car xs)) acc)))))

Using an accumulation parameter allows the recursive call to be the
function's final value, which means the compiler can actually turn it
into a simple jump rather than pushing one level deeper into a stack on
every call. That is kind of a lame explanation, but it is a very
important idiom in functional programming, so you should probably spend
some time studying it to understand it, e.g. by doing a web search on
"tail recursion" and looking at explanations in the results.

Pure functional style would also prefer using reverse instead of
nreverse, but using nreverse this way is a Common Lisp idiom.

Finally, notice that the pattern of creating a new list by applying some
function to every element of an old list is very common, and CL (and
related languages) usually have a built-in for it, called some variant
of "map". In CL's case, that function is called MAPCAR, so you would
simply write:

(defun double-odd (xs)
(mapcar #'double-odd-1 xs))

where DOUBLE-ODD-1 is as defined above.

Re: Can someone help me fix a basic recursive function

<h4eUsC6VK7qVIoHqv@bongo-ra.co>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3444&group=comp.lang.lisp#3444

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: Can someone help me fix a basic recursive function
Date: Tue, 22 Nov 2022 12:46:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <h4eUsC6VK7qVIoHqv@bongo-ra.co>
References: <d088e62b-7798-4d56-b8c2-5de08acc10e8n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 22 Nov 2022 12:46:16 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="3ab888a9ecc63ea627a0e8efd3051d1c";
logging-data="113772"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/5qHq3AcyVDL9veG81I/21"
Cancel-Lock: sha1:ZKbYs2HJ2LmvY1CTqr0Ly+dIDj8=
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
In-Reply-To: <d088e62b-7798-4d56-b8c2-5de08acc10e8n@googlegroups.com>
 by: Spiros Bousbouras - Tue, 22 Nov 2022 12:46 UTC

On Mon, 21 Nov 2022 20:32:08 -0800 (PST)
ME Jones <markjones@shawday.com> wrote:
> Hello,
> I am trying to create the following recursive function:
>
> Example: (doubleodd '(1 2 3 4 5)) -> (2 2 6 4 10)
>
> (defun doubleodd (list)
> (when list
> (if (oddp (car list)) (setf (car list) (* (car list) 2)))
> (doubleodd (cdr list))
> )
> )
>
> When i evaluate i am not getting back a list and it's missing some values
> in the list. What am i doing wrong?
>
> (doubleodd '(1 2 3 4 5))
>
> evaluates to:
> 26410
> NIL

Others have explained what you're doing wrong but I'm wondering in which
implementation (doubleodd '(1 2 3 4 5)) returns 26410 .I tried clisp
and SBCL and the code just returns NIL which is what I would have expected.
No matter what happens earlier , the recursion will terminate by calling
doubleodd with argument NIL .Try the following modified version and study
its output.

(defun doubleodd2 (list &aux ret)
(format t "Received ~S~%" list)
(when list
(if (oddp (car list)) (setf (car list) (* (car list) 2)))
(setq ret (doubleodd (cdr list)))
(format t "Got back ~S~%" ret)
ret))
--
And my personal favourite - carries out > 400 circumcisions per week. I
think he uses the foreskins in his Fortune 500 company making wallets
that expand into suitcases when rubbed.
http://www.freeratio.org/showthread.php?p=7302620#post7302620

Re: Can someone help me fix a basic recursive function

<EKon0d876u8XJI=2W@bongo-ra.co>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3445&group=comp.lang.lisp#3445

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!wMjcvFyyQbKkD1DyxkS8fQ.user.46.165.242.91.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: Can someone help me fix a basic recursive function
Date: Tue, 22 Nov 2022 12:52:28 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <EKon0d876u8XJI=2W@bongo-ra.co>
References: <d088e62b-7798-4d56-b8c2-5de08acc10e8n@googlegroups.com> <8735ab1iqf.fsf@nightsong.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="24715"; posting-host="wMjcvFyyQbKkD1DyxkS8fQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Tue, 22 Nov 2022 12:52 UTC

On Tue, 22 Nov 2022 00:44:24 -0800
Paul Rubin <no.email@nospam.invalid> wrote:
> ME Jones <markjones@shawday.com> writes:
> > I am trying to create the following recursive function:
> > Example: (doubleodd '(1 2 3 4 5)) -> (2 2 6 4 10)
>
> I would first break this out into a function that conditionally doubles
> a single number:
>
> (defun double-odd-1 (n)
> (cond ((oddp n) (+ n n))
> (t n)))
>
> and then a tail-recursive function that applies DOUBLE-ODD-1 to each
> element of a list, consing it up into a new list that is in reverse
> order. Then, at the end, reverse the new list "in place" using
> nreverse:
>
> (defun double-odd (xs &optional acc)
> (defun f (n) (+ n n))
What's this for ?

> (cond ((null xs) (nreverse acc))
> (t (double-odd (cdr xs) (cons (double-odd-1 (car xs)) acc)))))
>
> Using an accumulation parameter allows the recursive call to be the
> function's final value, which means the compiler can actually turn it
> into a simple jump rather than pushing one level deeper into a stack on
> every call. That is kind of a lame explanation, but it is a very
> important idiom in functional programming, so you should probably spend
> some time studying it to understand it, e.g. by doing a web search on
> "tail recursion" and looking at explanations in the results.

Re: Can someone help me fix a basic recursive function

<coQdJ6CGVXBEFpxsy@bongo-ra.co>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3446&group=comp.lang.lisp#3446

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: Can someone help me fix a basic recursive function
Date: Tue, 22 Nov 2022 13:05:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <coQdJ6CGVXBEFpxsy@bongo-ra.co>
References: <d088e62b-7798-4d56-b8c2-5de08acc10e8n@googlegroups.com> <tlho6p$1i0r$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 22 Nov 2022 13:05:34 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="3ab888a9ecc63ea627a0e8efd3051d1c";
logging-data="116766"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zyTS5VeIBT5czZvtX6cp8"
Cancel-Lock: sha1:/YnF+uLRnPdQyzyAKUTIcbqSumw=
X-Server-Commands: nowebcancel
In-Reply-To: <tlho6p$1i0r$1@dont-email.me>
X-Organisation: Weyland-Yutani
 by: Spiros Bousbouras - Tue, 22 Nov 2022 13:05 UTC

On Tue, 22 Nov 2022 05:54:33 -0000 (UTC)
ST <usenet.233ph@slmail.me> wrote:
> On 2022-11-22, ME Jones <markjones@shawday.com> wrote:
> > Hello,
> > I am trying to create the following recursive function:
> >
> > Example: (doubleodd '(1 2 3 4 5)) -> (2 2 6 4 10)
> >
> > (defun doubleodd (list)
> > (when list
> > (if (oddp (car list)) (setf (car list) (* (car list) 2)))
> > (doubleodd (cdr list))
> > )
> > )
> >
> > When i evaluate i am not getting back a list and it's missing some values in the list. What am i doing wrong?
>
>
> (defun doubleodd (l)
> (if (null l)
> nil
> (if (oddp (car l))
> (cons (* 2 (car l)) (doubleodd (cdr l)))
> (cons (car l) (doubleodd (cdr l))))))
>
> In a recursive function with a list, 2 important things to remember:
>
> you apply the function on the car of the list then your recursive call
> goes on the cdr.
>
> Once the list is null, you return a nil to end the recursion.
>
> Lisp is mostly a functional language, avoid the usage of (setf) inside
> a function unless it's to change the value of a lexical
> variable. Otherwise, you function is called destructive.

Common Lisp is a multi-paradigm language and it is up to individual preference
when one should use SETF .But SETF is specified to return the new value assigned
so that is another reason the general idea the opening poster had would not
work. For example

* (let ((l (list 1 2)))
(setf (car l) (* 2 (car l))))
2

* (let ((l (list 1 2)))
(setf (car l) (* 2 (car l)))
l)

(2 2)

> 2 books to read absolutely to understand Lisp and its philosophy:
>
> Ansi Common Lisp
> On Lisp
>
> Both from Paul Graham. The second one is not printed anymore, but
> available at low cost from lulu.com

Personally I don't believe in language "philosophies" , the concept is
too vague and subjective. I'll just note that "On Lisp" also exists at
http://www.paulgraham.com/onlisptext.html .

Re: Can someone help me fix a basic recursive function

<8735abkpcd.fsf@bsb.me.uk>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3447&group=comp.lang.lisp#3447

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.lisp
Subject: Re: Can someone help me fix a basic recursive function
Date: Tue, 22 Nov 2022 14:58:58 +0000
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <8735abkpcd.fsf@bsb.me.uk>
References: <d088e62b-7798-4d56-b8c2-5de08acc10e8n@googlegroups.com>
<8735ab1iqf.fsf@nightsong.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="9b85f22d308ce2c1806d1ce4165d5a1d";
logging-data="131121"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+IPbeD1V6C1jbgIh0HVsB4sY5ShEoTetY="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:vwMExinF4PVlUId5wXJq4GDktf0=
sha1:fGOaRNByZBvHaFHrM7dE9WU2GoY=
X-BSB-Auth: 1.ba30087933527ae8fcfc.20221122145858GMT.8735abkpcd.fsf@bsb.me.uk
 by: Ben Bacarisse - Tue, 22 Nov 2022 14:58 UTC

Paul Rubin <no.email@nospam.invalid> writes:

> ME Jones <markjones@shawday.com> writes:
>> I am trying to create the following recursive function:
>> Example: (doubleodd '(1 2 3 4 5)) -> (2 2 6 4 10)
>
> I would first break this out into a function that conditionally doubles
> a single number:
>
> (defun double-odd-1 (n)
> (cond ((oddp n) (+ n n))
> (t n)))

This is specific enough that I would make it a lambda. Are we going to
need it for anything other than this exercise?

> and then a tail-recursive function that applies DOUBLE-ODD-1 to each
> element of a list, consing it up into a new list that is in reverse
> order.

I don't see this as a use-case for an accumulating parameter. Some
tutorials will want the plain hand-written recursive solution, but
really the way to go is surely with mapcar as you suggest:

> Finally, notice that the pattern of creating a new list by applying some
> function to every element of an old list is very common, and CL (and
> related languages) usually have a built-in for it, called some variant
> of "map". In CL's case, that function is called MAPCAR, so you would
> simply write:
>
> (defun double-odd (xs)
> (mapcar #'double-odd-1 xs))
>
> where DOUBLE-ODD-1 is as defined above.

(defun doubleodd (list)
(mapcar (lambda (x) (if (oddp x) (* 2 x) x)) list))

--
Ben.

Re: Can someone help me fix a basic recursive function

<13c89cae-ff57-4ce6-a97b-740b584e1944n@googlegroups.com>

  copy mid

https://news.novabbs.org/devel/article-flat.php?id=3448&group=comp.lang.lisp#3448

  copy link   Newsgroups: comp.lang.lisp
X-Received: by 2002:a05:622a:514d:b0:3a5:258c:d69c with SMTP id ew13-20020a05622a514d00b003a5258cd69cmr8654393qtb.279.1669135052472;
Tue, 22 Nov 2022 08:37:32 -0800 (PST)
X-Received: by 2002:a05:6808:1592:b0:35a:e1a7:c3b2 with SMTP id
t18-20020a056808159200b0035ae1a7c3b2mr2088013oiw.223.1669135052022; Tue, 22
Nov 2022 08:37:32 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.lisp
Date: Tue, 22 Nov 2022 08:37:31 -0800 (PST)
In-Reply-To: <d088e62b-7798-4d56-b8c2-5de08acc10e8n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2620:0:102f:1005:2671:984:2fee:34fe;
posting-account=05zmAwoAAAAJZM-3jv1hCWLHGZQceqwA
NNTP-Posting-Host: 2620:0:102f:1005:2671:984:2fee:34fe
References: <d088e62b-7798-4d56-b8c2-5de08acc10e8n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <13c89cae-ff57-4ce6-a97b-740b584e1944n@googlegroups.com>
Subject: Re: Can someone help me fix a basic recursive function
From: taruss@google.com (Tom Russ)
Injection-Date: Tue, 22 Nov 2022 16:37:32 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2682
 by: Tom Russ - Tue, 22 Nov 2022 16:37 UTC

On Monday, November 21, 2022 at 8:32:11 PM UTC-8, mark...@shawday.com wrote:
> Hello,
> I am trying to create the following recursive function:
>
> Example: (doubleodd '(1 2 3 4 5)) -> (2 2 6 4 10)
>
> (defun doubleodd (list)
> (when list
> (if (oddp (car list)) (setf (car list) (* (car list) 2)))
> (doubleodd (cdr list))
> )
> )
>
> When i evaluate i am not getting back a list and it's missing some values in the list. What am i doing wrong?
>
> (doubleodd '(1 2 3 4 5))

There are a lot of other answers about how to update the function. I just want to
point out some other somewhat subtle issues with the code as presented here.

First off, the code uses (SETF (CAR LIST) ...) which will destructively mutate
the list. Generally as a beginner in the language you don't want to do destructive
list operations. It is really an optimization and can cause some very hard-to-debug
problems. So it is best to avoid it until you have a good understanding of lisp.

As an example of that, you are invoking your DOUBLEODD function with a constant
argument of '(1 2 3 4 5). And the code then destructively modifies that constant
list. This is undefined behavior in Common Lisp and must be avoided. You cannot
predict the results of doing this. There is no requirement that the compiler or in
this case the run time warn you about doing something like this. Common Lisp
allows you to do unwise things that might be prohibited in other languages.

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor