;; read byte with all EOF conventions
;; + it also stops on linefeed
;; compatible BF interpreters translate CRLF => LF
;; so this would be portable
;; char value is one more than actual value
;; assumes current cell is empty
;; prints out a linefeed
;; Assumes data starts to the left of current cell
;; prints until zero
;;; main program
while more $input +
>@input ;; shift variables to the right
&read_byte ;; read in byte
Since someone beat me to a BF answer I rewrote it in EBF and made it portable and compatible. This doesn't wrap cells, it stops when encontering any one of the 3 EOF indicators or a linefeed. In compatible interpreters CRLF is translated to just a LF so this should work on any interpreter.
% bf ebf.bf < rev.ebf > rev.bf
% echo 2345 | bf -w rev.bf
The resulting BrainFuck code (output of
jitbf rev.bf --bf) is:
Same as with the previous answer and the other BF entry this just stores the input and print it in reverse order.
I don't consider this an array since I made no way of random access (yes, I use arrays in (E)BF) so this is more a stack structure.
Strings do not exist in BF but we do store them in similar manner as in this code.