Created
February 16, 2018 18:23
-
-
Save Vaguery/4911d7b88c245b3bd23378add76fbaa0 to your computer and use it in GitHub Desktop.
Trace of an evolved FizzBuzz program in Push, with input = 14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clojush.core=> (run-push my-program start-state true) | |
State after 0 steps: | |
;; program is on :exec | |
:exec = ((exec_stackdepth integer_mod exec_s string_swap in1 integer_mult exec_stackdepth integer_mod "fizz" exec_do*range (string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false)) | |
:integer = nil | |
:boolean = nil | |
:string = nil | |
:input = (14) | |
State after 1 steps (last step: (...)): | |
;; unwrap the code block | |
:exec = (exec_stackdepth integer_mod exec_s string_swap in1 integer_mult exec_stackdepth integer_mod "fizz" exec_do*range (string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = nil | |
:boolean = nil | |
:string = nil | |
:input = (14) | |
State after 2 steps (last step: exec_stackdepth): | |
;; count the items on :exec | |
:exec = (integer_mod exec_s string_swap in1 integer_mult exec_stackdepth integer_mod "fizz" exec_do*range (string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (15) | |
:boolean = nil | |
:string = nil | |
:input = (14) | |
State after 3 steps (last step: integer_mod): | |
;; missing argument | |
:exec = (exec_s string_swap in1 integer_mult exec_stackdepth integer_mod "fizz" exec_do*range (string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (15) | |
:boolean = nil | |
:string = nil | |
:input = (14) | |
State after 4 steps (last step: exec_s): | |
;; consume three things from :exec, push three items (one now a code block) | |
:exec = (string_swap integer_mult (in1 integer_mult) exec_stackdepth integer_mod "fizz" exec_do*range (string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (15) | |
:boolean = nil | |
:string = nil | |
:input = (14) | |
State after 5 steps (last step: string_swap): | |
;; missing arguments | |
:exec = (integer_mult (in1 integer_mult) exec_stackdepth integer_mod "fizz" exec_do*range (string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (15) | |
:boolean = nil | |
:string = nil | |
:input = (14) | |
State after 6 steps (last step: integer_mult): | |
;; missing arguments | |
:exec = ((in1 integer_mult) exec_stackdepth integer_mod "fizz" exec_do*range (string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (15) | |
:boolean = nil | |
:string = nil | |
:input = (14) | |
State after 7 steps (last step: (...)): | |
;; unpack code block | |
:exec = (in1 integer_mult exec_stackdepth integer_mod "fizz" exec_do*range (string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (15) | |
:boolean = nil | |
:string = nil | |
:input = (14) | |
State after 8 steps (last step: in1): | |
;; input value is 14 | |
:exec = (integer_mult exec_stackdepth integer_mod "fizz" exec_do*range (string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (14 15) | |
:boolean = nil | |
:string = nil | |
:input = (14) | |
State after 9 steps (last step: integer_mult): | |
;; push (* 14 15) | |
:exec = (exec_stackdepth integer_mod "fizz" exec_do*range (string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (210) | |
:boolean = nil | |
:string = nil | |
:input = (14) | |
State after 10 steps (last step: exec_stackdepth): | |
;; there are 9 items on :exec | |
:exec = (integer_mod "fizz" exec_do*range (string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (9 210) | |
:boolean = nil | |
:string = nil | |
:input = (14) | |
State after 11 steps (last step: integer_mod): | |
;; push (mod 210 9) | |
:exec = ("fizz" exec_do*range (string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (3) | |
:boolean = nil | |
:string = nil | |
:input = (14) | |
State after 12 steps (last step: fizz): | |
;; literal "fizz" | |
:exec = (exec_do*range (string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (3) | |
:boolean = nil | |
:string = ("fizz") | |
:input = (14) | |
State after 13 steps (last step: exec_do*range): | |
;; missing arguments | |
:exec = ((string_parse_to_chars string_rest "fizz" string_shove) in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (3) | |
:boolean = nil | |
:string = ("fizz") | |
:input = (14) | |
State after 14 steps (last step: (...)): | |
;; unwrap code block | |
:exec = (string_parse_to_chars string_rest "fizz" string_shove in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (3) | |
:boolean = nil | |
:string = ("fizz") | |
:input = (14) | |
State after 15 steps (last step: string_parse_to_chars): | |
;; break "fizz" down into characters | |
:exec = (string_rest "fizz" string_shove in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (3) | |
:boolean = nil | |
:string = ("f" "i" "z" "z") | |
:input = (14) | |
State after 16 steps (last step: string_rest): | |
;; remove first character of top :string item | |
:exec = ("fizz" string_shove in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (3) | |
:boolean = nil | |
:string = ("" "i" "z" "z") | |
:input = (14) | |
State after 17 steps (last step: fizz): | |
;; string literal "fizz" | |
:exec = (string_shove in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (3) | |
:boolean = nil | |
:string = ("fizz" "" "i" "z" "z") | |
:input = (14) | |
State after 18 steps (last step: string_shove): | |
;; move top :string to position 3 (zero-based) in its stack | |
:exec = (in1 boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = () | |
:boolean = nil | |
:string = ("" "i" "z" "fizz" "z") | |
:input = (14) | |
State after 19 steps (last step: in1): | |
;; input value is 14 | |
:exec = (boolean_xor exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (14) | |
:boolean = nil | |
:string = ("" "i" "z" "fizz" "z") | |
:input = (14) | |
State after 20 steps (last step: boolean_xor): | |
;; missing arguments | |
:exec = (exec_swap (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) false) | |
:integer = (14) | |
:boolean = nil | |
:string = ("" "i" "z" "fizz" "z") | |
:input = (14) | |
State after 21 steps (last step: exec_swap): | |
;; swap top two :exec items | |
:exec = (false (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and)) | |
:integer = (14) | |
:boolean = nil | |
:string = ("" "i" "z" "fizz" "z") | |
:input = (14) | |
State after 22 steps (last step: false): | |
;; boolean literal `false` | |
:exec = ((string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and)) | |
:integer = (14) | |
:boolean = (false) | |
:string = ("" "i" "z" "fizz" "z") | |
:input = (14) | |
State after 23 steps (last step: (...)): | |
;; unwrap code block | |
:exec = (string_dup "buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) | |
:integer = (14) | |
:boolean = (false) | |
:string = ("" "i" "z" "fizz" "z") | |
:input = (14) | |
State after 24 steps (last step: string_dup): | |
;; duplicate top :string item | |
:exec = ("buzz" string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) | |
:integer = (14) | |
:boolean = (false) | |
:string = ("" "" "i" "z" "fizz" "z") | |
:input = (14) | |
State after 25 steps (last step: buzz): | |
;; string literal "buzz" | |
:exec = (string_concat exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) | |
:integer = (14) | |
:boolean = (false) | |
:string = ("buzz" "" "" "i" "z" "fizz" "z") | |
:input = (14) | |
State after 26 steps (last step: string_concat): | |
;; concatenate "buzz" and "" | |
:exec = (exec_stackdepth integer_mod string_empty boolean_dup string_shove boolean_and) | |
:integer = (14) | |
:boolean = (false) | |
:string = ("buzz" "" "i" "z" "fizz" "z") | |
:input = (14) | |
State after 27 steps (last step: exec_stackdepth): | |
;; stack depth is 5 | |
:exec = (integer_mod string_empty boolean_dup string_shove boolean_and) | |
:integer = (5 14) | |
:boolean = (false) | |
:string = ("buzz" "" "i" "z" "fizz" "z") | |
:input = (14) | |
State after 28 steps (last step: integer_mod): | |
;; push (mod 14 5) = 4 | |
:exec = (string_empty boolean_dup string_shove boolean_and) | |
:integer = (4) | |
:boolean = (false) | |
:string = ("buzz" "" "i" "z" "fizz" "z") | |
:input = (14) | |
State after 29 steps (last step: string_empty): | |
;; is the :string stack empty? | |
:exec = (boolean_dup string_shove boolean_and) | |
:integer = (4) | |
:boolean = (false false) | |
:string = ("buzz" "" "i" "z" "fizz" "z") | |
:input = (14) | |
State after 30 steps (last step: boolean_dup): | |
;; duplicate the top :boolean item | |
:exec = (string_shove boolean_and) | |
:integer = (4) | |
:boolean = (false false false) | |
:string = ("buzz" "" "i" "z" "fizz" "z") | |
:input = (14) | |
State after 31 steps (last step: string_shove): | |
;; shove the top :string down to be in position 4 in its stack | |
:exec = (boolean_and) | |
:integer = () | |
:boolean = (false false false) | |
:string = ("" "i" "z" "fizz" "buzz" "z") | |
:input = (14) | |
State after 32 steps (last step: boolean_and): | |
;; calculate (and false false) and push to :boolean | |
:exec = () | |
:integer = () | |
:boolean = (false false) | |
:string = ("" "i" "z" "fizz" "buzz" "z") | |
:input = (14) | |
#clojush.pushstate.PushState{:exec (), :code nil, :integer (), :float nil, :boolean (false false), :char nil, :string ("" "i" "z" "fizz" "buzz" "z"), :zip nil, :vector_integer nil, :vector_float nil, :vector_boolean nil, :vector_string nil, :input (14), :output nil, :auxiliary nil, :tag nil, :return nil, :environment nil, :genome nil, :termination :normal} | |
clojush.core=> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment