(defn paths ([xs] (paths [] xs)) ([path xs] (if (keyword? (first (rest xs))) (map (partial conj path) xs) (let [path (conj path (first xs))] (mapcat (partial paths path) (rest xs)))))) (let [xs [:a [:b [:c :d :e]] [:f [:g :h]]]] (prn (paths xs)))
Write, Run & Share Clojure code online using OneCompiler's Clojure online compiler for free. It's one of the robust, feature-rich online compilers for Clojure language, Getting started with the OneCompiler's Clojure editor is easy and fast. The editor shows sample boilerplate code when you choose language as Clojure and start coding.
OneCompiler's Clojure online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample Clojure program which takes name as input and prints hello message with your name.
(println "Hello" (read-line))
Clojure is a dialect of Lisp and a dynamic general-purpose programming language
(def var-name var-value)
(while(expression)
(do
statements))
(doseq (sequence)
statement)
(dotimes (variable value)
statements)
loop [binding]
(condition
(statement)
(recur (binding)))
(defn function-name [parameters] (codeblock) )
(fn [parameters] (codeblock) )