Whitespace (programming language): Difference between revisions

Content deleted Content added
Added missing labels explanation and clarified how numbers are stored. I also prettified the article a little :)
NeatNit (talk | contribs)
Sample code: Added description of what each line does. Might benefit from nicer formatting, but I couldn't think of a good way to improve it.
Line 103:
<!--NOTE: Please be careful when copying/editing the code below. Some user agents may automatically insert linefeed characters for text wrapping, which will cause the code to run incorrectly.-->
The following is a commented Whitespace program that simply prints [[Hello world program|"Hello, world!"]], where each <span style="color:#ffffff;background:#ff9999">Space</span>, <span style="color:#ffffff;background:#9999ff">Tab</span>, or Linefeed character is preceded by the identifying comment "S", "T", or "L", respectively:
S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L:Push_+1001000=72='H'_onto_the_stack&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S:Output_'H';_S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>L:Push_+1100101=101='e'_onto_the_stack&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S:Output_'e';_S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L:+1101100=108='l'&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L:+1101100=108='l'&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>L:+1101111=111='o'&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L:+101100=44=','&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L:+100000=32=' '&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>L:+1110111=119='w'&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>L:+1101111=111='o'&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>L:+1110010=114='r'&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L:+1101100=108='l'&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L=+1100100=100='d'&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>T<span style="background:#9999ff">&#9;</span>L:+100001=33='!'&#10;T<span style="background:#9999ff">&#9;</span>L&#10;S<span style="background:#ff9999">&#32;</span>S<span style="background:#ff9999">&#32;</span>L:Output_'!';_L&#10;L&#10;L:End_the_program&#10;
 
Note that when Whitespace source code is displayed in some browsers, the horizontal spacing produced by a tab character is not fixed, but depends on its ___location in the text relative to the next [[Tab key#HTML|horizontal tab stop]]. Depending on the software, tab characters may also get replaced by the corresponding variable number of space characters.