Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
JOSS
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
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!
===Loops and conditions=== JOSS uses a suffix notation to indicate conditional evaluation, "do this if this is true", in contrast to most languages which place the condition in front in prefix notation, "if this is true, do this". Unlike [[FORTRAN]] or [[FOCAL (programming language)|FOCAL]], any statement can be conditionally evaluated in this fashion. For example, to print a string only if a condition is met, one can combine the if with a {{code|Type}}: 1.1 Type "Hello, World!" if X=5. JOSS supported six infix comparisons, {{code|{{=}}}}, {{code|β }}, {{code|β₯}}, {{code|β€}}, {{code|>}}, {{code|<}}, and Boolean operators {{code|or}}, {{code|and}}, and {{code|not}}.{{sfn|Gimble|1967|p=70}} Loops were handled in a similar fashion, using the {{code|For}} command and a somewhat obscure format for specifying the loop bounds and step value, {{code|start(step)end}}. For instance, to step from 1 to 10 by 2, the format is {{code|1(2)10}}. Like {{code|If}}, {{code|For}} could be applied to any other statement: 1.2 Type "Hello, Wikipedia!" for i=1(2)10. Note that the for applies only to a single statement; if one wants to run multiple statements in a loop, they would be separated to another part and called using do: 1.3 Do part 5 for i=1(1)100. 5.1 Type "Hello, Wikipedia!". 5.2 Type "This is JOSS.". As in BASIC, any of the inputs to the for loop could be constants, variables or other expressions. As these sorts of ranges could be applied to any line of code, it was possible to define limits and loops when the program was invoked. For instance, consider the program: 1.1 Type X. Normally if one invoked this in a fashion similar to BASIC's {{code|RUN}}: Do part 1. It would produce: 0 However, one can modify this behaviour by adding a loop construct to the invocation: Do part 1 for X = 1(1)5. Which would produce: 1 2 3 4 5 This allows formulas to be constructed in programs without having to be placed within loops. Looping, if desired, can be provided by the user when they start the program.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
JOSS
(section)
Add topic