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

   (de pairlis (X Y A)
            '((A B) (and A B (cons A B)))
            Y )
         A ) )

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

Reply via email to