Created
March 18, 2016 03:15
-
-
Save Property404/6b9abc1508ad92a9d1ed to your computer and use it in GitHub Desktop.
Bounded Flushing Input (Brainfuck)
This file contains 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
[ | |
# Bounded flushing input for string, (unoptimized for easy reading) | |
# Iterations are predetermined | |
# This example takes a max of four characters | |
# Precondition: Start at origin | |
# Array has empty cell before it | |
# Empty "array" series of cells | |
# Postcondition: End at origin | |
# All cells(except last) in "arrays" are filled with input from keyboard | |
# until <enter> or until array ends. In this example, the array is FIVE | |
# characters long(Last character ends with \0) | |
# | |
# Concept: | |
# >(&a) | |
# | |
# {,----------[++++++++++>}(^a-1) | |
# | |
# +[,----------] # Flush | |
# | |
# ](^a-1) | |
# | |
# <[<]<(&a-1) | |
] | |
# Go to address | |
>>> | |
# Read input | |
, | |
# If not \n | |
----------[++++++++++ | |
# Read next character | |
>, | |
# Two more times | |
----------[++++++++++ | |
>, | |
----------[++++++++++ | |
>, | |
# flush input if last input was not \n | |
----------[++++++++++>+[,----------]] | |
# End "loops" | |
]]] | |
# Return to head of string | |
<[<]> | |
# Go to origin | |
<<< |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment