10 + 20
// Access object properies with .
// Access string and array elements with []
let data = {
numbers: [1, 2, 3],
chars: ["a", "b", "c"],
string: "Albert"
};
write!(data.numbers[0]);
write!(data.chars[2]);
write!(data.string[0]);
write!({a: 1, b: 2, c: 3}.b);
write!("Albert"[3]);
write!([1, 2, 3][2]);
plus(x, y)
// Functional Text Adventure Game in Lits
// Define locations
let locations = {
forest: {
description: "You are in a dense forest. Light filters through the leaves above.",
exits: { north: "cave", east: "river", south: "meadow" }
},
cave: {
description: "You stand in a dark cave. Water drips from stalactites overhead.",
exits: { south: "forest", east: "tunnel" },
items: ["torch"]
},
river: {
description: "A swift river flows from the mountains. The water is crystal clear.",
exits: { west: "forest", north: "waterfall" },
items: ["fishing rod"]
},
meadow: {
description: "A peaceful meadow stretches before you, filled with wildflowers.",
exits: { north: "forest", east: "cottage" },
items: ["flowers"]
},
waterfall: {
description: "A magnificent waterfall cascades down from high cliffs.",
exits: { south: "river" },
items: ["shiny stone"]
},
tunnel: {
description: "A narrow tunnel leads deeper into the mountain.",
exits: { west: "cave", east: "treasure room" }
},
"treasure room": {
description: "A small chamber glittering with treasure!",
exits: { west: "tunnel" },
items: ["gold key", "ancient map", "jeweled crown"]
},
cottage: {
description: "A cozy cottage with a smoking chimney stands here.",
exits: { west: "meadow" },
items: ["bread"]
}
};
// Define game state
let initial-state = {
current-location: "forest",
inventory: [],
visited: {},
game-over: false,
moves: 0,
light-source: false
};
// Helper functions
let has-item? = (state, item) -> {
contains?(state.inventory, item);
};
let location-has-item? = (location, item) -> {
contains?(get(location, "items", []), item);
};
let describe-location = (state) -> {
let location = get(locations, state.current-location);
let description = location.description;
// Add visited status
let visited-status = if get(state.visited, state.current-location, 0) > 1 then
"You've been here before."
else
"This is your first time here."
end;
// Check if location has items
let items-desc = if !(empty?(get(location, "items", []))) then
"You see: " ++ join(location.items, ", ")
else
""
end;
// Describe exits
let exits = keys(location.exits) join ", ";
let exits-desc = "Exits: " ++ exits;
// Join all descriptions
filter([description, visited-status, items-desc, exits-desc], -> !(empty?($))) join "\n"
};
let get-location-items = (state) -> {
let location = get(locations, state.current-location);
get(location, "items", [])
};
// Game actions
let move = (state, direction) -> {
let location = get(locations, state.current-location);
let exits = get(location, "exits", {});
// Check if direction is valid
if contains?(exits, direction) then
let new-location = get(exits, direction);
let is-dark = new-location == "tunnel" || new-location == "treasure room";
// Check if player has light source for dark areas
if is-dark && !(state.light-source) then
[state, "It's too dark to go that way without a light source."]
else
let new-visited = assoc(
state.visited,
new-location,
inc(state.visited["new-location"] ?? 0)
);
let new-state = assoc(
assoc(
assoc(state, "current-location", new-location),
"visited",
new-visited
),
"moves",
state.moves + 1
);
[new-state, "You move " ++ direction ++ " to the " ++ new-location ++ "."]
end
else
[state, "You can't go that way."]
end
};
let take! = (state, item) -> {
let items = get-location-items(state);
if contains?(items, item) then
let location = get(locations, state.current-location);
let new-location-items = filter(items, -> $ ≠ item);
let new-inventory = push(state.inventory, item);
// Update game state
let new-locations = assoc(
locations,
state.current-location,
assoc(location, "items", new-location-items)
);
// Special case for torch
let has-light = item == "torch" || state.light-source;
// Update locations and state
let locations = new-locations;
let new-state = assoc(
assoc(
assoc(state, "inventory", new-inventory),
"light-source", has-light
),
"moves",
state.moves + 1
);
[new-state, "You take the " ++ item ++ "."]
else
[state, "There is no " ++ item ++ " here."]
end
};
let drop! = (state, item) -> {
if has-item?(state, item) then
let location = get(locations, state.current-location);
let location-items = get(location, "items", []);
let new-location-items = push(location-items, item);
let new-inventory = filter(-> $ ≠ item, state.inventory);
// Special case for torch
let still-has-light = !(item == "torch") || contains?(new-inventory, "torch");
// Update locations and state
let new-location = assoc(location, "items", new-location-items);
let locations = assoc(locations, state.current-location, new-location);
let new-state = assoc(
assoc(
assoc(
state, "inventory", new-inventory),
"light-source",
still-has-light
),
"moves",
state.moves + 1
);
[new-state, "You drop the " ++ item ++ "."]
else
[state, "You don't have a " ++ item ++ " in your inventory."]
end
};
let inventory = (state) -> {
if empty?(state.inventory) then
[state, "Your inventory is empty."]
else
[state, "Inventory: " ++ join(state.inventory, ", ")]
end
};
let use = (state, item) -> {
switch item
case "fishing rod" then
if state.current-location == "river" then
[assoc(state, "moves", state.moves + 1), "You catch a small fish, but it slips away."]
else
[state, "There's no place to use a fishing rod here."]
end
case "torch" then
if has-item?(state, item) then
[
assoc(assoc(state, "light-source", true), "moves", state.moves + 1),
"The torch illuminates the area with a warm glow."
]
else
[state, "You don't have a torch."]
end
case "gold key" then
if has-item?(state, item) && state.current-location == "treasure room" then
[
assoc(
assoc(state, "game-over", true),
"moves",
state.moves + 1
),
"You use the gold key to unlock a secret compartment, revealing a fabulous diamond! You win!"
]
else
[state, "The key doesn't fit anything here."]
end
case "bread" then
if has-item?(state, item) then
let new-inventory = filter(state.inventory, -> $ ≠ item);
[
assoc(
assoc(state, "inventory", new-inventory),
"moves",
state.moves + 1
),
"You eat the bread. It's delicious and nourishing."
]
else
[state, "You don't have any bread."]
end
case "shiny stone" then
if has-item?(state, item) then
[
assoc(state, "moves", state.moves + 1),
"The stone glows with a faint blue light. It seems magical but you're not sure how to use it yet."
]
else
[state, "You don't have a shiny stone."]
end
case "flowers" then
if has-item?(state, item) then
[
assoc(state, "moves", state.moves + 1),
"You smell the flowers. They have a sweet, calming fragrance."
]
else
[state, "You don't have any flowers."]
end
case "ancient map" then
if has-item?(state, item) then
[
assoc(state, "moves", state.moves + 1),
"The map shows the layout of the area. All locations are now marked as visited."
]
else
[state, "You don't have a map."]
end
case "jeweled crown" then
if has-item?(state, item) then
[
assoc(state, "moves", state.moves + 1),
"You place the crown on your head. You feel very regal."
]
else
[state, "You don't have a crown."]
end
end ?? [state, "You can't use that."]
};
// Command parser
let parse-command = (state, input) -> {
let tokens = lower-case(input) split " ";
let command = first(tokens);
let args = rest(tokens) join " ";
let result = switch command
case "go" then
move(state, args)
case "north" then
move(state, "north")
case "south" then
move(state, "south")
case "east" then
move(state, "east")
case "west" then
move(state, "west")
case "take" then
take!(state, args)
case "drop" then
drop!(state, args)
case "inventory" then
inventory(state)
case "i" then
inventory(state)
case "look" then
[assoc(state, "moves", state.moves + 1), describe-location(state)]
case "use" then
use(state, args)
case "help" then
[state, "Commands then go [direction], north, south, east, west, take [item], drop [item], inventory, look, use [item], help, quit"]
case "quit" then
[assoc(state, "game-over", true), "Thanks for playing!"]
end ?? [state, "I don't understand that command. Type 'help' for a list of commands."];
result
};
// Game loop
let game-loop = (state) -> {
alert!(describe-location(state) ++ "\nWhat do you do? ");
let input = read-line!();
let command_result = parse-command(state, input);
let new-state = first(command_result);
let message = second(command_result);
alert!("\n" ++ message ++ "\n");
if new-state.game-over then
alert!("\nGame over! You made " ++ str(new-state.moves) ++ " moves.");
new-state
else
game-loop(new-state)
end
};
// Start game
let start-game = () -> {
alert!("=== Lits Adventure Game ===\n" ++ "Type 'help' for a list of commands.\n\n");
game-loop(initial-state)
};
// Call the function to start the game
start-game()
// Determinant function for square matrices
let determinant = (matrix) -> {
// Check if input is an array
unless array?(matrix) then
throw("Input must be an array");
end;
// Check if matrix is empty
if empty?(matrix) then
throw("Matrix cannot be empty");
end;
let rows = count(matrix);
// Get first row to check column count
let firstRow = first(matrix);
// Check if first row is an array
unless array?(firstRow) then
throw("Input must be a 2D array");
end;
let cols = count(firstRow);
// Ensure matrix is square
if rows ≠ cols then
throw("Matrix must be square");
end;
// Base case: 1x1 matrix
if rows == 1 then
matrix[0][0];
else
// Base case: 2x2 matrix
if rows == 2 then
let a = matrix[0][0];
let b = matrix[0][1];
let c = matrix[1][0];
let d = matrix[1][1];
a * d - b * c;
else
// For larger matrices, use cofactor expansion along first row
// Use reduce to calculate the determinant without mutating variables
reduce(
range(cols),
(acc, j) -> {
let minor = getMinor(matrix, 0, j);
let cofactor = determinant(minor);
let signFactor = even?(j) ? 1 : -1;
let term = signFactor * matrix[0][j] * cofactor;
acc + term;
},
0,
);
end
end
};
// Helper function to get minor (submatrix) by removing specific row and column
let getMinor = (matrix, rowToRemove, colToRemove) -> {
// Use map with filter to create the new matrix without mutating
map(
range(count(matrix)),
i -> {
if i == rowToRemove then
null; // This will be filtered out
else
let row = get(matrix, i);
// Filter out the column to remove
map(
range(count(row)),
j -> {
if j == colToRemove then
null; // This will be filtered out
else
get(row, j)
end
}
) filter (item -> item ≠ null);
end
}
) filter (row -> row ≠ null);
};
// 4x4 invertible matrix
let matrix4x4 = [
[4, 3, 2, 2],
[0, 1, -3, 3],
[0, -1, 3, 3],
[0, 3, 1, 1]
];
determinant(matrix4x4);
// Matrix multiplication with correct syntax
let matrixMultiply = (matrixA, matrixB) -> {
// Check if inputs are arrays
unless array?(matrixA) then throw("First input must be an array") end;
unless array?(matrixB) then throw("Second input must be an array") end;
// Check if matrices are not empty
if empty?(matrixA) || empty?(matrixB) then throw("Matrices cannot be empty") end;
// Check if matrices are 2D arrays
unless array?(first(matrixA)) then throw("First input must be a 2D array") end;
unless array?(first(matrixB)) then throw("Second input must be a 2D array") end;
// Get dimensions
let rowsA = count(matrixA);
let colsA = count(first(matrixA));
let rowsB = count(matrixB);
let colsB = count(first(matrixB));
// Check if all rows have consistent length
unless every?(matrixA, row -> array?(row) && count(row) == colsA) then
throw("First matrix has inconsistent row lengths")
end;
unless every?(matrixB, row -> array?(row) && count(row) == colsB) then
throw("Second matrix has inconsistent row lengths")
end;
// Check if matrices can be multiplied
unless colsA == rowsB then
throw("Matrix dimensions mismatch: first matrix columns must equal second matrix rows");
end;
// Create a row of the result matrix
let createRow = (rowIndex) -> {
for (j in range(colsB)) -> {
reduce(
range(colsA),
(sum, k) -> {
let aValue = matrixA[rowIndex][k];
let bValue = matrixB[k][j];
sum + (aValue * bValue);
},
0
)
}
};
// Create the result matrix row by row
for (i in range(rowsA)) -> createRow(i);
};
let matrixA = [
[1, 2, 3],
[4, 5, 6]
];
let matrixB = [
[7, 8],
[9, 10],
[11, 12]
];
matrixMultiply(matrixA, matrixB);
let formatPhoneNumber = (data) -> {
if string?(data) then
let phoneNumber = data[0] == "+" ? data slice 2 : data;
let length = count(phoneNumber);
cond
case length > 6 then
"(" ++ slice(phoneNumber, 0, 3) ++ ") " ++ slice(phoneNumber, 3, 6) ++ "-" ++ slice(phoneNumber, 6)
case length > 3 then
"(" ++ slice(phoneNumber, 0, 3) ++ ") " ++ slice(phoneNumber, 3)
case length > 0 then
"(" ++ slice(phoneNumber, 0)
end ?? ""
else
""
end
};
write!(formatPhoneNumber);
write!(formatPhoneNumber(123234));
write!(formatPhoneNumber("123234"));
write!(formatPhoneNumber("1232343456"));
write!(formatPhoneNumber("+11232343456789"));
write!(formatPhoneNumber("+11232343456"));
let factorial = (x) -> {
if x == 1 then
1
else
x * self(x - 1)
end
};
factorial(5)
let l = [7, 39, 45, 0, 23, 1, 50, 100, 12, -5];
let numberComparer = (a, b) -> {
cond
case a < b then -1
case a > b then 1
end ?? 0
};
sort(l, numberComparer)
let isoDateString? = (data) -> {
let m = data match #"^(\d{4})-(\d{2})-(\d{2})$";
if m then
let [year, month, day] = slice(m, 1) map number;
let leapYear = zero?(year mod 4) && (!zero?(year mod 100) || zero?(year mod 400));
let invalid =
(year < 1900 || year > 2100)
|| (month < 1 || month > 12)
|| (day < 1 || day > 31)
|| day > 30 && (month == 4 || month == 6 || month == 9 || month == 11)
|| month == 2 && (leapYear && day > 29 || !leapYear && day > 28);
!(invalid)
else
false
end
};
write!(isoDateString?("1978-12-21"));
write!(isoDateString?("197-12-21"));
let label-from-value = (items, value) -> {
let entry = items some (-> value == $["value"]);
if entry == null then
null
else
entry["label"]
end
};
let items = [
{ label: "Name", value: "name" },
{ label: "Age", value: "age" }
];
label-from-value(items, "name");
let labels-from-values = ($array, $values) -> {
for (
value in $values
let label = {
let entry = $array some -> value == $["value"];
if entry == null then
value
else
entry["label"]
end
}
) -> label
};
let arr = [
{ label: "Name", value: "name" },
{ label: "Age", value: "age" },
{ label: "Email", value: "email" },
];
labels-from-values(arr, ["name", "age"])
a filter b | → | collection |
filter(coll, fun) | → | collection |
a | collection |
b | function |
coll | collection |
fun | function |
a filteri b | → | collection |
filteri(a, b) | → | collection |
a | collection | |
b | function |
The function to call for each element in the collection. The function should take two arguments: the element itself and the index.
|
a map b | → | collection |
map(...colls, fun) | → | collection |
a | collection | |
b | function | |
colls | Array<collection> |
At least one.
|
fun | function |
a mapi b | → | collection |
mapi(a, b) | → | collection |
a | collection | |
b | function |
The function to call for each element in the collection. The function should take two arguments: the element itself and the index.
|
reduce(coll, fun, initial) | → | any |
fun | function |
coll | collection |
initial | any |
reduce-right(coll, fun, initial) | → | any |
fun | function |
coll | collection |
initial | any |
reducei-right(coll, fun, initial) | → | any |
coll | collection | |
fun | function |
The function to call for each element in the collection. The function should take three arguments: the accumulator, the element itself, and the index.
|
initial | any |
The initial value to use as the accumulator.
|
reducei(coll, fun, initial) | → | any |
coll | collection | |
fun | function |
The function to call for each element in the collection. The function should take three arguments: the accumulator, the element itself, and the index.
|
initial | any |
The initial value to use as the accumulator.
|
reductions(coll, fun, initial) | → | Array<any> |
fun | function |
coll | collection |
initial | any |
reductionsi(coll, fun, initial) | → | Array<any> |
coll | collection | |
fun | function |
The function to call for each element in the collection. The function should take three arguments: the accumulator, the element itself, and the index.
|
initial | any |
The initial value to use as the accumulator.
|
count(coll) | → | number |
coll | collection | null |
a | collection | |
b | string | integer | |
not-found | any |
Default value to return if b is not found.
|
a | collection |
b | array |
not-found | any |
a | collection | null |
b | string | integer |
assoc(coll, key, value) | → | collection |
assoc(coll, key, value, ...kvs) | → | collection |
If coll is an 'array', key must be number satisfying 0 <= key <= length.
coll | collection | |
key | string | number | |
value | any | |
kvs | Array<any> |
Key-value pairs to associate.
|
assoc-in(coll, ks, value) | → | collection |
If any levels do not exist, objects will be created - and the corresponding keys must be of type string.
coll | collection |
ks | Array<number | string> |
value | any |
a ++ b | → | collection |
++(a) | → | collection |
++(a, ...colls) | → | collection |
a concat b | → | collection |
concat(a) | → | collection |
concat(a, ...colls) | → | collection |
a | collection |
b | collection |
colls | Array<collection> |
not-empty(coll) | → | boolean |
coll | collection | null |
a | collection |
b | function |
a | collection |
b | function |
a | collection |
b | function |
a | collection |
b | function |
update(coll, , fun) | → | collection |
update(coll, , fun, ...fun-args) | → | collection |
coll | collection |
key | string | number |
fun | function |
fun-args | Array<any> |
update-in(coll, ks, fun) | → | collection |
update-in(coll, ks, fun, ...fun-args) | → | collection |
coll | collection |
ks | array |
fun | function |
fun-args | Array<any> |
a range b | → | Array<number> |
range(b) | → | Array<number> |
range(a, b) | → | Array<number> |
range(a, b, step) | → | Array<number> |
a defaults to 0.
step defaults to 1.
flatten(x) | → | Array<any> |
a mapcat b | → | collection |
mapcat(colls, fun) | → | collection |
a | collection |
b | function |
colls | Array<collection> |
fun | function |
moving-fn(arr, windowSize, fn) | → | array |
seq | sequence |
seq | sequence |
a slice b | → | sequence |
slice(...seq) | → | sequence |
slice(...seq, start) | → | sequence |
slice(...seq, start, stop) | → | sequence |
a | sequence | |
b | integer | |
seq | Array<sequence> | |
start | integer |
Defaults to 0.
|
stop | integer |
Defaults lenght of sequence + 1.
|
splice(...seq, start, deleteCount) | → | sequence |
splice(...seq, start, deleteCount, ...items) | → | sequence |
first(seq) | → | any |
second(seq) | → | any |
last(seq) | → | any |
seq | sequence |
seq | sequence |
a sort-by b | → | Array<any> |
sort-by(seq, keyfn) | → | Array<any> |
sort-by(seq, keyfn, comparer) | → | Array<any> |
distinct(seq) | → | sequence |
seq | sequence |
frequencies(seq) | → | object |
seq | sequence |
a partition b | → | sequence |
partition(seq, n) | → | sequence |
partition(seq, n, step) | → | sequence |
partition(seq, n, step, pad) | → | sequence |
a partition-all b | → | sequence |
partition-all(seq, n) | → | sequence |
partition-all(seq, n, step) | → | sequence |
a * b | → | number | vector | matrix |
*(...xs) | → | number | vector | matrix |
a · b | → | number | vector | matrix |
·(...xs) | → | number | vector | matrix |
a rem b | → | number | vector | matrix |
rem(a, b) | → | number | vector | matrix |
a % b | → | number | vector | matrix |
%(a, b) | → | number | vector | matrix |
inc(x) | → | number |
a round b | → | number | vector | matrix |
round(a) | → | number | vector | matrix |
round(a, b) | → | number | vector | matrix |
identity(x) | → | any |
x | any |
The returned function takes a variable number of arguments, applies the rightmost function to the args, the next function (right-to-left) to the result, etc.
constantly(x) | → | function |
x | any |
The returned function takes a variable number of args, and returns a vector containing the result of applying each function to the args (left-to-right).
complement(fun) | → | function |
fun | function |
doc(fun) | → | string |
fun | function |
arity(fun) | → | object |
fun | function |
a != b | → | boolean |
!=(x) | → | boolean |
!=(x, ...ys) | → | boolean |
a ≠ b | → | boolean |
≠(x) | → | boolean |
≠(x, ...ys) | → | boolean |
a <= b | → | boolean |
<=(x) | → | boolean |
<=(x, ...ys) | → | boolean |
a ≤ b | → | boolean |
≤(x) | → | boolean |
≤(x, ...ys) | → | boolean |
a >= b | → | boolean |
>=(x) | → | boolean |
>=(x, ...ys) | → | boolean |
a ≥ b | → | boolean |
≥(x) | → | boolean |
≥(x, ...ys) | → | boolean |
!(x) | → | boolean |
x | any |
write!(...values) | → | any |
values | Array<any> |
iso-date->epoch(iso) | → | number |
iso | string |
epoch->iso-date(ms) | → | string |
ms | number |
boolean(x) | → | boolean |
x | any |
json-parse(x) | → | any |
x | string |
keys(obj) | → | Array<any> |
obj | object |
vals(obj) | → | Array<any> |
obj | object |
entries(obj) | → | array |
obj | object |
If two keys appears in more than one object the value from the last object is used.
If no arguments are provided null is returned.
merge-with(...objs, fun) | → | object |
If no arguments are provided null is returned.
boolean?(x) | → | boolean |
x | any |
null?(x) | → | boolean |
x | any |
number?(x) | → | boolean |
x | any |
string?(x) | → | boolean |
x | any |
function?(x) | → | boolean |
x | any |
integer?(x) | → | boolean |
x | any |
array?(x) | → | boolean |
x | any |
object?(x) | → | boolean |
x | any |
coll?(x) | → | boolean |
x | any |
seq?(x) | → | boolean |
x | any |
regexp?(x) | → | boolean |
x | any |
zero?(x) | → | boolean |
x | number |
pos?(x) | → | boolean |
x | number |
neg?(x) | → | boolean |
x | number |
even?(x) | → | boolean |
x | number |
odd?(x) | → | boolean |
x | number |
finite?(x) | → | boolean |
x | number |
negative-infinity?(x) | → | boolean |
x | number |
positive-infinity?(x) | → | boolean |
x | number |
false?(x) | → | boolean |
x | any |
true?(x) | → | boolean |
x | any |
empty?(x) | → | boolean |
x | collection | string | null |
not-empty?(x) | → | boolean |
x | collection | string | null |
vector?(value) | → | boolean |
value | any |
The value to check.
|
matrix?(value) | → | boolean |
value | any |
The value to check.
|
grid?(value) | → | boolean |
value | any |
The value to check.
|
pattern | string | |
flags | string |
Optional flags for the regular expression. Possible values are the same as Javascript RegExp takes.
|
replace(a, b, x) | → | Array<any> |
replace-all(a, b, x) | → | Array<any> |
str(...values) | → | string |
values | Array<any> |
number(s) | → | number |
s | string |
lower-case(s) | → | string |
s | string |
upper-case(s) | → | string |
s | string |
trim(s) | → | string |
s | string |
trim-left(s) | → | string |
s | string |
trim-right(s) | → | string |
s | string |
split-lines(s) | → | string |
s | string |
template(s, ...params) | → | string |
to-char-code(c) | → | number |
c | string |
from-char-code(code) | → | string |
code | number |
encode-base64(s) | → | string |
s | string |
decode-base64(base64string) | → | string |
base64string | string |
encode-uri-component(s) | → | string |
s | string |
decode-uri-component(s) | → | string |
s | string |
capitalize(s) | → | string |
s | string |
blank?(s) | → | boolean |
bit-not(a) | → | integer |
a | integer |
vec:mean(vector) | → | number |
vector | vector |
The vector to calculate the mean of.
|
vector | vector |
The vector to calculate the moving mean of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-mean b | → | array |
vec:centered-moving-mean(vector, windowSize) | → | array |
vec:centered-moving-mean(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-mean(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving mean of.
|
windowSize | integer |
The size of the centered moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-mean(vector) | → | vector |
vector | vector |
The vector to calculate the running mean of.
|
vec:geometric-mean(vector) | → | number |
vector | vector |
The vector to calculate the geometric mean of.
|
vector | vector |
The vector to calculate the moving geometric mean of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-geometric-mean b | → | array |
vec:centered-moving-geometric-mean(vector, windowSize) | → | array |
vec:centered-moving-geometric-mean(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-geometric-mean(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving geometric mean of.
|
windowSize | integer |
The size of the centered moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-geometric-mean(vector) | → | vector |
vector | vector |
The vector to calculate the running geometric mean of.
|
vec:harmonic-mean(vector) | → | number |
vector | vector |
The vector to calculate the harmonic mean of.
|
vector | vector |
The vector to calculate the moving harmonic mean of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-harmonic-mean b | → | array |
vec:centered-moving-harmonic-mean(vector, windowSize) | → | array |
vec:centered-moving-harmonic-mean(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-harmonic-mean(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving harmonic mean of.
|
windowSize | integer |
The size of the centered moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-harmonic-mean(vector) | → | vector |
vector | vector |
The vector to calculate the running harmonic mean of.
|
vec:median(vector) | → | number |
vector | vector |
The vector to calculate the median of.
|
vector | vector |
The vector to calculate the moving median of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-median b | → | array |
vec:centered-moving-median(vector, windowSize) | → | array |
vec:centered-moving-median(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-median(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving median of.
|
windowSize | integer |
The size of the centered moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-median(vector) | → | vector |
vector | vector |
The vector to calculate the running median of.
|
vec:variance(vector) | → | number |
vector | vector |
The vector to calculate the variance of.
|
vector | vector |
The vector to calculate the moving variance of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-variance b | → | array |
vec:centered-moving-variance(vector, windowSize) | → | array |
vec:centered-moving-variance(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-variance(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving variance of.
|
windowSize | integer |
The size of the centered moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-variance(vector) | → | vector |
vector | vector |
The vector to calculate the running variance of.
|
vec:sample-variance(vector) | → | number |
vector | vector |
Non emtpy vector to calculate the sample variance of.
|
vector | vector |
The vector to calculate the moving sample variance of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-sample-variance b | → | array |
vec:centered-moving-sample-variance(vector, windowSize) | → | array |
vec:centered-moving-sample-variance(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-sample-variance(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving sample variance of.
|
windowSize | integer |
The size of the centered moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-sample-variance(vector) | → | array |
vector | vector |
The vector to calculate the running sample variance of. First element in result is null since sample variance is not defined for a single element.
|
vec:stdev(vector) | → | number |
vector | vector |
Non emtpy vector to calculate the standard deviation of.
|
vector | vector |
The vector to calculate the moving standard deviation of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-stdev b | → | array |
vec:centered-moving-stdev(vector, windowSize) | → | array |
vec:centered-moving-stdev(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-stdev(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving standard deviation of.
|
windowSize | integer |
The size of the centered moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-stdev(vector) | → | vector |
vector | vector |
The vector to calculate the running standard deviation of.
|
vec:sample-stdev(vector) | → | number |
vector | vector |
Non emtpy vector to calculate the sample standard deviation of.
|
vector | vector |
The vector to calculate the moving sample standard deviation of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-sample-stdev b | → | array |
vec:centered-moving-sample-stdev(vector, windowSize) | → | array |
vec:centered-moving-sample-stdev(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-sample-stdev(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving sample standard deviation of.
|
windowSize | integer |
The size of the centered moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-sample-stdev(vector) | → | array |
vector | vector |
The vector to calculate the running sample standard deviation of. First element in result is null since sample standard deviation is not defined for a single element.
|
vec:iqr(vector) | → | number |
vector | vector |
The vector to calculate the interquartile range of. Minimum length is 4.
|
vector | vector |
The vector to calculate the moving interquartile range of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-iqr b | → | array |
vec:centered-moving-iqr(vector, windowSize) | → | array |
vec:centered-moving-iqr(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-iqr(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving interquartile range of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-iqr(vector) | → | vector |
vector | vector |
The vector to calculate the running interquartile range of.
|
vec:sum(vector) | → | number |
vector | vector |
The vector to sum.
|
vector | vector |
The vector to calculate the moving sum of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-sum b | → | array |
vec:centered-moving-sum(vector, windowSize) | → | array |
vec:centered-moving-sum(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-sum(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving sum of.
|
windowSize | integer |
The size of the centered moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-sum(vector) | → | vector |
vector | vector |
The vector to calculate the running sum of.
|
vec:prod(vector) | → | number |
vector | vector |
The vector to calculate the product of.
|
vector | vector |
The vector to calculate the moving product of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-prod b | → | array |
vec:centered-moving-prod(vector, windowSize) | → | array |
vec:centered-moving-prod(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-prod(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving product of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-prod(vector) | → | vector |
vector | vector |
The vector to calculate the running product of.
|
vec:min(vector) | → | number |
vector | vector |
Non emtpy vector to calculate the minimum of.
|
vector | vector |
The vector to calculate the moving minimum of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-min b | → | array |
vec:centered-moving-min(vector, windowSize) | → | array |
vec:centered-moving-min(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-min(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving minimum of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-min(vector) | → | vector |
vector | vector |
The vector to calculate the running minimum of.
|
vec:max(vector) | → | number |
vector | vector |
Non emtpy vector to calculate the maximum of.
|
vector | vector |
The vector to calculate the moving maximum of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-max b | → | array |
vec:centered-moving-max(vector, windowSize) | → | array |
vec:centered-moving-max(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-max(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving maximum of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-max(vector) | → | vector |
vector | vector |
The vector to calculate the running maximum of.
|
vec:span(vector) | → | number |
vector | vector |
The vector to calculate the span of.
|
vector | vector |
The vector to calculate the moving span of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-span b | → | array |
vec:centered-moving-span(vector, windowSize) | → | array |
vec:centered-moving-span(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-span(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving span of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
The value to pad the result with on the left.
|
rightPadding | number |
The value to pad the result with on the right.
|
a | vector | |
b | integer |
vec:running-span(vector) | → | vector |
vector | vector |
The vector to calculate the running span of.
|
vec:skewness(vector) | → | number |
vector | vector |
The vector to calculate the skewness of. Minimum length is 3.
|
vector | vector |
The vector to calculate the moving skewness of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-skewness b | → | array |
vec:centered-moving-skewness(vector, windowSize) | → | array |
vec:centered-moving-skewness(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-skewness(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving skewness of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-skewness(vector) | → | array |
vector | vector |
The vector to calculate the running skewness of.
|
vec:sample-skewness(vector) | → | number |
vector | vector |
The vector to calculate the sample skewness of. Minimum length is 3.
|
vector | vector |
The vector to calculate the moving sample skewness of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-sample-skewness b | → | array |
vec:centered-moving-sample-skewness(vector, windowSize) | → | array |
vec:centered-moving-sample-skewness(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-sample-skewness(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving sample skewness of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-sample-skewness(vector) | → | array |
vector | vector |
The vector to calculate the running sample skewness of.
|
vec:excess-kurtosis(vector) | → | number |
vector | vector |
The vector to calculate the excess kurtosis of. Minimum length is 3.
|
vector | vector |
The vector to calculate the moving excess kurtosis of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-excess-kurtosis b | → | array |
vec:centered-moving-excess-kurtosis(vector, windowSize) | → | array |
vec:centered-moving-excess-kurtosis(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-excess-kurtosis(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving excess kurtosis of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-excess-kurtosis(vector) | → | array |
vector | vector |
The vector to calculate the running excess kurtosis of.
|
vec:kurtosis(vector) | → | number |
vector | vector |
The vector to calculate the kurtosis of. Minimum length is 3.
|
vector | vector |
The vector to calculate the moving kurtosis of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-kurtosis b | → | array |
vec:centered-moving-kurtosis(vector, windowSize) | → | array |
vec:centered-moving-kurtosis(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-kurtosis(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving kurtosis of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-kurtosis(vector) | → | array |
vector | vector |
The vector to calculate the running kurtosis of.
|
vec:sample-excess-kurtosis(vector) | → | number |
vector | vector |
The vector to calculate the sample excess kurtosis of. Minimum length is 3.
|
a vec:moving-sample-excess-kurtosis b | → | vector |
vec:moving-sample-excess-kurtosis(vector, windowSize) | → | vector |
vector | vector |
The vector to calculate the moving sample excess kurtosis of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-sample-excess-kurtosis b | → | array |
vec:centered-moving-sample-excess-kurtosis(vector, windowSize) | → | array |
vec:centered-moving-sample-excess-kurtosis(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-sample-excess-kurtosis(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving sample excess kurtosis of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-sample-excess-kurtosis(vector) | → | array |
vector | vector |
The vector to calculate the running sample excess kurtosis of.
|
vec:sample-kurtosis(vector) | → | number |
vector | vector |
The vector to calculate the sample kurtosis of. Minimum length is 3.
|
vector | vector |
The vector to calculate the moving sample kurtosis of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-sample-kurtosis b | → | array |
vec:centered-moving-sample-kurtosis(vector, windowSize) | → | array |
vec:centered-moving-sample-kurtosis(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-sample-kurtosis(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving sample kurtosis of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-sample-kurtosis(vector) | → | array |
vector | vector |
The vector to calculate the running sample kurtosis of.
|
vec:rms(vector) | → | number |
vector | vector |
The vector to calculate the root mean square of. Minimum length is 1.
|
vector | vector |
The vector to calculate the moving root mean square of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-rms b | → | vector |
vec:centered-moving-rms(vector, windowSize) | → | vector |
vec:centered-moving-rms(vector, windowSize, leftPadding) | → | vector |
vec:centered-moving-rms(vector, windowSize, leftPadding, rightPadding) | → | vector |
vector | vector |
The vector to calculate the centered moving root mean square of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-rms(vector) | → | vector |
vector | vector |
The vector to calculate the running root mean square of.
|
vec:mad(vector) | → | number |
vector | vector |
The vector to calculate the mean absolute deviation of.
|
vector | vector |
The vector to calculate the moving mean absolute deviation of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-mad b | → | array |
vec:centered-moving-mad(vector, windowSize) | → | array |
vec:centered-moving-mad(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-mad(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving mean absolute deviation of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-mad(vector) | → | vector |
vector | vector |
The vector to calculate the running mean absolute deviation of.
|
vec:medad(vector) | → | number |
vector | vector |
The vector to calculate the median absolute deviation of.
|
vector | vector |
The vector to calculate the moving median absolute deviation of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-medad b | → | array |
vec:centered-moving-medad(vector, windowSize) | → | array |
vec:centered-moving-medad(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-medad(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving median absolute deviation of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-medad(vector) | → | vector |
vector | vector |
The vector to calculate the running median absolute deviation of.
|
vec:gini-coefficient(vector) | → | number |
vector | vector |
The vector to calculate the gini coefficient of.
|
vector | vector |
The vector to calculate the moving gini coefficient of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-gini-coefficient b | → | array |
vec:centered-moving-gini-coefficient(vector, windowSize) | → | array |
vec:centered-moving-gini-coefficient(vector, windowSize, leftPadding) | → | array |
vec:centered-moving-gini-coefficient(vector, windowSize, leftPadding, rightPadding) | → | array |
vector | vector |
The vector to calculate the centered moving gini coefficient of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-gini-coefficient(vector) | → | array |
vector | vector |
The vector to calculate the running gini coefficient of.
|
vec:entropy(vector) | → | number |
vector | vector |
The vector to calculate the entropy of. Minimum length is 1.
|
vector | vector |
The vector to calculate the moving entropy of.
|
windowSize | integer |
The size of the moving window.
|
a | vector | |
b | integer |
a vec:centered-moving-entropy b | → | vector |
vec:centered-moving-entropy(vector, windowSize) | → | vector |
vec:centered-moving-entropy(vector, windowSize, leftPadding) | → | vector |
vec:centered-moving-entropy(vector, windowSize, leftPadding, rightPadding) | → | vector |
vector | vector |
The vector to calculate the centered moving entropy of.
|
windowSize | integer |
The size of the moving window.
|
leftPadding | number |
Optional value to use for padding. Default is null.
|
rightPadding | number |
Optional value to use for right padding. Default is null.
|
a | vector | |
b | integer |
vec:running-entropy(vector) | → | vector |
vector | vector |
The vector to calculate the running entropy of.
|
vec:monotonic?(vector) | → | boolean |
vector | vector |
The vector to check.
|
vec:strictly-monotonic?(vector) | → | boolean |
vector | vector |
The vector to check.
|
vec:increasing?(vector) | → | boolean |
vector | vector |
The vector to check.
|
vec:decreasing?(vector) | → | boolean |
vector | vector |
The vector to check.
|
vec:strictly-increasing?(vector) | → | boolean |
vector | vector |
The vector to check.
|
vec:strictly-decreasing?(vector) | → | boolean |
vector | vector |
The vector to check.
|
vec:mode(vector) | → | number |
vector | vector |
The vector to calculate the mode of.
|
vec:min-index(vector) | → | integer |
vector | vector |
Non emtpy vector to calculate the minimum index of.
|
vec:max-index(vector) | → | integer |
vector | vector |
Non emtpy vector to calculate the maximum index of.
|
vec:sort-indices(vector) | → | vector |
vector | vector |
Non emtpy vector to calculate the sorted indices of.
|
vec:count-values(vector) | → | Array<number> |
vector | vector |
Vector to count the values of.
|
vec:linspace(start, stop, n) | → | Array<number> |
start | number |
The starting value.
|
stop | number |
The ending value.
|
n | integer |
The number of values to generate.
|
vec:ones(length) | → | Array<number> |
length | integer |
The length of the vector.
|
vec:zeros(length) | → | Array<number> |
length | integer |
The length of the vector.
|
length | integer |
The length of the vector.
|
value | number |
The value to fill the vector with.
|
a | number | |
b | integer |
length | integer |
The length of the vector.
|
func | function |
A function that takes an index and returns a number.
|
a | number | |
b | integer |
vec:cumsum(vector) | → | Array<number> |
vector | vector |
The vector to calculate the cumulative sum of.
|
vec:cumprod(vector) | → | Array<number> |
vector | vector |
The vector to calculate the cumulative product of.
|
vec:quartiles(vector) | → | Array<number> |
vector | vector |
The vector to calculate the quartiles of. Minimum length is 4.
|
vector | vector |
The non empty vector to calculate the percentile of.
|
percentile | number |
The percentile to calculate. Must be between 0 and 1.
|
a | number | |
b | integer |
vector | vector |
The non empty vector to calculate the quantile of.
|
quantile | number |
The quantile to calculate. Must be between 0 and 1.
|
a | number | |
b | integer |
vector | vector |
The numeric array to create a histogram from.
|
bins | integer |
The number of bins to divide the data range into.
|
a | number | |
b | integer |
vector | vector |
The numeric array to calculate the ECDF from.
|
threshold | number |
The threshold value to calculate the ECDF for.
|
a | number | |
b | integer |
vec:outliers?(vector) | → | boolean |
vector | vector |
The vector to check for outliers.
|
vec:outliers(vector) | → | Array<number> |
vector | vector |
The vector to check for outliers.
|
vec:bincount(vector) | → | vector |
vec:bincount(vector, minSize) | → | vector |
vec:bincount(vector, minSize, weights) | → | vector |
vector | vector |
The vector to count occurrences in.
|
minSize | integer |
Optional minimum size of the output array.
|
weights | Array<number> |
Optional weights for each element in the vector.
|
vec:winsorize(vector, lower-quantile) | → | vector |
vec:winsorize(vector, lower-quantile, upper-quantile) | → | vector |
vector | vector |
The vector to winsorize.
|
lower-quantile | number |
The lower quantile threshold (between 0 and 1).
|
upper-quantile | number |
Optional Upper quantile threshold (between 0 and 1). Defaults to (1 - lower-quantile) if lower-quantile <= 0.5 otherwise 1.
|
lin:refract(vector, axis, eta) | → | vector |
vector | vector |
Vector to refract.
|
axis | vector |
Axis of refraction.
|
eta | number |
Refraction index.
|
lin:lerp(a, b, t) | → | vector |
lin:rotate3d(v, axis, radians) | → | vector |
lin:normalize-minmax(v) | → | number |
v | vector |
Vector to normalize.
|
lin:normalize-zscore(v) | → | number |
v | vector |
Vector to normalize.
|
lin:normalize-robust(v) | → | number |
v | vector |
Vector to normalize.
|
lin:normalize-l1(v) | → | number |
v | vector |
Vector to normalize.
|
v | vector |
Vector to normalize.
|
lin:normalize-log(v) | → | number |
v | vector |
Vector to normalize.
|
a lin:euclidean-distance b | → | number |
lin:euclidean-distance(a, b) | → | number |
a lin:distance b | → | number |
lin:distance(a, b) | → | number |
a lin:l2-distance b | → | number |
lin:l2-distance(a, b) | → | number |
v | vector |
Vector to calculate the norm for.
|
a lin:manhattan-distance b | → | number |
lin:manhattan-distance(a, b) | → | number |
a lin:l1-distance b | → | number |
lin:l1-distance(a, b) | → | number |
a lin:cityblock-distance b | → | number |
lin:cityblock-distance(a, b) | → | number |
v | vector |
Vector to calculate the norm for.
|
lin:hamming-norm(v) | → | integer |
v | vector |
Vector to calculate the norm for.
|
lin:chebyshev-norm(v) | → | number |
v | vector |
Vector to calculate the norm for.
|
lin:minkowski-distance(a, b, p) | → | number |
a lin:spearman-corr b | → | number |
lin:spearman-corr(a, b) | → | number |
a lin:spearman-rho b | → | number |
lin:spearman-rho(a, b) | → | number |
a lin:autocorrelation b | → | vector |
lin:autocorrelation(a, b) | → | vector |
a lin:acf b | → | vector |
lin:acf(a, b) | → | vector |
a | vector |
Vector to calculate the autocorrelation for.
|
b | integer |
Lag value for the autocorrelation.
|
lin:rref(m) | → | matrix |
m | matrix |
Matrix to calculate the RREF for.
|
lin:to-polar(vector) | → | vector |
vector | vector |
2D Vector to convert.
|
lin:from-polar(polar) | → | vector |
polar | vector |
Polar coordinates to convert.
|
mat:det(m) | → | number |
m | matrix |
The matrix to calculate the determinant of.
|
mat:inv(m) | → | matrix |
m | matrix |
The matrix to calculate the inverse of.
|
mat:adj(m) | → | matrix |
m | matrix |
The matrix to calculate the adjugate of.
|
mat:cofactor(m) | → | matrix |
m | matrix |
The matrix to calculate the cofactor of.
|
mat:minor(m, row, col) | → | matrix |
m | matrix |
The matrix to calculate the minor of.
|
row | integer |
The row index of the element to calculate the minor for.
|
col | integer |
The column index of the element to calculate the minor for.
|
mat:trace(m) | → | number |
m | matrix |
The matrix to calculate the trace of.
|
mat:symmetric?(m) | → | boolean |
m | matrix |
The matrix to check for symmetry.
|
mat:triangular?(m) | → | boolean |
m | matrix |
The matrix to check for triangularity.
|
mat:upper-triangular?(m) | → | boolean |
m | matrix |
The matrix to check for upper triangularity.
|
mat:lower-triangular?(m) | → | boolean |
m | matrix |
The matrix to check for lower triangularity.
|
mat:diagonal?(m) | → | boolean |
m | matrix |
The matrix to check for diagonal property.
|
mat:square?(m) | → | boolean |
m | matrix |
The matrix to check for square property.
|
mat:orthogonal?(m) | → | boolean |
m | matrix |
The matrix to check for orthogonality.
|
mat:identity?(m) | → | boolean |
m | matrix |
The matrix to check for identity property.
|
mat:invertible?(m) | → | boolean |
m | matrix |
The matrix to check for invertibility.
|
mat:hilbert(n) | → | matrix |
n | integer |
The size of the Hilbert matrix.
|
mat:vandermonde(v) | → | matrix |
v | vector |
The vector to generate the Vandermonde matrix from.
|
mat:band(n, lband, uband) | → | matrix |
n | integer |
The size of the banded matrix.
|
lband | integer |
The lower band index.
|
uband | integer |
The upper band index.
|
mat:banded?(m, lband, uband) | → | boolean |
m | matrix |
The matrix to check for banded property.
|
lband | integer |
The lower band index.
|
uband | integer |
The upper band index.
|
mat:rank(m) | → | number |
m | matrix |
The matrix to calculate the rank of.
|
mat:frobenius-norm(m) | → | number |
m | matrix |
The matrix to calculate the Frobenius norm of.
|
mat:1-norm(m) | → | number |
m | matrix |
The matrix to calculate the 1-norm of.
|
m | matrix |
The matrix to calculate the infinity norm of.
|
mat:max-norm(m) | → | number |
m | matrix |
The matrix to calculate the max norm of.
|
nth:abundant-seq(length) | → | Array<integer> |
length | integer |
The length of the sequence to generate.
|
nth:abundant-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:abundant-nth(n) | → | integer |
n | integer |
The index of the number in the sequence.
|
nth:abundant?(n) | → | boolean |
n | integer |
The number to check.
|
nth:arithmetic-seq(start, step, length) | → | Array<integer> |
start | number |
The starting term of the sequence.
|
step | number |
The common difference of the sequence.
|
length | integer |
The length of the sequence to generate.
|
nth:arithmetic-take-while(start, step, takeWhile) | → | Array<integer> |
start | number |
The starting term of the sequence.
|
step | number |
The common difference of the sequence.
|
takeWhile | function |
A function that takes a number and an index and returns a boolean.
|
nth:arithmetic-nth(start, step, n) | → | integer |
start | number |
The starting term of the sequence.
|
step | number |
The common difference of the sequence.
|
n | integer |
The index of the term to generate.
|
nth:arithmetic?(start, step, n) | → | boolean |
start | number |
The starting term of the sequence.
|
step | number |
The common difference of the sequence.
|
n | integer |
The number to check.
|
length | integer |
The length of the sequence to generate. If not provided, the default is 22 (the maximum length of the pre-calculated bell numbers).
|
nth:bell-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:bell-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:bell?(n) | → | boolean |
n | integer |
The number to check.
|
nth:bernoulli-seq(length) | → | Array<number> |
length | integer |
The length of the sequence to generate.
|
nth:bernoulli-take-while(takeWhile) | → | Array<number> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:bernoulli-nth(n) | → | number |
n | integer |
The index of the term to generate.
|
length | integer |
The length of the sequence to generate. If not provided, the default is 30 (the maximum length of the pre-calculated catalan numbers).
|
nth:catalan-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:catalan-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:catalan?(n) | → | boolean |
n | integer |
The number to check.
|
nth:collatz-seq(start) | → | Array<integer> |
start | integer |
The starting integer for the collatz sequence.
|
nth:composite-seq(length) | → | Array<integer> |
length | integer |
The length of the sequence to generate.
|
nth:composite-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:composite-nth(n) | → | integer |
n | integer |
The index of the composite number to retrieve.
|
nth:composite?(n) | → | boolean |
n | integer |
The number to check.
|
nth:deficient-seq(length) | → | Array<integer> |
length | integer |
The length of the sequence to generate.
|
nth:deficient-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:deficient-nth(n) | → | integer |
n | integer |
The index of the number in the sequence.
|
nth:deficient?(n) | → | boolean |
n | integer |
The number to check.
|
length | integer |
The length of the sequence to generate. If not provided, the default is 19 (the maximum length of the pre-calculated factorial numbers).
|
nth:factorial-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:factorial-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:factorial?(n) | → | boolean |
n | integer |
The number to check.
|
length | integer |
The length of the sequence to generate. If not provided, the default is 79 (the maximum length of the pre-calculated Fibonacci numbers).
|
nth:fibonacci-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:fibonacci-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:fibonacci?(n) | → | boolean |
n | integer |
The number to check.
|
nth:geometric-seq(start, ratio, length) | → | Array<integer> |
start | number |
The starting term of the sequence.
|
ratio | number |
The common ratio of the sequence.
|
length | integer |
The length of the sequence to generate.
|
nth:geometric-take-while(start, ratio, takeWhile) | → | Array<integer> |
start | number |
The starting term of the sequence.
|
ratio | number |
The common ratio of the sequence.
|
takeWhile | function |
A function that takes a number and an index and returns a boolean.
|
nth:geometric-nth(start, ratio, n) | → | integer |
start | number |
The starting term of the sequence.
|
ratio | number |
The common ratio of the sequence.
|
n | integer |
The index of the term to generate.
|
nth:geometric?(start, ratio, n) | → | boolean |
start | number |
The starting term of the sequence.
|
ratio | number |
The common ratio of the sequence.
|
n | number |
The number to check.
|
nth:golomb-seq(length) | → | Array<integer> |
length | integer |
The length of the sequence to generate.
|
nth:golomb-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:golomb-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:golomb?(n) | → | boolean |
n | integer |
The number to check.
|
length | integer |
The length of the sequence to generate. If not provided, the default is 20 (the maximum length of the pre-calculated happy numbers).
|
nth:happy-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:happy-nth(n) | → | integer |
n | integer |
The index of the happy number to return.
|
nth:happy?(n) | → | boolean |
n | integer |
The number to check.
|
nth:juggler-seq(start) | → | Array<integer> |
start | integer |
The starting integer for the Juggler sequence.
|
nth:look-and-say-seq(length) | → | Array<string> |
length | integer |
The length of the sequence to generate.
|
nth:look-and-say-take-while(takeWhile) | → | Array<string> |
takeWhile | function |
A function that takes a string and an index and returns a boolean.
|
nth:look-and-say-nth(n) | → | string |
n | integer |
The index of the term in the sequence.
|
nth:look-and-say?(term) | → | boolean |
term | string |
The term to check.
|
length | integer |
The length of the sequence to generate. If not provided, the default is 77 (the maximum length of the pre-calculated Lucas numbers).
|
nth:lucas-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:lucas-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:lucas?(n) | → | boolean |
n | integer |
The number to check.
|
nth:lucky-seq(length) | → | Array<integer> |
length | integer |
The length of the sequence to generate.
|
nth:lucky-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:lucky-nth(n) | → | integer |
n | integer |
The position in the sequence.
|
nth:lucky?(n) | → | boolean |
n | integer |
The number to check.
|
length | integer |
The length of the sequence to generate. If not provided, the default is 9 (the maximum length of the pre-calculated mersenne numbers).
|
nth:mersenne-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:mersenne-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:mersenne?(n) | → | boolean |
n | integer |
The number to check.
|
nth:padovan-seq(length) | → | Array<integer> |
length | integer |
The length of the sequence to generate.
|
nth:padovan-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:padovan-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:padovan?(n) | → | boolean |
n | integer |
The number to check.
|
length | integer |
The length of the sequence to generate.
|
nth:partition-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:partition-nth(n) | → | integer |
n | integer |
The index of the partition number to generate.
|
nth:partition?(n) | → | boolean |
n | integer |
The number to check.
|
length | integer |
The length of the sequence to generate. If not provided, the default is 42 (the maximum length of the pre-calculated Pell numbers).
|
nth:pell-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:pell-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:pell?(n) | → | boolean |
n | integer |
The number to check.
|
length | integer |
The length of the sequence to generate. If no length is provided, it defaults to 7 (the maximum length of the pre-calculated perfect numbers).
|
nth:perfect-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:perfect-nth(n) | → | integer |
n | integer |
The index of the perfect number to generate.
|
nth:perfect?(n) | → | boolean |
n | integer |
The number to check.
|
nth:perfect-square-seq(length) | → | Array<integer> |
length | integer |
The length of the sequence to generate.
|
nth:perfect-square-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:perfect-square-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:perfect-square?(n) | → | boolean |
n | integer |
The number to check.
|
nth:perfect-cube-seq(length) | → | Array<integer> |
length | integer |
The length of the sequence to generate.
|
nth:perfect-cube-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:perfect-cube-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:perfect-cube?(n) | → | boolean |
n | integer |
The number to check.
|
nth:perfect-power-seq(length) | → | Array<integer> |
length | integer |
The length of the sequence to generate.
|
nth:perfect-power-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:perfect-power-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:perfect-power?(n) | → | boolean |
n | integer |
The number to check.
|
sides | integer |
The number of sides of the polygon.
|
length | integer |
The length of the sequence to generate.
|
a | integer | |
b | integer |
a nth:polygonal-take-while b | → | Array<integer> |
nth:polygonal-take-while(sides, takeWhile) | → | Array<integer> |
sides | integer |
The number of sides of the polygon.
|
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
a | integer | |
b | function |
sides | integer |
The number of sides of the polygon.
|
n | integer |
The index of the term to generate.
|
a | integer | |
b | integer |
sides | integer |
The number of sides of the polygon.
|
n | integer |
The number to check.
|
a | integer | |
b | integer |
nth:prime-seq(length) | → | Array<integer> |
length | integer |
The length of the sequence to generate.
|
nth:prime-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:prime-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:prime?(n) | → | boolean |
n | integer |
The number to check.
|
nth:recaman-seq(length) | → | Array<integer> |
length | integer |
The length of the sequence to generate.
|
nth:recaman-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:recaman-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:recaman?(n) | → | boolean |
n | integer |
The number to check.
|
length | integer |
The length of the sequence to generate. If not provided, the default is 6 (the maximum length of the pre-calculated Sylvester numbers).
|
nth:sylvester-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:sylvester-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:sylvester?(n) | → | boolean |
n | integer |
The number to check.
|
nth:thue-morse-seq(length) | → | Array<integer> |
length | integer |
The length of the sequence to generate.
|
nth:thue-morse-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:thue-morse-nth(n) | → | integer |
n | integer |
The index of the term in the sequence.
|
nth:thue-morse?(n) | → | boolean |
n | integer |
The number to check.
|
nth:tribonacci-seq(length) | → | Array<integer> |
length | integer |
The length of the sequence to generate.
|
nth:tribonacci-take-while(takeWhile) | → | Array<integer> |
takeWhile | function |
A function that takes an integer and an index and returns a boolean.
|
nth:tribonacci-nth(n) | → | integer |
n | integer |
The index of the term to generate.
|
nth:tribonacci?(n) | → | boolean |
n | integer |
The number to check.
|
a nth:count-combinations b | → | integer |
nth:count-combinations(a, b) | → | integer |
a nth:binomial b | → | integer |
nth:binomial(a, b) | → | integer |
set | Array<array> |
The input collection to generate combinations from.
|
n | integer |
The size of each combination.
|
a | array | |
b | integer |
nth:count-derangements(n) | → | integer |
n | integer |
The total number of items.
|
nth:derangements(set) | → | Array<array> |
set | Array<array> |
The input collection to generate derangements from.
|
nth:divisors(n) | → | Array<integer> |
n | integer |
The number to find divisors for.
|
nth:count-divisors(n) | → | integer |
n | integer |
The number to count divisors for.
|
nth:proper-divisors(n) | → | Array<integer> |
n | integer |
The number to find proper divisors for.
|
nth:count-proper-divisors(n) | → | integer |
n | integer |
The number to count proper divisors for.
|
n | integer |
The number to calculate the factorial for.
|
nth:partitions(n) | → | Array<array> |
n | integer |
The number to partition.
|
nth:count-partitions(n) | → | integer |
n | integer |
The number to count partitions for.
|
nth:permutations(set) | → | Array<array> |
set | Array<array> |
The input collection to generate permutations from.
|
nth:power-set(set) | → | Array<array> |
set | Array<any> |
The input collection to generate the power set from.
|
nth:count-power-set(n) | → | integer |
n | integer |
The size of the set.
|
nth:prime-factors(n) | → | Array<integer> |
n | integer |
The number to factor.
|
nth:count-prime-factors(n) | → | integer |
n | integer |
The number to count prime factors for.
|
nth:distinct-prime-factors(n) | → | Array<integer> |
n | integer |
The number to find distinct prime factors for.
|
nth:count-distinct-prime-factors(n) | → | integer |
n | integer |
The number to count distinct prime factors for.
|
nth:multinomial(...args) | → | integer |
args | Array<integer> |
The numbers representing the sizes of each group.
|
nth:euler-totient(n) | → | integer |
n | integer |
The number to calculate the totient for.
|
n | integer |
The number to calculate the Möbius function for.
|
nth:mertens(n) | → | integer |
n | integer |
The number to calculate the Mertens function for.
|
nth:sigma(n) | → | integer |
n | integer |
The number to calculate the sum of divisors for.
|
nth:carmichael-lambda(n) | → | integer |
n | integer |
The number to calculate the Carmichael function for.
|
sets | Array<array> |
The input collections to calculate the Cartesian product from.
|
a | array | |
b | array |
nth:perfect-power(n) | → | Array<array> |
n | integer |
The number to check.
|
nth:mod-exp(base, exponent, modulus) | → | integer |
remainders | Array<integer> |
The remainders of the congruences.
|
moduli | Array<integer> |
The moduli of the congruences.
|
a | array | |
b | array |
grid:shape(g) | → | vector |
g | grid |
The grid to get the shape of.
|
grid:fill(rows, cols, value) | → | grid |
rows | integer |
The number of rows in the grid.
|
cols | integer |
The number of columns in the grid.
|
value | any |
The value to fill the grid with.
|
grid:generate(rows, cols, fn) | → | grid |
rows | number |
The number of rows in the grid.
|
cols | number |
The number of columns in the grid.
|
fn | function |
The function to generate the grid. It takes two arguments: the row index and the column index.
|
g | grid |
The grid to transpose.
|
grid:flip-h(g) | → | grid |
g | grid |
The grid to flip horizontally.
|
grid:flip-v(g) | → | grid |
g | grid |
The grid to flip vertically.
|
grid:reverse-rows(g) | → | grid |
g | grid |
The grid to reverse rows.
|
grid:reverse-cols(g) | → | grid |
g | grid |
The grid to reverse columns.
|
g | grid |
The grid to slice.
|
begin | vector |
The starting index of the slice as a vector of two numbers: [row, col].
|
stop | vector |
Optional ending index of the slice as a vector of two numbers: [row, col].
|
g | grid |
The grid to slice.
|
begin | number |
The starting index of the slice.
|
stop | number |
Optional ending index of the slice.
|
g | grid |
The grid to slice.
|
begin | number |
The starting index of the slice.
|
stop | number |
Optional ending index of the slice.
|
grid:splice-rows(g, begin, deleteCount) | → | grid |
grid:splice-rows(g, begin, deleteCount, ...items) | → | grid |
g | grid |
The grid to splice.
|
begin | number |
The starting index of the splice.
|
deleteCount | number |
The number of rows to delete.
|
items | Array<array> |
The rows to insert.
|
grid:splice-cols(g, begin, deleteCount) | → | grid |
grid:splice-cols(g, begin, deleteCount, ...items) | → | grid |
g | grid |
The grid to splice.
|
begin | number |
The starting index of the splice.
|
deleteCount | number |
The number of columns to delete.
|
items | Array<array> |
The columns to insert.
|
grid:reduce(g, fn, initial-value) | → | any |
g | grid |
The grid to reduce.
|
fn | function |
The function to reduce the grid. It takes two arguments: the accumulator and the current element.
|
initial-value | any |
The initial value for the accumulator.
|
grid:reducei(g, fn, initial-value) | → | any |
g | grid |
The grid to reduce.
|
fn | function |
The function to reduce the grid. It takes four arguments: the accumulator, the current element, the row index, and the column index.
|
initial-value | any |
The initial value for the accumulator.
|
grid:push-rows(g, ...rows) | → | grid |
grid:unshift-rows(g, ...rows) | → | grid |
g | grid |
The grid to unshift rows into.
|
rows | Array<array> |
The rows to unshift into the grid.
|
grid:pop-row(g) | → | grid |
g | grid |
The grid to pop a row from.
|
grid:shift-row(g) | → | grid |
g | grid |
The grid to shift a row from.
|
grid:push-cols(g, ...cols) | → | grid |
g | grid |
The grid to push columns into.
|
cols | Array<array> |
The columns to push into the grid.
|
grid:unshift-cols(g, ...cols) | → | grid |
g | grid |
The grid to unshift columns into.
|
cols | Array<array> |
The columns to unshift into the grid.
|
grid:pop-col(g) | → | grid |
g | grid |
The grid to pop a column from.
|
grid:shift-col(g) | → | grid |
g | grid |
The grid to shift a column from.
|
!:random() | → | number |
!:random-boolean(prob) | → | boolean |
prob | number |
The probability of returning true (between 0 and 1).
|
!:random-item(a) | → | any |
a | array |
The array to sample from.
|
!:shuffle(a) | → | array |
a | array |
The array to shuffle.
|
!:random-normal(mean, stdDev) | → | number |
mean | number |
The mean of the normal distribution.
|
stdDev | number |
The standard deviation of the normal distribution.
|
!:random-exponential(lambda) | → | number |
lambda | number |
The rate parameter of the exponential distribution.
|
!:random-binomial(n, p) | → | integer |
!:random-poisson(lambda) | → | integer |
lambda | number |
The rate parameter of the Poisson distribution.
|
!:random-gamma(shape, scale) | → | number |
shape | number |
The shape parameter of the gamma distribution.
|
scale | number |
The scale parameter of the gamma distribution.
|
!:random-pareto(alpha) | → | number |
alpha | number |
The shape parameter of the Pareto distribution.
|
!:uuid() | → | string |
!:random-char(charSet) | → | string |
charSet | string |
The string to sample from.
|
!:random-string(length, charSet) | → | string |
!:random-id(length) | → | string |
length | integer |
The length of the random ID.
|
!:random-color() | → | string |
doseq (...binding) -> body |
binding | loop-var in collection [...let-binding] [where whereExpr] [while whileExp] |
A doseq loop binding
|
loop-var | symbol |
The name of the loop variable.
|
collection | any |
The collection to iterate over.
|
let-binding | let binding |
A let binding to create a local variable.
|
whereExpr | expression |
An expression that must evaluate to truthy for the loop body to be executed.
|
whileExp | expression |
An expression that must evaluate to truthy for the loop to continue.
|
body | expressions |
The expressions to evaluate for each iteration of the loop.
|
for (...binding) -> body |
binding | loop-var in collection [...let-binding] [where whereExpr] [while whileExp] |
A for loop binding
|
loop-var | symbol |
The name of the loop variable.
|
collection | any |
The collection to iterate over.
|
let-binding | let binding |
A let binding to create a local variable.
|
whereExpr | expression |
An expression that must evaluate to truthy for the loop body to be executed.
|
whileExp | expression |
An expression that must evaluate to truthy for the loop to continue.
|
body | expressions |
The expressions to evaluate for each iteration of the loop.
|
values | Array<any> |
kvps | Array<any> |
key - value pairs, where key is a string
|
If all expressions evaluate to truthy values, the value of the last expression is returned.
If all expressions evaluate to falsy values, the value of the last expression is returned.
let s = value; |
s | symbol |
The name of the variable to bind.
|
value | any |
The value to bind to the variable.
|
try { try-body } catch { catch-body } |
try { try-body } catch(error) { catch-body } |
try-body | expressions |
The expressions to try.
|
error | symbol |
The error variable to bind.
|
catch-body | expression |
The expressions to evaluate if the try-body throws an error.
|
throw(expr) | → | never |
expr | any |
if test then true-expr else false-expr |
if test then true-expr |
test | expression |
The condition to test.
|
true-expr | expression |
The expression to evaluate if the test is truthy.
|
false-expr | expression |
The expression to evaluate if the test is falsy.
|
unless test then true-expr else false-expr end |
unless test true-expr end |
test | expression |
The condition to test.
|
true-expr | expression |
The expressions to evaluate if the test is falsy.
|
false-expr | expression |
The expressions to evaluate if the test is truthy.
|
cond cond-branch cond-branch ... end |
cond-branch | case test then body |
A branch of the cond expression.
|
test | expression |
The condition to test.
|
body | expressions |
The expressions to evaluate if the test is truthy.
|
switch value switch-branch switch-branch ... end |
value | any |
The value to test.
|
switch-branch | case test then body |
A branch of the switch expression.
|
test | expression |
The condition to test.
|
body | expressions |
The expressions to evaluate if the test is truthy.
|
{ body } |
body | expressions |
The expressions to evaluate.
|
recur(...recur-args) |
You can reference the first argument using either $1 or $. However, please note that $1 and $ are mutually exclusive and cannot be used simultaneously. E.g. #(* $ $1) is not valid.