expose stringish

pull/2/head
Matthew Butterick 11 years ago
parent 44e61cd330
commit fe412cb670

@ -1,15 +1,14 @@
#lang racket/base #lang racket/base
(require racket/contract) (require racket/contract)
(require "coerce.rkt" "container.rkt" "len.rkt") (require "coerce.rkt" "container.rkt" "len.rkt" "try.rkt")
(provide starts-with? ends-with?) (provide starts-with? ends-with? stringish?)
;; stringish: data type that can be trivially converted to string ;; stringish: data type that can be trivially converted to string
;; todo: merge this with pathish ;; todo: merge this with pathish
(define/contract (stringish? x) (define/contract (stringish? x)
(any/c . -> . boolean?) (any/c . -> . boolean?)
(with-handlers ([exn:fail? (λ(e) #f)]) (try (->boolean (->string x)) (except [exn:fail? (λ(e) #f)])))
(->boolean (->string x))))
;; python-style string testers ;; python-style string testers
(define/contract (starts-with? str starter) (define/contract (starts-with? str starter)

Loading…
Cancel
Save