diff --git a/src/propeller/problems/PSB2/basement.cljc b/src/propeller/problems/PSB2/basement.cljc index e7598eb..c80243c 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 6625385..f18bb16 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 6c80629..045659c 100644 --- a/src/propeller/problems/PSB2/bowling.cljc +++ b/src/propeller/problems/PSB2/bowling.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 ====================== ; BOWLING from PSB2 diff --git a/src/propeller/problems/PSB2/camel_case.cljc b/src/propeller/problems/PSB2/camel_case.cljc index 08610b1..a5449e1 100644 --- a/src/propeller/problems/PSB2/camel_case.cljc +++ b/src/propeller/problems/PSB2/camel_case.cljc @@ -6,7 +6,8 @@ [propeller.push.utils.helpers :refer [get-stack-instructions]] [propeller.push.state :as state] [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 96bed0f..285b652 100644 --- a/src/propeller/problems/PSB2/dice_game.cljc +++ b/src/propeller/problems/PSB2/dice_game.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 =============================== ; DICE GAME from PSB2 diff --git a/src/propeller/problems/PSB2/fizz_buzz.cljc b/src/propeller/problems/PSB2/fizz_buzz.cljc index 3397851..4b97416 100644 --- a/src/propeller/problems/PSB2/fizz_buzz.cljc +++ b/src/propeller/problems/PSB2/fizz_buzz.cljc @@ -6,7 +6,8 @@ [propeller.push.utils.helpers :refer [get-stack-instructions]] [propeller.push.state :as state] [propeller.tools.metrics :as metrics] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ; =========== PROBLEM DESCRIPTION ========================= ; FIZZ BUZZ from PSB2 diff --git a/src/propeller/problems/PSB2/fuel_cost.cljc b/src/propeller/problems/PSB2/fuel_cost.cljc index dbd39af..fafda27 100644 --- a/src/propeller/problems/PSB2/fuel_cost.cljc +++ b/src/propeller/problems/PSB2/fuel_cost.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 ========================= ; FUEL COST from PSB2 diff --git a/src/propeller/problems/PSB2/gcd.cljc b/src/propeller/problems/PSB2/gcd.cljc index 079cfd3..25dedc8 100644 --- a/src/propeller/problems/PSB2/gcd.cljc +++ b/src/propeller/problems/PSB2/gcd.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 =============================== ; GCD [GREATEST COMMON DIVISOR] from PSB2 diff --git a/src/propeller/problems/PSB2/luhn.cljc b/src/propeller/problems/PSB2/luhn.cljc index 9c2c6fe..cdfb175 100644 --- a/src/propeller/problems/PSB2/luhn.cljc +++ b/src/propeller/problems/PSB2/luhn.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 ============================ ; LUHN from PSB2 diff --git a/src/propeller/problems/PSB2/middle_character.cljc b/src/propeller/problems/PSB2/middle_character.cljc index f4d4a31..55850a6 100644 --- a/src/propeller/problems/PSB2/middle_character.cljc +++ b/src/propeller/problems/PSB2/middle_character.cljc @@ -6,7 +6,8 @@ [propeller.push.utils.helpers :refer [get-stack-instructions]] [propeller.push.state :as state] [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/paired_digits.cljc b/src/propeller/problems/PSB2/paired_digits.cljc index bcccf73..baa4e30 100644 --- a/src/propeller/problems/PSB2/paired_digits.cljc +++ b/src/propeller/problems/PSB2/paired_digits.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 ============================= ; PAIRED DIGITS from PSB2 diff --git a/src/propeller/problems/PSB2/shopping_list.cljc b/src/propeller/problems/PSB2/shopping_list.cljc index e3120bd..dd26edc 100644 --- a/src/propeller/problems/PSB2/shopping_list.cljc +++ b/src/propeller/problems/PSB2/shopping_list.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 =============================== ; DICE GAME from PSB2 diff --git a/src/propeller/problems/PSB2/snow_day.cljc b/src/propeller/problems/PSB2/snow_day.cljc index b68c886..a6f10fe 100644 --- a/src/propeller/problems/PSB2/snow_day.cljc +++ b/src/propeller/problems/PSB2/snow_day.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 =============================== ; SNOW DAY from PSB2 diff --git a/src/propeller/problems/PSB2/solve_boolean.cljc b/src/propeller/problems/PSB2/solve_boolean.cljc index 42c29ea..432f8b2 100644 --- a/src/propeller/problems/PSB2/solve_boolean.cljc +++ b/src/propeller/problems/PSB2/solve_boolean.cljc @@ -5,7 +5,8 @@ [propeller.utils :as utils] [propeller.push.utils.helpers :refer [get-stack-instructions]] [propeller.push.state :as state] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ; =========== PROBLEM DESCRIPTION ================================ ; SOLVE BOOLEAN from PSB2 diff --git a/src/propeller/problems/PSB2/spin_words.cljc b/src/propeller/problems/PSB2/spin_words.cljc index c67328f..c991f95 100644 --- a/src/propeller/problems/PSB2/spin_words.cljc +++ b/src/propeller/problems/PSB2/spin_words.cljc @@ -6,7 +6,8 @@ [propeller.push.utils.helpers :refer [get-stack-instructions]] [propeller.push.state :as state] [propeller.tools.metrics :as metrics] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ; =========== PROBLEM DESCRIPTION ============================== ; SPIN WORDS from PSB2 diff --git a/src/propeller/problems/PSB2/square_digits.cljc b/src/propeller/problems/PSB2/square_digits.cljc index bb242d4..23a4304 100644 --- a/src/propeller/problems/PSB2/square_digits.cljc +++ b/src/propeller/problems/PSB2/square_digits.cljc @@ -6,7 +6,8 @@ [propeller.push.utils.helpers :refer [get-stack-instructions]] [propeller.push.state :as state] [propeller.tools.metrics :as metrics] - [propeller.gp :as gp])) + [propeller.gp :as gp] + #?(:cljs [cljs.reader :refer [read-string]]))) ; =========== PROBLEM DESCRIPTION ========================= ; SQUARE DIGITS from PSB2 diff --git a/src/propeller/problems/PSB2/substitution_cipher.cljc b/src/propeller/problems/PSB2/substitution_cipher.cljc index 22ec93c..13152c5 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 7b85fc2..9c6acfa 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) 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))))