From c5b9aece9c41789085eaa8c2934524fe2075379c Mon Sep 17 00:00:00 2001 From: Tom Helmuth Date: Tue, 2 Nov 2021 13:12:46 -0400 Subject: [PATCH] Fixed issue with translation that caused infinite loops if an explicit number of open parentheses is set to 0 --- src/propeller/genome.cljc | 7 ++++++- src/propeller/push/instructions.cljc | 9 ++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/propeller/genome.cljc b/src/propeller/genome.cljc index 70470fe..cd71c8c 100755 --- a/src/propeller/genome.cljc +++ b/src/propeller/genome.cljc @@ -16,7 +16,12 @@ (let [plushy (if (:diploid argmap) (map first (partition 2 plushy)) plushy) opener? #(and (vector? %) (= (first %) 'open))] ;; [open ] marks opens (loop [push () ;; iteratively build the Push program from the plushy - plushy (mapcat #(if-let [n (get instructions/opens %)] [% ['open n]] [%]) plushy)] + plushy (mapcat #(let [n (get instructions/opens %)] + (if (and n + (> n 0)) + [% ['open n]] + [%])) + plushy)] (if (empty? plushy) ;; maybe we're done? (if (some opener? push) ;; done with plushy, but unclosed open (recur push '(close)) ;; recur with one more close diff --git a/src/propeller/push/instructions.cljc b/src/propeller/push/instructions.cljc index 30a83bc..361c28b 100644 --- a/src/propeller/push/instructions.cljc +++ b/src/propeller/push/instructions.cljc @@ -36,15 +36,10 @@ :vector_boolean_iterate 1 :vector_string_iterate 1 :vector_integer_iterate 1 - :vector_float_iterate 1}) + :vector_float_iterate 1 + }) -#_(generate-instructions - [:boolean :char :code :exec :float :integer :string - :vector_boolean :vector_float :vector_integer :vector_string] - [_dup _dup_times _dup_items _empty _eq _flush _pop _rot _shove - _stack_depth _swap _yank _yank_dup _deep_dup]) - #?(:clj (def cls->type {Boolean :boolean