<div dir="ltr"><div class="gmail_default" style><div class="gmail_default" style><font face="courier new, monospace">(require racklog)</font></div><div class="gmail_default" style><font face="courier new, monospace"><br></font></div>
<div class="gmail_default" style><font face="courier new, monospace">(define (list-index l x)</font></div><div class="gmail_default" style><font face="courier new, monospace"> (for/or ([y l] [i (in-naturals)] #:when (equal? x y)) i))</font></div>
<div class="gmail_default" style><font face="courier new, monospace"><br></font></div><div class="gmail_default" style><font face="courier new, monospace">(define ALPHAQ '(A B C D E F G H I J K L M N O P Q))</font></div>
<div class="gmail_default" style><font face="courier new, monospace"><br></font></div><div class="gmail_default" style><font face="courier new, monospace">;; Are U and V within N words of each other in S</font></div><div class="gmail_default" style>
<font face="courier new, monospace">(define %within-span-relational</font></div><div class="gmail_default" style><font face="courier new, monospace"> (%rel (u up v vp n s)</font></div><div class="gmail_default" style><font face="courier new, monospace"><span class="" style="white-space:pre"> </span>[(u v n s)</font></div>
<div class="gmail_default" style><font face="courier new, monospace"><span class="" style="white-space:pre"> </span> (%is up (list-index s u))</font></div><div class="gmail_default" style><font face="courier new, monospace"><span class="" style="white-space:pre"> </span> (%is vp (list-index s v))</font></div>
<div class="gmail_default" style><font face="courier new, monospace"><span class="" style="white-space:pre"> </span> (%is #t (<= n (abs (- up vp))))] ))</font></div><div class="gmail_default" style><font face="courier new, monospace"><br>
</font></div><div class="gmail_default" style><font face="courier new, monospace">;; > (%which () (%within-span-relational 'C 'G 3 ALPHAQ))</font></div><div class="gmail_default" style><font face="courier new, monospace">;; '()</font></div>
<div class="gmail_default" style><font face="courier new, monospace"><br></font></div><div class="gmail_default" style><font face="courier new, monospace">;; Same as above but using the relation %<= instead of </font></div>
<div class="gmail_default" style><font face="courier new, monospace">(define %within-span-procedural </font></div><div class="gmail_default" style><font face="courier new, monospace"> (%rel (u up v vp n s)</font></div><div class="gmail_default" style>
<font face="courier new, monospace"><span class="" style="white-space:pre"> </span>[(u v n s)</font></div><div class="gmail_default" style><font face="courier new, monospace"><span class="" style="white-space:pre"> </span> (%is up (list-index s u))</font></div>
<div class="gmail_default" style><font face="courier new, monospace"><span class="" style="white-space:pre"> </span> (%is vp (list-index s v))</font></div><div class="gmail_default" style><font face="courier new, monospace"><span class="" style="white-space:pre"> </span> (%<= n (abs (- up vp)))] ))</font></div>
<div class="gmail_default" style><font face="courier new, monospace"><br></font></div><div class="gmail_default" style><font face="courier new, monospace">;; > (%which () (%within-span-procedural 'C 'G 3 ALPHAQ))</font></div>
<div class="gmail_default" style><font face="courier new, monospace">;; > -: contract violation</font></div><div class="gmail_default" style><font face="courier new, monospace">;; expected: number?</font></div><div class="gmail_default" style>
<font face="courier new, monospace">;; given: #<logic-var></font></div><div class="gmail_default" style><font face="courier new, monospace">;; argument position: 1st</font></div><div class="gmail_default" style>
<font face="courier new, monospace">;; other arguments...:</font></div><div class="gmail_default" style><font face="courier new, monospace">;; #<logic-var></font></div><div class="gmail_default" style><font face="courier new, monospace">;; context...:</font></div>
<div class="gmail_default" style><font face="courier new, monospace">;; /Applications/Racket/collects/racket/private/misc.rkt:87:7</font></div><div style="font-size:small"><br></div></div></div>