Created
April 28, 2010 03:00
-
-
Save polgfred/381666 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(declare read-term) | |
;; accumulate terms from an input sequence until \) | |
(defn read-terms [[c & more :as input] acc] | |
(if (= c \)) [(reverse acc) more] | |
(let [[term input] (read-term input)] | |
(recur input (cons term acc))))) | |
;; read one term from an input param | |
(defn read-term [[c & more]] | |
(if (not= c \() [c more] | |
(read-terms more ()))) | |
(println (first (read-term (vec "(ABC(DE(FGH)I)J)")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment