Looks good to me.<br>We write a macro for (run #f (q) ...), which we call (run* (q) ...)<br>You might want to add it.<br>... Dan<br><br><div class="gmail_quote">On Sun, Apr 5, 2009 at 3:23 AM, Jon Loldrup <span dir="ltr"><<a href="mailto:loldrup@gmail.com">loldrup@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Well it sure does evaluate successfully now, and testing the first 4 expressions on page 4 in "The Reasoned Schemer" makes them all return the same value as the ones in that book. Only thing is, the book doesn't mention the definitions of fail and succeed (only that they are longs for #u and #s), so I'm not sure whether this solution is some crude hack or the official way to do it.<br>
<br>Now this code:<div class="im"><br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">#lang scheme</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(require (planet dfriedman/miniKanren:1:1/minikanren))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">(define succeed (== #t #t))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(define fail (== #t #f))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">(run #f (q) fail)</span><br style="font-family: courier new,monospace;"></div><span style="font-family: courier new,monospace;">(run #f (q) (== #t q))</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">(run #f (q) fail (== #t q))</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(run #f (q) succeed (== #t q))</span><br>
<br>returns this:<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(#t)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">()</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">(#t)</span><br><br><br clear="all">Jon Loldrup<br>
<br><br><div class="gmail_quote">2009/4/5 Ben Goetter <span dir="ltr"><<a href="mailto:goetter@mazama.net" target="_blank">goetter@mazama.net</a>></span><div><div></div><div class="h5"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Jon Loldrup wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
[...] the third line was taken from the file mktests.scm <<a href="http://kanren.cvs.sourceforge.net/viewvc/kanren/kanren/mini/mktests.scm?revision=1.6&view=markup" target="_blank">http://kanren.cvs.sourceforge.net/viewvc/kanren/kanren/mini/mktests.scm?revision=1.6&view=markup</a>> which I think is designed to test a minikanren implementation.<br>
</blockquote>
That file tests the particular version of minikanren currently on Sourceforge, which is not the same as the version on PLaneT. You cannot necessarily mix and match the two. Still, (run #f (q) fail) seems like a reasonable command to issue... isn't that out of the book?<br>
<br>
Inspecting minikanren.ss reveals that, indeed, it doesn't export any "fail." The mk.scm on Sourceforge includes the following two definitions<br>
<br>
(define succeed (lambdag@ (s) (unit s)))<br>
(define fail (lambdag@ (s) (mzero)))<br>
<br>
which you can't issue yourself, because the version on PLaneT exports neither lambdag@ nor mzero. Try instead<div><br>
<br>
#lang scheme<br>
(require (planet dfriedman/miniKanren:1:1/minikanren))<br></div>
(define succeed (== #t #t))<br>
(define fail (== #t #f))<br>
(run #f (q) fail)<br>
<br>
That seems to fail correctly. I don't have my copy of TRS at hand, so I can't opine further.<br>
<br>
Hope that helps,<br><font color="#888888">
Ben<br>
<br>
</font></blockquote></div></div></div><br>
</blockquote></div><br>