On Oct 6, 2008, at 5:16 AM, ssecorp wrote:

> (also, what is the best way to deal with strings in clojure, java-
> strings?)

Clojure strings are Java strings. Search for "java.lang.String split"  
on the web to find:

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html

Try it in Clojure.

user=> (seq (.split "Hot-cross-buns" "-"))
("Hot" "cross" "buns")
user=> (seq (.split "Hot-cross-buns" "-" 1))
("Hot-cross-buns")
user=> (seq (.split "Hot-cross-buns" "-" 2))
("Hot" "cross-buns")
user=> (seq (.split "Hot-cross-buns" "-" 3))
("Hot" "cross" "buns")

Those expressions are idiomatic Clojure. If you wanted split and split- 
all as Clojure functions:

user=>
(defn split
   [str delim]
   (seq (.split str delim 2)))
#'user/split
user=>
(defn split-all
   [str delim]
   (seq (.split str delim)))
#'user/split-all

With example uses:

user=> (split "hot-cross-buns" "-")
("hot" "cross-buns")
user=> (split-all "hot-cross-buns" "-")
("hot" "cross" "buns")
user=>

--Steve


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to