Insertion Sort in Clojure

In Insertion Sort, insert means search and find the position of current element ... . The code is listed as below. (defn insertion-sort [a] (loop [rest-part a partial-sorted ... ))) ) ) ) ) ) (insertion-sort '( 1 4 223 3 2 4 23 45 5 43 3 12 113 1)) The output. user ... > (insertion-sort '( 1 4 223 3 2 4 23 45 5 43 3 12 113 1)) ["rest-part" (1 4 223 3 2 4 23 45 5 43 3

Clojure cons, conj and concat

Manipulating lists and vectors in Clojure usually involves three functions: cons, conj ... and concat. Learn to use them helps you deal with list and vectors more efficiently. [cons two ... slots can be anything ELISP> (cons 2 '(3)) (2 3) ELISP> (cons 2 2) (2 . 2) In Clojure ... :505) It prepends the first parameter to the collection. [conj works on collection] Clojure

Convert XML to HTML with XSLT in Clojure

Convert XML to HTML with XSLT, using javax.xml package. (defn xslt-transform [xml xslt ... . ( xml))) tfactory (javax.xml.transform.TransformerFactory/newInstance ... ) xslt-source ( ( xslt ... )) transformer (.newTransformer tfactory xslt-source) source

Java IO PushbackReader example in Clojure

to pushback chars back to the stream or look ahead. For example the Clojure programming language ... A PushbackReader can wrap a stream from file, string or standard input. PushbackReader ... then wrapped in a LineNumberingPushbackReader. [Create a PushbackReader] Let's define a PushbackReader ... on a String in Clojure (def pbr ( (

How to automatically add parentheses in Clojure REPL

in a REPL. In this post we will introduce how to automatically add parentheses to your one line of Clojure ... In previous post we discussed about how Clojure REPL works and the basic component ... with '(', we will read the whole expression from input stream and add parentheses to it then push the string ... send expression in Emacs cider REPL, it doesn't work, as if they use two different Clojure instance

How Clojure REPL works

If you are using Clojure REPL, there will be times you want to adjust the REPL behavior ... \core.clj, clojure1.6\src\jvm\clojure\lang\ [Where the REPL waiting input ... , the only way will be to modify the source code of Clojure. Clojure is open source, you can build ... it from source and run it in 1 minutes. This post illustrate some key points in Clojure's REPL

Convert Clojure data structure to JSON and parse it in PHP

them can be JSON. We have a data structure in Clojure [ ["obj1" "obj2" "obj3"] ] To convert ... -json read-str write write-json write-str nil To parse the JSON string to PHP data structures ... of document, XML maybe better, for other cases, JSON is better. If you are generating data in Clojure ... JSON is an idea data exchange format between different applications. If the data is type

Clojure how to eval code from a string

I have a string of Clojure code comes from another text file, its actually a DSL language which ... functions in Clojure can evaluate code from a string: read-string, load-string. The read-string ... of Clojure code. When we process the text file, we will extract the Clojure code from the file ... , this function may be designed to use in a REPL, to evaluate one liner of Clojure code. user

Clojure regular expression extract text between two strings

Given a prefix and suffix string, how to extract all the text between them? In Clojure ... [a] (.replace a "\"" "\\\"") ) (defn extract-anything-between [prefix suffix from-string] (let [pattern ... pattern) from-string)) ) ) (defn extract-anything-between-combine [prefix suffix ... "start-tag hello world end-tag") (extract-anything-between "start-tag" "end-tag" s) Output
1 2 ... 6 Next Page