Awkl
Loading...
Searching...
No Matches
arr Namespace Reference

Enumerations

enum  REPR {
  REPR_COMP = 0 , REPR_COMPK = 1 , REPR_PRET = 2 , REPR_PRETK = 3 ,
  REPR_AWK = 4
}
 Array representation format. More...
 

Functions

any idx (array A, string i)
 Get element of array by index.
 
unassigned setIdx (array A, string i, any v)
 Set element of array by index.
 
auto slice ()
 
auto declare (A)
 Declare an empty array.
 
auto push (A, x)
 Push element to an indexed array with starting index 1.
 
unassigned values (array A, array R)
 Get array values into an indexed array.
 
unassigned keys (array A, array R)
 Get array keys into an indexed array.
 
unassigned keyValues (array A, array R)
 Get array keys and values into an indexed array.
 
unassigned flip (array A, array R)
 Flip array keys with values.
 
auto swap (A, i, j)
 Swap elements of an array.
 
auto swapKV (A, i, j)
 Swap key-value subindexes in elements of an array.
 
auto uniq (A, R)
 Unique elements from an array.
 
auto repr (A, fmt, s, name, i)
 String representation of an array.
 
auto reprKV (A, s, name, i)
 

 
auto echo (A, fmt, s, name, i)
 
auto echoKV (A, s, name, i)
 
auto inside (x, A)
 
auto contains (A, x)
 
auto count (A, x)
 
auto countV (A, R)
 
auto rev (A, R)
 Elements of array in reversed order, into an indexed array.
 
unassigned foreach (string fn, array A)
 For-each function. Call a function for each value (element) of an array.
 
unassigned foreachK (string fn, array A)
 For-each-key function. Call a function for each key of an array.
 
unassigned foreachKV (string fn, array A)
 For-each-key-value function. Call a function for each key-value pair of an array.
 
auto map (fn, A, R)
 
auto mapI (fn, A, R)
 Map always into an indexed array.
 
auto mapK (fn, A, R)
 Map keys.
 
auto mapV (fn, A, R)
 Map values.
 
auto mapKV (fn, A, R)
 Map key-values.
 
auto mapMany ()
 
auto pairmap ()
 
auto filter (fn, A, R)
 Filter.
 
auto filterI (fn, A, R)
 Filter values into an indexed array.
 
auto filterKV (fn, A, R)
 Filter.
 
auto grep (re, A, R)
 
auto grepI (fn, A, R)
 Grep into an indexed array.
 
any lfold (string fn, array A, any r0)
 Fold left-to-right associativity.
 
any rfold (string fn, array A, any r0)
 Fold right-to-left associativity.
 
auto foldings ()
 
number all (array A, string fn)
 All function.
 
bool allBool (array A, string fn)
 Boolean all function.
 
number any (array A, string fn)
 Any function.
 
bool anyBool (array A, string fn)
 Boolean any function.
 
number none (array A, string fn)
 None function.
 
auto some ()
 
auto one ()
 
auto notall ()
 
auto first (array A, string fn, number key_f) -> any|unassigned
 First element (its key or value) of an array that satisfies a function.
 
unassigned zipOp (string fn, array A, array B, array R)
 Zip operator (or pairwise / element-wise operator)
 
auto allOp (fn, A, B)
 
auto allEq (A, B)
 
auto allNe (A, B)
 
auto allLt (A, B)
 
auto allLe (A, B)
 
auto allGt (A, B)
 
auto allGe (A, B)
 
auto allRematch (A, B)
 
auto allRenomatch (A, B)
 
auto allApprox (A, B, rt, at)
 
auto anyNe (A, B)
 
auto anyRenomatch (A, B)
 
auto sort (A, B, how)
 
auto rsort (A, B)
 
auto sortK (A, B, how)
 
auto ltK (x, y)
 
auto gtK (x, y)
 
auto ltV (x, y)
 
auto gtV (x, y)
 
auto sortKV (A, R, how)
 
auto rsortKV (A, R)
 
auto quickSort (A, l, r, cmp, swap)
 

Enumeration Type Documentation

◆ REPR

enum arr::REPR

Array representation format.

Enumerator
REPR_COMP 

Compact format without keys.

REPR_COMPK 

Compact format with keys.

REPR_PRET 

Pretty printed format without keys.

REPR_PRETK 

Pretty printed format with keys.

REPR_AWK 

Awk array like format.

Function Documentation

◆ all()

number arr::all ( array A,
string fn )

All function.

Parameters
AArray, either of boolean (1 or 0) elements if no function passed, or of element of any type if a function is passed
fnBoolean function, that returns 1 or 0. Its parameter is the value. Optional
Returns
1 if all elements in the array are 1 or if all returns of applying the function to the elements are 1; 0 otherwise

◆ allApprox()

auto arr::allApprox ( A ,
B ,
rt ,
at  )

◆ allBool()

bool arr::allBool ( array A,
string fn )

Boolean all function.

Parameters
AArray, either of boolean (1 or 0 of type "number|bool") elements if no function passed, or of element of any type if a function is passed
fnBoolean function, that returns "true" or "false" (1 or 0 of type "number|bool"). Its parameter is a value. Optional
Returns
True if all elements in the array are true or if all returns of applying the function to the elements are true; false otherwise

◆ allEq()

auto arr::allEq ( A ,
B  )

◆ allGe()

auto arr::allGe ( A ,
B  )

◆ allGt()

auto arr::allGt ( A ,
B  )

◆ allLe()

auto arr::allLe ( A ,
B  )

◆ allLt()

auto arr::allLt ( A ,
B  )

◆ allNe()

auto arr::allNe ( A ,
B  )

◆ allOp()

auto arr::allOp ( fn ,
A ,
B  )

◆ allRematch()

auto arr::allRematch ( A ,
B  )

◆ allRenomatch()

auto arr::allRenomatch ( A ,
B  )

◆ any()

number arr::any ( array A,
string fn )

Any function.

Parameters
AArray, either of boolean (1 or 0) elements if no function passed, or of element of any type if a function is passed
fnBoolean function, that returns 1 or 0. Its parameter is a value. Optional
Returns
1 if any element in the array is 1 or if any return of applying the function to the elements is 1; 0 otherwise

◆ anyBool()

bool arr::anyBool ( array A,
string fn )

Boolean any function.

Parameters
AArray, either of boolean (1 or 0 of type "number|bool") elements if no function passed, or of element of any type if a function is passed
fnBoolean function, that returns "true" or "false" (1 or 0 of type "number|bool"). Its parameter is a value. Optional
Returns
True if any element in the array is true or if any return of applying the function to the elements is true; false otherwise

◆ anyNe()

auto arr::anyNe ( A ,
B  )

◆ anyRenomatch()

auto arr::anyRenomatch ( A ,
B  )

◆ contains()

auto arr::contains ( A ,
x  )

◆ count()

auto arr::count ( A ,
x  )

◆ countV()

auto arr::countV ( A ,
R  )

◆ declare()

auto arr::declare ( A )

Declare an empty array.

◆ echo()

auto arr::echo ( A ,
fmt ,
s ,
name ,
i  )

◆ echoKV()

auto arr::echoKV ( A ,
s ,
name ,
i  )
Examples
opt_parse.awk.

◆ filter()

auto arr::filter ( fn ,
A ,
R  )

Filter.

◆ filterI()

auto arr::filterI ( fn ,
A ,
R  )

Filter values into an indexed array.

◆ filterKV()

auto arr::filterKV ( fn ,
A ,
R  )

Filter.

◆ first()

auto arr::first ( array A,
string fn,
number key_f ) -> any | unassigned

First element (its key or value) of an array that satisfies a function.

Parameters
AArray
fnBoolean function, that returns 1 or 0. Its parameter is a value
key_f1 to return the key instead of the value
Returns
First value or key of the array that satisfies the function

◆ flip()

unassigned arr::flip ( array A,
array R )

Flip array keys with values.

Parameters
AOriginal array
RArray to be filled, with keys of original array as values, and values of original array as keys
Returns
Note
Duplicated values or the ones that coerce to the same string are lost since array indexes are unique

◆ foldings()

auto arr::foldings ( )

◆ foreach()

unassigned arr::foreach ( string fn,
array A )

For-each function. Call a function for each value (element) of an array.

Parameters
fnFunction name to be called for each value. Its parameter is a value
AArray
Returns

◆ foreachK()

unassigned arr::foreachK ( string fn,
array A )

For-each-key function. Call a function for each key of an array.

Parameters
fnFunction name to be called for each key. Its parameter is a key
AArray
Returns

◆ foreachKV()

unassigned arr::foreachKV ( string fn,
array A )

For-each-key-value function. Call a function for each key-value pair of an array.

Parameters
fnFunction name to be called for each key-value pair. Its parameter is an array with the key in the "key" key and the value in the "value" key
AArray
Returns

◆ grep()

auto arr::grep ( re ,
A ,
R  )

◆ grepI()

auto arr::grepI ( fn ,
A ,
R  )

Grep into an indexed array.

◆ gtK()

auto arr::gtK ( x ,
y  )

◆ gtV()

auto arr::gtV ( x ,
y  )

◆ idx()

any arr::idx ( array A,
string i )

Get element of array by index.

Parameters
AArray to index
iIndex
Returns
Element of array at certain index

◆ inside()

auto arr::inside ( x ,
A  )

◆ keys()

unassigned arr::keys ( array A,
array R )

Get array keys into an indexed array.

Parameters
AOriginal array
RArray to be filled, indexily, with keys of the original array
Returns

◆ keyValues()

unassigned arr::keyValues ( array A,
array R )

Get array keys and values into an indexed array.

Parameters
AOriginal array
RArray to be filled, indexily, with keys in the "key" subindex and values in the "value" subindex
Returns

◆ lfold()

any arr::lfold ( string fn,
array A,
any r0 )

Fold left-to-right associativity.

Parameters
fnBinary function
AArray to fold
r0First element. Optional, if not passed, the first element of the array is used
Returns
Reduction from left to right of elements in array

◆ ltK()

auto arr::ltK ( x ,
y  )

◆ ltV()

auto arr::ltV ( x ,
y  )

◆ map()

auto arr::map ( fn ,
A ,
R  )

◆ mapI()

auto arr::mapI ( fn ,
A ,
R  )

Map always into an indexed array.

◆ mapK()

auto arr::mapK ( fn ,
A ,
R  )

Map keys.

◆ mapKV()

auto arr::mapKV ( fn ,
A ,
R  )

Map key-values.

◆ mapMany()

auto arr::mapMany ( )

◆ mapV()

auto arr::mapV ( fn ,
A ,
R  )

Map values.

◆ none()

number arr::none ( array A,
string fn )

None function.

Parameters
AArray, either of boolean (1 or 0) elements if no function passed, or of element of any type if a function is passed
fnBoolean function, that returns 1 or 0. Its parameter is a value. Optional
Returns
1 if no elements in the array are 1 or if no returns of applying the function to the elements are 1; 0 otherwise

◆ notall()

auto arr::notall ( )

◆ one()

auto arr::one ( )

◆ pairmap()

auto arr::pairmap ( )

◆ push()

auto arr::push ( A ,
x  )

Push element to an indexed array with starting index 1.

◆ quickSort()

auto arr::quickSort ( A ,
l ,
r ,
cmp ,
swap  )

◆ repr()

auto arr::repr ( A ,
fmt ,
s ,
name ,
i  )

String representation of an array.

Todo
mode to not show key if it is correlative number from 1

◆ reprKV()

auto arr::reprKV ( A ,
s ,
name ,
i  )


/** String representation of an array with pretty-printed key-values

◆ rev()

auto arr::rev ( A ,
R  )

Elements of array in reversed order, into an indexed array.

Todo
version which reverses keys

◆ rfold()

any arr::rfold ( string fn,
array A,
any r0 )

Fold right-to-left associativity.

Parameters
fnBinary function
AArray to fold
r0First element. Optional, if not passed, the first element of the array is used
Returns
Reduction from right to left of elements in array

◆ rsort()

auto arr::rsort ( A ,
B  )

◆ rsortKV()

auto arr::rsortKV ( A ,
R  )

◆ setIdx()

unassigned arr::setIdx ( array A,
string i,
any v )

Set element of array by index.

Parameters
AArray to index
iIndex
vValue to set the element of array at certain index
Returns

◆ slice()

auto arr::slice ( )

◆ some()

auto arr::some ( )

◆ sort()

auto arr::sort ( A ,
B ,
how  )

◆ sortK()

auto arr::sortK ( A ,
B ,
how  )

◆ sortKV()

auto arr::sortKV ( A ,
R ,
how  )

◆ swap()

auto arr::swap ( A ,
i ,
j  )

Swap elements of an array.

◆ swapKV()

auto arr::swapKV ( A ,
i ,
j  )

Swap key-value subindexes in elements of an array.

◆ uniq()

auto arr::uniq ( A ,
R  )

Unique elements from an array.

Note
Not counting values that coerce to the same string

◆ values()

unassigned arr::values ( array A,
array R )

Get array values into an indexed array.

Parameters
AOriginal array
RArray to be filled, indexily, with values of the original array
Returns

◆ zipOp()

unassigned arr::zipOp ( string fn,
array A,
array B,
array R )

Zip operator (or pairwise / element-wise operator)

Parameters
fnFunction name to be applied element-wise between 2 arrays, to their shortest zip
AFirst array
BSecond array
RArray to be filled with results
Returns