From 18044c5cd4e92195e90a84f1db3f6d449acdb528 Mon Sep 17 00:00:00 2001 From: Matthew Butterick Date: Thu, 9 Apr 2020 21:36:54 -0700 Subject: [PATCH] omit chars arg --- words/main.rkt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/words/main.rkt b/words/main.rkt index ceb970a..e821272 100644 --- a/words/main.rkt +++ b/words/main.rkt @@ -5,6 +5,7 @@ (define (make-words #:letters [letters-arg #f] #:mandatory [mandatory #f] + #:omit [omit #f] #:combo [combo #f] #:min [min-length-arg 5] #:max [max-length-arg 10] @@ -19,6 +20,10 @@ (remove-duplicates (for/list ([c (in-string (string-append (or mandatory "") (or combo "")))]) (char-downcase c)) char=?) null)) + (define forbidden-cs + (remove-duplicates + (for/list ([c (in-string (or omit ""))]) + (char-downcase c)) char=?)) (define letter-cs-charidx (word->charidx (list->string @@ -54,6 +59,9 @@ (letter-cs-charidx . contains-char? . wc)) (or (not combo) (regexp-match combo word)) + ;; word does not contain forbidden characters + (for/and ([fc (in-list forbidden-cs)]) + (not (word-charidx . contains-char? . fc))) ;; maybe only proper names (if proper-names? (capitalized? word-charidx)