diff --git a/.DS_Store b/.DS_Store index 9a874b5..feca861 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/README.md b/README.md index 63ad5f2..cf514c5 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,13 @@ After page is loaded, you may also start a REPL connected to browser with: yarn shadow-cljs cljs-repl app ``` +Once the REPL is loaded, load the core namespace with: + +``` +(ns propeller.core) +``` +Calling `(-main)` will run the default genetic programming problem. + ## Description Propel is an implementation of the Push programming diff --git a/src/propeller/push/instructions/input_output.cljc b/src/propeller/push/instructions/input_output.cljc index e5fccd4..55db2ee 100755 --- a/src/propeller/push/instructions/input_output.cljc +++ b/src/propeller/push/instructions/input_output.cljc @@ -19,7 +19,9 @@ [state instruction] (if-let [input (instruction (:input state))] (state/push-to-stack state :exec input) - (throw (Exception. (str "Undefined input instruction " instruction))))) + (throw #?(:clj (Exception. (str "Undefined input instruction " instruction)) + :cljs (js/Error + (str "Undefined input instruction " instruction)))))) ;; ============================================================================= ;; OUTPUT Instructions diff --git a/src/propeller/tools/character.cljc b/src/propeller/tools/character.cljc index 32d64d3..6c8b846 100755 --- a/src/propeller/tools/character.cljc +++ b/src/propeller/tools/character.cljc @@ -1,18 +1,24 @@ (ns propeller.tools.character) +(defn get-ascii + "Gets the ASCII code of a char" + [c] + #?(:clj (int c) + :cljs (.charCodeAt c 0))) + (defn is-letter "Returns true if the given character is a letter, A-Z or a-z." [c] - (<= (int \A) (int c) (int \z))) + (<= (get-ascii \A) (get-ascii c) (get-ascii \z))) (defn is-digit "Returns true if the given character is a digit, 0-9." [c] - (<= (int \0) (int c) (int \9))) + (<= (get-ascii \0) (get-ascii c) (get-ascii \9))) (defn is-whitespace "Returns true if the given character is whitespace (newline, space, tab)." [c] - (contains? #{(int \newline) (int \tab) (int \space)} (int c))) + (contains? #{(get-ascii \newline) (get-ascii \tab) (get-ascii \space)} (get-ascii c)))