Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Mystics always hope that science will some day overtake them. -- Booth Tarkington


devel / comp.lang.lisp / Can someone explain to me how can I destructively modify subtrees?

SubjectAuthor
* Can someone explain to me how can I destructively modify subtrees?Bigos
`* Re: Can someone explain to me how can I destructively modify subtrees?Spiros Bousbouras
 `* Re: Can someone explain to me how can I destructively modify subtrees?Bigos
  +* Re: Can someone explain to me how can I destructively modify subtrees?Bigos
  |`- Re: Can someone explain to me how can I destructively modify subtrees?Bigos
  `* Re: Can someone explain to me how can I destructively modify subtrees?Spiros Bousbouras
   +- Re: Can someone explain to me how can I destructively modify subtrees?Spiros Bousbouras
   `* Re: Can someone explain to me how can I destructively modify subtrees?Bigos
    `* Re: Can someone explain to me how can I destructively modify subtrees?Madhu
     `* Re: Can someone explain to me how can I destructively modify subtrees?Bigos
      `* Re: Can someone explain to me how can I destructively modify subtrees?Ben Bacarisse
       `* Re: Can someone explain to me how can I destructively modify subtrees?Bigos
        `- Re: Can someone explain to me how can I destructively modify subtrees?Bigos

1
Can someone explain to me how can I destructively modify subtrees?

<4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16963&group=comp.lang.lisp#16963

  copy link   Newsgroups: comp.lang.lisp
X-Received: by 2002:ae9:ec0a:0:b0:67d:6c34:de44 with SMTP id h10-20020ae9ec0a000000b0067d6c34de44mr18505339qkg.152.1647425161462;
Wed, 16 Mar 2022 03:06:01 -0700 (PDT)
X-Received: by 2002:a05:6871:153:b0:db:20bd:4cbd with SMTP id
z19-20020a056871015300b000db20bd4cbdmr3044915oab.46.1647425161233; Wed, 16
Mar 2022 03:06:01 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.lisp
Date: Wed, 16 Mar 2022 03:06:01 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=80.3.9.155; posting-account=7RMTtAoAAAAl53cGsT2A48BtOsVJ7mF2
NNTP-Posting-Host: 80.3.9.155
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com>
Subject: Can someone explain to me how can I destructively modify subtrees?
From: ruby.object@googlemail.com (Bigos)
Injection-Date: Wed, 16 Mar 2022 10:06:01 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 4
 by: Bigos - Wed, 16 Mar 2022 10:06 UTC

I am trying to modify a tree made of cons cells. Recursively I descend to the cons where I want to append a subtree like (cons 'header (cons 'name nil)).

How do I do it so that the addition is seen when I later check the cons cell that is at the root of the tree?

I do not want to change every tree element that matches certain criteria. I want to descent to the point where I append my subtree following a path similar to descending down the file system tree.

Re: Can someone explain to me how can I destructively modify subtrees?

<tEFMYlAIUAPJnh11E@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16964&group=comp.lang.lisp#16964

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: Can someone explain to me how can I destructively modify subtrees?
Date: Wed, 16 Mar 2022 12:58:44 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <tEFMYlAIUAPJnh11E@bongo-ra.co>
References: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 16 Mar 2022 12:58:44 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5cd7d5325c0d11bf11e4d9a0238366b2";
logging-data="6385"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KVn4cyRgM5tG1CS08Q2ji"
Cancel-Lock: sha1:V6/vtR+lrLRoU7FpT22ZWFpH5xs=
In-Reply-To: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com>
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Wed, 16 Mar 2022 12:58 UTC

On Wed, 16 Mar 2022 03:06:01 -0700 (PDT)
Bigos <ruby.object@googlemail.com> wrote:
> I am trying to modify a tree made of cons cells. Recursively I descend to
> the cons where I want to append a subtree like (cons 'header (cons 'name
> nil)).
>
> How do I do it so that the addition is seen when I later check the cons
> cell that is at the root of the tree?
>
> I do not want to change every tree element that matches certain criteria. I
> want to descent to the point where I append my subtree following a path
> similar to descending down the file system tree.

It's not clear what your precise requirements are so I will give you some
examples :

[1]> (defvar tree1)
TREE1
[2]> (setq tree1 (list 1 (list 2 3 (list 4 5))))
(1 (2 3 (4 5)))
[3]> tree1
(1 (2 3 (4 5)))
[4]> (defvar tree2 (list 'a (list 'b 'c)))
TREE2

"Deep" in tree1 we have the subtree (4 5) so I will show examples where
you can replace 4 or 5 or append to (4 5) the tree tree2 .There are various
ways to descend to the right spot in tree1 , the following present just one
way.

[5]> (setf (first (caddr (car (cdr tree1)))) tree2)
(A (B C))
[6]> tree1
(1 (2 3 ((A (B C)) 5)))
[7]> (setq tree1 (list 1 (list 2 3 (list 4 5))))
(1 (2 3 (4 5)))
; We return tree1 to its initial value.

[8]> (setf (second (caddr (car (cdr tree1)))) tree2)
(A (B C))
[9]> tree1
(1 (2 3 (4 (A (B C)))))
[10]> (setq tree1 (list 1 (list 2 3 (list 4 5))))
(1 (2 3 (4 5)))
; We return tree1 to its initial value.

[11]> (setf (cdaddr (car (cdr tree1))) tree2)
(A (B C))
[12]> tree1
(1 (2 3 (4 A (B C))))
[13]> (setq tree1 (list 1 (list 2 3 (list 4 5))))
(1 (2 3 (4 5)))
; We return tree1 to its initial value.

[14]> (rplacd (cdaddr (car (cdr tree1))) tree2)
(5 A (B C))
[15]> tree1
(1 (2 3 (4 5 A (B C))))

--
How do you know that a webpage belongs to a postmodernist philosopher ?
It is constantly under deconstruction.

Re: Can someone explain to me how can I destructively modify subtrees?

<a568099b-5734-4fbe-8b9f-63361de1504dn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16966&group=comp.lang.lisp#16966

  copy link   Newsgroups: comp.lang.lisp
X-Received: by 2002:a05:6214:23c8:b0:432:e69f:5d77 with SMTP id hr8-20020a05621423c800b00432e69f5d77mr30512qvb.7.1647442038829;
Wed, 16 Mar 2022 07:47:18 -0700 (PDT)
X-Received: by 2002:a9d:8f6:0:b0:5b2:2a34:adff with SMTP id
109-20020a9d08f6000000b005b22a34adffmr111086otf.237.1647442038568; Wed, 16
Mar 2022 07:47:18 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.lisp
Date: Wed, 16 Mar 2022 07:47:18 -0700 (PDT)
In-Reply-To: <tEFMYlAIUAPJnh11E@bongo-ra.co>
Injection-Info: google-groups.googlegroups.com; posting-host=109.144.210.114; posting-account=7RMTtAoAAAAl53cGsT2A48BtOsVJ7mF2
NNTP-Posting-Host: 109.144.210.114
References: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com> <tEFMYlAIUAPJnh11E@bongo-ra.co>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a568099b-5734-4fbe-8b9f-63361de1504dn@googlegroups.com>
Subject: Re: Can someone explain to me how can I destructively modify subtrees?
From: ruby.object@googlemail.com (Bigos)
Injection-Date: Wed, 16 Mar 2022 14:47:18 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 17
 by: Bigos - Wed, 16 Mar 2022 14:47 UTC

This is my lame attempt. Only if I knew how to replace your cars and cdrs following the setf I would have my solution.

(defparameter *bintree* '(((1) . (2)) (3 . 4)))

(defun bintrav (tr)
(format t "trying ~S~%" tr)
(when (equal tr '(2))
(progn
(setf tr (cons 2222 nil))
(format t "trying changed ~S~%" tr)))

(if (atom tr)
nil
(progn
(format t "trying with ~S~%" tr)
(bintrav (car tr))
(bintrav (cdr tr)))))

Re: Can someone explain to me how can I destructively modify subtrees?

<de751a68-f76a-4678-b267-ee30eebebfb5n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16967&group=comp.lang.lisp#16967

  copy link   Newsgroups: comp.lang.lisp
X-Received: by 2002:a05:6214:5284:b0:42c:8d98:53ee with SMTP id kj4-20020a056214528400b0042c8d9853eemr264439qvb.114.1647444257984;
Wed, 16 Mar 2022 08:24:17 -0700 (PDT)
X-Received: by 2002:a05:6808:a1b:b0:2ec:aec1:b010 with SMTP id
n27-20020a0568080a1b00b002ecaec1b010mr3912390oij.247.1647444257729; Wed, 16
Mar 2022 08:24:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.lisp
Date: Wed, 16 Mar 2022 08:24:17 -0700 (PDT)
In-Reply-To: <a568099b-5734-4fbe-8b9f-63361de1504dn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=109.144.210.114; posting-account=7RMTtAoAAAAl53cGsT2A48BtOsVJ7mF2
NNTP-Posting-Host: 109.144.210.114
References: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com>
<tEFMYlAIUAPJnh11E@bongo-ra.co> <a568099b-5734-4fbe-8b9f-63361de1504dn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <de751a68-f76a-4678-b267-ee30eebebfb5n@googlegroups.com>
Subject: Re: Can someone explain to me how can I destructively modify subtrees?
From: ruby.object@googlemail.com (Bigos)
Injection-Date: Wed, 16 Mar 2022 15:24:17 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 17
 by: Bigos - Wed, 16 Mar 2022 15:24 UTC

Trying to accumulate the car cdr path does not work
(defparameter *bintree* '(((1) . (2)) (3 . 4)))

(defun bintrav (tr &optional (p '*bintree*))
(format t "trying ~S ~S~%" tr p)
(when (equal tr '(2))
(progn
(eval (setf p 2222))
(format t "trying changed ~S~%" *bintree*)))

(if (atom tr)
nil
(progn
(format t "trying with ~S~%" tr)
(bintrav (car tr) (list 'car p))
(bintrav (cdr tr) (list 'cdr p)))))

Re: Can someone explain to me how can I destructively modify subtrees?

<7cd30785-493d-4902-b163-aafeda65d1a6n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16968&group=comp.lang.lisp#16968

  copy link   Newsgroups: comp.lang.lisp
X-Received: by 2002:a05:6214:518d:b0:435:cf8c:63c1 with SMTP id kl13-20020a056214518d00b00435cf8c63c1mr269542qvb.61.1647445005658;
Wed, 16 Mar 2022 08:36:45 -0700 (PDT)
X-Received: by 2002:a05:6830:91d:b0:5c9:30bd:20f3 with SMTP id
v29-20020a056830091d00b005c930bd20f3mr185312ott.363.1647445005313; Wed, 16
Mar 2022 08:36:45 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.lisp
Date: Wed, 16 Mar 2022 08:36:45 -0700 (PDT)
In-Reply-To: <de751a68-f76a-4678-b267-ee30eebebfb5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=109.144.210.114; posting-account=7RMTtAoAAAAl53cGsT2A48BtOsVJ7mF2
NNTP-Posting-Host: 109.144.210.114
References: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com>
<tEFMYlAIUAPJnh11E@bongo-ra.co> <a568099b-5734-4fbe-8b9f-63361de1504dn@googlegroups.com>
<de751a68-f76a-4678-b267-ee30eebebfb5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <7cd30785-493d-4902-b163-aafeda65d1a6n@googlegroups.com>
Subject: Re: Can someone explain to me how can I destructively modify subtrees?
From: ruby.object@googlemail.com (Bigos)
Injection-Date: Wed, 16 Mar 2022 15:36:45 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 16
 by: Bigos - Wed, 16 Mar 2022 15:36 UTC

finally this one works.

thank you very much for giving me the idea, but this still does feel hacky. Is there a better way to do it?

(defun bintrav (tr &optional (p '*bintree*))
(format t "trying ~S ~S~%" tr p)
(when (equal tr '(2))
(progn
(eval (list 'setf p 2222))
(format t "trying changed ~S >>> ~S~%" *bintree* p)))

(if (atom tr)
nil
(progn
(format t "trying with ~S~%" tr)
(bintrav (car tr) (list 'car p))
(bintrav (cdr tr) (list 'cdr p)))))

Re: Can someone explain to me how can I destructively modify subtrees?

<HNSkxauVnXWaVrSwn@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16969&group=comp.lang.lisp#16969

  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 explain to me how can I destructively modify subtrees?
Date: Wed, 16 Mar 2022 16:41:25 -0000 (UTC)
Organization: Aioe.org NNTP Server
Message-ID: <HNSkxauVnXWaVrSwn@bongo-ra.co>
References: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com> <tEFMYlAIUAPJnh11E@bongo-ra.co> <a568099b-5734-4fbe-8b9f-63361de1504dn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="52713"; posting-host="wMjcvFyyQbKkD1DyxkS8fQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
X-Notice: Filtered by postfilter v. 0.9.2
X-Server-Commands: nowebcancel
X-Organisation: Weyland-Yutani
 by: Spiros Bousbouras - Wed, 16 Mar 2022 16:41 UTC

On Wed, 16 Mar 2022 07:47:18 -0700 (PDT)
Bigos <ruby.object@googlemail.com> wrote:
> This is my lame attempt. Only if I knew how to replace your cars and
> cdrs following the setf I would have my solution.
>
>
> (defparameter *bintree* '(((1) . (2)) (3 . 4)))
>
> (defun bintrav (tr)
> (format t "trying ~S~%" tr)
> (when (equal tr '(2))
> (progn
> (setf tr (cons 2222 nil))
> (format t "trying changed ~S~%" tr)))
>
> (if (atom tr)
> nil
> (progn
> (format t "trying with ~S~%" tr)
> (bintrav (car tr))
> (bintrav (cdr tr)))))

A few general remarks first :

1. It is much more useful if you specify what is the initial and final tree
you want. Instead you are leaving us to guess that the initial tree is the
value of *bintree* and for the final tree we must guess based on the code
for bintrav which does not actually achieve what you want !

2. If you are doing (bintrav *bintree*) then it's undefined behaviour
because *bintree* is a quoted object and you are not supposed to modify
those. So what you really want is

(defparameter *bintree* (list (cons (list 1) (list 2)) (cons 3 4))))

3. Note that
(equalp '(((1) . (2)) (3 . 4)) '(((1) 2) (3 . 4)))

returns T so your quoted object is more complicated than it needs to be.

4. WHEN is an implicit PROGN so instead of

(when (equal tr '(2))
(progn
(setf tr (cons 2222 nil))
(format t "trying changed ~S~%" tr)))

you can simply do

(when (equal tr '(2))
(setf tr (cons 2222 nil))
(format t "trying changed ~S~%" tr))

I didn't examine carefully your subsequent posts using EVAL because it is
almost certain that you don't want EVAL for this. Instead I think you want
something like

(defun bintrav2 (arg &aux (tr arg))
(format t "trying ~S~%" tr)
(when (equalp tr '(2))
(setf (car tr) (cons 2222 nil))
(format t "trying changed ~S~%" tr))

(if (atom tr)
nil
(progn
(format t "trying with ~S~%" tr)
(bintrav2 (car tr))
(bintrav2 (cdr tr)))))

--
There are so many people coming out that they're not even gay , they're
trendsexual.
John Waters

Re: Can someone explain to me how can I destructively modify subtrees?

<Ht1CEBgDQlMv8K4Se@bongo-ra.co>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16970&group=comp.lang.lisp#16970

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: spibou@gmail.com (Spiros Bousbouras)
Newsgroups: comp.lang.lisp
Subject: Re: Can someone explain to me how can I destructively modify subtrees?
Date: Wed, 16 Mar 2022 16:48:56 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <Ht1CEBgDQlMv8K4Se@bongo-ra.co>
References: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com> <tEFMYlAIUAPJnh11E@bongo-ra.co> <a568099b-5734-4fbe-8b9f-63361de1504dn@googlegroups.com>
<HNSkxauVnXWaVrSwn@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 16 Mar 2022 16:48:56 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5cd7d5325c0d11bf11e4d9a0238366b2";
logging-data="29422"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18t7KPOF9T+pBb8Dqqbc2gg"
Cancel-Lock: sha1:qSWz3fviOiqMs2ANPkwCL66BFao=
In-Reply-To: <HNSkxauVnXWaVrSwn@bongo-ra.co>
X-Organisation: Weyland-Yutani
X-Server-Commands: nowebcancel
 by: Spiros Bousbouras - Wed, 16 Mar 2022 16:48 UTC

On Wed, 16 Mar 2022 16:41:25 -0000 (UTC)
Spiros Bousbouras <spibou@gmail.com> wrote:
> Instead I think you want
> something like
>
> (defun bintrav2 (arg &aux (tr arg))

Make that
(defun bintrav2 (tr)

What I posted originally was part of an unsuccessful experiment.

> (format t "trying ~S~%" tr)
> (when (equalp tr '(2))
> (setf (car tr) (cons 2222 nil))
> (format t "trying changed ~S~%" tr))
>
> (if (atom tr)
> nil
> (progn
> (format t "trying with ~S~%" tr)
> (bintrav2 (car tr))
> (bintrav2 (cdr tr)))))
>

Re: Can someone explain to me how can I destructively modify subtrees?

<72f9aea8-0c8a-45ad-8450-dfacc51c845cn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16971&group=comp.lang.lisp#16971

  copy link   Newsgroups: comp.lang.lisp
X-Received: by 2002:ae9:ec0a:0:b0:67d:6c34:de44 with SMTP id h10-20020ae9ec0a000000b0067d6c34de44mr549010qkg.152.1647449531932;
Wed, 16 Mar 2022 09:52:11 -0700 (PDT)
X-Received: by 2002:a05:6830:448d:b0:5c9:2585:521e with SMTP id
r13-20020a056830448d00b005c92585521emr320232otv.92.1647449531545; Wed, 16 Mar
2022 09:52:11 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.lisp
Date: Wed, 16 Mar 2022 09:52:11 -0700 (PDT)
In-Reply-To: <HNSkxauVnXWaVrSwn@bongo-ra.co>
Injection-Info: google-groups.googlegroups.com; posting-host=80.3.9.155; posting-account=7RMTtAoAAAAl53cGsT2A48BtOsVJ7mF2
NNTP-Posting-Host: 80.3.9.155
References: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com>
<tEFMYlAIUAPJnh11E@bongo-ra.co> <a568099b-5734-4fbe-8b9f-63361de1504dn@googlegroups.com>
<HNSkxauVnXWaVrSwn@bongo-ra.co>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <72f9aea8-0c8a-45ad-8450-dfacc51c845cn@googlegroups.com>
Subject: Re: Can someone explain to me how can I destructively modify subtrees?
From: ruby.object@googlemail.com (Bigos)
Injection-Date: Wed, 16 Mar 2022 16:52:11 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Bigos - Wed, 16 Mar 2022 16:52 UTC

It appears that (setf (car tr) 'whatever) was the answer I was looking for. I could not figure out why (setf tr 'whatever) was the wrong approach.

Re: Can someone explain to me how can I destructively modify subtrees?

<m3czik7p2q.fsf@leonis4.robolove.meer.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16974&group=comp.lang.lisp#16974

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: enometh@meer.net (Madhu)
Newsgroups: comp.lang.lisp
Subject: Re: Can someone explain to me how can I destructively modify subtrees?
Date: Thu, 17 Mar 2022 17:45:09 +0530
Organization: Motzarella
Lines: 14
Message-ID: <m3czik7p2q.fsf@leonis4.robolove.meer.net>
References: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com>
<tEFMYlAIUAPJnh11E@bongo-ra.co>
<a568099b-5734-4fbe-8b9f-63361de1504dn@googlegroups.com>
<HNSkxauVnXWaVrSwn@bongo-ra.co>
<72f9aea8-0c8a-45ad-8450-dfacc51c845cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="ad1fd848ece4576e600aaad040f37513";
logging-data="24228"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19NQXydsyhhz+L3kN/KaW95hUEA0n90tIE="
Cancel-Lock: sha1:hvLhGUUuu6CVSLZtbqHPMLIcEx0=
sha1:2SbSOuA2ef2KghlYyUzsGeg6rRI=
 by: Madhu - Thu, 17 Mar 2022 12:15 UTC

* Bigos <72f9aea8-0c8a-45ad-8450-dfacc51c845cn @googlegroups.com> :
Wrote on Wed, 16 Mar 2022 09:52:11 -0700 (PDT):

> It appears that (setf (car tr) 'whatever) was the answer I was looking
> for. I could not figure out why (setf tr 'whatever) was the wrong
> approach.

is it still a problem? For SETF to mutate its first argument the first
argument of SETF has to be a SETF'able "place". If it is not a place but
a variable will merely modify the binding of the variable
like (setq var val)

[coming in late, havent caught up]

Re: Can someone explain to me how can I destructively modify subtrees?

<2416e32c-8a2f-499d-a285-6754e9a51d57n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16976&group=comp.lang.lisp#16976

  copy link   Newsgroups: comp.lang.lisp
X-Received: by 2002:ac8:7fc6:0:b0:2e1:ce3e:b491 with SMTP id b6-20020ac87fc6000000b002e1ce3eb491mr6606433qtk.287.1647595681916;
Fri, 18 Mar 2022 02:28:01 -0700 (PDT)
X-Received: by 2002:a05:6870:b029:b0:db:d29:5211 with SMTP id
y41-20020a056870b02900b000db0d295211mr3289147oae.98.1647595681712; Fri, 18
Mar 2022 02:28:01 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!nntp.club.cc.cmu.edu!45.76.7.193.MISMATCH!3.us.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.lisp
Date: Fri, 18 Mar 2022 02:28:01 -0700 (PDT)
In-Reply-To: <m3czik7p2q.fsf@leonis4.robolove.meer.net>
Injection-Info: google-groups.googlegroups.com; posting-host=80.3.9.155; posting-account=7RMTtAoAAAAl53cGsT2A48BtOsVJ7mF2
NNTP-Posting-Host: 80.3.9.155
References: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com>
<tEFMYlAIUAPJnh11E@bongo-ra.co> <a568099b-5734-4fbe-8b9f-63361de1504dn@googlegroups.com>
<HNSkxauVnXWaVrSwn@bongo-ra.co> <72f9aea8-0c8a-45ad-8450-dfacc51c845cn@googlegroups.com>
<m3czik7p2q.fsf@leonis4.robolove.meer.net>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2416e32c-8a2f-499d-a285-6754e9a51d57n@googlegroups.com>
Subject: Re: Can someone explain to me how can I destructively modify subtrees?
From: ruby.object@googlemail.com (Bigos)
Injection-Date: Fri, 18 Mar 2022 09:28:01 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 7
 by: Bigos - Fri, 18 Mar 2022 09:28 UTC

On Thursday, 17 March 2022 at 12:15:17 UTC, Madhu wrote:

> is it still a problem? For SETF to mutate its first argument the first
> argument of SETF has to be a SETF'able "place". If it is not a place but
> a variable will merely modify the binding of the variable
> like (setq var val)

It is not a problem. But I must admit I did not understand the distinction. I thought the binding of the variable was a SETF'able place.

Re: Can someone explain to me how can I destructively modify subtrees?

<87ee2ztev5.fsf@bsb.me.uk>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16978&group=comp.lang.lisp#16978

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.usenet@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.lisp
Subject: Re: Can someone explain to me how can I destructively modify subtrees?
Date: Fri, 18 Mar 2022 16:17:02 +0000
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <87ee2ztev5.fsf@bsb.me.uk>
References: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com>
<tEFMYlAIUAPJnh11E@bongo-ra.co>
<a568099b-5734-4fbe-8b9f-63361de1504dn@googlegroups.com>
<HNSkxauVnXWaVrSwn@bongo-ra.co>
<72f9aea8-0c8a-45ad-8450-dfacc51c845cn@googlegroups.com>
<m3czik7p2q.fsf@leonis4.robolove.meer.net>
<2416e32c-8a2f-499d-a285-6754e9a51d57n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="83ecc5115f210f8766016cf9056ac8f3";
logging-data="10449"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/mDXPb9iVFbbI+9p/rCvz66D6j1dGVKhc="
Cancel-Lock: sha1:4Y5UWKclTtPo53VmEOUJE940m1Y=
sha1:Tl+4t5PMy9va+0oo/BPWdxP68KU=
X-BSB-Auth: 1.6103b033b958b2835363.20220318161702GMT.87ee2ztev5.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 18 Mar 2022 16:17 UTC

Bigos <ruby.object@googlemail.com> writes:

> On Thursday, 17 March 2022 at 12:15:17 UTC, Madhu wrote:
>
>> is it still a problem? For SETF to mutate its first argument the first
>> argument of SETF has to be a SETF'able "place". If it is not a place but
>> a variable will merely modify the binding of the variable
>> like (setq var val)
>
> It is not a problem. But I must admit I did not understand the
> distinction. I thought the binding of the variable was a SETF'able
> place.

The variable is setfable, but what the variable is bound to is not (at
least not directly). However if a variable, x, is bound to (i.e.
"refers" to) a cons cell, then both (car x) and (cdr x) are setfable
places.

This is why you have to stop "one level up" from where you want to
modify a tree (if you are doing it this way) and why you can't modify an
empty tree this way (there is no one-level up!).

--
Ben.

Re: Can someone explain to me how can I destructively modify subtrees?

<3421fc37-45cb-4eec-b5d2-c3452df43c17n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16980&group=comp.lang.lisp#16980

  copy link   Newsgroups: comp.lang.lisp
X-Received: by 2002:a05:6214:29c7:b0:440:a60d:5e82 with SMTP id gh7-20020a05621429c700b00440a60d5e82mr7947225qvb.116.1647623092353;
Fri, 18 Mar 2022 10:04:52 -0700 (PDT)
X-Received: by 2002:a4a:6218:0:b0:320:ed7b:a2f8 with SMTP id
x24-20020a4a6218000000b00320ed7ba2f8mr3105725ooc.32.1647623092051; Fri, 18
Mar 2022 10:04:52 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.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: Fri, 18 Mar 2022 10:04:51 -0700 (PDT)
In-Reply-To: <87ee2ztev5.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=80.3.9.155; posting-account=7RMTtAoAAAAl53cGsT2A48BtOsVJ7mF2
NNTP-Posting-Host: 80.3.9.155
References: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com>
<tEFMYlAIUAPJnh11E@bongo-ra.co> <a568099b-5734-4fbe-8b9f-63361de1504dn@googlegroups.com>
<HNSkxauVnXWaVrSwn@bongo-ra.co> <72f9aea8-0c8a-45ad-8450-dfacc51c845cn@googlegroups.com>
<m3czik7p2q.fsf@leonis4.robolove.meer.net> <2416e32c-8a2f-499d-a285-6754e9a51d57n@googlegroups.com>
<87ee2ztev5.fsf@bsb.me.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3421fc37-45cb-4eec-b5d2-c3452df43c17n@googlegroups.com>
Subject: Re: Can someone explain to me how can I destructively modify subtrees?
From: ruby.object@googlemail.com (Bigos)
Injection-Date: Fri, 18 Mar 2022 17:04:52 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1893
 by: Bigos - Fri, 18 Mar 2022 17:04 UTC

On Friday, 18 March 2022 at 16:17:07 UTC, Ben Bacarisse wrote:

>
> This is why you have to stop "one level up" from where you want to
> modify a tree (if you are doing it this way) and why you can't modify an
> empty tree this way (there is no one-level up!).
>

Aha!

That explains why I have cddr in accessing children and cdr in SETFing the tree.

Re: Can someone explain to me how can I destructively modify subtrees?

<ff53c5cf-96b0-4b20-881d-be92bc73a47bn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=16981&group=comp.lang.lisp#16981

  copy link   Newsgroups: comp.lang.lisp
X-Received: by 2002:ac8:5bcd:0:b0:2e1:c6c4:ca00 with SMTP id b13-20020ac85bcd000000b002e1c6c4ca00mr8278559qtb.528.1647623413708;
Fri, 18 Mar 2022 10:10:13 -0700 (PDT)
X-Received: by 2002:a05:6870:a188:b0:da:cecb:8c2f with SMTP id
a8-20020a056870a18800b000dacecb8c2fmr7671242oaf.247.1647623413380; Fri, 18
Mar 2022 10:10:13 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.lisp
Date: Fri, 18 Mar 2022 10:10:13 -0700 (PDT)
In-Reply-To: <3421fc37-45cb-4eec-b5d2-c3452df43c17n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=80.3.9.155; posting-account=7RMTtAoAAAAl53cGsT2A48BtOsVJ7mF2
NNTP-Posting-Host: 80.3.9.155
References: <4f75bec7-b571-4871-a17e-102e0386f4a5n@googlegroups.com>
<tEFMYlAIUAPJnh11E@bongo-ra.co> <a568099b-5734-4fbe-8b9f-63361de1504dn@googlegroups.com>
<HNSkxauVnXWaVrSwn@bongo-ra.co> <72f9aea8-0c8a-45ad-8450-dfacc51c845cn@googlegroups.com>
<m3czik7p2q.fsf@leonis4.robolove.meer.net> <2416e32c-8a2f-499d-a285-6754e9a51d57n@googlegroups.com>
<87ee2ztev5.fsf@bsb.me.uk> <3421fc37-45cb-4eec-b5d2-c3452df43c17n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ff53c5cf-96b0-4b20-881d-be92bc73a47bn@googlegroups.com>
Subject: Re: Can someone explain to me how can I destructively modify subtrees?
From: ruby.object@googlemail.com (Bigos)
Injection-Date: Fri, 18 Mar 2022 17:10:13 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 4
 by: Bigos - Fri, 18 Mar 2022 17:10 UTC

On Friday, 18 March 2022 at 17:04:56 UTC, Bigos wrote:

> That explains why I have cddr in accessing children and cdr in SETFing the tree.

https://pastebin.com/b0e6QJXk

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor