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

