Re: altering LOCAL list elements

2017-02-11 Thread dean
Thank you On 11 February 2017 at 11:51, Joh-Tob Schäg wrote: > You can also explicitly change the car or cdr of a list cell. > If you do a little diging in the docs you might find the functions. > Am 11.02.2017 12:45 schrieb "dean" : > > > >Does

Re: altering LOCAL list elements

2017-02-11 Thread Joh-Tob Schäg
You can also explicitly change the car or cdr of a list cell. If you do a little diging in the docs you might find the functions. Am 11.02.2017 12:45 schrieb "dean" : > >Does that explanation make sense? > > Yes it does > > >You can either destructivly change the car of

Re: altering LOCAL list elements

2017-02-11 Thread dean
>Does that explanation make sense? Yes it does >You can either destructivly change the car of a cell in the list or write your own pop which keeps the same >cell at the head of the list (by reassigning car parts appropiatly). Thank you...this is the only way I know about at the moment that lets

Re: altering LOCAL list elements

2017-02-11 Thread Joh-Tob Schäg
I understand your problem now. You have think about cells in this case. When you inc a 'symbol the value part of the symbol-cell is changed. [prop|val] represents a symbol in this case. (inc '[NIL|5]) is [NIL|6] The Symbol was changed destructivly. All earlier refernces to this cell now evaluate

Re: altering LOCAL list elements

2017-02-11 Thread dean
This works too but I really want to remove setq from the middle of doit : (de doit () (let L (0 0 0) (setq L (insert '1 (remove '1 L) 2)) (prinl "L is " L) ) ) -> doit : (doit) L is 200 -> (2 0 0) On 11 February 2017 at 10:29, dean wrote: > Here's

Re: altering LOCAL list elements

2017-02-11 Thread dean
and use a local solution but don't think that I can On 11 February 2017 at 10:38, dean wrote: > This works too but I really want to remove setq from the middle of doit > > : (de doit () >(let L (0 0 0) > (setq L (insert '1 (remove '1 L) 2)) > (prinl "L

Re: altering LOCAL list elements

2017-02-11 Thread dean
BTW I left setq in the midlle of doit by accident...i.e I used it to work out how to replace a list element by index not value as per the built-in replace. On 11 February 2017 at 10:38, dean wrote: > and use a local solution but don't think that I can > > On 11

Re: altering LOCAL list elements

2017-02-11 Thread dean
Here's the desired behaviour using the above code : (setq L (0 0 0)) -> (0 0 0) : (de doit () #(let L (0 0 0) (setq L (insert '1 (remove '1 L) 2)) (prinl "L is " L) #) ) -> doit : (doit) L is 200 -> (2 0 0) I was after (2 0 0) using let L i.e. the two lines commented out which

Re: altering LOCAL list elements

2017-02-11 Thread dean
Hi Joh-tob & Joe With setq L.(0 0 0) gets changed to (2 0 0) i.e. the replace is done by index not matching value With let L...(0 0 0) stays at (0 0 0) I'd wanted the former in conjunction with let. Thank you for the suggestion re need...and the explanation re let. I can do this with setq but

Re: altering LOCAL list elements

2017-02-10 Thread Joe Bogner
dean, is this what you are describing? (let L (list 1 2 3) (setq L (append L (4))) (printsp L) ) (1 2 3 4) The key to this is understanding how let works. It restores the prior value after execution. See http://software-lab.de/doc/refL.html#let Defines local variables. The

Re: altering LOCAL list elements

2017-02-10 Thread Joh-Tob Schäg
Not related to your problem. You might wanna take a look at the 'need function. Furthermore i fail to understand your problem. If picolisp behaves unexpected could you please describe what behavior you expect wjat you get and provide a test case which runs the functions it defines? Alternativly