Anonymous user
Optional parameters: Difference between revisions
m
→{{header|REXX}}: added whitespace and additional comments.
m (→{{header|REXX}}: added whitespace and additional comments.) |
|||
Line 2,475:
The REXX language allows for default values for positional arguments as well as an easy method to check if a string is part of a parameter.
<br>Also allowed are named parameters.
<br><br>The REXX language doesn't have any native sorting functions, so you have to write your own sorting subroutine.
<lang rexx>sortStrings: procedure expose @. /*the stemmed array is named: @. */
col= 1
reverse= 'NO'
order= 'LEXICOGRAPHIC'
do j=1 for words(options); x=word(options,j)▼
x= word(options, j)
select
when datatype(x, 'W') then col= x / 1 /*normalize the number. */
when pos('=', x)==0 then order= x /*has it an equal sign? */
otherwise parse var x nam '=' value /*get value.*/
end /*select*/
end /*j*/
/*╔═══════════════════════════════════════════════════════════╗
║ ORDER value is recognized ··· ║
╚═══════════════════════════════════════════════════════════╝*/
... main body of string sort here ...
▲return /*stick a fork in it, we're done.*/</lang>
return /*stick a fork in it, we're all done. */</lang>
An example use is:
<lang rexx>/*REXX example uses the
/*···define array (@.nnn) of strings here···*/▼
call sortStrings 'Reverse=no' 3
/*stick a fork in it, we're all done. */</lang>
=={{header|Ruby}}==
|