Skip to content

Commit

Permalink
add two truth-machine examples
Browse files Browse the repository at this point in the history
  • Loading branch information
hornc committed Dec 7, 2018
1 parent 7dac453 commit 5813cee
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/truth-machine-trivial.ιχ
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Trivial (cheating?) Truth-machine
# Does not test conditionals properly,
# simply runs one or two defined statements '0' or '1'
# based on character symbols rather than values.
# 1 will hit the interpreter's Python recursion limit
# Usage:
# ixqus.py examples/truth-machine-trivial.ιχ <(echo 0)
# ixqus.py examples/truth-machine-trivial.ιχ <(echo 1) | head

ιιθιιιθ
Ι0χΥΘ
Ι1Υ1Θ
19 changes: 19 additions & 0 deletions examples/truth-machine.ιχ
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# More interesting truth-machine
# tests the value of the accumulator
# by triggering Deadfish overflow to destroy
# a statement definition to pick an outcome
# Still triggers recursion limits
# Usage:
# zero:
# ixqus.py examples/truth-machine.ιχ
# one:
# ixqus.py <(echo ι) examples/truth-machine.ιχ | head
# Because these "comments" are parsed as code, we need one more χ
# to bring the accumulator back to the intended 0 or 1

ΙαΑχΧΘ # define <alpha>: Test for False, break self if acc==0, and call to <ALPHA>=Truth outcome
ΙβΧιιθιιιθχΘ # define <beta>: False action
α # Tests <alpha> before <ALPHA> is defined. If accumulator is 0 <alpha> breaks and <ALPHA> will never execute
ΙΑΧιιθιιιθΥΑΘ # define <ALPHA>: True action (recursive)
αβ # Always execute <beta> and <alpha>, if acc==0 <alpha> will not be defined at this point so is either NOOP or Truth result
Υ # If <ALPHA> recursion not executed, output the False result

0 comments on commit 5813cee

Please sign in to comment.