more
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#lang pl
|
||||
|
||||
(define-type Token = (U Symbol Integer))
|
||||
|
||||
(: in? : Symbol (Listof Symbol) -> Boolean)
|
||||
(define (in? s l) (and (not (null? l)) (not (and (not (symbol=? s (first l))) (not (in? s (rest l)))))))
|
||||
|
||||
(test (in? 'a '(b d e a f e)))
|
||||
(test (in? 'a '(b x e a x e)))
|
||||
(test (in? 'a '(a b d e a f e)))
|
||||
(test (in? 'a '(b d e a f e a)))
|
||||
(test (not (in? 'a '(b d e f e))))
|
||||
(test (not (in? 'a '())))
|
||||
|
||||
#|
|
||||
(: abc : String -> Boolean)
|
||||
; Identifies strings that match "(ab(c+))+"
|
||||
(define abc (automaton one (four)
|
||||
[one : (a -> two)]
|
||||
[two : (b -> three)]
|
||||
[three : (c -> four)]
|
||||
[four : (c -> four) (a -> two)]))
|
||||
|
||||
(test (abc "abccc"))
|
||||
(test (abc "abcccabc"))
|
||||
(test (not (abc "ab")))
|
||||
(test (not (abc "q")))
|
||||
(test (not (abc "abcb")))
|
||||
(test (not (abc "abcab")))
|
||||
|#
|
||||
Reference in New Issue
Block a user