(import strse (chicken string) srfi-13 srfi-1) (define dont-touch-me #t) (define set-me #f) (unless (string=? "that was SO very, very nice" (strse "this is freaking awesome" "is" "at" "at" "was so" 2 'word string-upcase 3 "very "(then (set! dont-touch-me #f)) "frea" "ve" "king" "ry" "very "(then (set! set-me #t)) (=> adjective "very") (conc adjective ", " adjective) 'word "nice" -1)) (error "Strings don't match!")) (unless (and set-me dont-touch-me) (error "Setting, then, side-effects system is borked")) (define (acc) (let ((things '())) (lambda thing (if (null? thing) things (set! things (cons (car thing) things)))))) (define (extract str) (define digs (acc)) (define words (acc)) (strse str (= 3 num) (then (digs (string->number (m 0)))) (+ alpha) (then (words (m 0)))) (list (digs) (words))) (unless (equal? (extract "it will get 234 and 123 and 747 but not 1983 or 42 but then again 420") '((420 198 747 123 234) ("again" "then" "but" "or" "not" "but" "and" "and" "get" "will" "it"))) (error "Bindings in then bodies borked")) (unless (strse? "banayna" "y") (error "Even strse? is off today!")) (unless (equal? (strse "chirp chirp birds" "chir" "shee" "sheep" "The sentence got woolly" 0) "The sentence got woolly") (error "Error in zero operator")) (unless (equal? (strse "chirp chirp birds" "chir" "shee" "sheep" (entire "The sentence got woolly")) "The sentence got woolly") (error "Error in entire operator")) (unless (equal? (strse "aaaaaaaah!" (recursively "aa") "a") "ah!") (error "Error in recursively operator")) (unless (equal? (strse "this is freaking awesome" "is" "at" (only second "at") "was so" (only third 'word) string-upcase "frea" "ve" "king" "ry" (=> adjective "very") (conc adjective ", " adjective) (only last 'word) "nice") (strse "this is freaking awesome" "is" "at" (only 1 "at") "was so" (only 2 'word) string-upcase "frea" "ve" "king" "ry" (=> adjective "very") (conc adjective ", " adjective) (only last 'word) "nice")) (error "New flavor is broken")) (unless (equal? '(some (old style) lisp) (strse* '(SOME (OLD STYLE) LISP) 'word string-downcase)) (error "(strse* (quote (SOME (OLD STYLE) LISP)) (quote word) string-downcase)")) (unless (equal? '3411 (strse* 3422 "2" "1")) (error "(strse* 3422 \"2\" \"1\")")) (unless (equal? '(#f #t #f #f #f #f #f #f #f #f #t #t #t) (map (strse?* "1") (iota 13))) (error "(map (strse?* \"1\") (iota 13))")) (unless (equal? (strse "banana" "a" (return "t") "n" "j") "t") (error "Return isn't returning"))