Skip to content

Instantly share code, notes, and snippets.

@bergwerf
Created January 10, 2019 22:33
Show Gist options
  • Select an option

  • Save bergwerf/86a1edcd794eed623f3b75bc0786ccfc to your computer and use it in GitHub Desktop.

Select an option

Save bergwerf/86a1edcd794eed623f3b75bc0786ccfc to your computer and use it in GitHub Desktop.
; This program counts the number of a characters in a string
; and appends it in reverse binary to the end of the tape
; Go to nil state
0 * * * nil
; Counting program
nil a x r odd
even a x r odd
odd a a r even
nil * * r nil
odd * * r odd
even * * r even
; Put down 0 at the end of the tape if the number
; of a characters is even. This is the case if we
; are in the even state.
even _ 0 * return
odd _ 1 * return
nil _ # * halt
; Return to tape start
return _ _ r nil
return * * l return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment