Hi Alex,

I missed to include it...
   (de null (X) (not X))

Thanks! for the suggestions.

I tried the pairlis alternatives. Much better.
'extract' will be very useful.

I'll have to work with nond a bit more to get how/when use that.

/Lindsay


On Thu, Feb 9, 2017 at 3:17 AM, Alexander Burger <a...@software-lab.de>
wrote:

> Hi Lindsay,
>
> > # pairlis2: gives a list of pairs of corresponding elements
> > # of the lists x and y, and appends this to the list a.
> > # (pairlis '(A B C) '(1 2) () ) -> ((A . 1) (B . 2))
> >
> > (de pairlis2 (X Y A)
> >    (cond
> >       ((null X) A)
> >       ((null Y) A)
> >       (T
> >          (cons
> >             (cons (car X) (car Y))
> >             (pairlis2 (cdr X) (cdr Y) A) ) ) ) )
>
> Sorry, I have not tested, but 'null' should be undefined. You could
> replace it
> with 'not'. But then 'nond' is better than 'cond', avoiding it completely
> (see
> discussion here in this list).
>
>
> In general, using recursion here is quite an overkill. A simpler form
> could be
>
>    (de pairlis (X Y A)
>       (conc (mapcar cons X Y) A) )
>
> or, if you want to handle the case where the first list is longer than the
> second,
>
>    (de pairlis (X Y A)
>       (conc
>          (extract
>             '((A B) (and A B (cons A B)))
>             X
>             Y )
>          A ) )
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>

Reply via email to