I find loop recur kind of hard to follow sometimes
I was browsing through this pdf the other day:
http://www.cs.umbc.edu/331/resources/papers/Evolution-of-Lisp.pdf
And I found the tail recursive definition of common lisp/scheme style
do.
Thoroughly intrigued, I implemented it:
(defmacro cl-
There's also re-split in str-utils in clojure.contrib;
(use 'clojure.contrib.str-utils)
(re-split #"\s" "The quick brown fox")
=> ("The" "quick" "brown" "fox")
You can then use all the good clojure collection functions;
(def words (re-split #"\s" "The quick brown fox"))
(some #{"brown"} words)
Also keep in mind that for string operations the Java String provides
a lot of built in functionality:
(let [s "the quick brown fox"]
(.substring s (.indexOf s "brown")))
"brown fox"
And you could simply ask the regular expression to find what you want:
(re-find #"brown.*" "the quick brown fox")
I think you're looking for something more like this:
(use '[clojure.contrib.str-utils :only (str-join)])
(def mystr "the quick brown fox")
(defn split-at-word
[text keyword]
(str-join " " (drop-while (partial not= keyword)
(re-seq #"\w+" text
user=> (split
Aridaman Pandit wrote:
> Thanks for the reply. I understand the code that you have given.
> Actually I also wanted it to be stored into some variable (if not the
> same) everytime I run it.
> Suppose I am matching for keyword "brown" and I want to store
> everything after "brown". So for that purpo
Hi
Thanks for the reply. I understand the code that you have given.
Actually I also wanted it to be stored into some variable (if not the
same) everytime I run it.
Suppose I am matching for keyword "brown" and I want to store
everything after "brown". So for that purpose I wanted to chop off
ever
Aridaman,
> I am very new to clojure and have worked previously on C/C++
>
> I wanted to do some string operations, where I can match occurrence of
> a particular string. However, I get this error everytime.
>
> java.lang.ClassCastException: clojure.lang.Var cannot be cast to
> java.lang.CharSeq
Hi everyone
I am very new to clojure and have worked previously on C/C++
I wanted to do some string operations, where I can match occurrence of
a particular string. However, I get this error everytime.
java.lang.ClassCastException: clojure.lang.Var cannot be cast to
java.lang.CharSequence (myse