问题
I started studying miniKanren with the book "The Reasoned Schemer - second edition" and the DrRacket scheme environment.
I installed the "faster-minikanren" package, but the first examples of the book with the command run*
(for example, (run* q #f)
) produce error messages such as run*: bad syntax in: (run* q #f)
.
Does this mean that the "faster-minikanren" package does not provide the right definition of minikanren? Or am I making a mistake?
回答1:
As the readme says, you need to put (require minikanren)
in your Racket source file.
I've put in on the second line, after #lang racket
, copied the appendo
definition,
#lang racket
(require minikanren)
(define (appendo l s out)
(conde
[(== l '()) (== s out)]
[(fresh (a d res)
(== `(,a . ,d) l)
(== `(,a . ,res) out)
(appendo d s res))]))
then clicked on "Run", and tried this at the prompt:
> (run* (q r) (appendo q r '(1 2 3 4 5)))
'((() (1 2 3 4 5))
((1) (2 3 4 5))
((1 2) (3 4 5))
((1 2 3) (4 5))
((1 2 3 4) (5))
((1 2 3 4 5) ()))
>
Seems to be working. This didn't:
> (run* q #f)
. run*: bad syntax in: (run* q #f)
> (run* (q) #f)
application: not a procedure;
expected a procedure that can be applied to arguments
given: #f
arguments...:
but this did:
> (run* (q) (lambda (_) #f))
'()
>
回答2:
Okay, everything Will Ness says is correct. Let me add another high-level comment: it looks like there's a combination of further development and a certain lack of support that's contributing to your situation.
1) It looks like the minikanren language has continued to evolve since the book was published.
2) It looks like certain changes (e.g. the #u success goal) weren't easy fits for Racket (though they'd certainly be possible with a Reader extension), and the authors of the libraries you're using elected to change the language instead.
One thing that may help are the docs for the original minikanren package (online at https://docs.racket-lang.org/minikanren/index.html ), which are nicely formatted and readable, and provide references for further reading.
回答3:
You may find the code from the second edition we just released helpful:
https://github.com/TheReasonedSchemer2ndEd/CodeFromTheReasonedSchemer2ndEd
Hope this helps!
Cheers,
--Will
来源:https://stackoverflow.com/questions/50568981/minikanren-support-by-dr-racket