iop v1.4.1
Miscellaneous useful functions in one place.
Arrays
count(a, f)
Count how many elements of an array satisfy a predicate.
Functional maps
val = get(m, key)
Get a value. If not present, returns the false value supplied initially for this map. This operation takes O(N) time.
m = put(m, key, val)
Put a new key-value pair in a map, returning the new map while leaving the old one unchanged. Any existing value for that key will be overridden. Represent an empty map with any false value. Keys don't need to be ordered, just comparable by strict equality. This operation takes O(1) time.
These functions also work with JavaScript Map
s. In that case, put
still works in functional style, creating a new Map
, which takes O(N) time but lets subsequent get
s take O(1) time.
ctype
isalnum(c)
isalpha(c)
isdigit(c)
islower(c)
isspace(c)
isupper(c)
As the C equivalents.
print(a)
Print a value with useful settings, including full expansion of nested objects to any depth, arrays to any length, and color coding that turns off when stdout is redirected.