Add variable-prefix enumerator

This commit is contained in:
Max New 2013-11-10 13:11:44 -06:00
parent 46d3493b99
commit c23f326b58
2 changed files with 26 additions and 10 deletions

View File

@ -102,8 +102,16 @@
[`(variable-except ,s ...)
(apply except/e var/e s)]
[`(variable-prefix ,s)
;; todo
(unimplemented "var-prefix")]
(define as-str (symbol->string s))
(map/e (compose string->symbol
(curry string-append as-str)
symbol->string)
(compose string->symbol
list->string
(curry (flip drop) (string-length as-str))
string->list
symbol->string)
var/e)]
[`variable-not-otherwise-mentioned
unused/e]
[`hole
@ -323,3 +331,7 @@
(disj-sum/e #:alternate? #t
(cons base/e (negate pair?))
(cons (cons/e any/e any/e) pair?)))))
(define (flip f)
(λ (x y)
(f y x)))

View File

@ -101,17 +101,21 @@
(n (p_!_1 p_!_1))
(x number))
;; Mismatch isn't working for now, will come back to this.
#;#;#;
(try-it 100 M m)
(try-it 100 M n)
(try-it 100 M p)
;; test variable-not-otherwise-mentioned
(define-language VarMentioned
;; (try-it 100 M m)
;; (try-it 100 M n)
;; (try-it 100 M p)
;; test variable filtering
(define-language Vars
(mention a b c x y z 2 #f #\c (vec 1 2))
(var variable-not-otherwise-mentioned))
(varpre (variable-prefix moo))
(varexc (variable-except x λ))
(varnom variable-not-otherwise-mentioned))
(try-it 20 VarMentioned var)
(try-it 100 Vars varpre)
(try-it 100 Vars varexc)
(try-it 100 Vars varnom)
;; Named repeats
(define-language NRep