ALGOL 68/prelude: Difference between revisions
Content added Content deleted
m (Fixed section headings) |
m (→aArrayBase.a68) |
||
Line 97: | Line 97: | ||
=== aArrayBase.a68 === |
=== aArrayBase.a68 === |
||
The MODEs for associative arrays. The AAKEY and AAVALUE MODEs must be defined as required. |
The MODEs for associative arrays. The AAKEY and AAVALUE MODEs must be defined as required. |
||
<br>An item "init element value" must also be defined. |
|||
<br>If AAKEY is not STRING, a suitable HASH operator will also need to be defined. |
<br>If AAKEY is not STRING, a suitable HASH operator will also need to be defined. |
||
<lang algol68># associative array handling using hashing # |
<lang algol68># associative array handling using hashing # |
||
Line 154: | Line 155: | ||
# find the element in the list, if it is there # |
# find the element in the list, if it is there # |
||
BOOL found element := FALSE; |
BOOL found element := FALSE; |
||
INT ec := 0; |
|||
WHILE ( element ISNT nil element list ) |
WHILE ( element ISNT nil element list ) |
||
AND NOT found element |
AND NOT found element |
||
DO |
DO |
||
ec +:= 1; |
|||
found element := ( key OF element OF element = key ); |
found element := ( key OF element OF element = key ); |
||
IF found element |
IF found element |
||
Line 172: | Line 175: | ||
:= HEAP AAELEMENTLIST |
:= HEAP AAELEMENTLIST |
||
:= ( HEAP AAELEMENT := ( key |
:= ( HEAP AAELEMENT := ( key |
||
, HEAP AAVALUE := |
, HEAP AAVALUE := init element value |
||
) |
) |
||
, ( elements OF array )[ hash value ] |
, ( elements OF array )[ hash value ] |
||
Line 233: | Line 236: | ||
element OF found element |
element OF found element |
||
FI |
FI |
||
END; # NEXT # |
END; # NEXT # |
||
</lang> |
|||
=== The classic [http://web.comlab.ox.ac.uk/people/Jeremy.Gibbons/wg21/ UNESCO IFIP Working Group 2.1]'s standard prelude contents === |
=== The classic [http://web.comlab.ox.ac.uk/people/Jeremy.Gibbons/wg21/ UNESCO IFIP Working Group 2.1]'s standard prelude contents === |