(get "foo" 0)
;; => \f
(get "foo" 0)returns a char, not string, so if you want to use check-first, you will need to replace the strings with characters.
(defn check-first [s]
(case (first s) \+ 1, \- 2, 3))
By the way, Clojure library coding standards are
recommended sas an argument name for functions that require string input.
: (str (first "foo")) (subs "foo" 0 1) => "f"
case-indexed.
:
(defmacro case-indexed [expr & clauses]
(list* 'case expr (interleave clauses (iterate inc 1))))
;; (case-indexed "foo" "bar" "baz" "foo") => 3
;; (case-indexed (+ 5 1) 3 4 5 6 7) => 4
(defn check-first [s]
(case-indexed (first s)
\+, \-, \*, \/))
, , , .
case-indexed , - . , check-first ; , . (, .)