From 4ff98629f9a8f9f4e337e6aaca901519f53ef76b Mon Sep 17 00:00:00 2001 From: Rowan Torbitzky-Lane Date: Wed, 12 Mar 2025 16:42:28 -0500 Subject: [PATCH] add instructions, is breaking things tho? --- src/propeller/push/instructions/numeric.cljc | 13 +++++++-- src/propeller/push/state.cljc | 28 +++++++++++--------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/propeller/push/instructions/numeric.cljc b/src/propeller/push/instructions/numeric.cljc index 7de1e3c..d61a2ac 100755 --- a/src/propeller/push/instructions/numeric.cljc +++ b/src/propeller/push/instructions/numeric.cljc @@ -20,6 +20,16 @@ (fn [stack state] (make-instruction state > [stack stack] :boolean))) +;; Pushes :buy onto the SIGNAL stack if the first item is greater than the second +;; item, and acts as a no-op otherwise. +(def _gt_buy + "Pushes :buy onto the SIGNAL stack if the first item is greater + than the second item, and acts as a no-op otherwise" + ^{:stacks #{:signal} + :name "_gt_buy"} + (fn [stack state] + (make-instruction state #(if (%1 > %2) :buy nil) [stack stack] :signal))) + ;; Pushes TRUE onto the BOOLEAN stack if the second item is greater than or ;; equal to the top item, and FALSE otherwise (def _gte @@ -173,11 +183,10 @@ Otherwise, acts as a NOOP" (fn [stack state] (make-instruction state dec [stack] stack))) -;; 2 types x 16 functions = 32 instructions (generate-instructions [:float :integer] [_gt _gte _lt _lte _add _subtract _mult _quot _mod _max _min _inc _dec - _from_boolean _from_char _from_string]) + _from_boolean _from_char _from_string, _gt_buy]) ;; ============================================================================= ;; FLOAT Instructions only diff --git a/src/propeller/push/state.cljc b/src/propeller/push/state.cljc index 1a00ead..a11019f 100755 --- a/src/propeller/push/state.cljc +++ b/src/propeller/push/state.cljc @@ -5,19 +5,21 @@ ;; Empty push state - all available stacks are empty (defonce ^:no-doc empty-state {:boolean '() - :char '() - :code '() - :exec '() - :float '() - :input {} - :output {} - :integer '() - :print '("") - :string '() - :vector_boolean '() - :vector_float '() - :vector_integer '() - :vector_string '()}) + :char '() + :code '() + :exec '() + :float '() + :input {} + :output {} + :integer '() + :print '("") + :string '() + :vector_boolean '() + :vector_float '() + :vector_integer '() + :vector_string '() + :signal '() ;; stock trading signal (:buy, :sell, or :hold only), long only for now + }) ;; All stack types available in a Push state (defonce ^:no-doc stacks (set (keys empty-state)))