This commit is contained in:
2026-05-30 09:12:55 -04:00
parent 18e5275a76
commit f7810ac1a6
3 changed files with 464 additions and 0 deletions
+30
View File
@@ -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")))
|#