You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
770 B
28 lines
770 B
2 years ago
|
|
||
|
Exercise 4.71: Louis Reasoner wonders why the
|
||
|
simple-query and disjoin procedures (4.4.4.2) are
|
||
|
implemented using explicit delay operations, rather than being defined
|
||
|
as follows:
|
||
|
|
||
|
|
||
|
(define (simple-query
|
||
|
query-pattern frame-stream)
|
||
|
(stream-flatmap
|
||
|
(lambda (frame)
|
||
|
(stream-append
|
||
|
(find-assertions query-pattern frame)
|
||
|
(apply-rules query-pattern frame)))
|
||
|
frame-stream))
|
||
|
|
||
|
(define (disjoin disjuncts frame-stream)
|
||
|
(if (empty-disjunction? disjuncts)
|
||
|
the-empty-stream
|
||
|
(interleave
|
||
|
(qeval (first-disjunct disjuncts)
|
||
|
frame-stream)
|
||
|
(disjoin (rest-disjuncts disjuncts)
|
||
|
frame-stream))))
|
||
|
|
||
|
Can you give examples of queries where these simpler definitions would lead to
|
||
|
undesirable behavior?
|