GolfScript: Difference between revisions

Content deleted Content added
m Language: Citations; +clause
m ref naming
Line 8:
== Language ==
 
Programs in GolfScript consist of lists of items, each of which is pushed onto the [[Stack (abstract data type)|stack]] as it is encountered with the exception of variables which have code blocks as their value, in which case the code is executed. When a variable assignment (carried out through the placement of a colon before the name of the variable) is encountered, the top item on the stack is popped and assigned to the variable.<ref name=":0tutorial">{{Cite web|url = http://www.golfscript.com/golfscript/tutorial.html|title = GolfScript Tutorial|accessdate = 25 June 2014|website = GolfScript|date = 18 May 2012}}</ref>
 
GolfScript attempts to reach its goal of solving problems in as few keystrokes as possible through the use of single symbols to represent high-level operations.<ref name="official website" /> A single symbol can stand for multiple operations depending on the type of the arguments passed to it,<ref>{{Cite web|url = http://www.golfscript.com/golfscript/quickref.html|title = GolfScript Quick Reference|date = 18 May 2012|accessdate = 25 June 2014|website = GolfScript}}</ref> and can even be reassigned and used like a variable.<ref name=":0tutorial" />
 
=== Input and output ===
If input is supplied to a GolfScript program, it is pushed onto the stack as a string before the program is executed. Output is provided via the stack's contents being printed when execution of the program finishes.<ref name=":0tutorial" />
 
== Examples ==
Line 19:
=== Hello world ===
 
The traditional [[Hello world program]] can be written in GolfScript as:<ref name=":0tutorial">{{Cite web|url = http://www.golfscript.com/golfscript/tutorial.html|title = GolfScript Tutorial|accessdate = 25 June 2014|website = GolfScript|date = 18 May 2012}}</ref>
 
"Hello World!"