add instructions, is breaking things tho?

This commit is contained in:
Rowan Torbitzky-Lane 2025-03-12 16:42:28 -05:00
parent a4703d60a8
commit 4ff98629f9
2 changed files with 26 additions and 15 deletions

View File

@ -20,6 +20,16 @@
(fn [stack state] (fn [stack state]
(make-instruction state > [stack stack] :boolean))) (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 ;; Pushes TRUE onto the BOOLEAN stack if the second item is greater than or
;; equal to the top item, and FALSE otherwise ;; equal to the top item, and FALSE otherwise
(def _gte (def _gte
@ -173,11 +183,10 @@ Otherwise, acts as a NOOP"
(fn [stack state] (fn [stack state]
(make-instruction state dec [stack] stack))) (make-instruction state dec [stack] stack)))
;; 2 types x 16 functions = 32 instructions
(generate-instructions (generate-instructions
[:float :integer] [:float :integer]
[_gt _gte _lt _lte _add _subtract _mult _quot _mod _max _min _inc _dec [_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 ;; FLOAT Instructions only

View File

@ -5,19 +5,21 @@
;; Empty push state - all available stacks are empty ;; Empty push state - all available stacks are empty
(defonce ^:no-doc empty-state {:boolean '() (defonce ^:no-doc empty-state {:boolean '()
:char '() :char '()
:code '() :code '()
:exec '() :exec '()
:float '() :float '()
:input {} :input {}
:output {} :output {}
:integer '() :integer '()
:print '("") :print '("")
:string '() :string '()
:vector_boolean '() :vector_boolean '()
:vector_float '() :vector_float '()
:vector_integer '() :vector_integer '()
:vector_string '()}) :vector_string '()
:signal '() ;; stock trading signal (:buy, :sell, or :hold only), long only for now
})
;; All stack types available in a Push state ;; All stack types available in a Push state
(defonce ^:no-doc stacks (set (keys empty-state))) (defonce ^:no-doc stacks (set (keys empty-state)))