How to read character in whitespace language
Asked Answered
S

1

22

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

Summons answered 28/12, 2013 at 17:5 Comment(2)
Apparently stackoverflow does not preserve spaces.Moffatt
This is one of the funniest questions I have ever seen on SO.Indiction
C
6

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
Categorical answered 28/12, 2013 at 21:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.