Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read character in whitespace language

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

like image 517
kukis Avatar asked Dec 28 '13 17:12

kukis


People also ask

What characters are whitespace?

Space, tab, line feed (newline), carriage return, form feed, and vertical tab characters are called "white-space characters" because they serve the same purpose as the spaces between words and lines on a printed page — they make reading easier.

How does whitespace language work?

Its name is a reference to whitespace characters. Unlike most programming languages, which ignore or assign little meaning to most whitespace characters, the Whitespace interpreter ignores any non-whitespace characters. Only spaces, tabs and linefeeds have meaning.

What is whitespace code?

What is whitespace? Whitespace is any string of text composed only of spaces, tabs or line breaks (to be precise, CRLF sequences, carriage returns or line feeds). These characters allow you to format your code in a way that will make it easily readable by yourself and other people.

Is whitespace a special character?

Special characters are those characters that are neither a letter nor a number. Whitespace is also not considered a special character.


1 Answers

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 
like image 96
Lynn Avatar answered Sep 28 '22 07:09

Lynn