Re: shorter way of assigning list elements to multiple symbols?

2016-12-24 Thread dean
Thank you very much Danilo

On 23 December 2016 at 17:34, Danilo Kordic  wrote:

> When `continuation' is:
>   - `list' 3rd becomes 2nd.
>   - `[quote @ [mapc 'set '[R1 R2 R3] [rest]]]' 3rd becomes 1st.
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: shorter way of assigning list elements to multiple symbols?

2016-12-23 Thread Danilo Kordic
When `continuation' is:
  - `list' 3rd becomes 2nd.
  - `[quote @ [mapc 'set '[R1 R2 R3] [rest]]]' 3rd becomes 1st.
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: shorter way of assigning list elements to multiple symbols?

2016-12-18 Thread dean
Hi Alex
>(let ((A B C) (foo))
I am using pil64 so...That's great...Thank you very much indeed
Best Regards
Dean

On 18 December 2016 at 21:05, Alexander Burger  wrote:

> Hi Dean,
>
> > I'm sure I can only return multiple values from a function as a list.
> > I can assign those values to multiple symbols in the calling function
> like
> > this...
> >
> > (setq L (1 100 1000))
> >
> > (setq A (get L 1) B (get L 2) C (get L 3))
>
> Right.
>
>
> > but wonder if there's a shorter way.
>
> For the elements near the beginning of a nested List structure there are
> direct
> access functions cr, i.e. car, cdr, cadr, cdar, cddr ... up until 4
> 'a's or
> 'd's.
>
> So the 4th element of a list is (cadddr L), and the above becomes
>
>(setq A (car L)  B (cadr L)  C (caddr L))
>
>
> Another possibility is to use de "destructuring bind" feature of 'let'
> (only
> available in pil64). It is the shortest:
>
>(let ((A B C) L) ...
>
> So if you get this list from a function 'foo', you would do
>
>(let ((A B C) (foo)) ...
>
> - Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: shorter way of assigning list elements to multiple symbols?

2016-12-18 Thread Alexander Burger
Hi Dean,

> I'm sure I can only return multiple values from a function as a list.
> I can assign those values to multiple symbols in the calling function like
> this...
> 
> (setq L (1 100 1000))
> 
> (setq A (get L 1) B (get L 2) C (get L 3))

Right.


> but wonder if there's a shorter way.

For the elements near the beginning of a nested List structure there are direct
access functions cr, i.e. car, cdr, cadr, cdar, cddr ... up until 4 'a's or
'd's.

So the 4th element of a list is (cadddr L), and the above becomes

   (setq A (car L)  B (cadr L)  C (caddr L))


Another possibility is to use de "destructuring bind" feature of 'let' (only
available in pil64). It is the shortest:

   (let ((A B C) L) ...

So if you get this list from a function 'foo', you would do

   (let ((A B C) (foo)) ...

- Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


shorter way of assigning list elements to multiple symbols?

2016-12-18 Thread dean
I'm sure I can only return multiple values from a function as a list.
I can assign those values to multiple symbols in the calling function like
this...

(setq L (1 100 1000))

(setq A (get L 1) B (get L 2) C (get L 3))

but wonder if there's a shorter way.
Thank you in anticipation.
Dean