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!
===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.
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