From 62fc20f8e7a86e16abffc208be567a9713e95c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Flores=20Garc=C3=ADa?= Date: Wed, 14 Jul 2021 20:29:52 -0400 Subject: [PATCH 1/2] Change literals map to vector of vectors --- src/propeller/push/utils/helpers.cljc | 28 +++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/propeller/push/utils/helpers.cljc b/src/propeller/push/utils/helpers.cljc index 748f9eb..55ae2e6 100755 --- a/src/propeller/push/utils/helpers.cljc +++ b/src/propeller/push/utils/helpers.cljc @@ -113,21 +113,21 @@ ;; :integer. Otherwise, return nil" (defn get-literal-type [data] - (let [literals {:boolean (fn [thing] (or (true? thing) (false? thing))) - :char char? - :float float? - :integer integer? - :string string? - :vector_boolean (fn [thing] (and (vector? thing) + (let [literals [[:boolean (fn [thing] (or (true? thing) (false? thing)))] + [:integer integer?] + [:float float?] + [:string string?] + [:char char?] + [:vector_boolean (fn [thing] (and (vector? thing) (or (true? (first thing)) - (false? (first thing))))) - :vector_float (fn [thing] (and (vector? thing) - (float? (first thing)))) - :vector_integer (fn [thing] (and (vector? thing) - (integer? (first thing)))) - :vector_string (fn [thing] (and (vector? thing) - (string? (first thing)))) - :generic-vector (fn [thing] (= [] thing))}] + (false? (first thing)))))] + [:vector_float (fn [thing] (and (vector? thing) + (float? (first thing))))] + [:vector_integer (fn [thing] (and (vector? thing) + (integer? (first thing))))] + [:vector_string (fn [thing] (and (vector? thing) + (string? (first thing))))] + [:generic-vector (fn [thing] (= [] thing))]]] (first (for [[stack function] literals :when (function data)] stack)))) From 9cf15369bfd8fc12dd606d4d1be79017e5a70715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Flores=20Garc=C3=ADa?= Date: Thu, 15 Jul 2021 11:06:24 -0400 Subject: [PATCH 2/2] Add cljs.reader to problems --- src/propeller/problems/PSB2/basement.cljc | 3 ++- src/propeller/problems/PSB2/bouncing_balls.cljc | 3 ++- src/propeller/problems/PSB2/bowling.cljc | 3 ++- src/propeller/problems/PSB2/camel_case.cljc | 3 ++- src/propeller/problems/PSB2/dice_game.cljc | 3 ++- src/propeller/problems/PSB2/fuel_cost.cljc | 3 ++- src/propeller/problems/PSB2/middle_character.cljc | 3 ++- src/propeller/problems/PSB2/substitution_cipher.cljc | 3 ++- src/propeller/problems/PSB2/twitter.cljc | 3 ++- src/propeller/problems/simple_regression.cljc | 3 ++- src/propeller/problems/string_classification.cljc | 3 ++- src/propeller/problems/valiant.cljc | 3 ++- 12 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/propeller/problems/PSB2/basement.cljc b/src/propeller/problems/PSB2/basement.cljc index 9143c0e..2e3ca1a 100644 --- a/src/propeller/problems/PSB2/basement.cljc +++ b/src/propeller/problems/PSB2/basement.cljc @@ -6,7 +6,8 @@ [propeller.push.utils.helpers :refer [get-stack-instructions]] [propeller.push.state :as state] [propeller.tools.math :as math] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ; =========== PROBLEM DESCRIPTION ============================ ; BASEMENT from PSB2 diff --git a/src/propeller/problems/PSB2/bouncing_balls.cljc b/src/propeller/problems/PSB2/bouncing_balls.cljc index 0cab515..9984af6 100644 --- a/src/propeller/problems/PSB2/bouncing_balls.cljc +++ b/src/propeller/problems/PSB2/bouncing_balls.cljc @@ -7,7 +7,8 @@ [propeller.push.state :as state] [clojure.pprint :as pprint] [propeller.tools.math :as math] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ; =========== PROBLEM DESCRIPTION =============================== ; BOUNCING BALLS from PSB2 diff --git a/src/propeller/problems/PSB2/bowling.cljc b/src/propeller/problems/PSB2/bowling.cljc index 6fd63b8..63e0423 100644 --- a/src/propeller/problems/PSB2/bowling.cljc +++ b/src/propeller/problems/PSB2/bowling.cljc @@ -7,7 +7,8 @@ [propeller.push.state :as state] [clojure.pprint :as pprint] [propeller.tools.math :as math] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ; =========== PROBLEM DESCRIPTION ====================== ; BOWLING from PSB2 diff --git a/src/propeller/problems/PSB2/camel_case.cljc b/src/propeller/problems/PSB2/camel_case.cljc index 3bc2447..ee58f19 100644 --- a/src/propeller/problems/PSB2/camel_case.cljc +++ b/src/propeller/problems/PSB2/camel_case.cljc @@ -7,7 +7,8 @@ [propeller.push.state :as state] [propeller.tools.math :as math] [propeller.tools.metrics :as metrics] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ; =========== PROBLEM DESCRIPTION ===================================== ; CAMEL CASE from PSB2 diff --git a/src/propeller/problems/PSB2/dice_game.cljc b/src/propeller/problems/PSB2/dice_game.cljc index db669b5..9b63f1c 100644 --- a/src/propeller/problems/PSB2/dice_game.cljc +++ b/src/propeller/problems/PSB2/dice_game.cljc @@ -7,7 +7,8 @@ [propeller.push.state :as state] [clojure.pprint :as pprint] [propeller.tools.math :as math] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ; =========== PROBLEM DESCRIPTION =============================== ; DICE GAME from PSB2 diff --git a/src/propeller/problems/PSB2/fuel_cost.cljc b/src/propeller/problems/PSB2/fuel_cost.cljc index 0f1592a..2f556ac 100644 --- a/src/propeller/problems/PSB2/fuel_cost.cljc +++ b/src/propeller/problems/PSB2/fuel_cost.cljc @@ -7,7 +7,8 @@ [propeller.push.state :as state] [clojure.pprint :as pprint] [propeller.tools.math :as math] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ; =========== PROBLEM DESCRIPTION ========================= ; FUEL COST from PSB2 diff --git a/src/propeller/problems/PSB2/middle_character.cljc b/src/propeller/problems/PSB2/middle_character.cljc index 8b7e123..de86325 100644 --- a/src/propeller/problems/PSB2/middle_character.cljc +++ b/src/propeller/problems/PSB2/middle_character.cljc @@ -7,7 +7,8 @@ [propeller.push.state :as state] [propeller.tools.math :as math] [propeller.tools.metrics :as metrics] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ; =========== PROBLEM DESCRIPTION ============================= ; MIDDLE CHARACTER from PSB2 diff --git a/src/propeller/problems/PSB2/substitution_cipher.cljc b/src/propeller/problems/PSB2/substitution_cipher.cljc index 554c203..9562a1c 100644 --- a/src/propeller/problems/PSB2/substitution_cipher.cljc +++ b/src/propeller/problems/PSB2/substitution_cipher.cljc @@ -7,7 +7,8 @@ [propeller.push.state :as state] [propeller.tools.math :as math] [propeller.tools.metrics :as metrics] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ; =========== PROBLEM DESCRIPTION ========================= ; SUBSTITUTION CIPHER from PSB2 diff --git a/src/propeller/problems/PSB2/twitter.cljc b/src/propeller/problems/PSB2/twitter.cljc index bdf35f7..cd00b74 100644 --- a/src/propeller/problems/PSB2/twitter.cljc +++ b/src/propeller/problems/PSB2/twitter.cljc @@ -7,7 +7,8 @@ [propeller.push.state :as state] [propeller.tools.math :as math] [propeller.tools.metrics :as metrics] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ; =========== PROBLEM DESCRIPTION ============================= ; TWITTER from PSB2 diff --git a/src/propeller/problems/simple_regression.cljc b/src/propeller/problems/simple_regression.cljc index e0ed37d..6112b3d 100755 --- a/src/propeller/problems/simple_regression.cljc +++ b/src/propeller/problems/simple_regression.cljc @@ -3,7 +3,8 @@ [propeller.push.interpreter :as interpreter] [propeller.push.state :as state] [propeller.tools.math :as math] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) (defn- target-function "Target function: f(x) = x^3 + x + 3" diff --git a/src/propeller/problems/string_classification.cljc b/src/propeller/problems/string_classification.cljc index a06490d..a79a6d4 100755 --- a/src/propeller/problems/string_classification.cljc +++ b/src/propeller/problems/string_classification.cljc @@ -2,7 +2,8 @@ (:require [propeller.genome :as genome] [propeller.push.interpreter :as interpreter] [propeller.push.state :as state] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ;; ============================================================================= ;; String classification diff --git a/src/propeller/problems/valiant.cljc b/src/propeller/problems/valiant.cljc index a98410a..29fcf5c 100644 --- a/src/propeller/problems/valiant.cljc +++ b/src/propeller/problems/valiant.cljc @@ -2,7 +2,8 @@ (:require [propeller.genome :as genome] [propeller.push.interpreter :as interpreter] [propeller.push.state :as state] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) (def num-vars 100) ;10) ;100) ;1000) (def num-inputs 50) ;5) ; 50) ;500)