mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 09:37:34 +00:00
Spreadsheet: Add a 'choose' function
This commit is contained in:
parent
f159d161fa
commit
9c1143fe13
1 changed files with 19 additions and 0 deletions
|
@ -128,6 +128,12 @@ function select(criteria, t, f) {
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function choose(index, ...args) {
|
||||||
|
if (index > args.length) return undefined;
|
||||||
|
if (index < 0) return undefined;
|
||||||
|
return args[index];
|
||||||
|
}
|
||||||
|
|
||||||
function now() {
|
function now() {
|
||||||
return new Date();
|
return new Date();
|
||||||
}
|
}
|
||||||
|
@ -299,6 +305,19 @@ select.__documentation = JSON.stringify({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
choose.__documentation = JSON.stringify({
|
||||||
|
name: "choose",
|
||||||
|
argc: 1,
|
||||||
|
argnames: ["index"],
|
||||||
|
doc: "Selects an argument by the given `index`, starting at zero",
|
||||||
|
examples: {
|
||||||
|
"choose(A3, 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')":
|
||||||
|
"Get the day name by the number in A3",
|
||||||
|
"choose(randRange(0, 2), 'Well', 'Hello', 'Friends')":
|
||||||
|
"Randomly pick one of the three words 'well', 'hello' and 'friends'",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
now.__documentation = JSON.stringify({
|
now.__documentation = JSON.stringify({
|
||||||
name: "now",
|
name: "now",
|
||||||
argc: 0,
|
argc: 0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue