Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Turing (programming language)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Syntax== Turing is designed to have a very lightweight, readable, intuitive [[Syntax (programming languages)|syntax]]. Here is the entire [["Hello, World!" program]] in Turing with [[syntax highlighting]]: '''put''' <span style="color:red">"Hello World!"</span> Turing avoids [[semicolon]]s and [[Curly brackets|braces]], using explicit end markers for most language constructs instead, and allows [[Declaration (computer programming)|declarations]] anywhere. Here is a complete program defining and using the traditional [[Recursion|recursive]] function to calculate a [[factorial]]. <span style="color:green">[[Comment (computer programming)|%]] Accepts a number and calculates its factorial</span> '''function''' <span style="color:blue">factorial</span> (<span style="color:blue">n</span>: '''int''') : '''real''' '''if''' <span style="color:blue">n</span> = 0 '''then''' '''result''' 1 '''else''' '''result''' <span style="color:blue">n</span> * <span style="color:blue">factorial</span> (<span style="color:blue">n</span> - 1) '''end if''' '''end''' <span style="color:blue">factorial</span> '''var''' <span style="color:blue">n</span>: '''int''' '''loop''' '''put''' <span style="color:red">"Please input an integer: "</span> .. '''get''' <span style="color:blue">n</span> '''exit when''' <span style="color:blue">n</span> >= 0 '''put''' <span style="color:red">"Input must be a non-negative integer."</span> '''end loop''' '''put''' <span style="color:red">"The factorial of "</span>, <span style="color:blue">n</span>, <span style="color:red">" is "</span>, <span style="color:blue">factorial</span> (<span style="color:blue">n</span>)
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)