Arc Forumnew | comments | leaders | submitlogin
7 points by almkglor 6119 days ago | link | parent

  (def pair (xs (o f list))
    " Applies pairs of elements to the function `f'.
      See also [[tuples]] [[map]] "
    (if (no xs)
         nil
        (no (cdr xs))
         (list (list (car xs)))
        (cons (f (car xs) (cadr xs))
              (pair (cddr xs) f))))

  (defpat *defpat-pair
          " Example/testcase for defpat in redefining
            the `pair' function. "
          ((x y . zs))    `((,x ,y) ,@(*defpat-pair zs))
          ((x y . zs) f)  `(,(f x y) ,@(*defpat-pair zs f))
          ((x) . _)       `((,x))
          (() . _)        ())