How to read character in whitespace language

1k views Asked by At

I am having tough time to understand how characters reading works in Whitespace. I was able to run Hello World program. But now I try to read just one character from user and then print it on standard output. I am getting no errors, everything compiles fine but character doesnt appear on output. I've tried to debug it a little but its really hard in whitespace and I believe that it doesn't print nothing because the value that I read from user is 0 (or null).

Here is how I read the character (I believe its the correct way)

start          















end

And here the SSCCE of printing out (this should work because its almost the same an it was in Hello World project.

start           


















end

I am using Whitespace 0.3 and Haskell Compiler version 5.02

1

There are 1 answers

0
Lynn On BEST ANSWER

Here's some example code that gets a character, stores it in the heap, immediately retrieves it and prints it:

Command                 Description     Stack   Heap
=======================================================
space space space lf    push 0          0
space lf space          duplicate       0 0
tab lf tab space        get character   0       h[0]=c
tab tab tab             retrieve        c       h[0]=c
tab lf space space      put character           h[0]=c
lf lf lf                exit