Skip to content

Instantly share code, notes, and snippets.

@Vaguery
Created February 19, 2018 00:48
Show Gist options
  • Save Vaguery/62a5db1696ac3a0c86c4ef00c6d635db to your computer and use it in GitHub Desktop.
Save Vaguery/62a5db1696ac3a0c86c4ef00c6d635db to your computer and use it in GitHub Desktop.
Trace of a new evolved fizz buzz program in Push with input 3333
clojush.core=> (run-push my-program start-state true)
State after 0 steps:
;; program in :exec
:exec = ((in1 integer_dup in1 integer_stackdepth integer_mod in1 in1 "fizz" integer_stackdepth integer_mod integer_mult integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat))
:integer = nil
:boolean = nil
:char = nil
:string = nil
:input = (3333)
State after 1 steps (last step: (...)):
;; unwrap program
:exec = (in1 integer_dup in1 integer_stackdepth integer_mod in1 in1 "fizz" integer_stackdepth integer_mod integer_mult integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = nil
:boolean = nil
:char = nil
:string = nil
:input = (3333)
State after 2 steps (last step: in1):
;; input is 3333
:exec = (integer_dup in1 integer_stackdepth integer_mod in1 in1 "fizz" integer_stackdepth integer_mod integer_mult integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3333)
:boolean = nil
:char = nil
:string = nil
:input = (3333)
State after 3 steps (last step: integer_dup):
;; duplicate top :integer
:exec = (in1 integer_stackdepth integer_mod in1 in1 "fizz" integer_stackdepth integer_mod integer_mult integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3333 3333)
:boolean = nil
:char = nil
:string = nil
:input = (3333)
State after 4 steps (last step: in1):
;; input again
:exec = (integer_stackdepth integer_mod in1 in1 "fizz" integer_stackdepth integer_mod integer_mult integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3333 3333 3333)
:boolean = nil
:char = nil
:string = nil
:input = (3333)
State after 5 steps (last step: integer_stackdepth):
;; count :integer items
:exec = (integer_mod in1 in1 "fizz" integer_stackdepth integer_mod integer_mult integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3 3333 3333 3333)
:boolean = nil
:char = nil
:string = nil
:input = (3333)
State after 6 steps (last step: integer_mod):
;; remainder of (mod 3333 3) = 0
:exec = (in1 in1 "fizz" integer_stackdepth integer_mod integer_mult integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (0 3333 3333)
:boolean = nil
:char = nil
:string = nil
:input = (3333)
State after 7 steps (last step: in1):
;; input again
:exec = (in1 "fizz" integer_stackdepth integer_mod integer_mult integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3333 0 3333 3333)
:boolean = nil
:char = nil
:string = nil
:input = (3333)
State after 8 steps (last step: in1):
;; input again
:exec = ("fizz" integer_stackdepth integer_mod integer_mult integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3333 3333 0 3333 3333)
:boolean = nil
:char = nil
:string = nil
:input = (3333)
State after 9 steps (last step: fizz):
;; "fizz"
:exec = (integer_stackdepth integer_mod integer_mult integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3333 3333 0 3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
State after 10 steps (last step: integer_stackdepth):
;; now it's 5
:exec = (integer_mod integer_mult integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (5 3333 3333 0 3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
State after 11 steps (last step: integer_mod):
;; remainder of (mod 3333 5) = 3
:exec = (integer_mult integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3 3333 0 3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
State after 12 steps (last step: integer_mult):
;; (* 3333 3) = 9999
:exec = (integer_mult exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (9999 0 3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
State after 13 steps (last step: integer_mult):
;; (* 0 9999) = 0
:exec = (exec_dup_times string_rest integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (0 3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
State after 14 steps (last step: exec_dup_times):
;; probably the result here is too large, and is discarded (?)
:exec = (integer_dup integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
State after 15 steps (last step: integer_dup):
;; duplicate 3333
:exec = (integer_stackdepth in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3333 3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
State after 16 steps (last step: integer_stackdepth):
;; again? it's still 3
:exec = (in1 integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3 3333 3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
State after 17 steps (last step: in1):
;; oh look
:exec = (integer_stackdepth integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3333 3 3333 3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
State after 18 steps (last step: integer_stackdepth):
;; dammit we've been over this
:exec = (integer_mod exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (5 3333 3 3333 3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
State after 19 steps (last step: integer_mod):
;; no really we did this
:exec = (exec_dup_times exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3 3 3333 3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
State after 20 steps (last step: exec_dup_times):
;; aha! Now we do `exec_dup_times` 3 times
:exec = (exec_y exec_y exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3 3333 3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
State after 21 steps (last step: exec_y):
;; uh-oh
:exec = (exec_y (exec_y exec_y) exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3 3333 3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
State after 22 steps (last step: exec_y):
;; and forever....
:exec = ((exec_y exec_y) (exec_y (exec_y exec_y)) exec_y integer_mod integer_div exec_dup_times "buzz" "buzz" string_concat)
:integer = (3 3333 3333 3333)
:boolean = nil
:char = nil
:string = ("fizz")
:input = (3333)
;; this repeats forever, making more `exec_y` crap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment