Hi all, newcomer to clojure/lisp/fp here. I'm working my way through the Programming Clojure book (very excellent, well worth the money), and doing some dabbling in the REPL, and I'm seeing something that puzzles me. In the book there's an example of a clojure blank? function that looks like this:
(defn blank? [s] (every? #(Character/isWhitespace %) s)) So far so good. I want to use that sort of pattern to define a hex? function to see if a string is all hexadecimal characters. (Not that I need a hex? function, I just want to see if I can write it.) I start with a hexchar? function to test individual characters. ;;;;;;;;;;;;;;;; user=> (defn hexchar? [c] (re-find #"[0-9A-Fa-f]" c)) #'user/hexchar? nil user=> (hexchar? "a") "a" nil user=> (hexchar? "w") nil nil ;;;;;;;;;;;;;;;; Ok, so far so good. Now I want to use this function to define hex?, using the pattern from Programming Clojure ;;;;;;;;;;;;;;;; user=> (defn hex? [s] (every? #(hexchar? %) s)) #'user/hex? nil user=> (hex? "a") #<CompilerException java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.CharSequence (NO_SOURCE_FILE:0)> ;;;;;;;;;;;;;;;; Not what I expected at all! I assume there's a problem with the result returned by re-find? Not sure. I'm going to keep playing with it, but in the meantime I thought I'd post what I'm seeing in case somebody wanted to shed some light on the subject. This is from the Netbeans REPL provided by the enclojure plugin by the way. Thanks for any clues you have to share. Mark --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---