                          (ParseOut i)
                          ParseEnd)
 
+(def parse-symbol (input)
+     (match (read-while atom-character? input)
+            (Pair input Empty) (ParseOut input)
+            (Pair input name)  (ParseNext input (Symbol name))))
+
+(def parse-list (input parse-expressions)
+     (match (parse-expressions input Empty)
+            (Pair input expressions) (ParseNext input (List expressions))))
+
 (def parse-expression (input parse-expressions)
      (match input
             Empty       ParseEnd
             (Cons x xs) (match (whitespace? x)
                                True (parse-expression xs parse-expressions)
                   False (match (= x 40)
-                               True (match (parse-expressions xs Empty)
-                                           (Pair input expressions) (ParseNext input (List expressions)))
+                               True (parse-list xs parse-expressions)
                   False (match (= x 41)
                                True (ParseOut xs)
-                  False (match (read-while atom-character? input)
-                               (Pair input Empty) (ParseOut input)
-                               (Pair input name)  (ParseNext input (Symbol name))))))))
+                  False (parse-symbol input))))))
 
 (def parse-expressions (input expressions)
      (match (parse-expression input parse-expressions)

(def list-map (f list)
     (list-foldr (fn (x xs)
                     (Cons (f x) xs))
                 Empty
                 list))


(def parse (input)
     (match (parse-expressions input Empty)
            (Pair _ expressions) expressions))

(def wrap-in-brackets (string)
     (string-concat (string-of-char 40) (string-concat string (string-of-char 41))))
