Make plushy->push obey :diploid setting
This commit is contained in:
parent
4516339412
commit
12002d17a6
@ -12,7 +12,8 @@
|
||||
(defn plushy->push
|
||||
"Returns the Push program expressed by the given plushy representation."
|
||||
[plushy argmap]
|
||||
(let [opener? #(and (vector? %) (= (first %) 'open))] ;; [open <n>] marks opens
|
||||
(let [plushy (if (:diploid argmap) (map first (partition 2 plushy)) plushy)
|
||||
opener? #(and (vector? %) (= (first %) 'open))] ;; [open <n>] marks opens
|
||||
(loop [push () ;; iteratively build the Push program from the plushy
|
||||
plushy (mapcat #(if-let [n (get push/opens %)] [% ['open n]] [%]) plushy)]
|
||||
(if (empty? plushy) ;; maybe we're done?
|
||||
|
Loading…
x
Reference in New Issue
Block a user