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 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 me
> > destroy the car and replace it with something new...as you say though it
> > creates a whole new AND GLOBAL list because of setq.
> >   (setq L (insert '1 (remove '1 L) 2))
> >
> > Irrespective...thank you for your further advice.
> >
> >
> >
> >
> > On 11 February 2017 at 10:51, Joh-Tob Schäg  wrote:
> >
> > > List operations in Picolisp tend to be non destructive and constructive
> > > (they allocate new cells to get what you want) leaving old ones to be
> > > collected by gc.
> > > Am 11.02.2017 11:48 schrieb "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 to 6. That is because a cell evaluates to its value.
> > >>
> > >> If you push 88 on to a list. You do not get back the original list
> > >> changed but a new list which has a a cell with 88 in the beginning and
> > >> pointer to the old list in the cdr.
> > >> [1|pointer to 2nd cell] [2| pointer to 2nd cell ] [3|Nil] [Nil|Nil]
> > >> You save this list in to a symbol which now has the pointer to the
> first
> > >> element in it value slot.
> > >>
> > >> If you push 88 on to this list it looks like this:
> > >> [1|pointer to 2nd cell] [2| pointer to 2nd cell ] [3|Nil] [88|pointer
> to
> > >> first cell]
> > >> However your symbol L does not notice this change because it is still
> > >> pointing to the first cell.
> > >> To make it point to the head of the new list you need to setq the
> value
> > >> of L to the new head of the list.
> > >>
> > >> Does that explanation make sense?
> > >>
> > >> 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).
> > >> Am 11.02.2017 11:29 schrieb "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 was just wondering if there was a way
> > around
> > >>> "setting" let'd values more than once...like you can with let'd
> > >>> atoms...using inc and dec.
> > >>> I don't think you can but didn't think you could with atoms until inc
> > >>> and dec came back as an answer on this forum...hence this question :)
>


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 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 me
> destroy the car and replace it with something new...as you say though it
> creates a whole new AND GLOBAL list because of setq.
>   (setq L (insert '1 (remove '1 L) 2))
>
> Irrespective...thank you for your further advice.
>
>
>
>
> On 11 February 2017 at 10:51, Joh-Tob Schäg  wrote:
>
> > List operations in Picolisp tend to be non destructive and constructive
> > (they allocate new cells to get what you want) leaving old ones to be
> > collected by gc.
> > Am 11.02.2017 11:48 schrieb "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 to 6. That is because a cell evaluates to its value.
> >>
> >> If you push 88 on to a list. You do not get back the original list
> >> changed but a new list which has a a cell with 88 in the beginning and
> >> pointer to the old list in the cdr.
> >> [1|pointer to 2nd cell] [2| pointer to 2nd cell ] [3|Nil] [Nil|Nil]
> >> You save this list in to a symbol which now has the pointer to the first
> >> element in it value slot.
> >>
> >> If you push 88 on to this list it looks like this:
> >> [1|pointer to 2nd cell] [2| pointer to 2nd cell ] [3|Nil] [88|pointer to
> >> first cell]
> >> However your symbol L does not notice this change because it is still
> >> pointing to the first cell.
> >> To make it point to the head of the new list you need to setq the value
> >> of L to the new head of the list.
> >>
> >> Does that explanation make sense?
> >>
> >> 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).
> >> Am 11.02.2017 11:29 schrieb "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 was just wondering if there was a way
> around
> >>> "setting" let'd values more than once...like you can with let'd
> >>> atoms...using inc and dec.
> >>> I don't think you can but didn't think you could with atoms until inc
> >>> and dec came back as an answer on this forum...hence this question :)

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 me
destroy the car and replace it with something new...as you say though it
creates a whole new AND GLOBAL list because of setq.
  (setq L (insert '1 (remove '1 L) 2))

Irrespective...thank you for your further advice.




On 11 February 2017 at 10:51, Joh-Tob Schäg  wrote:

> List operations in Picolisp tend to be non destructive and constructive
> (they allocate new cells to get what you want) leaving old ones to be
> collected by gc.
> Am 11.02.2017 11:48 schrieb "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 to 6. That is because a cell evaluates to its value.
>>
>> If you push 88 on to a list. You do not get back the original list
>> changed but a new list which has a a cell with 88 in the beginning and
>> pointer to the old list in the cdr.
>> [1|pointer to 2nd cell] [2| pointer to 2nd cell ] [3|Nil] [Nil|Nil]
>> You save this list in to a symbol which now has the pointer to the first
>> element in it value slot.
>>
>> If you push 88 on to this list it looks like this:
>> [1|pointer to 2nd cell] [2| pointer to 2nd cell ] [3|Nil] [88|pointer to
>> first cell]
>> However your symbol L does not notice this change because it is still
>> pointing to the first cell.
>> To make it point to the head of the new list you need to setq the value
>> of L to the new head of the list.
>>
>> Does that explanation make sense?
>>
>> 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).
>> Am 11.02.2017 11:29 schrieb "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 was just wondering if there was a way around
>>> "setting" let'd values more than once...like you can with let'd
>>> atoms...using inc and dec.
>>> I don't think you can but didn't think you could with atoms until inc
>>> and dec came back as an answer on this forum...hence this question :).
>>> Thank you for your advice and best regards
>>> Dean
>>>
>>>
>>>
>>> On 11 February 2017 at 02:07, Joe Bogner  wrote:
>>>
 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 value of the symbol sym - or the values of
 the symbols sym in the list of the second form - ***are saved** and the
 symbols are bound to the evaluated any arguments The 64-bit version also
 accepts lst arguments in the second form; they may consist only of symbols
 and sublists, and match the any argument (destructuring bind). prg is
 executed, then the symbols ***are restored to their original values***

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 to 6. That is because a cell evaluates to its value.

If you push 88 on to a list. You do not get back the original list changed
but a new list which has a a cell with 88 in the beginning and pointer to
the old list in the cdr.
[1|pointer to 2nd cell] [2| pointer to 2nd cell ] [3|Nil] [Nil|Nil]
You save this list in to a symbol which now has the pointer to the first
element in it value slot.

If you push 88 on to this list it looks like this:
[1|pointer to 2nd cell] [2| pointer to 2nd cell ] [3|Nil] [88|pointer to
first cell]
However your symbol L does not notice this change because it is still
pointing to the first cell.
To make it point to the head of the new list you need to setq the value of
L to the new head of the list.

Does that explanation make sense?

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).
Am 11.02.2017 11:29 schrieb "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 was just wondering if there was a way around
> "setting" let'd values more than once...like you can with let'd
> atoms...using inc and dec.
> I don't think you can but didn't think you could with atoms until inc and
> dec came back as an answer on this forum...hence this question :).
> Thank you for your advice and best regards
> Dean
>
>
>
> On 11 February 2017 at 02:07, Joe Bogner  wrote:
>
>> 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 value of the symbol sym - or the values of
>> the symbols sym in the list of the second form - ***are saved** and the
>> symbols are bound to the evaluated any arguments. The 64-bit version also
>> accepts lst arguments in the second form; they may consist only of symbols
>> and sublists, and match the any argument (destructuring bind). prg is
>> executed, then the symbols ***are restored to their original values***.
>>
>>
>>
>> On Fri, Feb 10, 2017 at 3:22 PM, dean  wrote:
>>
>>> Hi
>>> I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
>>> 'Some_atom)
>>> which gets me a long way...
>>> ...but what about list elements?
>>>
>>>
>>> (setq L (0 0 0))
>>> (de doit ()
>>>#(let L (0 0 0)
>>>   (setq L (insert '1 (remove '1 L) 2))
>>>   (prinl "L is " L)
>>>#)
>>> )
>>>
>>> When I "setq" L this works but can I do it (somehow) when L is created
>>> with "let"?
>>>
>>
>>
>


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 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
> would replace the top setq... line
> but no go and probably quite rightly. It just that (let A 3..(inc
> 'A)...allows A to have it's value altered but there doesn't seem to be a
> way to bring inc/dec to bear on a list element in the same very influential
> way.
>
> On 11 February 2017 at 10:23, dean  wrote:
>
>> 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 was just wondering if there was a way around
>> "setting" let'd values more than once...like you can with let'd
>> atoms...using inc and dec.
>> I don't think you can but didn't think you could with atoms until inc and
>> dec came back as an answer on this forum...hence this question :).
>> Thank you for your advice and best regards
>> Dean
>>
>>
>>
>> On 11 February 2017 at 02:07, Joe Bogner  wrote:
>>
>>> 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 value of the symbol sym - or the values of
>>> the symbols sym in the list of the second form - ***are saved** and the
>>> symbols are bound to the evaluated any arguments. The 64-bit version also
>>> accepts lst arguments in the second form; they may consist only of symbols
>>> and sublists, and match the any argument (destructuring bind). prg is
>>> executed, then the symbols ***are restored to their original values***.
>>>
>>>
>>>
>>> On Fri, Feb 10, 2017 at 3:22 PM, dean  wrote:
>>>
 Hi
 I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
 'Some_atom)
 which gets me a long way...
 ...but what about list elements?


 (setq L (0 0 0))
 (de doit ()
#(let L (0 0 0)
   (setq L (insert '1 (remove '1 L) 2))
   (prinl "L is " L)
#)
 )

 When I "setq" L this works but can I do it (somehow) when L is created
 with "let"?

>>>
>>>
>>
>


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 is " L)
>)
> )
> -> doit
> : (doit)
> L is 200
> -> (2 0 0)
>
>
>
>
> On 11 February 2017 at 10:29, dean  wrote:
>
>> 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
>> would replace the top setq... line
>> but no go and probably quite rightly. It just that (let A 3..(inc
>> 'A)...allows A to have it's value altered but there doesn't seem to be a
>> way to bring inc/dec to bear on a list element in the same very influential
>> way.
>>
>> On 11 February 2017 at 10:23, dean  wrote:
>>
>>> 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 was just wondering if there was a way around
>>> "setting" let'd values more than once...like you can with let'd
>>> atoms...using inc and dec.
>>> I don't think you can but didn't think you could with atoms until inc
>>> and dec came back as an answer on this forum...hence this question :).
>>> Thank you for your advice and best regards
>>> Dean
>>>
>>>
>>>
>>> On 11 February 2017 at 02:07, Joe Bogner  wrote:
>>>
 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 value of the symbol sym - or the values of
 the symbols sym in the list of the second form - ***are saved** and the
 symbols are bound to the evaluated any arguments. The 64-bit version also
 accepts lst arguments in the second form; they may consist only of symbols
 and sublists, and match the any argument (destructuring bind). prg is
 executed, then the symbols ***are restored to their original values***.



 On Fri, Feb 10, 2017 at 3:22 PM, dean  wrote:

> Hi
> I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
> 'Some_atom)
> which gets me a long way...
> ...but what about list elements?
>
>
> (setq L (0 0 0))
> (de doit ()
>#(let L (0 0 0)
>   (setq L (insert '1 (remove '1 L) 2))
>   (prinl "L is " L)
>#)
> )
>
> When I "setq" L this works but can I do it (somehow) when L is created
> with "let"?
>


>>>
>>
>


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 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 is " L)
>>)
>> )
>> -> doit
>> : (doit)
>> L is 200
>> -> (2 0 0)
>>
>>
>>
>>
>> On 11 February 2017 at 10:29, dean  wrote:
>>
>>> 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
>>> would replace the top setq... line
>>> but no go and probably quite rightly. It just that (let A 3..(inc
>>> 'A)...allows A to have it's value altered but there doesn't seem to be a
>>> way to bring inc/dec to bear on a list element in the same very influential
>>> way.
>>>
>>> On 11 February 2017 at 10:23, dean  wrote:
>>>
 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 was just wondering if there was a way
 around "setting" let'd values more than once...like you can with let'd
 atoms...using inc and dec.
 I don't think you can but didn't think you could with atoms until inc
 and dec came back as an answer on this forum...hence this question :).
 Thank you for your advice and best regards
 Dean



 On 11 February 2017 at 02:07, Joe Bogner  wrote:

> 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 value of the symbol sym - or the values
> of the symbols sym in the list of the second form - ***are saved** and the
> symbols are bound to the evaluated any arguments. The 64-bit version also
> accepts lst arguments in the second form; they may consist only of symbols
> and sublists, and match the any argument (destructuring bind). prg is
> executed, then the symbols ***are restored to their original values***.
>
>
>
> On Fri, Feb 10, 2017 at 3:22 PM, dean 
> wrote:
>
>> Hi
>> I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
>> 'Some_atom)
>> which gets me a long way...
>> ...but what about list elements?
>>
>>
>> (setq L (0 0 0))
>> (de doit ()
>>#(let L (0 0 0)
>>   (setq L (insert '1 (remove '1 L) 2))
>>   (prinl "L is " L)
>>#)
>> )
>>
>> When I "setq" L this works but can I do it (somehow) when L is
>> created with "let"?
>>
>
>

>>>
>>
>


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
would replace the top setq... line
but no go and probably quite rightly. It just that (let A 3..(inc
'A)...allows A to have it's value altered but there doesn't seem to be a
way to bring inc/dec to bear on a list element in the same very influential
way.

On 11 February 2017 at 10:23, dean  wrote:

> 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 was just wondering if there was a way around
> "setting" let'd values more than once...like you can with let'd
> atoms...using inc and dec.
> I don't think you can but didn't think you could with atoms until inc and
> dec came back as an answer on this forum...hence this question :).
> Thank you for your advice and best regards
> Dean
>
>
>
> On 11 February 2017 at 02:07, Joe Bogner  wrote:
>
>> 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 value of the symbol sym - or the values of
>> the symbols sym in the list of the second form - ***are saved** and the
>> symbols are bound to the evaluated any arguments. The 64-bit version also
>> accepts lst arguments in the second form; they may consist only of symbols
>> and sublists, and match the any argument (destructuring bind). prg is
>> executed, then the symbols ***are restored to their original values***.
>>
>>
>>
>> On Fri, Feb 10, 2017 at 3:22 PM, dean  wrote:
>>
>>> Hi
>>> I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
>>> 'Some_atom)
>>> which gets me a long way...
>>> ...but what about list elements?
>>>
>>>
>>> (setq L (0 0 0))
>>> (de doit ()
>>>#(let L (0 0 0)
>>>   (setq L (insert '1 (remove '1 L) 2))
>>>   (prinl "L is " L)
>>>#)
>>> )
>>>
>>> When I "setq" L this works but can I do it (somehow) when L is created
>>> with "let"?
>>>
>>
>>
>


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 was just wondering if there was a way around
"setting" let'd values more than once...like you can with let'd
atoms...using inc and dec.
I don't think you can but didn't think you could with atoms until inc and
dec came back as an answer on this forum...hence this question :).
Thank you for your advice and best regards
Dean



On 11 February 2017 at 02:07, Joe Bogner  wrote:

> 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 value of the symbol sym - or the values of
> the symbols sym in the list of the second form - ***are saved** and the
> symbols are bound to the evaluated any arguments. The 64-bit version also
> accepts lst arguments in the second form; they may consist only of symbols
> and sublists, and match the any argument (destructuring bind). prg is
> executed, then the symbols ***are restored to their original values***.
>
>
>
> On Fri, Feb 10, 2017 at 3:22 PM, dean  wrote:
>
>> Hi
>> I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
>> 'Some_atom)
>> which gets me a long way...
>> ...but what about list elements?
>>
>>
>> (setq L (0 0 0))
>> (de doit ()
>>#(let L (0 0 0)
>>   (setq L (insert '1 (remove '1 L) 2))
>>   (prinl "L is " L)
>>#)
>> )
>>
>> When I "setq" L this works but can I do it (somehow) when L is created
>> with "let"?
>>
>
>


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 value of the symbol sym - or the values of the
symbols sym in the list of the second form - ***are saved** and the symbols
are bound to the evaluated any arguments. The 64-bit version also accepts
lst arguments in the second form; they may consist only of symbols and
sublists, and match the any argument (destructuring bind). prg is executed,
then the symbols ***are restored to their original values***.



On Fri, Feb 10, 2017 at 3:22 PM, dean  wrote:

> Hi
> I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
> 'Some_atom)
> which gets me a long way...
> ...but what about list elements?
>
>
> (setq L (0 0 0))
> (de doit ()
>#(let L (0 0 0)
>   (setq L (insert '1 (remove '1 L) 2))
>   (prinl "L is " L)
>#)
> )
>
> When I "setq" L this works but can I do it (somehow) when L is created
> with "let"?
>


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 you could define the behavior of the function you want.
Am 10.02.2017 21:28 schrieb "dean" :

> Hi
> I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
> 'Some_atom)
> which gets me a long way...
> ...but what about list elements?
>
>
> (setq L (0 0 0))
> (de doit ()
>#(let L (0 0 0)
>   (setq L (insert '1 (remove '1 L) 2))
>   (prinl "L is " L)
>#)
> )
>
> When I "setq" L this works but can I do it (somehow) when L is created
> with "let"?
>


altering LOCAL list elements

2017-02-10 Thread dean
Hi
I've seen that I can alter local/let'd atoms? via inc/dec i.e. (inc
'Some_atom)
which gets me a long way...
..but what about list elements?


(setq L (0 0 0))
(de doit ()
   #(let L (0 0 0)
  (setq L (insert '1 (remove '1 L) 2))
  (prinl "L is " L)
   #)
)

When I "setq" L this works but can I do it (somehow) when L is created with
"let"?