   [[name args & body :as code] fns]
   {:pre [(list? code)]}
   (let [fns (assoc fns name {})
-        [stmt & stmts] (mapcat #(compile-form args fns %) body)]
-    (concat [(conj stmt (format "; define %s" name))]
-            stmts
-            [[:rtn]])))
+        [stmt & stmts] (mapcat #(compile-form args fns %) body)
+        code (concat [(conj stmt (format "; define %s" name))]
+                     stmts
+                     [[:rtn]])]
+    {:name name
+     :code code
+     :length (count code)}))
 
 (defn compile-ai
   [file]

    (loop [form (read prog false nil)
           fns {}]
      (if form
        (let [code (compile-function form fns)]
          (recur (read prog false nil) (assoc fns (first form) {:name (first form) :code code})))
        (emit-code (assign-addresses fns))))))

           address 0]
      (if-let [func (get funcs index)]
        (let [new-funcs (update-in funcs [index] assoc :address address)
              address (+ address (:length func))]
          (recur new-funcs (inc index) address))
        funcs))))

