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
JOSS
(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!
===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.
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)