- The Law of Fresh
- If x is fresh, then (= v x) succeeds and associates x with v.
- The Law of =
- (= v w) is the same as (= w v)
- The Law of cond-e
- To get more values from cond, pretend that the successful cond line has failed, refreshing all variables that got an associated from that line.
- The Law of cond-i
- Cond-i behaves like cond-e, except that its values are interleaved.
- We believe that it is natural to extend functional programming to relational programming.
- In order to do relational programming, we need only two constants: #s and #u, and only three operators: =, fresh, and cond-e.
- #s and #u are reminiscent of the Boolean constants: #t and #f; fresh expressions resemble lambda expressions; and cond-e expressions are syntactically like cond expressions.
- The First Commandment
- To transform a function whose value is a Boolean into a function whose value is a goal, replace cond with cond-e and un-nest each question and answer. Un-nest the answer #t (or #f) by replacing it with #s (or #u).
- The Second Commandment
- To transform a function whose value is not a Boolean into a function whose value is a goal, add an extra argument to hold its value, replace cond with cond-e, and un-nest each question and answer.
- The Third Commandment
- If prior to determining the question of a cond-a (or cond-u) line a variable is fresh, it must remain fresh in the question of that line.
20190210
The Reasoned Schemer by Daniel P. Friedman, William E. Byrd, & Oleg Kiselyov
Labels:
books
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment