|
|
|
@ -232,10 +232,18 @@
|
|
|
|
|
(check-false ("F" . in? . #\F)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; stringish: data type that can be trivially converted to string
|
|
|
|
|
;; todo: merge this with pathish
|
|
|
|
|
(define/contract (stringish? x)
|
|
|
|
|
(any/c . -> . boolean?)
|
|
|
|
|
(->boolean (or path? string? symbol?)))
|
|
|
|
|
|
|
|
|
|
;; python-style string testers
|
|
|
|
|
(define/contract (starts-with? str starter)
|
|
|
|
|
(string? string? . -> . boolean?)
|
|
|
|
|
(and (<= (len starter) (len str)) (equal? (get str 0 (len starter)) starter)))
|
|
|
|
|
(stringish? stringish? . -> . boolean?)
|
|
|
|
|
(let ([str (->string str)]
|
|
|
|
|
[starter (->string starter)])
|
|
|
|
|
(and (<= (len starter) (len str)) (equal? (get str 0 (len starter)) starter))))
|
|
|
|
|
|
|
|
|
|
(module+ test
|
|
|
|
|
(check-true ("foobar" . starts-with? . "foo"))
|
|
|
|
|