([program settings]
(merge (build-state program) settings)))
+(defn intcode-until [pred state]
+ (as-> (assoc state :step true) it
+ (iterate intcode it)
+ (drop-while #(or (not (:exit %)) (pred %)) it)
+ (first it)
+ (dissoc it :step)))
+
(defn intcode [{:as state :keys [memory output]}]
(cond ; quit if :exit, step and return state if :step, else loop
- (get state :exit) {:memory memory :output output}
+ (get state :exit) {:memory memory :output output :exit true}
(get state :step) (perform-operation state)
:else (recur (perform-operation state))))