Hacker News new | past | comments | ask | show | jobs | submit login

FP is nice, but logic programming also has its niceties.

  (define (zipo a b z)
    (conde ((nullo a) (nullo z))
           ((nullo b) (pairo a) (nullo z))
           ((fresh (ahead atail bhead btail ztail)
              (conso ahead atail a)
              (conso bhead btail b)
              (conso (list ahead bhead) ztail z)
              (zipo atail btail ztail)))))

  (run* (q) (zipo '(1 2 3) '(a b c) q))
  => (((1 a) (2 b) (3 c)))
  (run* (q) (zipo '(1 2 3) q '((1 a) (2 b) (3 c)))
  => ((a b c . _.0))



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: