Skip to content

Conversation

@NoahStoryM
Copy link

@NoahStoryM NoahStoryM commented Sep 12, 2021

Bug 1:

> (run* (q) (== q #f))
'()

In the definition of case-inf, the cond's first branch:

[(not a-inf) e0]

When q was bound to #f, however, #f was regard as a kind of failure, then it was ignored.

So instead of putting the result directly into stream, it's better to encapsulate it with a list first.

Bug 2:

> (run 1.2 (q) (== q #t))
'(#t)
> (run -3 (q) (== q #t))
'(#t)

take should not accept negative number or float number.

Bug 3:

> (define teacupo
    (λ (x)
      (conde [(== 'tea x) succeed]
             [(== 'cup x) succeed]
             [fail])))
> (run* (r)
        (conde [(teacupo r) succeed]
               [(== 'f r) succeed]
               [fail]))
'(f tea cup)

It should return '(tea cup #f) .

On the Appendix A of The Reasoned Schemer, mplus and mplusi are defined like this:

(define mplus
  (λ (a-inf f)
    (case-inf a-inf
      (f)
      [(a) (choice a f)]
      [(a f0) (choice a (λf@ () (mplus (f0) f)))])))

(define mplusi
  (λ (a-inf f)
    (case-inf a-inf
      (f)
      [(a) (choice a f)]
      [(a f0) (choice a (λf@ () (mplusi (f) f0)))])))

We can see that mplusm is defined as mplusi instead of mplus in the old code.

@NoahStoryM NoahStoryM changed the title take should be given a natural number or false. Fix some bugs Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant