Associative array/Iteration: Difference between revisions
Content added Content deleted
m (added whitespace to the task's preamble.) |
m (→{{header|REXX}}: changed/added comments and whitespace, changed indentations.) |
||
Line 2,221:
=={{header|REXX}}==
<lang rexx>/*REXX program demonstrates how to set and display values for an associative array. */
/*╔════════════════════════════════════════════════════════════════════════════════════╗
║ isn't defined, it can be displayed
▲ ║ indicate such, or its value can be checked to determine if a ║
╚════════════════════════════════════════════════════════════════════════════════════╝*/
▲ ║ particular associative array element has been set (defined). ║
stateL=
▲stateF.=' [not defined yet] ' /*sets any/all state former capitols.*/
/*╔════════════════════════════════════════════════════════════════════════════════════╗
▲stateN.=' [not defined yet] ' /*sets any/all state names. */
║ they'll be listed in this order.
▲ ║ The list of states (empty now). It's convenient to have them in ║
║ characters (including '00'x, 'ff'x, commas, periods,
╚════════════════════════════════════════════════════════════════════════════════════╝*/
▲ ║ In REXX, when a "key" is used, it's normally stored (internally) ║
▲ ║ as uppercase characters (as in the examples below). Actually, any ║
▲ ║ characters can be used, including blank(s) and non─displayable ║
call setSC 'al', "Alabama" , 'Tuscaloosa'
call setSC 'ca', "California" , 'Benicia'
call setSC 'co', "Colorado" , 'Denver City'
call setSC 'ct', "Connecticut" , 'Hartford and New Haven (
call setSC 'de', "Delaware" , 'New-Castle'
call setSC 'ga', "Georgia" , 'Milledgeville'
Line 2,275 ⟶ 2,269:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
setSC:
stateL=stateL code /*keep a list of all the US state codes*/
stateN.code=name /*set (define) the state's name. */
stateC.code=cap /* " " " " capitol. */
return /*return to invoker, SETSC is finished.*/
</lang>
'''output'''
<pre>
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
the former
</pre>
When this example was started, the intention was to list the former capitals by key. Unfortunately, there's a duplicate (Lancaster).
|