From a42d23bf7aa867214b86fe98f1390b64e5fc3e11 Mon Sep 17 00:00:00 2001 From: Tom Helmuth Date: Tue, 2 Nov 2021 11:18:29 -0400 Subject: [PATCH] Moved push/core.cljc to push/instructions.cljc --- src/propeller/genome.cljc | 4 ++-- src/propeller/push/{core.cljc => instructions.cljc} | 2 +- src/propeller/push/interpreter.cljc | 4 ++-- src/propeller/push/utils/helpers.cljc | 6 +++--- src/propeller/push/utils/macros.cljc | 4 ++-- src/propeller/session.cljc | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) rename src/propeller/push/{core.cljc => instructions.cljc} (93%) mode change 100755 => 100644 diff --git a/src/propeller/genome.cljc b/src/propeller/genome.cljc index d032081..70470fe 100755 --- a/src/propeller/genome.cljc +++ b/src/propeller/genome.cljc @@ -1,5 +1,5 @@ (ns propeller.genome - (:require [propeller.push.core :as push] + (:require [propeller.push.instructions :as instructions] [propeller.utils :as utils])) (defn make-random-plushy @@ -16,7 +16,7 @@ (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 push/opens %)] [% ['open n]] [%]) plushy)] + plushy (mapcat #(if-let [n (get instructions/opens %)] [% ['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/core.cljc b/src/propeller/push/instructions.cljc old mode 100755 new mode 100644 similarity index 93% rename from src/propeller/push/core.cljc rename to src/propeller/push/instructions.cljc index f9d23bd..7761637 --- a/src/propeller/push/core.cljc +++ b/src/propeller/push/instructions.cljc @@ -1,4 +1,4 @@ -(ns propeller.push.core) +(ns propeller.push.instructions) ;; PushGP instructions are represented as keywords, and stored in an atom. They ;; can be either constant literals or functions that take and return a Push state diff --git a/src/propeller/push/interpreter.cljc b/src/propeller/push/interpreter.cljc index 9941146..87ec56d 100755 --- a/src/propeller/push/interpreter.cljc +++ b/src/propeller/push/interpreter.cljc @@ -1,5 +1,5 @@ (ns propeller.push.interpreter - (:require [propeller.push.core :as push] + (:require [propeller.push.instructions :as instructions] [propeller.push.state :as state] [propeller.push.instructions.input-output :as io] [propeller.push.utils.helpers :refer [get-literal-type]])) @@ -14,7 +14,7 @@ ;; ;; Recognize functional instruction or input instruction (keyword? instruction) - (if-let [function (instruction @push/instruction-table)] + (if-let [function (instruction @instructions/instruction-table)] (function popped-state) (io/handle-input-instruction popped-state instruction)) ;; diff --git a/src/propeller/push/utils/helpers.cljc b/src/propeller/push/utils/helpers.cljc index 8de76be..4b3b818 100755 --- a/src/propeller/push/utils/helpers.cljc +++ b/src/propeller/push/utils/helpers.cljc @@ -1,6 +1,6 @@ (ns propeller.push.utils.helpers (:require [clojure.set] - [propeller.push.core :as push] + [propeller.push.instructions :as instructions] [propeller.push.state :as state] [propeller.utils :as u] #?(:cljs [goog.string :as gstring]) @@ -29,7 +29,7 @@ ;; only. Won't include random instructions unless :random is in the set as well (defn get-stack-instructions [stacks] - (doseq [[instruction-name function] @push/instruction-table] + (doseq [[instruction-name function] @instructions/instruction-table] (assert (:stacks (meta function)) #?(:clj (format @@ -38,7 +38,7 @@ :cljs (gstring/format "ERROR: Instruction %s does not have :stacks defined in metadata." (name instruction-name))))) - (for [[instruction-name function] @push/instruction-table + (for [[instruction-name function] @instructions/instruction-table :when (clojure.set/subset? (:stacks (meta function)) stacks)] instruction-name)) diff --git a/src/propeller/push/utils/macros.cljc b/src/propeller/push/utils/macros.cljc index 939f831..08ab01a 100755 --- a/src/propeller/push/utils/macros.cljc +++ b/src/propeller/push/utils/macros.cljc @@ -1,12 +1,12 @@ (ns propeller.push.utils.macros - (:require [propeller.push.core :as push] + (:require [propeller.push.instructions :as instructions] [propeller.push.utils.helpers :refer [get-vector-literal-type]])) (defn def-instruction "Defines a Push instruction as a keyword-function pair, and adds it to the instruction table" [instruction function] - (swap! push/instruction-table assoc instruction function)) + (swap! instructions/instruction-table assoc instruction function)) (defn make-metadata "Given a generic function, e.g. _dup, and a stack type to instantiate it for, diff --git a/src/propeller/session.cljc b/src/propeller/session.cljc index d949528..4996b0e 100755 --- a/src/propeller/session.cljc +++ b/src/propeller/session.cljc @@ -5,7 +5,7 @@ [propeller.variation :as variation] [propeller.problems.simple-regression :as regression] [propeller.problems.string-classification :as string-classif] - [propeller.push.core :as push] + [propeller.push.instructions :as instructions] [propeller.push.interpreter :as interpreter] [propeller.push.state :as state] [propeller.push.utils.helpers :refer [get-stack-instructions]]))