clojure - Returning a value from a loop -


i'm new clojure , hoping me out here:

;; loop collect data (defn read-multiple []   (def inputs (list))    (loop [ins inputs]     (def input (read-val ">"))     (if (not= input "0")       (recur (conj ins input)))     (i-would-like-to-return-something-when-the-loop-terminates))) 

how i, after collecting input, list of input collected far?

the return value of loop retrun value of if statement

 (loop [ins inputs]    (def input (read-val ">"))    (if (not= input "0")      (recur (conj ins input))      return-value-goes-here)) 

and replace def let binding locals

(loop [ins inputs]  (let [input (read-val ">")]   (if (not= input "0")     (recur (conj ins input))     return-value-goes-here))) 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -