Skip to content

Differences from The Reasoned Schemer

swannodette edited this page May 30, 2011 · 20 revisions

The following are the most important differences from version of miniKanren described in The Reasoned Schemer (TRS).

  • #s is s#
  • #u is u#
  • fresh is exist
  • conde is actually condi. There is no conde as is presented in the book.
  • conde does not support defining an else clause.
  • the run interface returns a lazy-sequence not a list
  • Clojure has no way to create pairs (sequences with improper tails). The core.logic lcons constructor fn provides this behavior. llist is a convenience macro that expands out into nested lcons expressions.
  • nullo is emptyo
  • nilo unifies with nil
  • caro is firsto
  • cdro is resto

For example TRS 2-52 (Chapter 2, #52) is written like so in Scheme:

(run #f (r)
  (fresh (x y)
    (== (cons x (cons y 'salad)) r)))

It can be written like this in core.logic:

(run* [r]
  (exist [x y]
    (== (lcons x (lcons y 'salad)) r)))

TRS 3-10 is written like so in Scheme:

(run 1 (x)
  (listo '(a b c . x)))

Can be written like this in core.logic:

(run 1 [x]
  (listo (llist a b c x)))
Clone this wiki locally