Rows
This page is under active development. It may contain bugs or incomplete descriptions.
TODO: Update with function and type signatures.
This module defines operations on rows, which are data-jetted arrays. Since PLAN is untyped, these are also used as the building blocks for tuples, records, and datatypes.
They are defined with []:
arr=[10 64 42]
arr
[10 64 42]null
(null xs)
> xs : Row a
> BoolChecks if a row is empty.
null returns TRUE if the given row is empty, and FALSE otherwise.
null [] == 1
null [1 2 3] == 0
null [0] == 0arity
Returns the arity of a function or row.
arity returns the number of arguments a function takes, or the number of elements in a row plus one.
len
Returns the length of a row.
len counts the number of elements in a given row.
idx
Retrieves an element from a row at a specified index.
idx returns the element at the given index in the row. Indexing starts at 0.
last
Retrieves an element from the end of a row.
get
Retrieves an element from a row at a specified index.
get is an alias for idx. It returns the element at the given index in the row.
mut
Modifies an element in a row at a specified index.
mut returns a new row with the element at the given index replaced by the provided value.
put
Modifies an element in a row at a specified index.
put is an alias for mut. It returns a new row with the element at the given index replaced by the provided value.
switch
Selects a value from a row based on an index, with a fallback value.
switch returns the element at the given index if it exists, otherwise it returns the fallback value.
c0, c1, c2, c3, c4, c5, c6, c7, c8, c9
Creates a row constructor of the specified arity.
These functions create row constructors of arity 0 to 9 respectively.
v0, v1, v2, v3, v4, v5, v6, v7, v8, v9
Creates a row of the specified arity.
These functions create rows of arity 0 to 9 respectively, with the arguments in reverse order.
isRow
Checks if a value is a row.
isRow returns TRUE if the given value is a row, and FALSE otherwise.
foldr
Folds a row from right to left.
foldr applies a binary function to a starting value (from the right) and all elements of the row, going from right to left.
foldl
Folds a row from left to right.
foldl applies a binary function to a starting value (from the left) and all elements of the row, going from left to right.
foldr1
Folds a non-empty row from right to left using the last element as the initial accumulator.
unfoldr
Builds a row from a seed value using a function that returns either a value and a new seed, or nothing.
strictRow
Forces evaluation of all elements in a row.
weld
Concatenates two rows.
weld combines two rows into a single row, with the elements of the first row followed by the elements of the second row.
gen
Generates a row based on a function and a length.
gen creates a row of the specified length, where each element is the result of applying the given function to its index.
fst
Returns the first element of a row.
fst retrieves the leftmost element of a given row.
snd
Returns the second element of a row.
snd retrieves the second element of a given row. If the row has fewer than two elements, it returns 0.
thr
Returns the third element of a row.
thr retrieves the third element of a given row. If the row has fewer than three elements, it returns 0.
map
Applies a function to each element of a row.
map creates a new row by applying the given function to each element of the input row.
foreach
Alias for map with arguments reversed.
foreach is an alias for map. It applies a function to each element of a row.
rev
Reverses a row.
rev creates a new row with the elements of the input row in reverse order.
curry
Converts a function that takes a row to a curried function.
curry takes a function that expects a row as its argument and returns a function that takes two arguments separately.
uncurry
Converts a curried function to a function that takes a row.
uncurry takes a function that expects two separate arguments and returns a function that takes a row of two elements.
rowCons
Prepends an element to a row.
rowCons creates a new row with the given element as the first element, followed by all elements of the input row.
rowSnoc
Appends an element to a row.
rowSnoc creates a new row with all elements of the input row, followed by the given element as the last element.
rowApply
Applies a function to a row of arguments.
rowApply takes a function and a row of arguments, and applies the function to those arguments.
rowRepel
Applies a function to a row of arguments in reverse order.
rowRepel takes a function and a row of arguments, and applies the function to those arguments in reverse order.
slash
Extracts a slice from a row, from index s to index e, padding with zeros if necessary.
slice
Similar to slash, but doesn't pad with zeros. It returns a slice from index s up to (but not including) index e.
chunks
Splits a row into chunks of a specified size.
rep
Creates a row by repeating a value a specified number of times.
rowIndexed
Creates a row of pairs, where each pair contains the index and the corresponding element from the input row.
findIdx
Finds the index of the first element in a row that satisfies a predicate function.
elemIdx
Finds the index of the first occurrence of a specific element in a row.
has
Checks if a row contains a specific element.
rowAnd
Performs a logical AND operation on all elements of a row.
rowOr
Performs a logical OR operation on all elements of a row.
sum
Calculates the sum of all elements in a row.
sumOf
Applies a function to each element of a row and then calculates the sum of the results.
all
Checks if all elements in a row satisfy a given predicate.
any
Checks if any element in a row satisfies a given predicate.
zip
Combines two rows into a row of pairs.
zipWith
Combines two rows using a given function.
cat
Concatenates a row of rows into a single row.
catMap
Applies a function to each element of a row and concatenates the results.
take
Returns the first n elements of a row.
drop
Removes the first n elements from a row.
rev
Reverses the order of elements in a row.
span
Splits a row into two parts: the longest prefix that satisfies a predicate and the rest.
splitAt
Splits a row at a given index.
intersperse
Intersperses an element between every element of a row.
insert
Inserts an element at a specified index in a row.
Sorting and Filtering
sort
Sorts a row in ascending order.
sortBy
Sorts a row using a custom comparison function.
sortOn
Sorts a row by applying a function to each element before comparing.
sortUniq
Sorts a row and removes duplicate elements.
filter
Keeps only the elements of a row that satisfy a predicate.
delete
Removes all occurrences of a value from a row.
findIdxMany
Finds all indices where a predicate is satisfied.
elemIdxMany
Finds all indices where a specific element occurs.
Last updated