|
|
@ -56,12 +56,12 @@
|
|
|
|
;; put item as first arg so function can use infix notation
|
|
|
|
;; put item as first arg so function can use infix notation
|
|
|
|
;; (item . in . container)
|
|
|
|
;; (item . in . container)
|
|
|
|
(define/contract (in? item container)
|
|
|
|
(define/contract (in? item container)
|
|
|
|
(any/c any/c . -> . boolean?)
|
|
|
|
(any/c any/c . -> . coerce/boolean?)
|
|
|
|
(->boolean (cond
|
|
|
|
(cond
|
|
|
|
[(list? container) (member item container)] ; returns #f or sublist beginning with item
|
|
|
|
[(list? container) (member item container)] ; returns #f or sublist beginning with item
|
|
|
|
[(vector? container) (vector-member item container)] ; returns #f or zero-based item index
|
|
|
|
[(vector? container) (vector-member item container)] ; returns #f or zero-based item index
|
|
|
|
[(hash? container)
|
|
|
|
[(hash? container)
|
|
|
|
(and (hash-has-key? container item) (get container item))] ; returns #f or hash value
|
|
|
|
(and (hash-has-key? container item) (get container item))] ; returns #f or hash value
|
|
|
|
[(string? container) ((->string item) . in? . (map ->string (string->list container)))] ; returns #f or substring beginning with item
|
|
|
|
[(string? container) (regexp-match (->string item) (->string container))] ; returns #f or substring beginning with item
|
|
|
|
[(symbol? container) ((->string item) . in? . (->string container))] ; returns #f or subsymbol (?!) beginning with item
|
|
|
|
[(symbol? container) ((->string item) . in? . (->string container))] ; returns #f or subsymbol (?!) beginning with item
|
|
|
|
[else #f])))
|
|
|
|
[else #f]))
|