Miscellaneous array algorithms Usage:

Flattened version is here



count(a: ATP,v:ETP):INT
**** The number of elements that are `elt_eq' to `v'.
equals(a: ATP,e: $ARR{ETP}): BOOL
**** Returns true if all of "e"'s elements are equal to a's elts
inds(a: ATP): ARRAY{INT}
**** Return an index array which is the same size as self and is set to the values of the indices
map(a: ATP,r:ROUT{ETP}:ETP)
**** Set each element of self to the result of applying `r' to it.
mismatch(a:ATP,pattern: ARRAY{ETP}):INT
**** The index of the first element of self which differs from `a'. -1 if self is a prefix of `a' or self is void.
reduce(a:ATP, r:ROUT{ETP,ETP}:ETP, start_value:ETP) :ETP
**** Combine all the elements of self by applying `r' over elements in the order determined by ind!
replace(a: ATP, old_elt,new_replacement: ETP)
**** Replace elements that are `elt_eq' to `o' by `n' wherever it occurs
replace_if(a: ATP,test: ROUT{ETP}:BOOL,replacement_value: ETP)
scan(a:ATP, r:ROUT{ETP,ETP}:ETP, start_value:ETP)
**** Set each element in a to the result of applying `r' left to right to the array up to the element. The first element is left unchanged.
str(a: ATP): STR
**** Prints out a string version of the array of the components that are under $STR, and their associated indices


elt_str(e: ETP,i: INT): STR

The Sather Home Page