(create string)
create reader from string
(type (create "hello world")) => clojure.tools.reader.reader_types.IndexingPushbackReader
create reader from string (type (create "hello world")) => clojure.tools.reader.reader_types.IndexingPushbackReader
(ignore-char reader)
returns nil and moves reader one char forward
(->> ignore-char (read-repeatedly (create "abc")) (take 3) (apply str)) => ""
returns nil and moves reader one char forward (->> ignore-char (read-repeatedly (create "abc")) (take 3) (apply str)) => ""
(peek-char reader)
returns the current reader char with moving
(->> (read-times (create "abc") peek-char 3) (apply str)) => "aaa"
returns the current reader char with moving (->> (read-times (create "abc") peek-char 3) (apply str)) => "aaa"
(read-char reader)
reads single char and move forward
(->> read-char (read-repeatedly (create "abc")) (take 3) (apply str)) => "abc"
reads single char and move forward (->> read-char (read-repeatedly (create "abc")) (take 3) (apply str)) => "abc"
(read-include reader read-fn)
(read-include reader read-fn stop-fn)
reads up to a given predicate
(read-include (create " a") read-char (complement check/voidspace?)) => [[\space \space] \a]
reads up to a given predicate (read-include (create " a") read-char (complement check/voidspace?)) => [[\space \space] \a]
(read-repeatedly reader read-fn)
(read-repeatedly reader read-fn stop-fn)
reads input repeatedly
(->> (read-repeatedly (create "abcdefg") #(str (read-char %) (read-char %)) empty?) (take 5)) => ["ab" "cd" "ef" "g"]
reads input repeatedly (->> (read-repeatedly (create "abcdefg") #(str (read-char %) (read-char %)) empty?) (take 5)) => ["ab" "cd" "ef" "g"]
(read-times reader read-fn n)
reads input repeatedly
(->> (read-times (create "abcdefg") #(str (read-char %) (read-char %)) 2)) => ["ab" "cd"]
reads input repeatedly (->> (read-times (create "abcdefg") #(str (read-char %) (read-char %)) 2)) => ["ab" "cd"]
(read-to-boundary reader)
(read-to-boundary reader allowed)
reads to an input boundary
(read-to-boundary (create "abc efg")) => "abc"
reads to an input boundary (read-to-boundary (create "abc efg")) => "abc"
(read-until reader pred)
reads inputs until the predicate is reached
(read-until (create "abcde") (fn [ch] (= (str ch) "d"))) => "abc"
reads inputs until the predicate is reached (read-until (create "abcde") (fn [ch] (= (str ch) "d"))) => "abc"
(read-while reader pred & [eof?])
reads input while the predicate is true
(read-while (create "abcde") (fn [ch] (not= (str ch) "d"))) => "abc"
reads input while the predicate is true (read-while (create "abcde") (fn [ch] (not= (str ch) "d"))) => "abc"
(reader-position reader)
returns the position of the reader
(-> (create "abc") step-char step-char reader-position) => [1 3]
returns the position of the reader (-> (create "abc") step-char step-char reader-position) => [1 3]
(slurp reader)
reads rest of input from reader
(reader/slurp (reader/step-char (create "abc efg"))) => "bc efg"
reads rest of input from reader (reader/slurp (reader/step-char (create "abc efg"))) => "bc efg"
(step-char reader)
moves reader one char forward
(-> (create "abc") step-char read-char str) => "b"
moves reader one char forward (-> (create "abc") step-char read-char str) => "b"
(throw-reader reader message & input)
throws a reader message
(throw-reader (create "abc") "Message" {:data true}) => (throws)
throws a reader message (throw-reader (create "abc") "Message" {:data true}) => (throws)
(unread-char reader ch)
move reader one char back, along with char
(-> (create "abc") (step-char) (unread-char \A) (reader/slurp)) => "Abc"
move reader one char back, along with char (-> (create "abc") (step-char) (unread-char \A) (reader/slurp)) => "Abc"
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close