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!
===Ranges=== Another advanced feature of JOSS was that it had the concept of a [[Range (computer programming)|range]] as a built-in type that could be stored and manipulated. Ranges are normally found as the inputs to [[for loop]]s, where they are part of the syntax of the loop itself. For instance, in BASIC one writes a for loop using this basic syntax: {{sxhl|2=basic|1= FOR I=1 TO 5 STEP 2 }} This will perform a loop that assigns I the values 1, 3, 5 and then exits. JOSS used a somewhat obscure format to define the limits of the loop. The equivalent code in JOSS would be: I=1(2)5 Note that this code does not include a for. That is because in JOSS, ranges are first-class citizens of the language, not something that is part of a loop as in BASIC. Ranges can be defined and used in many contexts outside loops. For example, here is a conditional expression that evaluates the factorial of a parameter x:{{sfn|Gimble|1967|p=75}} Let f(x)=[x=0:1 ; fp(x)=0:prod(i=1(1)x:i)]. In this example, there are two main propositions, separated by the semicolon. The first, on the left, states that if the parameter x is 0, the condition should immediately return 1. If that proposition fails, it moves to the second test, on the right. This one checks if the fractional part of x is zero (i.e., it is an integer), and if so, it calls the {{code|prod}} function to multiply a range of values. The {{code|prod}}'s parameter is also a proposition, but in this case, the test is replaced by a loop iterator that runs from 1 to x stepping by 1. If that proposition is true, which is it for all values of the loop, it returns the index i. This causes a series of values to be sent into {{code|prod}} from 1 to x.{{sfn|Gimble|1967|p=75}} The combination of these features allows for complex functions to be written in a few commands. This sort of functionality has only become common in much more modern languages, which typically use [[iterator]]s or a [[Map (higher-order function)|map function]] to provide the same outcomes. JOSS's capability to combine decisions and loops in a compact form is unknown in other languages of the era, including offshoots like FOCAL.
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)