ALGOL 68/prelude: Difference between revisions

m (Fixed section headings)
(→‎string in string: more bugfix)
 
(9 intermediate revisions by the same user not shown)
Line 49:
<br/>
Here is a version for other implementations of Algol 68:
<langsyntaxhighlight lang=algol68># A string in string procedure for use with compilers other than Algol 68G #
# returns TRUE if s is in t, FALSE otherwise. #
# if pos is not NIL: #
Line 63:
BOOL found := FALSE;
CHAR first char = s[ LWB s ];
INT first pos := LWB t;
INT end pos = UPB t;
INT s length = ( UPB s - LWB s ) + 1;
INT first pos := LWB t;
INT end pos = ( UPB t - s length ) + 1;
WHILE NOT found AND first pos <= end pos DO
found := char in string( first char, first pos, t[ first pos : @ first pos ] );
Line 71:
# the first character is not present #
first pos := end pos + 1
ELIF first pos > end pos THEN
# the first character is present but the rest of the string #
# is too short to contain s #
found := FALSE
ELIF s = t[ first pos : first pos + ( s length - 1 ) ] THEN
# found the full string s at first pos #
Line 81 ⟶ 85:
OD;
found
FI # string in string # ;</langsyntaxhighlight>
 
=== aArray.a68 ===
 
An associative array MODE for STRING keys and values. THis is used by a number of Rosseta Code tasks.
<lang algol68>#An associative array MODE for STRING elementskeys and keys values. This is used by a number of Rosseta Code #tasks.
<syntaxhighlight lang=algol68># associative array for STRING elements and keys #
 
# the modes allowed as associative array element values - change to suit #
Line 92 ⟶ 97:
MODE AAKEY = STRING;
 
# an initial value for an array element #
AAVALUE init element value = "";
 
PR read "aArrayBase.a68" PR</lang>
</syntaxhighlight>
 
=== aArrayBase.a68 ===
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.
<langsyntaxhighlight lang=algol68># associative array handling using hashing #
# AAKEY and AAVALUE modes and OP HASH(AAKEY)INT must be defined to use this #
 
Line 172 ⟶ 181:
:= HEAP AAELEMENTLIST
:= ( HEAP AAELEMENT := ( key
, HEAP AAVALUE := ""init element value
)
, ( elements OF array )[ hash value ]
Line 233 ⟶ 242:
element OF found element
FI
END; # NEXT #</lang>
</syntaxhighlight>
 
=== URI Parser ===
An Algol 68 URI parser is here: [[URL_parser/URI_parser_ALGOL68]].
 
 
=== The classic [http://web.comlab.ox.ac.uk/people/Jeremy.Gibbons/wg21/ UNESCO IFIP Working Group 2.1]'s standard prelude contents ===
Line 241 ⟶ 255:
 
These names next were intended for internal compiler use only: אBEYOND, אBFILE, אBOOK, אCOLLECTION, אCOLLITEM, אCONV, אCPATTERN, אFLEXTEXT, אFPATTERN, אFRAME, אGPATTERN, אINSERTION, אINTYPE, אNUMBER, אOUTTYPE, אPATTERN, אPICTURE, אPIECE, אPOS, אROWS, אSFRAME, אSIMPLIN, אSIMPLOUT, אSINSERT, אSTRAIGHTIN, אSTRAIGHTOUT, אTEXT, אalignment, אassociate format, אbfileprotect, אbook bounds, אchainbfile, אchar dig, אcheck pos, אcurrent pos, אdig char, אdo fpattern, אedit string, אfalse, אfile available, אfrom bin, אget char, אget good file, אget good line, אget good page, אget insertion, אget next picture, אgremlins, אidf ok, אindit string, אline ended, אlockedbfile, אlogical file ended, אmatch, אnext pos, אpage ended, אphysical file ended, אput char, אput insertion, אset bin mood, אset char mood, אset mood, אset read mood, אset write mood, אstandardize, אstaticize frames, אstaticize insertion, אstring to L int, אstring to L real, אsubfixed, אsubwhole, אto bin, אundefined, אL standardize
<!--[[Category:ALGOL 68|*]]-->
3,021

edits