@mojir/lits 2.6.1 → 2.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.js +8 -29
- package/dist/cli/src/evaluator/ContextStack.d.ts +1 -1
- package/dist/cli/src/parser/types.d.ts +0 -2
- package/dist/full.esm.js +1 -1
- package/dist/full.esm.js.map +1 -1
- package/dist/full.js +1 -1
- package/dist/full.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +1 -1
- package/dist/lits.iife.js.map +1 -1
- package/dist/modules/src/evaluator/ContextStack.d.ts +1 -1
- package/dist/modules/src/parser/types.d.ts +0 -2
- package/dist/src/evaluator/ContextStack.d.ts +1 -1
- package/dist/src/parser/types.d.ts +0 -2
- package/dist/testFramework.esm.js +1 -1
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +1 -1
- package/dist/testFramework.js.map +1 -1
- package/package.json +2 -1
package/dist/full.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e){if(!e.position||!e.code)return"";const t=e.position.column-1,r=e.code.length-t-1;return`${" ".repeat(Math.max(t,0))}^${" ".repeat(Math.max(r,0))}`}class t extends Error{params;constructor(e){super(`recur, params: ${e}`),Object.setPrototypeOf(this,t.prototype),this.name="RecurSignal",this.params=e}}class r extends Error{sourceCodeInfo;shortMessage;constructor(t,n){const o=t instanceof Error?t.message:`${t}`;super(function(t,r){if(!r)return t;const n=`${r.position.line}:${r.position.column}`;return`${t}${r.filePath?`\n${r.filePath}:${n}`:`\nLocation ${n}`}\n${r.code}\n${e(r)}`}(o,n)),this.shortMessage=o,this.sourceCodeInfo=n,Object.setPrototypeOf(this,r.prototype),this.name="LitsError"}getCodeMarker(){return this.sourceCodeInfo&&e(this.sourceCodeInfo)}}class n extends r{userMessage;constructor(e,t){super(e,t),this.userMessage=e,Object.setPrototypeOf(this,n.prototype),this.name="UserDefinedError"}}class o extends r{constructor(e,t){super(e,t),Object.setPrototypeOf(this,o.prototype),this.name="AssertionError"}}class a extends r{symbol;constructor(e,t){super(`Undefined symbol '${e}'.`,t),this.symbol=e,Object.setPrototypeOf(this,a.prototype),this.name="UndefinedSymbolError"}}function i(e){return e instanceof r}const s={Number:1,String:2,NormalExpression:3,SpecialExpression:4,UserDefinedSymbol:5,NormalBuiltinSymbol:6,SpecialBuiltinSymbol:7,ReservedSymbol:8,Binding:9,Spread:10},c=new Set(Object.values(s));function l(e){return Object.keys(s).find(t=>s[t]===e)}const m=new Set(["UserDefined","Partial","Comp","Constantly","Juxt","Complement","EveryPred","SomePred","Fnull","Builtin","SpecialBuiltin","NativeJsFunction","Module"]);const u="^^fn^^",p="^^re^^";function g(e){return null!==e&&"object"==typeof e&&(u in e&&"functionType"in e&&function(e){return"string"==typeof e&&m.has(e)}(e.functionType))}function h(e){return!(!Array.isArray(e)||e.length<2)&&function(e){return"number"==typeof e&&c.has(e)}(e[0])}function d(e){return g(e)?`<function ${e.name||"λ"}>`:h(e)?`${l(e[0])}-node`:null===e?"null":"object"==typeof e&&e instanceof RegExp?`${e}`:"object"==typeof e&&e instanceof Error?e.toString():JSON.stringify(e)}function y(e,t){return e?.sourceCodeInfo??t}function v(e,t,n){return new r(`Expected ${e}, got ${d(t)}.`,y(t,n))}function f(e,t){return b(e,t),e}function b(e,t){if(!function(e){return void 0!==e}(e))throw new r("Unexpected undefined",y(e,t))}function x(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function w(e){return null!==e&&"object"==typeof e&&!!e[u]}function k(e,t){return q(e,t),e}function q(e,t){if(!w(e))throw v("LitsFunction",e,t)}function A(e){return w(e)&&"UserDefined"===e.functionType}function N(e,t){return $(e,t),e}function $(e,t){if(!A(e))throw v("NativeJsFunction",e,t)}function T(e){return w(e)&&"NativeJsFunction"===e.functionType}function z(e,t){return S(e,t),e}function S(e,t){if(!T(e))throw v("NativeJsFunction",e,t)}function E(e){return x(e)&&"Builtin"===e.functionType}function j(e){return void 0!==e}function M(e,t){return C(e,t),e}function C(e,t){if(!j(e))throw v("not undefined",e,t)}function P(e){return Array.isArray(e)||"string"==typeof e}function R(e,t){return I(e,t),e}function I(e,t){if(!P(e))throw v("string or array",e,t)}function O(e){return!(null===e||"object"!=typeof e||Array.isArray(e)||e instanceof RegExp||w(e)||G(e))}function F(e,t){if(!O(e))throw v("object",e,t)}function U(e){return P(e)||O(e)}function D(e,t){return W(e,t),e}function W(e,t){if(!U(e))throw v("string, array or object",e,t)}function G(e){return null!==e&&"object"==typeof e&&!!e[p]}function V(e,t){if(!function(e){return G(e)||"string"==typeof e}(e))throw v("string or RegularExpression",e,t)}function B(e,t){return L(e,t),e}function L(e,t){if(!function(e){return"number"==typeof e||!!U(e)||!!w(e)}(e))throw v("FunctionLike",e,t)}function _(e,t={}){return"string"==typeof e&&((!t.nonEmpty||0!==e.length)&&(!t.char||1===e.length))}function K(e,t,r={}){if(!_(e,r))throw v(""+(r.nonEmpty?"non empty string":r.char?"character":"string"),e,t)}function J(e,t,r={}){return K(e,t,r),e}function Y(e){return"string"==typeof e||"number"==typeof e}function H(e,t){return X(e,t),e}function X(e,t){if(!Y(e))throw v("string or number",e,t)}const Z={assert:{evaluate:(e,t)=>{const r=e[0],n=2===e.length?e[1]:`${r}`;if(K(n,t),!r)throw new o(n,t);return M(r,t)},arity:{min:1,max:2},docs:{category:"assertion",description:"If $value is falsy it throws `AssertionError` with $message. If no $message is provided, message is set to $value.",returns:{type:"any"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['try assert(0, "Expected a positive value") catch (e) e.message end'],seeAlso:["assertion.assert-truthy","assertion.assert-true"],hideOperatorForm:!0}}};function Q(e,t={}){return"number"==typeof e&&(!Number.isNaN(e)&&(!(t.integer&&!Number.isInteger(e))&&(!(t.finite&&!Number.isFinite(e))&&((!t.zero||0===e)&&((!t.nonZero||0!==e)&&(!(t.positive&&e<=0)&&(!(t.negative&&e>=0)&&(!(t.nonPositive&&e>0)&&(!(t.nonNegative&&e<0)&&(!("number"==typeof t.gt&&e<=t.gt)&&(!("number"==typeof t.gte&&e<t.gte)&&(!("number"==typeof t.lt&&e>=t.lt)&&!("number"==typeof t.lte&&e>t.lte)))))))))))))}function ee(e,t,n={}){if(!Q(e,n))throw new r(`Expected ${function(e){if(e.zero)return"zero";const t=function(e){return e.positive?"positive":e.negative?"negative":e.nonNegative?"non negative":e.nonPositive?"non positive":e.nonZero?"non zero":""}(e),r=e.integer?"integer":"number",n=e.finite?"finite":"",o=function(e){return"number"!=typeof e.gt&&"number"!=typeof e.gte||"number"!=typeof e.lt&&"number"!=typeof e.lte?"number"==typeof e.gt||"number"==typeof e.gte?"number"==typeof e.gt?`n > ${e.gt}`:`n >= ${e.gte}`:"number"==typeof e.lt||"number"==typeof e.lte?"number"==typeof e.lt?`n < ${e.lt}`:`n <= ${e.lte}`:"":`${"number"==typeof e.gt?`${e.gt} < n `:`${e.gte} <= n `}${"number"==typeof e.lt?`< ${e.lt}`:`<= ${e.lte}`}`}(e);return[t,n,r,o].filter(e=>!!e).join(" ")}(n)}, got ${d(e)}.`,y(e,t))}function te(e,t,r={}){return ee(e,t,r),e}function re(e){return"number"==typeof e||U(e)?ae(1):e.arity}function ne(e,t,n){const{min:o,max:a}=e;if("number"==typeof o&&t<o)throw new r(`Wrong number of arguments, expected at least ${o}, got ${d(t)}.`,n);if("number"==typeof a&&t>a)throw new r(`Wrong number of arguments, expected at most ${a}, got ${d(t)}.`,n)}function oe(e){return!("number"==typeof e.max&&e.max<2)&&!("number"==typeof e.min&&e.min>2)}function ae(e){return{min:e,max:e}}function ie(e,t){return{a:{type:e},b:{type:t}}}const se={"<<":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0}),e<<t),arity:ae(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ie("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Shifts $a arithmetically left by $b bit positions.",seeAlso:[">>",">>>"],examples:["1 << 10","<<(1, 10)","<<(-4, 2)"]}},">>":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0}),e>>t),arity:ae(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ie("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Shifts $a arithmetically right by $b bit positions.",seeAlso:["<<",">>>"],examples:["2048 >> 10",">>(2048, 10)",">>>(-16, 2)",">>(4, 10)"]}},">>>":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0}),e>>>t),arity:ae(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ie("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Shifts $a arithmetically right by $b bit positions without sign extension.",seeAlso:["<<",">>"],examples:["-16 >>> 2",">>>(2048, 10)",">>>(-16, 2)",">>>(4, 10)",">>>(-1, 10)"]}},"&":{evaluate:([e,...t],r)=>(ee(e,r,{integer:!0}),t.reduce((e,t)=>(ee(t,r,{integer:!0}),e&t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...ie("integer","integer"),c:{type:"integer",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Returns bitwise `and` of all arguments.",seeAlso:["|","xor","bitwise.bit-not","bitwise.bit-and-not"],examples:["0b0011 & 0b0110","&(0b0011, 0b0110)","&(0b0011, 0b0110, 0b1001)"]}},"|":{evaluate:([e,...t],r)=>(ee(e,r,{integer:!0}),t.reduce((e,t)=>(ee(t,r,{integer:!0}),e|t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...ie("integer","integer"),c:{type:"integer",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Returns bitwise `or` of all arguments.",seeAlso:["&","xor","bitwise.bit-not","bitwise.bit-and-not"],examples:["0b0011 | 0b0110","|(0b0011, 0b0110)","|(0b1000, 0b0100, 0b0010)"]}},xor:{evaluate:([e,...t],r)=>(ee(e,r,{integer:!0}),t.reduce((e,t)=>(ee(t,r,{integer:!0}),e^t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...ie("integer","integer"),c:{type:"integer",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Returns bitwise `xor` of all arguments.",seeAlso:["&","|","bitwise.bit-not","bitwise.bit-and-not"],examples:["0b0011 xor 0b0110","xor(0b0011, 0b0110)","xor(0b11110000, 0b00111100, 0b10101010)"]}}};function ce(e,t){return!!U(e)&&("string"==typeof e||Array.isArray(e)?!!Q(t,{integer:!0})&&(t>=0&&t<e.length):!!Object.getOwnPropertyDescriptor(e,t))}function le(e,t,n){if(X(e,n),X(t,n),"string"==typeof e&&"string"==typeof t)return e<t?-1:e>t?1:0;if("number"==typeof e&&"number"==typeof t)return Math.sign(e-t);throw new r(`Cannot compare values of different types: ${typeof e} and ${typeof t}`,n)}function me(e,t,r){if(e===t)return!0;if("number"==typeof e&&"number"==typeof t)return fe(e,t);if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!me(M(e[n],r),M(t[n],r),r))return!1;return!0}if(G(e)&&G(t))return e.s===t.s&&e.f===t.f;if(x(e)&&x(t)){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const a=J(n[o],r);if(!me(e[a],t[a],r))return!1}return!0}return!1}function ue(e){return Math.max(0,Math.ceil(e))}function pe(e){return e??null}function ge(e){return O(e)?Object.entries(e).reduce((e,t)=>{const[r,n]=t;return e[r]=ge(n),e},{}):Array.isArray(e)?e.map(e=>ge(e)):e}function he(e){return ge(e)}function de(...e){const t=new Set;for(const r of e)r.forEach(e=>t.add(e));return t}function ye(e,t){t.forEach(t=>e.add(t))}const ve=1e-10;function fe(e,t,r=ve){if(e===t)return!0;const n=Math.abs(e-t);if(0===e||0===t||n<r)return n<r;return n/(Math.abs(e)+Math.abs(t))<r}function be(e){return Math.abs(e)<ve}function xe(e,t=0){const r=e.split("\n");for(;r[0]?.match(/^\s*$/);)r.shift();for(;r[r.length-1]?.match(/^\s*$/);)r.pop();const n=r.reduce((e,t)=>{if(t.match(/^\s*$/))return e;const r=t.match(/^\s*/)[0].length;return Math.min(e,r)},1/0);return r.map(e=>" ".repeat(t)+e.slice(n)).join("\n").trimEnd()}function we(e,t){if(!Array.isArray(e))throw v("array",e,t)}function ke(e,t){if(!function(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e)}(e))throw v("array of strings",e,t)}function qe(e,t){if(!function(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e&&1===e.length)}(e))throw v("array of strings",e,t)}function Ae(e,t){return e instanceof Promise?e.then(t):t(e)}function Ne(e,t){const r=[];for(let n=0;n<e.length;n++){const o=t(e[n],n);if(o instanceof Promise)return $e(o,r,e,t,n);r.push(o)}return r}async function $e(e,t,r,n,o){t.push(await e);for(let e=o+1;e<r.length;e++)t.push(await n(r[e],e));return t}function Te(e,t,r){let n=r;for(let r=0;r<e.length;r++){const o=t(n,e[r],r);if(o instanceof Promise)return ze(o,e,t,r);n=o}return n}async function ze(e,t,r,n){let o=await e;for(let e=n+1;e<t.length;e++)o=await r(o,t[e],e);return o}function Se(e,t){for(let r=0;r<e.length;r++){const n=t(e[r],r);if(n instanceof Promise)return Ee(n,e,t,r)}}async function Ee(e,t,r,n){await e;for(let e=n+1;e<t.length;e++)await r(t[e],e)}function je(e,t){try{const r=e();return r instanceof Promise?r.catch(t):r}catch(e){return t(e)}}function Me(e,t){for(let r=0;r<e.length;r++){const n=t(e[r],r);if(n instanceof Promise)return Ce(n,e,t,r);if(n)return!0}return!1}async function Ce(e,t,r,n){if(await e)return!0;for(let e=n+1;e<t.length;e++)if(await r(t[e],e))return!0;return!1}function Pe(e,t){for(let r=0;r<e.length;r++){const n=t(e[r],r);if(n instanceof Promise)return Re(n,e,t,r);if(!n)return!1}return!0}async function Re(e,t,r,n){if(!await e)return!1;for(let e=n+1;e<t.length;e++)if(!await r(t[e],e))return!1;return!0}function Ie(e,t){const r=[];for(let n=0;n<e.length;n++){const o=t(e[n],n);if(o instanceof Promise)return Oe(o,r,e,t,n);o&&r.push(e[n])}return r}async function Oe(e,t,r,n,o){await e&&t.push(r[o]);for(let e=o+1;e<r.length;e++)await n(r[e],e)&&t.push(r[e]);return t}function Fe(e,t){for(let r=0;r<e.length;r++){const n=t(e[r],r);if(n instanceof Promise)return Ue(n,e,t,r);if(n)return r}return-1}async function Ue(e,t,r,n){if(await e)return n;for(let e=n+1;e<t.length;e++)if(await r(t[e],e))return e;return-1}const De={filter:{evaluate:([e,t],r,n,{executeFunction:o})=>{if(W(e,r),L(t,r),Array.isArray(e))return Te(e,(e,a)=>Ae(o(t,[a],n,r),t=>(t&&e.push(a),e)),[]);if(_(e)){return Ae(Te(e.split(""),(e,a)=>Ae(o(t,[a],n,r),t=>(t&&e.push(a),e)),[]),e=>e.join(""))}return Te(Object.entries(e),(e,[a,i])=>Ae(o(t,[i],n,r),t=>(t&&(e[a]=i),e)),{})},arity:ae(2),docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function"},coll:{type:"collection"},fun:{type:"function"}},variants:[{argumentNames:["coll","fun"]}],description:"Creates a new collection with all elements that pass the test implemented by $fun.",seeAlso:["collection.filteri","map","sequence.remove"],examples:['\nfilter(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nfilter(\n [5, 10, 15, 20],\n -> $ > 10\n)","\nfilter(\n { a: 1, b: 2 },\n odd?\n)"]}},map:{evaluate:(e,t,n,{executeFunction:o})=>{const a=B(e.at(-1),t);if(O(e[0]))return function({colls:e,contextStack:t,executeFunction:n,fn:o,sourceCodeInfo:a}){F(e[0],a);const i=Object.keys(e[0]),s={};return e.forEach(e=>{F(e,a);const t=Object.keys(e);if(t.length!==i.length)throw new r(`All objects must have the same keys. Expected: ${i.join(", ")}. Found: ${t.join(", ")}`,a);if(!t.every(e=>i.includes(e)))throw new r(`All objects must have the same keys. Expected: ${i.join(", ")}. Found: ${t.join(", ")}`,a);Object.entries(e).forEach(([e,t])=>{s[e]||(s[e]=[]),s[e].push(t)})}),Te(i,(e,r)=>Ae(n(o,s[r],t,a),t=>(e[r]=t,e)),{})}({colls:e.slice(0,-1),fn:a,sourceCodeInfo:t,contextStack:n,executeFunction:o});const i=e.slice(0,-1);I(i[0],t);const s="string"==typeof i[0];let c=i[0].length;i.slice(1).forEach(e=>{s?K(e,t):we(e,t),c=Math.min(c,e.length)});const l=[];for(let e=0;e<c;e++)l.push(i.map(t=>t[e]));const m=Ne(l,e=>o(a,e,n,t));return s?Ae(m,e=>(e.forEach(e=>K(e,t)),e.join(""))):m},arity:{min:2},docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function"},colls:{type:"collection",rest:!0,description:"At least one."},fun:{type:"function"}},variants:[{argumentNames:["colls","fun"]}],description:"Creates a new collection populated with the results of calling $fun on every element in $colls.",seeAlso:["collection.mapi","filter","reduce","mapcat","grid.cell-map","grid.cell-mapi"],examples:["[1, 2, 3] map -","[1, 2, 3] map -> -($)",'map(["Albert", "Mojir", 42], str)',"map([1, 2, 3], inc)","map([1, 2, 3], [1, 10, 100], *)","map({ a: 1, b: 2 }, inc)","map({ a: 1, b: 2 }, { a: 10, b: 20 }, +)"]}},reduce:{evaluate:([e,t,r],n,o,{executeFunction:a})=>(W(e,n),L(t,n),C(r,n),"string"==typeof e?(K(r,n),0===e.length?r:Te(e.split(""),(e,r)=>a(t,[e,r],o,n),r)):Array.isArray(e)?0===e.length?r:Te(e,(e,r)=>a(t,[e,r],o,n),r):0===Object.keys(e).length?r:Te(Object.entries(e),(e,[,r])=>a(t,[e,r],o,n),r)),arity:ae(3),docs:{category:"collection",returns:{type:"any"},args:{fun:{type:"function"},coll:{type:"collection"},initial:{type:"any"}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Runs $fun function on each element of the $coll, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value.",seeAlso:["collection.reduce-right","collection.reducei","collection.reductions","map","grid.cell-reduce","grid.cell-reducei"],examples:["reduce([1, 2, 3], +, 0)","reduce([], +, 0)","reduce({ a: 1, b: 2 }, +, 0)","\nreduce(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + (even?(value) ? value : 0),\n 0)"]}},get:{evaluate:(e,t)=>{const[r,n]=e,o=pe(e[2]);if(X(n,t),null===r)return o;W(r,t);const a=function(e,t){if(O(e)){if("string"==typeof t&&ce(e,t))return pe(e[t])}else if(Q(t,{nonNegative:!0,integer:!0})&&t>=0&&t<e.length)return pe(e[t])}(r,n);return void 0===a?o:a},arity:{min:2,max:3},docs:{category:"collection",returns:{type:"any"},args:{a:{type:"collection"},b:{type:["string","integer"]},"not-found":{type:"any",description:"Default value to return if $b is not found."}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","not-found"]}],description:"Returns value in $a mapped at $b.",seeAlso:["collection.get-in","contains?","find","nth"],examples:["[1, 2, 3] get 1",'{ a: 1 } get "a"','"Albert" get "3"',"\nget(\n [1, 2, 3],\n 1, // Optional comma after last argument\n)","\nget(\n [],\n 1\n)",'\nget(\n [],\n 1,\n "default"\n)','\nget(\n { a: 1 },\n "a"\n)','\nget(\n { a: 1 },\n "b"\n)','\nget(\n { a: 1 },\n "b",\n "default"\n)','\nget(\n null,\n "a"\n)','\nget(\n null,\n "b",\n "default"\n)']}},count:{evaluate:([e],t)=>null===e?0:"string"==typeof e?e.length:(W(e,t),Array.isArray(e)?e.length:Object.keys(e).length),arity:ae(1),docs:{category:"collection",returns:{type:"number"},args:{coll:{type:["collection","null"]}},variants:[{argumentNames:["coll"]}],description:"Returns number of elements in $coll.",seeAlso:["empty?"],examples:["count([1, 2, 3])","count([])","count({ a: 1 })",'count("")','count("Albert")',"count(null)"]}},"contains?":{evaluate:([e,t],r)=>null!==e&&(W(e,r),_(e)?(K(t,r),e.includes(t)):P(e)?(C(t,r),!!e.find(e=>me(M(e),t,r))):(K(t,r),t in e)),arity:ae(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:["collection","null"]},b:{type:["string","integer"]}},variants:[{argumentNames:["a","b"]}],description:"Returns `true` if $a contains $b, otherwise returns `false`. For strings, it checks if substring is included.",seeAlso:["get","find","index-of"],examples:["[1, 2, 3] contains? 1","null contains? 1",'{ a: 1, b: 2 } contains? "a"',"\ncontains?(\n [],\n 1\n)","\ncontains?(\n [1],\n 1\n)","\ncontains?(\n [1, 2, 3],\n 1\n)",'\ncontains?(\n {},\n "a"\n)','\ncontains?(\n { a: 1, b: 2 },\n "a"\n)']}},assoc:{evaluate:([e,t,r],n)=>(W(e,n),X(t,n),C(r,n),function(e,t,r,n){if(W(e,n),X(t,n),Array.isArray(e)||"string"==typeof e){if(ee(t,n,{integer:!0}),ee(t,n,{gte:0}),ee(t,n,{lte:e.length}),"string"==typeof e)return K(r,n,{char:!0}),`${e.slice(0,t)}${r}${e.slice(t+1)}`;const o=[...e];return o[t]=r,o}K(t,n);const o={...e};return o[t]=r,o}(e,t,r,n)),arity:ae(3),docs:{category:"collection",returns:{type:"collection"},args:{coll:{type:"collection"},key:{type:["string","number"]},value:{type:"any"},kvs:{type:"any",description:"Key-value pairs to associate.",rest:!0}},variants:[{argumentNames:["coll","key","value"]},{argumentNames:["coll","key","value","kvs"]}],description:"\nAdd or replace the value of element $key to $value in $coll. Repeated for all key-value pairs in $kvs.\nIf $coll is an 'array', $key must be `number` satisfying `0 <=` $key `<= length`.",seeAlso:["collection.assoc-in","dissoc","merge","collection.update"],examples:['\nassoc(\n [1, 2, 3],\n 1,\n "Two"\n)','\nassoc(\n [1, 2, 3],\n 3,\n "Four"\n)','\nassoc(\n { a: 1, b: 2 },\n "a",\n "One")','\nassoc(\n { a: 1, b: 2 },\n "c",\n "Three")','\nassoc(\n "Albert",\n 6,\n "a")']}},"++":{evaluate:(e,t)=>(Q(e[0])||W(e[0],t),Array.isArray(e[0])?e.reduce((e,r)=>(we(r,t),e.concat(r)),[]):Y(e[0])?e.reduce((e,r)=>(X(r,t),`${e}${r}`),""):e.reduce((e,r)=>(F(r,t),Object.assign(e,r)),{})),arity:{min:1},docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"collection"},colls:{type:"collection",rest:!0}},variants:[{argumentNames:["a"]},{argumentNames:["a","colls"]}],description:"Concatenates collections into one collection.",seeAlso:["mapcat","str","join","push","sequence.unshift"],examples:['"Albert" ++ " " ++ "Mojir"','"Albert" ++ "Mojir"','++("Albert", "-", "Mojir")','++("Albert")','++("A", "l", "b", "e", "r", "t")',"++([1, 2], [3, 4])","++([], [3, 4])","++([1, 2], [])","++([1, 2], [3, 4], [5, 6])","++([])","++({ a: 1, b: 2 }, { b: 1, c: 2 })","++({}, { a: 1 })"]}}},We={range:{evaluate:(e,t)=>{const[r,n,o]=e;let a,i,s;ee(r,t,{finite:!0}),1===e.length?(a=0,i=r,s=i>=0?1:-1):2===e.length?(ee(n,t,{finite:!0}),a=r,i=n,s=i>=a?1:-1):(ee(n,t,{finite:!0}),ee(o,t,{finite:!0}),a=r,i=n,s=o,ee(s,t,i>a?{positive:!0}:i<a?{negative:!0}:{nonZero:!0}));const c=[];for(let e=a;s<0?e>i:e<i;e+=s)c.push(e);return c},arity:{min:1,max:3},docs:{category:"array",returns:{type:"number",array:!0},args:{a:{type:"number"},b:{type:"number"},step:{type:"number"}},variants:[{argumentNames:["b"]},{argumentNames:["a","b"]},{argumentNames:["a","b","step"]}],description:"$range creates an array with a range of numbers from $a to $b (exclusive), by $step.\n\n$a defaults to 0.\n$step defaults to 1.",seeAlso:["repeat","vector.linspace"],examples:["range(4)","range(1, 4)","1 range 10","range(0.4, 4.9)","\nrange(\n 0.25, // start value\n 1, // end value (exclusive)\n 0.25, // step value\n)"]}},repeat:{evaluate:([e,t],r)=>{ee(t,r,{integer:!0,nonNegative:!0});const n=[];for(let r=0;r<t;r+=1)n.push(e);return n},arity:ae(2),docs:{category:"array",returns:{type:"any",array:!0},args:{a:{type:"any"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],description:"Returns an array with $a repeated $b times.",seeAlso:["range","string.string-repeat"],examples:["repeat(10, 3)","repeat(10, 0)",'"Albert" repeat 5']}},flatten:{evaluate:([e,t],r)=>{we(e,r);const n=void 0===t||t===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:te(t,r,{integer:!0,nonNegative:!0});return e.flat(n)},arity:{min:1,max:2},docs:{category:"array",returns:{type:"any",array:!0},args:{x:{type:["array","any"],description:"If $x is not an array, `[ ]` is returned."}},variants:[{argumentNames:["x"]}],description:"Takes a nested array $x and flattens it.",seeAlso:["mapcat"],examples:["flatten([1, 2, [3, 4], 5])",'\nlet foo = "bar";\nflatten([\n 1,\n " 2 A ",\n [foo, [4, ["ABC"]]],\n 6,\n])'],hideOperatorForm:!0}},mapcat:{evaluate:([e,t],r,n,{executeFunction:o})=>(we(e,r),L(t,r),Ae(Ne(e,e=>o(t,[e],n,r)),e=>e.flat(1))),arity:ae(2),docs:{category:"array",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function"},colls:{type:"collection",array:!0},fun:{type:"function"}},variants:[{argumentNames:["colls","fun"]}],description:"Returns the result of applying concat to the result of applying map to $fun and $colls.",seeAlso:["flatten","map","++"],examples:["[[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]] mapcat reverse","mapcat([[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]], reverse)","[[3, 2, 1, 0,], [6, 5, 4,], [9, 8, 7]] mapcat reverse","\nlet foo = (n) -> do\n [n - 1, n, n + 1]\nend;\n[1, 2, 3] mapcat foo","\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ filter odd?\n)"]}},"moving-fn":{evaluate:([e,t,r],n,o,{executeFunction:a})=>{we(e,n),ee(t,n,{integer:!0,lte:e.length}),L(r,n);const i=[];for(let r=0;r<=e.length-t;r++)i.push(e.slice(r,r+t));return Ne(i,e=>a(r,[e],o,n))},arity:ae(3),docs:{category:"array",returns:{type:"array"},args:{arr:{type:"array"},windowSize:{type:"number",description:"The size of the moving window."},fn:{type:"function"}},variants:[{argumentNames:["arr","windowSize","fn"]}],description:"Returns the result of applying $fn to each moving window of size $windowSize in $arr.",seeAlso:["running-fn","vector.moving-mean"],examples:["moving-fn([1, 2, 3], 2, sum)","moving-fn([1, 2, 3], 1, sum)","moving-fn([1, 2, 3], 3, sum)"]}},"running-fn":{evaluate:([e,t],r,n,{executeFunction:o})=>{we(e,r),L(t,r);const a=[];for(let t=0;t<e.length;t+=1)a.push(e.slice(0,t+1));return Ne(a,e=>o(t,[e],n,r))},arity:ae(2),docs:{category:"array",returns:{type:"array"},args:{a:{type:"array"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns the result of applying $b to each element of $a.",seeAlso:["moving-fn","vector.running-mean"],examples:["running-fn([1, 2, 3], sum)","running-fn([1, 2, 3], max)","running-fn([1, 2, 3], min)"]}}},Ge={nth:{evaluate:(e,t)=>{const[r,n]=e,o=pe(e[2]);if(ee(n,t,{integer:!0}),null===r)return o;if(I(r,t),n>=0&&n<r.length){return pe(r[n])}return o},arity:{min:2,max:3},docs:{category:"sequence",returns:{type:"any"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:["sequence","null"]},n:{type:"integer"},"not-found":{type:"any"}},variants:[{argumentNames:["seq","n"]},{argumentNames:["seq","n","not-found"]}],description:"Accesses element $n of $seq. Accessing out-of-bounds indices returns $not-found, if present, else `null`.",seeAlso:["first","second","last","get","slice"],examples:["[1, 2, 3] nth 1",'"A string" nth 3',"nth([1, 2, 3], 1)","nth([1, 2, 3], 3)","nth([1, 2, 3], -1)","nth([1, 2, 3], 3, 99)",'nth("A string", 1)','nth("A string", 3)','nth("A string", -3)','nth("A string", 30, "X")',"nth(null, 1)",'nth(null, 1, "Default value")']}},first:{evaluate:([e],t)=>{if(null===e)return null;I(e,t);return pe(e[0])},arity:ae(1),docs:{category:"sequence",returns:{type:"any"},args:{seq:{type:["sequence","null"]}},variants:[{argumentNames:["seq"]}],description:"Returns the first element of $seq. If $seq is empty or `null`, `null` is returned.",seeAlso:["second","last","nth","rest","next"],examples:['first(["Albert", "Mojir", 160, [1, 2]])',"first([])","first(null)"]}},last:{evaluate:([e],t)=>{if(null===e)return null;I(e,t);return pe(e.at(-1))},arity:ae(1),docs:{category:"sequence",returns:{type:"any"},args:{seq:{type:["sequence","null"]}},variants:[{argumentNames:["seq"]}],description:"Returns the last element of $seq. If $seq is empty, `null` is returned.",seeAlso:["first","second","nth","pop"],examples:['last(["Albert", "Mojir", 160, [1, 2]])',"last([1, 2])","last([1])","last([])","last(null)"]}},pop:{evaluate:([e],t)=>(I(e,t),"string"==typeof e?e.substring(0,e.length-1):e.slice(0,e.length-1)),arity:ae(1),docs:{category:"sequence",returns:{type:["sequence","null"],rest:!0},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"Returns a copy of $seq with last element removed. If $seq is empty `null` is returned.",seeAlso:["push","last"],examples:["pop([1, 2, 3])","pop([])"]}},"index-of":{evaluate:([e,t],r)=>{if(C(t,r),null===e)return null;if(I(e,r),"string"==typeof e){K(t,r);const n=e.indexOf(t);return-1!==n?n:null}{const n=e.findIndex(e=>me(M(e,r),t),r);return-1!==n?n:null}},arity:ae(2),docs:{category:"sequence",returns:{type:["number","null"]},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:["sequence","null"]},x:{type:"any"}},variants:[{argumentNames:["seq","x"]}],description:"Returns the index of $x in $seq. If element is not present in $seq `null` is returned.",seeAlso:["sequence.last-index-of","sequence.position","contains?"],examples:["[[1], [2], [1], [2]] index-of [1]",'index-of(["Albert", "Mojir", 160, [1, 2]], "Mojir")',"index-of([5, 10, 15, 20], 15)","index-of([5, 10, 15, 20], 1)","index-of(null, 1)"]}},push:{evaluate:([e,...t],r)=>(I(e,r),"string"==typeof e?(qe(t,r),[e,...t].join("")):[...e,...t]),arity:{min:2},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:"sequence"},values:{type:"any",rest:!0,description:"At least one."}},variants:[{argumentNames:["seq","values"]}],description:"Returns copy of $seq with $values added to the end of it.",seeAlso:["sequence.unshift","pop","++"],examples:["[1, 2, 3] push 4",'"Albert" push "!"',"push([1, 2, 3], 4)","push([1, 2, 3], 4, 5, 6)","\nlet l = [1, 2, 3];\npush(l, 4);\nl"]}},rest:{evaluate:([e],t)=>(I(e,t),Array.isArray(e)?e.length<=1?[]:e.slice(1):e.substring(1)),arity:ae(1),docs:{category:"sequence",returns:{type:["sequence","null"]},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"If $seq is an array, returns a new array with all but the first element from $seq.\nIf $seq has less than two elements, an empty array is returned.\nFor string $seq returns all but the first characters in $seq.",seeAlso:["next","first"],examples:['rest(["Albert", "Mojir", 160, [1, 2]])','rest(["Albert"])',"rest([])",'rest("Albert")','rest("A",)','rest("")']}},next:{evaluate:([e],t)=>(I(e,t),Array.isArray(e)?e.length<=1?null:e.slice(1):e.length<=1?null:e.substring(1)),arity:ae(1),docs:{category:"sequence",returns:{type:["sequence","null"]},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"If $seq is an array, returns a new array with all but the first element from $seq. If $seq has less than two elements, `null` is returned. For string $seq returns all but the first characters in $seq. If length of string $seq is less than two, `null` is returned.",seeAlso:["rest","first"],examples:['next(["Albert", "Mojir", 160, [1, 2]])','next(["Albert"])',"next([])",'next("Albert")','next("A",)','next("")']}},reverse:{evaluate:([e],t)=>null===e?null:(I(e,t),Array.isArray(e)?[...e].reverse():e.split("").reverse().join("")),arity:ae(1),docs:{category:"sequence",returns:{type:["sequence","null"]},args:{seq:{type:["sequence","null"]}},variants:[{argumentNames:["seq"]}],description:"If $seq is an array, creates a new array with the elements from $seq in reversed order. If $seq is a string, returns new reversed string.",seeAlso:["sort"],examples:['reverse(["Albert", "Mojir", 160, [1, 2]])',"reverse([])",'reverse("Albert")',"reverse(null)"]}},second:{evaluate:([e],t)=>null===e?null:(I(e,t),pe(e[1])),arity:ae(1),docs:{category:"sequence",returns:{type:"any"},args:{seq:{type:["sequence","null"]}},variants:[{argumentNames:["seq"]}],description:"Returns the second element of $seq. If $seq has less than two elements or is `null`, `null` is returned.",seeAlso:["first","last","nth"],examples:['second(["Albert", "Mojir", 160, [1, 2]])',"second([1])","second([])","second(null)"]}},slice:{evaluate:(e,t)=>{const[r,n,o]=e;return I(r,t),ee(n,t,{integer:!0}),2===e.length?(Array.isArray(r),r.slice(n)):(ee(o,t,{integer:!0}),Array.isArray(r),r.slice(n,o))},arity:{min:2,max:3},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence",rest:!0},start:{type:"integer",description:"Defaults to `0`."},stop:{type:"integer",description:"Defaults lenght of sequence + 1."}},variants:[{argumentNames:["seq"]},{argumentNames:["seq","start"]},{argumentNames:["seq","start","stop"]}],description:"Returns a copy of a portion of $seq from index $start (inclusive) to $stop (exclusive).",seeAlso:["take","drop","sequence.splice","nth"],examples:["[1, 2, 3, 4, 5] slice 2","slice([1, 2, 3, 4, 5], 2, 4)","slice([1, 2, 3, 4, 5], 2)"]}},some:{evaluate:([e,t],r,n,{executeFunction:o})=>{if(L(t,r),null===e)return null;if(I(e,r),0===e.length)return null;return Te("string"==typeof e?e.split(""):e,(e,a)=>null!==e?e:Ae(o(t,[a],n,r),e=>e?pe(a):null),null)},arity:ae(2),docs:{category:"sequence",returns:{type:"any"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:["sequence","null"]},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns the first element that passes the test implemented by $fun. I no element was found, `null` is returned.",seeAlso:["sequence.position","collection.any?","find"],examples:['\nsome(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nsome(\n [5, 10, 15, 20],\n -> $ > 10\n)","\nsome(\n [1, 2, 3, 4],\n -> $ > 10\n)","\nsome(\n [],\n -> $ > 10\n)","\nsome(\n null,\n -> $ > 10\n)"]}},sort:{evaluate:(e,t,r,{executeFunction:n})=>{const[o]=e,a=1===e.length,i=a?null:e[1];if(I(o,t),"string"==typeof o){const e=o.split("");return a?e.sort((e,r)=>le(e,r,t)):(L(i,t),e.sort((e,o)=>{const a=n(i,[e,o],r,t);if(a instanceof Promise)throw new TypeError("Async functions cannot be used as sort comparators");return ee(a,t,{finite:!0}),a})),e.join("")}const s=[...o];return a?s.sort((e,r)=>(X(e,t),X(r,t),le(e,r,t))):s.sort((e,o)=>{L(i,t);const a=n(i,[e,o],r,t);if(a instanceof Promise)throw new TypeError("Async functions cannot be used as sort comparators");return ee(a,t,{finite:!0}),a}),s},arity:{min:1,max:2},docs:{category:"sequence",returns:{type:"any",rest:!0},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq"]},{argumentNames:["seq","fun"]}],description:"Returns a new sequence with the elements from $seq sorted according to $fun. If no $fun is supplied, builtin `compare` will be used.",seeAlso:["sequence.sort-by","compare","reverse","vector.sort-indices"],examples:["[3, 1, 2] sort (a, b) -> b - a","sort([3, 1, 2])","\nsort(\n [3, 1, 2],\n (a, b) -> cond case a < b then -1 case a > b then 1 case true then -1 end\n)","\nsort(\n [3, 1, 2],\n (a, b) -> cond case a > b then -1 case a < b then 1 case true then -1 end\n)"]}},take:{evaluate:([e,t],r)=>{ee(t,r),I(e,r);const n=Math.max(Math.ceil(t),0);return e.slice(0,n)},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},n:{type:"integer"},seq:{type:"sequence"}},variants:[{argumentNames:["seq","n"]}],description:"Constructs a new array/string with the $n first elements from $seq.",seeAlso:["take-last","take-while","drop","slice","sequence.split-at"],examples:["take([1, 2, 3, 4, 5], 3)","[1, 2, 3, 4, 5] take 3","take([1, 2, 3, 4, 5], 0)",'take("Albert", 2)','take("Albert", 50)']}},"take-last":{evaluate:([e,t],r)=>{I(e,r),ee(t,r);const n=Math.max(Math.ceil(t),0),o=e.length-n;return e.slice(o)},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},n:{type:"integer"},seq:{type:"sequence"}},variants:[{argumentNames:["seq","n"]}],description:"Constructs a new array with the $n last elements from $seq.",seeAlso:["take","drop-last"],examples:["take-last([1, 2, 3, 4, 5], 3)","[1, 2, 3, 4, 5] take-last 3","take-last([1, 2, 3, 4, 5], 0)"]}},drop:{evaluate:([e,t],r)=>{ee(t,r);const n=Math.max(Math.ceil(t),0);return I(e,r),e.slice(n)},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence"},n:{type:"integer"}},variants:[{argumentNames:["seq","n"]}],description:"Constructs a new array/string with the $n first elements dropped from $seq.",seeAlso:["drop-last","drop-while","take","slice","sequence.split-at"],examples:["drop([1, 2, 3, 4, 5], 3)","[1, 2, 3, 4, 5] drop 0",'drop("Albert", 2)','drop("Albert", 50)']}},"drop-last":{evaluate:([e,t],r)=>{I(e,r),ee(t,r);const n=Math.max(Math.ceil(t),0),o=e.length-n;return e.slice(0,o)},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence"},n:{type:"integer"}},variants:[{argumentNames:["seq","n"]}],description:"Constructs a new array with the $n last elements dropped from $seq.",seeAlso:["drop","take-last"],examples:["drop-last([1, 2, 3, 4, 5], 3)","[1, 2, 3, 4, 5] drop-last 3","drop-last([1, 2, 3, 4, 5], 0)"]}},"take-while":{evaluate:([e,t],r,n,{executeFunction:o})=>{I(e,r),L(t,r);const a="string"==typeof e?e.split(""):Array.from(e);return Ae(Fe(a,e=>Ae(o(t,[e],n,r),e=>!e)),t=>{const r=-1===t?a:a.slice(0,t);return"string"==typeof e?r.join(""):r})},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns the members of $seq in order, stopping before the first one for which `predicate` returns a falsy value.",seeAlso:["take","drop-while","sequence.split-with"],examples:["take-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)","take-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)"]}},"drop-while":{evaluate:([e,t],r,n,{executeFunction:o})=>{I(e,r),L(t,r);const a=Array.isArray(e)?e:e.split("");return Ae(Fe(a,e=>Ae(o(t,[e],n,r),e=>!e)),t=>-1===t?"string"==typeof e?"":[]:"string"==typeof e?a.slice(t).join(""):e.slice(t))},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns the members of $seq in order, skipping the fist elements for witch the `predicate` returns a truethy value.",seeAlso:["drop","take-while","sequence.split-with"],examples:["drop-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)","drop-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)"]}}},Ve=new WeakSet,Be=new WeakSet,Le=new WeakSet,_e=new WeakSet,Ke=new WeakSet,Je=new WeakSet,Ye=new WeakSet;function He(e){return Array.isArray(e)?(Ve.has(e)||(Xe(e),ot(e)||rt(e)),e):e}function Xe(e){return!!Array.isArray(e)&&(!!Be.has(e)||!Le.has(e)&&(e.every(e=>Q(e))?(Ve.add(e),Be.add(e),!0):(Le.add(e),!1)))}function Ze(e,t){if(!Xe(e))throw new r(`Expected a vector, but got ${e}`,t)}function Qe(e,t){if(!function(e){return!!Xe(e)&&2===e.length}(e))throw new r(`Expected a 2d vector, but got ${e}`,t)}function et(e,t){if(!function(e){return!!Xe(e)&&3===e.length}(e))throw new r(`Expected a 3d vector, but got ${e}`,t)}function tt(e,t){if(Ze(e,t),0===e.length)throw new r(`Expected a non empty vector, but got ${e}`,t)}function rt(e){if(!Array.isArray(e))return!1;if(Je.has(e))return!0;if(Ye.has(e))return!1;if(0===e.length)return Ye.add(e),!1;if(!Array.isArray(e[0]))return Ye.add(e),!1;const t=e[0].length;for(const r of e.slice(1)){if(!Array.isArray(r))return Ye.add(e),!1;if(r.length!==t)return Ye.add(e),!1}return Ve.add(e),Je.add(e),!0}function nt(e,t){if(!rt(e))throw new r(`Expected a grid, but got ${e}`,t)}function ot(e){if(!Array.isArray(e))return!1;if(_e.has(e))return!0;if(Ke.has(e))return!1;if(0===e.length)return Ke.add(e),!1;if(!Array.isArray(e[0])||0===e[0].length)return Ke.add(e),!1;const t=e[0].length;for(const r of e)if(!Array.isArray(r)||r.length!==t||r.some(e=>!Q(e)))return Ke.add(e),!1;return Ve.add(e),Je.add(e),_e.add(e),!0}function at(e,t){if(!ot(e))throw new r(`Expected a matrix, but got ${e}`,t)}function it(e,t){if(!ot(e))throw new r(`Expected a matrix, but got ${e}`,t);if(e.length!==e[0].length)throw new r(`Expected square matrix, but got ${e.length} and ${e[0].length}`,t)}function st(e,t){let n=!1,o=!1;for(const a of e)if(Xe(a))n=!0;else if(ot(a))o=!0;else if(!Q(a))throw new r("Invalid parameter type: "+typeof a,t);if(o){if(n)throw new r("Cannot mix vector and matrix types",t);let o=null,a=null;for(const n of e)if(ot(n))if(null===o)o=n.length,a=n[0].length;else if(n.length!==o||n[0].length!==a)throw new r("Matrix dimensions do not match",t);return["matrix",e.map(e=>ot(e)?e:Array.from({length:o},()=>Array.from({length:a},()=>e)))]}if(n){let n=null;for(const o of e)if(Xe(o))if(null===n)n=o.length;else if(o.length!==n)throw new r("Vector lengths do not match",t);return["vector",e.map(e=>Xe(e)?e:Array.from({length:n},()=>e))]}return["number",e]}function ct(e){return(t,r)=>{const[n,o]=st(t,r);return"number"===n?e(o[0]):"vector"===n?o[0].map(t=>e(t)):o[0].map(t=>t.map(t=>e(t)))}}function lt(e){return(t,r)=>{const[n,o]=st(t,r);return"number"===n?e(o[0],o[1]):"vector"===n?o[0].map((t,r)=>e(t,o[1][r])):o[0].map((t,r)=>t.map((t,n)=>e(t,o[1][r][n])))}}function mt(e,t){return(r,n)=>{if(0===r.length)return e;const[o,a]=st(r,n);if("number"===o)return a.reduce((e,r)=>t(e,r),e);if("vector"===o){const[e,...r]=a;return r.reduce((e,r)=>e.map((e,n)=>t(e,r[n])),e)}{const[e,...r]=a;return r.reduce((e,r)=>e.map((e,n)=>e.map((e,o)=>t(e,r[n][o]))),e)}}}const ut={inc:{evaluate:ct(e=>e+1),arity:ae(1),docs:{category:"math",returns:{type:"number"},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `inc` function increments its argument by 1, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it increases each element by 1 while preserving the original structure.",seeAlso:["dec","+"],examples:["inc(0)","inc(1)","inc(100.1)","inc([1, 2, 3])","inc([[1, 2], [3, 4]])"]}},dec:{evaluate:ct(e=>e-1),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `dec` function decrements its argument by 1, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it decreases each element by 1 while preserving the original structure.",seeAlso:["inc","-"],examples:["dec(0)","dec(1)","dec(100.1)","dec([1, 2, 3])","dec([[1, 2], [3, 4]])"]}},"+":{evaluate:mt(0,(e,t)=>e+t),arity:{},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]},xs:{type:["number","vector","matrix"],rest:!0}},variants:[{argumentNames:["xs"]}],description:"The `+` function performs addition of numbers and element-wise addition of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it adds the scalar to each element of the collection.",seeAlso:["-","*","/","inc"],examples:["1 + 2","1 + 20 + 30","+(1, 2, 3, 4)","+()","+(1)","[1, 2, 3] + 2","[1, 2, 3] + [4, 5, 6]","[[1, 2, 3], [4, 5, 6]] + [[7, 8, 9], [10, 11, 12]]","[[1, 2, 3], [4, 5, 6]] + 2"]}},"*":{evaluate:mt(1,(e,t)=>e*t),arity:{},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]},xs:{type:["number","vector","matrix"],rest:!0}},variants:[{argumentNames:["xs"]}],description:"The `*` function performs multiplication of `numbers` and element-wise multiplication of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it multiplies each element of the collection by the scalar.",seeAlso:["/","+","-","^"],examples:["6 * 7","-1 * 4","*(4, 7)","*(1, 2, 3, 4, 5)","*()","*(8)","[1, 2, 3] * 2","[1, 2, 3] * [4, 5, 6]","[[1, 2, 3], [4, 5, 6]] * [[7, 8, 9], [10, 11, 12]]","[[1, 2, 3], [4, 5, 6]] * 2"]}},"/":{evaluate:(e,t)=>{if(0===e.length)return 1;const[r,n]=st(e,t);if("number"===r){const[e,...t]=n;return 0===t.length?1/e:t.reduce((e,t)=>e/t,e)}if("vector"===r){const e=n[0];return n.slice(1).reduce((e,t)=>e.map((e,r)=>e/t[r]),e)}{const e=n[0];return n.slice(1).reduce((e,t)=>e.map((e,r)=>e.map((e,n)=>e/t[r][n])),e)}},arity:{},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]},xs:{type:["number","vector","matrix"],rest:!0}},variants:[{argumentNames:["xs"]}],description:"The `/` function performs division of `numbers` and element-wise division of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it divides each element of the collection by the scalar.",seeAlso:["*","+","-","quot","mod","%"],examples:["12 / 100","-1 / 4","/(7, 4)","/(1, 2, 4, 8)","/()","/(8)","[1, 2, 3] / 2","[1, 2, 3] / [4, 5, 6]","[[1, 2, 3], [4, 5, 6]] / [[7, 8, 9], [10, 11, 12]]","[[1, 2, 3], [4, 5, 6]] / 2"]}},"-":{evaluate:(e,t)=>{if(0===e.length)return 0;const[r,n]=st(e,t);if("number"===r){const[e,...t]=n;return 0===t.length?-e:t.reduce((e,t)=>e-t,e)}if("vector"===r){const e=n[0];return n.slice(1).reduce((e,t)=>e.map((e,r)=>e-t[r]),e)}{const e=n[0];return n.slice(1).reduce((e,t)=>e.map((e,r)=>e.map((e,n)=>e-t[r][n])),e)}},arity:{},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]},xs:{type:["number","vector","matrix"],rest:!0}},variants:[{argumentNames:["xs"]}],description:"Computes difference between first value and sum of the rest. When called with only one argument, it does negation.",seeAlso:["+","*","/","dec","abs"],examples:["50 - 8","1 - 1 - 1","-()","-(4, 2)","-(4, 3, 2, 1,)","[1, 2, 3] - 2","[1, 2, 3] - [4, 5, 6]","[[1, 2, 3], [4, 5, 6]] - [[7, 8, 9], [10, 11, 12]]","[[1, 2, 3], [4, 5, 6]] - 2"]}},quot:{evaluate:lt((e,t)=>Math.trunc(e/t)),arity:ae(2),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]}},variants:[{argumentNames:["a","b"]}],description:"The `quot` function performs integer division truncated toward zero, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies integer division between each element of the collection and the scalar.",seeAlso:["mod","%","/","trunc"],examples:["quot(5, 3)","quot(5.2, 3.1)","quot(-5, 3)","5 quot -3","-5 quot -3","quot(5, 0)","quot(0, 5)","[1, 2, 3] quot 2","2 quot [1, 2, 3]","quot([1, 2, 3], [4, 5, 6])","[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]","quot([[1, 2, 3], [4, 5, 6]], 2)","[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]"]}},mod:{evaluate:lt((e,t)=>e-t*Math.floor(e/t)),arity:ae(2),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]}},variants:[{argumentNames:["a","b"]}],description:"The `mod` function computes the modulo of division with the same sign as the divisor, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the modulo operation between each element of the collection and the scalar.",seeAlso:["%","quot","/"],examples:["mod(5, 3)","mod(5.2, 3.1)","mod(-5, 3)","5 mod -3","-5 mod -3","[1, 2, 3] mod 2","2 mod [1, 2, 3]","mod([1, 2, 3], [4, 5, 6])","[[1, 2, 3], [4, 5, 6]] mod [[7, 8, 9], [10, 11, 12]]","mod([[1, 2, 3], [4, 5, 6]], 2)"]}},"%":{evaluate:lt((e,t)=>e%t),arity:ae(2),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]}},variants:[{argumentNames:["a","b"]}],description:"The `%` function computes the remainder of division with the same sign as the dividend, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the remainder operation between each element of the collection and the scalar.",seeAlso:["mod","quot","/"],examples:["5 % 3","5.2 % 3.1","-5 % 3","%(5, -3)","%(-5, -3)","[1, 2, 3] % 2","2 % [1, 2, 3]","%([1, 2, 3], [4, 5, 6])","[[1, 2, 3], [4, 5, 6]] % [[7, 8, 9], [10, 11, 12]]","%([[1, 2, 3], [4, 5, 6]], 2)"]}},sqrt:{evaluate:ct(e=>Math.sqrt(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `sqrt` function calculates the square root of `numbers` and computes element-wise square roots of `vectors` and `matrices`. When applied to collections, it returns the square root of each element while preserving the original structure.",seeAlso:["cbrt","^"],examples:["sqrt(0)","sqrt(9)","sqrt(2)","sqrt(0)","sqrt(9)","sqrt(2)","sqrt([1, 4, 9])","sqrt([[1, 4], [9, 16]])"]}},cbrt:{evaluate:ct(e=>Math.cbrt(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `cbrt` function calculates the cube root of `numbers` and computes element-wise cube roots of `vectors` and `matrices`. When applied to collections, it returns the cube root of each element while preserving the original structure.",seeAlso:["sqrt","^"],examples:["cbrt(0)","cbrt(27)","cbrt(2)","cbrt(1)","cbrt(0)","cbrt(27)","cbrt(2)","cbrt(1)","cbrt([1, 8, 27])","cbrt([[1, 8], [27, 64]])"]}},"^":{evaluate:lt((e,t)=>e**t),arity:ae(2),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]}},variants:[{argumentNames:["a","b"]}],description:"The ^ function computes exponentiation, raising the first argument to the power of the second, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the power operation between each element of the collection and the scalar.",seeAlso:["sqrt","cbrt","*","math.ln"],examples:["2 ^ 3","2 ^ 0","2 ^ -3","^(-2, 3)","^(-2, -3)","[1, 2, 3] ^ 2","2 ^ [1, 2, 3]","^([1, 2, 3], [4, 5, 6])","[[1, 2, 3], [4, 5, 6]] ^ [[7, 8, 9], [10, 11, 12]]","^([[1, 2, 3], [4, 5, 6]], 2)"]}},round:{evaluate:([e,t],r)=>{const[n,o]=st([e],r);if("number"===n){if(void 0===t||0===t)return Math.round(o[0]);{ee(t,r,{integer:!0,positive:!0});const e=10**t;return Math.round(o[0]*e)/e}}if("vector"===n){const e=o[0];if(void 0===t||0===t)return e.map(e=>Math.round(e));{ee(t,r,{integer:!0,positive:!0});const n=10**t;return e.map(e=>Math.round(e*n)/n)}}{const e=o[0];if(void 0===t||0===t)return e.map(e=>e.map(e=>Math.round(e)));{ee(t,r,{integer:!0,positive:!0});const n=10**t;return e.map(e=>e.map(e=>Math.round(e*n)/n))}}},arity:{min:1,max:2},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:"integer"}},variants:[{argumentNames:["a"]},{argumentNames:["a","b"]}],description:"The `round` function rounds a `number` to the nearest `integer` or to a specified number of `decimal` places, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it rounds each element while preserving the original structure.",seeAlso:["floor","ceil","trunc"],examples:["round(2)","round(2.49)","round(2.5)","round(-2.49)","round(-2.5)","round(-2.501)","round(1.23456789, 4)","1.123456789 round 2","round([1.23456789, 2.3456789], 1)","[1.23456789, 2.3456789] round 4","[[1.23456789, 2.3456789], [3.456789, 4.56789]] round 4","round([[1.23456789, 2.3456789], [3.456789, 4.56789]], 2)"]}},trunc:{evaluate:ct(e=>Math.trunc(e)),arity:ae(1),docs:{category:"math",returns:{type:["integer","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `trunc` function truncates `numbers` toward zero (removing decimal portions without rounding), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it truncates each element while preserving the original structure.",seeAlso:["round","floor","ceil","quot"],examples:["trunc(2)","trunc(2.49)","trunc(2.5)","trunc(-2.49)","trunc(-2.5)","trunc(-2.501)","trunc([1.23456789, 2.3456789])","trunc([[1.23456789, 2.3456789], [3.456789, 4.56789]])"]}},floor:{evaluate:ct(e=>Math.floor(e)),arity:ae(1),docs:{category:"math",returns:{type:["integer","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `floor` function returns the largest `integer` less than or equal to a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the floor of each element while preserving the original structure.",seeAlso:["ceil","round","trunc"],examples:["floor(2)","floor(2.49)","floor(2.5)","floor(-2.49)","floor(-2.5)","floor(-2.501)","floor([1.23456789, 2.3456789])","floor([[1.23456789, 2.3456789], [3.456789, 4.56789]])"]}},ceil:{evaluate:ct(e=>Math.ceil(e)),arity:ae(1),docs:{category:"math",returns:{type:["integer","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `ceil` function returns the smallest `integer` greater than or equal to a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the ceiling of each element while preserving the original structure.",seeAlso:["floor","round","trunc"],examples:["ceil(2)","ceil(2.49)","ceil(2.5)","ceil(-2.49)","ceil(-2.5)","ceil(-2.501)","ceil([1.23456789, 2.3456789])","ceil([[1.23456789, 2.3456789], [3.456789, 4.56789]])"]}},min:{evaluate:(e,t)=>{if(1===e.length&&Xe(e[0])){const r=e[0];return tt(r,t),r.reduce((e,t)=>Math.min(e,t),1/0)}const[r,...n]=e;return ee(r,t),n.reduce((e,r)=>(ee(r,t),Math.min(e,r)),r)},arity:{min:1},docs:{category:"math",returns:{type:"number"},args:{a:{type:"number"},b:{type:"number"},xs:{type:"number",rest:!0},vector:{type:"vector"}},variants:[{argumentNames:["xs"]},{argumentNames:["vector"]}],description:"Returns the smallest value. Accepts either multiple numbers or a single vector of numbers.",seeAlso:["max","vector.span","vector.min-index"],examples:["2 min 3","min(2, 0, 1)","min(2, -1, 1)","min([2, 0, -1])","12 min 14"]}},max:{evaluate:(e,t)=>{if(1===e.length&&Xe(e[0])){const r=e[0];return tt(r,t),r.reduce((e,t)=>Math.max(e,t),-1/0)}const[r,...n]=e;return ee(r,t),n.reduce((e,r)=>(ee(r,t),Math.max(e,r)),r)},arity:{min:1},docs:{category:"math",returns:{type:"number"},args:{a:{type:"number"},b:{type:"number"},xs:{type:"number",rest:!0},vector:{type:"vector"}},variants:[{argumentNames:["xs"]},{argumentNames:["vector"]}],description:"Returns the largest value. Accepts either multiple numbers or a single vector of numbers.",seeAlso:["min","vector.span","vector.max-index"],examples:["2 max 3","max(2, 0, 1)","max(2, -1, 1)","max([2, 0, -1])","4 max 2"]}},abs:{evaluate:ct(e=>Math.abs(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The abs function returns the absolute value (magnitude) of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the absolute value of each element while preserving the original structure.",seeAlso:["sign","-"],examples:["abs(-2.3)","abs(0)","abs(2.5)","abs([1, -2, 3])","abs([[1, -2], [3, -4]])"]}},sign:{evaluate:ct(e=>Math.sign(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `sign` function returns the `sign` of a `number` (-1 for negative, 0 for zero, 1 for positive), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the sign of each element while preserving the original structure.",seeAlso:["abs"],examples:["sign(-2.3)","sign(-0)","sign(0)","sign(12312)","sign([1, -2, 3])","sign([[1, -2], [3, -4]])"]}}};function pt([e,...t],r){const n=M(e,r);for(const e of t)if(!me(n,M(e,r),r))return!1;return!0}const gt={"==":{evaluate:(e,t)=>pt(e,t),arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:"any"},b:{type:"any"},x:{type:"any"},ys:{type:"any",rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if all `values` are structaul equal to each other, otherwise result is `false`.",seeAlso:["!=","identical?"],examples:["1 == 1","[1, 2] == [1, 2]","\n{\n a: 1,\n b: 2,\n} == {\n b: 2,\n a: 1,\n}","==(1, 1)","==(1.01, 1)",'==("1", 1)','==("2", "2", "2", "2")',"==(2, 2, 1, 2)","==([1, 2], [1, 2])","==({ a: 1, b: 2 }, { b: 2, a: 1 })"]}},"!=":{evaluate:(e,t)=>!pt(e,t),arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:"any"},b:{type:"any"},x:{type:"any"},ys:{type:"any",rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if all `values` are not equal to each other, otherwise result is `false`. `(!= a b c)` is same as `(not (== a b c))`.",seeAlso:["==","identical?"],examples:["1 != 2","3 != 3","!=(3)","!=(3, 3, 2)",'!=("3", "2", "1", "0",)',"!=(0, -0)"]}},"identical?":{evaluate:e=>function([e,...t]){for(const r of t)if(r!==e)return!1;return!0}(e),arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:"any"},b:{type:"any"}},variants:[{argumentNames:["a","b"]}],description:"Returns true if $a and $b are referential equal.",seeAlso:["==","!="],examples:["identical?({ a: 10, b: 20 }, { b: 20, a: 10 })","identical?([1, true, null], [1, true, null])","identical?(0.3, 0.1 + 0.2)"]}},">":{evaluate:([e,...t],r)=>{let n=H(e);for(const e of t){if(le(n,H(e),r)<=0)return!1;n=H(e)}return!0},arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:["number","string"]},b:{type:["number","string"]},x:{type:["number","string"]},ys:{type:["number","string"],rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if $x and $ys are in decreasing order, `false` otherwise.",seeAlso:["<",">=","<=","compare"],examples:[">(1, 0)",">(1.01, 1)",">(1, 1)",">(4, 3, 2, 1)",">(3, 2, 2, 1)"]}},"<":{evaluate:([e,...t],r)=>{let n=H(e);for(const e of t){if(le(n,H(e),r)>=0)return!1;n=H(e)}return!0},arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:["number","string"]},b:{type:["number","string"]},x:{type:["number","string"]},ys:{type:["number","string"],rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if $x and $ys are in increasing order, `false` otherwise.",seeAlso:[">",">=","<=","compare"],examples:["<(0, 1)","<(1, 1.01)","<(1, 1)","<(1, 2, 2, 3)",'<("a", "b")']}},">=":{evaluate:([e,...t],r)=>{let n=H(e);for(const e of t){if(le(n,H(e),r)<0)return!1;n=H(e)}return!0},arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:["number","string"]},b:{type:["number","string"]},x:{type:["number","string"]},ys:{type:["number","string"],rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if $x and $ys are in non increasing order, `false` otherwise.",seeAlso:[">","<","<=","compare"],examples:["1 >= 1","0 >= 1",">=(1, 0)",">=(1.01, 1)",">=(1, 1)",">=(4, 3, 2, 1)",">=(3, 2, 2, 1)"]}},"<=":{evaluate:([e,...t],r)=>{let n=H(e);for(const e of t){if(le(n,H(e),r)>0)return!1;n=H(e)}return!0},arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:["number","string"]},b:{type:["number","string"]},x:{type:["number","string"]},ys:{type:["number","string"],rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if $x and $ys are in non decreasing order, `false` otherwise.",seeAlso:[">","<",">=","compare"],examples:["1 <= 1","<=(0, 1)","<=(1, 1.01)","<=(1, 1)","<=(1, 2, 3, 4)","<=(1, 2, 2, 3)"]}},not:{evaluate:([e])=>!e,arity:ae(1),docs:{category:"misc",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Computes logical negation. Note that any other $x than `false`, `0`, `null` and `''` is truthy.",seeAlso:["boolean"],examples:["not(3)","not(true)",'not("A string")',"not(0)","not(false)","not(null)",'not("")']}},"epoch->iso-date":{evaluate:([e],t)=>(ee(e,t),new Date(e).toISOString()),arity:ae(1),docs:{category:"misc",returns:{type:"string"},args:{ms:{type:"number"}},variants:[{argumentNames:["ms"]}],description:"Returns IOS date time string from `ms` (milliseconds elapsed since the UNIX epoch).",seeAlso:["iso-date->epoch"],examples:["epoch->iso-date(1649756230899)","epoch->iso-date(0)"]}},"iso-date->epoch":{evaluate:([e],t)=>{K(e,t);const r=new Date(e).valueOf();return ee(r,t,{finite:!0}),r},arity:ae(1),docs:{category:"misc",returns:{type:"number"},args:{iso:{type:"string"}},variants:[{argumentNames:["iso"]}],description:"Returns milliseconds elapsed since the UNIX epoch to `iso`.",seeAlso:["epoch->iso-date"],examples:['iso-date->epoch("2022-04-12T09:37:10.899Z")','iso-date->epoch("1980-01-01")']}},"write!":{evaluate:(e,t)=>(console.log(...e),e.length>0?M(e[e.length-1],t):null),pure:!1,arity:{},docs:{category:"misc",returns:{type:"any"},args:{values:{type:"any",rest:!0}},variants:[{argumentNames:["values"]}],description:"It logs the $values and then returns the last argument. If called with no arguments `null` is returned.",examples:['write!("A string")','write!(100, "items")','write!(object("a", 10))','write!(["a", "b", "c"])','write!(#"^start")',"write!(null, true, false)"],hideOperatorForm:!0}},boolean:{evaluate:([e])=>!!e,arity:ae(1),docs:{category:"misc",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Coerces $x to boolean.",seeAlso:["not","boolean?","true?","false?"],examples:["boolean(0)","boolean(1)","boolean(null)",'boolean("Albert")']}},compare:{evaluate:([e,t],r)=>(X(e,r),X(t,r),le(e,t,r)),arity:ae(2),docs:{category:"misc",returns:{type:"number"},args:{a:{type:["number","string"]},b:{type:["number","string"]}},variants:[{argumentNames:["a","b"]}],description:"Compares two values. Returns `-1` if $a < $b, `1` if $a > $b and `0` if $a and $b have the same sort order.",seeAlso:["<",">","<=",">=","sort","sequence.sort-by"],examples:["compare(0, 1)","compare(0, 0)","compare(1, 0)",'compare("Albert", "Mojir")']}},"json-parse":{evaluate:([e],t)=>(K(e,t),JSON.parse(e)),arity:ae(1),docs:{category:"misc",returns:{type:"any"},args:{x:{type:"string"}},variants:[{argumentNames:["x"]}],description:"Returns `JSON.parse(`$x`)`.",seeAlso:["json-stringify"],examples:['json-parse("[1, 2, 3]")']}},"json-stringify":{evaluate:([e,t],r)=>(C(e,r),void 0===t?JSON.stringify(e):(ee(t,r),JSON.stringify(e,null,t))),arity:{min:1,max:2},docs:{category:"misc",returns:{type:"string"},args:{x:{type:"any"},indent:{type:"integer",description:"Number of spaces to use for indentation."}},variants:[{argumentNames:["x"]},{argumentNames:["x","indent"]}],description:"Returns `JSON.stringify(`$x`)`. If second argument is provided, returns `JSON.stringify(`$x`, null, `$indent`)`.",seeAlso:["json-parse"],examples:["json-stringify([1, 2, 3])","json-stringify({ a: { b: 10 }}, 2)"],hideOperatorForm:!0}}},ht={keys:{evaluate:([e],t)=>(F(e,t),Object.keys(e)),arity:ae(1),docs:{category:"object",returns:{type:"any",array:!0},args:{obj:{type:"object"}},variants:[{argumentNames:["obj"]}],description:"Returns array of all keys in $obj.",seeAlso:["vals","entries","zipmap","select-keys"],examples:["keys({})",'keys({ x: 10, y: true, z: "A string" })','keys(object("x", 10, "y", true, "z", "A string"))']}},vals:{evaluate:([e],t)=>(F(e,t),Object.values(e)),arity:ae(1),docs:{category:"object",returns:{type:"any",array:!0},args:{obj:{type:"object"}},variants:[{argumentNames:["obj"]}],description:"Returns array of all values in $obj.",seeAlso:["keys","entries","zipmap"],examples:["vals({})",'vals({ x: 10, y: true, z: "A string" })','vals(object("x", 10, "y", true, "z", "A string"))']}},entries:{evaluate:([e],t)=>(F(e,t),Object.entries(e)),arity:ae(1),docs:{category:"object",returns:{type:"array"},args:{obj:{type:"object"}},variants:[{argumentNames:["obj"]}],description:"Returns nested array of all key - value pairs in $obj.",seeAlso:["keys","vals","zipmap","find"],examples:["entries({})",'entries({ x: 10, y: true, z: "A string" })','entries(object("x", 10, "y", true, "z", "A string"))']}},find:{evaluate:([e,t],r)=>(F(e,r),K(t,r),ce(e,t)?[t,e[t]]:null),arity:ae(2),docs:{category:"object",returns:{type:["array","null"]},args:{a:{type:"object"},b:{type:"string"},obj:{type:"object"},key:{type:"string"}},variants:[{argumentNames:["obj","key"]}],description:"Returns entry (key-value pair) for $key, or `null` if $key not present in $obj.",seeAlso:["get","contains?","entries","sequence.position","some"],examples:['{ a: 1, "b": 2 } find "a"','find(object("a", 1, "b", 2), "b")','find(object("a", 1, "b", 2), "c")']}},dissoc:{evaluate:([e,t],r)=>{F(e,r),K(t,r);const n={...e};return delete n[t],n},arity:ae(2),docs:{category:"object",returns:{type:"object"},args:{a:{type:"object"},b:{type:"string"},obj:{type:"object"},key:{type:"string"}},variants:[{argumentNames:["obj","key"]}],description:"Return shallow copy of $obj with $key deleted.",seeAlso:["assoc","select-keys"],examples:['{ x: 10, y: 20 } dissoc "y"','dissoc({ x: 10, y: 20 }, "x")','dissoc({ x: 10 }, "y")','\nlet o = { a: 5 };\ndissoc(o, "a");\no']}},merge:{evaluate:(e,t)=>{if(0===e.length)return null;const[r,...n]=e;return F(r,t),n.reduce((e,r)=>(F(r,t),{...e,...r}),{...r})},arity:{min:0},docs:{category:"object",returns:{type:"object"},args:{a:{type:"object"},b:{type:"object"},objs:{type:"object",rest:!0}},variants:[{argumentNames:["objs"]}],description:"Returns a new object created by merging together all arguments.\n\nIf two keys appears in more than one object the value from the last object is used.\nIf no arguments are provided `null` is returned.",seeAlso:["merge-with","assoc"],examples:["{ x: 10 } merge { y: 20 }",'merge(object("x", 10), object("y", 20))','merge(object("x", 10), object("x", 15, "y", 20))']}},"merge-with":{evaluate:(e,t,r,{executeFunction:n})=>{const o=e[0],a=e.at(-1),i=e.slice(1,-1);return F(o,t),L(a,t),Te(i,(e,o)=>{F(o,t);return Ae(Te(Object.entries(o),(e,o)=>{const i=J(o[0],t),s=pe(o[1]);return ce(e,i)?Ae(n(a,[e[i],s],r,t),t=>(e[i]=t,e)):(e[i]=s,e)},e),e=>e)},{...o})},arity:{min:2},docs:{category:"object",returns:{type:"object"},args:{objs:{type:"object",rest:!0},fun:{type:"function"}},variants:[{argumentNames:["objs","fun"]}],description:"\nReturns a new object created by merging together all arguments.\nIf two keys appears in more than one object $fun is used to calculate the new value.\n\nIf no arguments are provided `null` is returned.",seeAlso:["merge"],examples:['merge-with(object("x", 10), object("y", 20), +)','merge-with(object("x", 10), object("x", 15, "y", 20), +)',"merge-with({ x: 10 }, { x: 20 }, { x: 30 }, { x: 40 }, -)"],hideOperatorForm:!0}},zipmap:{evaluate:([e,t],r)=>{ke(e,r),we(t,r);const n=Math.min(e.length,t.length),o={};for(let a=0;a<n;a+=1){o[J(e[a],r)]=pe(t[a])}return o},arity:ae(2),docs:{category:"object",returns:{type:"object"},args:{a:{type:"array"},b:{type:"array"}},variants:[{argumentNames:["a","b"]}],description:"Returns a new object created by mapping $a to $b.",seeAlso:["entries","keys","vals","sequence.interleave"],examples:['["a", "b", "c"] zipmap [1, 2, 3]','zipmap(["a", "b", "c"], [10, null, [1, 2, 3]])','zipmap(["a", "b", "c"], [1])',"zipmap([], [10, null, [1, 2, 3]])"]}},"select-keys":{evaluate:([e,t],r)=>(ke(t,r),F(e,r),t.reduce((t,r)=>(ce(e,r)&&(t[r]=pe(e[r])),t),{})),arity:ae(2),docs:{category:"object",returns:{type:"object"},args:{a:{type:"object"},b:{type:"array"}},variants:[{argumentNames:["a","b"]}],description:"Returns an object containing only those entries in $a whose key is in $b.",seeAlso:["dissoc","keys"],examples:['{ a: 1, b: 2, c: 3 } select-keys ["a", "b"]','select-keys({ a: 1, b: 2, c: 3 }, ["a", "b"])','select-keys({ a: 1 }, ["a", "b"])']}}},dt={"function?":{evaluate:([e])=>w(e),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a function, otherwise `false`.",seeAlso:["string?","number?","boolean?","null?","array?","object?","regexp?"],examples:["function?(+)","function?(/)","function?((x, y) -> x + y)","function?(false)",'function?("false")',"function?([1, 2, 3])"]}},"string?":{evaluate:([e])=>"string"==typeof e,arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a string, otherwise `false`.",seeAlso:["blank?","number?","boolean?","null?","array?","object?","regexp?","function?","collection?","sequence?"],examples:['string?("")','string?("A string")','string?(true ? "A string" : false)',"string?(false)","string?([1, 2, 3])","string?(100)"]}},"number?":{evaluate:([e])=>"number"==typeof e,arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a number, otherwise `false`.",seeAlso:["integer?","zero?","pos?","neg?","finite?","number","string?","boolean?","null?","function?"],examples:["number?(0)","number?(2)","number?(-0.12)","number?(false)","number?([1, 2, 3])",'number?("A string")']}},"integer?":{evaluate:([e])=>"number"==typeof e&&Q(e,{integer:!0}),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is an integer, otherwise `false`.",seeAlso:["number?","number","even?","odd?"],examples:["integer?(0)","integer?(-12)","integer?(42)","integer?(10.1)","integer?((x, y) -> x + y)","integer?(false)",'integer?("false")',"integer?([1, 2, 3])"]}},"boolean?":{evaluate:([e])=>"boolean"==typeof e,arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a `boolean`, otherwise `false`.",seeAlso:["true?","false?","boolean","string?","number?","null?","function?"],examples:["boolean?(true)","boolean?(false)","boolean?([1, 2, 3])","boolean?(0)",'boolean?("A string")']}},"null?":{evaluate:([e])=>null==e,arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is `null`, otherwise `false`.",seeAlso:["empty?","not-empty?","string?","number?","boolean?","function?"],examples:["null?(null)","null?(false)","null?([1, 2, 3])","null?(0)",'null?("A string")']}},"zero?":{evaluate:([e],t)=>(ee(e,t,{finite:!0}),Math.abs(e)<ve),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is `0`, otherwise `false`.",seeAlso:["pos?","neg?","even?","number?"],examples:["zero?(0)","zero?(-0.0)","zero?(1)","zero?(0.1)"]}},"pos?":{evaluate:([e],t)=>(ee(e,t,{finite:!0}),e>0),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is greater than `0`, otherwise `false`.",seeAlso:["neg?","zero?","number?"],examples:["pos?(0)","pos?(-0.0)","pos?(1)","pos?(-0.1)"]}},"neg?":{evaluate:([e],t)=>(ee(e,t,{finite:!0}),e<0),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is less than `0`, otherwise `false`.",seeAlso:["pos?","zero?","number?"],examples:["neg?(0)","neg?(-0.0)","neg?(1)","neg?(-0.1)"]}},"even?":{evaluate:([e],t)=>(ee(e,t,{finite:!0}),e%2==0),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is even, otherwise `false`.",seeAlso:["odd?","integer?","zero?"],examples:["even?(0)","even?(-0.0)","even?(-1)","even?(2.1)"]}},"odd?":{evaluate:([e],t)=>(ee(e,t,{finite:!0}),Q(e,{integer:!0})&&e%2!=0),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is odd, otherwise `false`.",seeAlso:["even?","integer?"],examples:["odd?(1.0)","odd?(1.001)","odd?(-1)","odd?(2.1)"]}},"array?":{evaluate:([e])=>Array.isArray(e),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is an array, otherwise `false`.",seeAlso:["sequence?","collection?","object?","string?","vector?","matrix?","grid?","function?"],examples:["array?([])","array?([1, 2, 3])",'array?(object("a", 10))',"array?(42)","array?(10.1)","array?((x, y) -> x + y)"]}},"collection?":{evaluate:([e])=>U(e),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a collection i.e. an array, an object or a string, otherwise `false`.",seeAlso:["sequence?","array?","object?","string?"],examples:["collection?([])","collection?([1, 2, 3])",'collection?(object("a", 10))','collection?("Albert")',"collection?(42)","collection?(10.1)","collection?((x, y) -> x + y)"]}},"sequence?":{evaluate:([e])=>P(e),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a sequence i.e. an array or a string, otherwise `false`.",seeAlso:["collection?","array?","string?"],examples:["sequence?([])","sequence?([1, 2, 3])",'sequence?(object("a", 10))','sequence?("Albert")',"sequence?(42)","sequence?(10.1)","sequence?((x, y) -> x + y)"]}},"object?":{evaluate:([e])=>O(e),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is an object, otherwise `false`.",seeAlso:["collection?","array?","string?","function?"],examples:['object?(object("a", 10))',"object?(42)","object?(10.1)","object?((x, y) -> x + y)",'object?(#"^start")','object?("false")',"object?([1, 2, 3])"]}},"regexp?":{evaluate:([e])=>G(e),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a regexp, otherwise `false`.",seeAlso:["regexp","re-match","string?","function?"],examples:['regexp?(regexp("^start"))','regexp?(#"^start")',"regexp?(-12)","regexp?({})","regexp?(10.1)","regexp?((x, y) -> x + y)","regexp?(false)",'regexp?("false")',"regexp?([1, 2, 3])"]}},"finite?":{evaluate:([e],t)=>(ee(e,t),Number.isFinite(e)),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is finite, otherwise `false`.",seeAlso:["positive-infinity?","negative-infinity?","number?"],examples:["finite?(1.0)","finite?(1 / 0)","finite?(-1 / 0)"]}},"positive-infinity?":{evaluate:([e],t)=>(ee(e,t),e===Number.POSITIVE_INFINITY),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x equals positive infinity, otherwise `false`.",seeAlso:["negative-infinity?","finite?"],examples:["positive-infinity?(1.0)","positive-infinity?(1 / 0)","positive-infinity?(-1 / 0)"]}},"negative-infinity?":{evaluate:([e],t)=>(ee(e,t),e===Number.NEGATIVE_INFINITY),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x equals negative infinity, otherwise `false`.",seeAlso:["positive-infinity?","finite?"],examples:["negative-infinity?(1.0)","negative-infinity?(1 / 0)","negative-infinity?(-1 / 0)"]}},"true?":{evaluate:([e])=>!0===e,arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is `true`, otherwise `false`.",seeAlso:["false?","boolean?","boolean"],examples:["true?(false)","true?(true)","true?(1)","true?(0)"]}},"false?":{evaluate:([e])=>!1===e,arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is `true`, otherwise `false`.",seeAlso:["true?","boolean?","boolean"],examples:["false?(false)","false?(true)","false?(1)","false?(0)"]}},"empty?":{evaluate:([e],t)=>null===e||(W(e,t),"string"==typeof e||Array.isArray(e)?0===e.length:0===Object.keys(e).length),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:["collection","string","null"]}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is empty or `null`, otherwise `false`.",seeAlso:["not-empty?","collection.not-empty","null?","blank?","count"],examples:["empty?([])","empty?([1, 2, 3])","empty?({})","empty?({ a: 2 })",'empty?("")','empty?("Albert")',"empty?(null)"]}},"not-empty?":{evaluate:([e],t)=>null!==e&&(W(e,t),"string"==typeof e||Array.isArray(e)?e.length>0:Object.keys(e).length>0),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:["collection","string","null"]}},variants:[{argumentNames:["x"]}],description:"Returns `false` if $x is empty or `null`, otherwise `true`.",seeAlso:["empty?","collection.not-empty","null?"],examples:["not-empty?([])","not-empty?([1, 2, 3])","not-empty?({})","not-empty?({ a: 2 })",'not-empty?("")','not-empty?("Albert")',"not-empty?(null)"]}},"vector?":{evaluate:([e])=>Xe(e),arity:ae(1),docs:{category:"predicate",description:"Checks if a value is a `vector`. A `vector` is an array of `numbers`.",seeAlso:["matrix?","grid?","array?"],returns:{type:"boolean"},args:{value:{type:"any",description:"The value to check."}},variants:[{argumentNames:["value"]}],examples:["vector?(1)","vector?([1, 2, 3])",'vector?([1, 2, "3"])']}},"matrix?":{evaluate:([e])=>ot(e),arity:ae(1),docs:{category:"predicate",description:"Checks if a value is a `matrix`. A `matrix` is an array of arrays of `numbers`.",seeAlso:["vector?","grid?","array?"],returns:{type:"boolean"},args:{value:{type:"any",description:"The value to check."}},variants:[{argumentNames:["value"]}],examples:["matrix?(1)","matrix?([1, 2, 3])","matrix?([[1, 2], [3, 4]])",'matrix?([[1, 2], [3, "4"]])',"matrix?([[1, 2], [3]])"]}},"grid?":{evaluate:([e])=>rt(e),arity:ae(1),docs:{category:"predicate",description:"Checks if a `value` is a `grid`. A `grid` is an `array` of `arrays` where all inner `arrays` have the same length.",seeAlso:["vector?","matrix?","array?"],returns:{type:"boolean"},args:{value:{type:"any",description:"The value to check."}},variants:[{argumentNames:["value"]}],examples:['grid?("1")','grid?(["1", 2, 3])','grid?([["1", 2], [3, 4]])','grid?([["1", 2], [3, "4"]])','grid?([["1", 2], [3]])']}}},yt={regexp:{evaluate:([e,t],n)=>{K(e,n);const o=e||"(?:)",a="string"==typeof t?t:"";try{new RegExp(o,a)}catch(e){throw new r(`Invalid regular expression: ${o} ${a}`,n)}return{[p]:!0,sourceCodeInfo:n,s:o,f:a}},arity:{min:1,max:2},docs:{category:"regular-expression",returns:{type:"regexp"},args:{pattern:{type:"string"},flags:{type:"string",description:"Optional flags for the regular expression. Possible values are the same as Javascript RegExp takes."}},variants:[{argumentNames:["pattern"]},{argumentNames:["pattern","flags"]}],description:"Creates a RegExp from $pattern and $flags.",examples:['regexp("^\\s*(.*)$")','#"^\\s*(.*)$"','regexp("albert", "ig")','#"albert"ig'],seeAlso:["-short-regexp","re-match","replace","replace-all","regexp?"],hideOperatorForm:!0}},"re-match":{evaluate:([e,t],r)=>{if(function(e,t){if(!G(e))throw v("RegularExpression",e,t)}(t,r),!_(e))return null;const n=new RegExp(t.s,t.f).exec(e);return n?[...n]:null},arity:ae(2),docs:{category:"regular-expression",returns:{type:"any",array:!0},args:{a:{type:"regexp"},b:{type:"string"}},variants:[{argumentNames:["a","b"]}],description:"Matches $b against regular expression $a.\nIf $b is a string and matches the regular expression, a `re-match`-array is returned, otherwise `null` is returned.",seeAlso:["regexp","replace","replace-all","-short-regexp","regexp?"],examples:['re-match(" A string", regexp("^\\\\s*(.*)$"))','re-match(" A string", #"^\\s*(.*)$")','re-match("My name is Albert", #"albert"i)','re-match("My name is Ben", #"albert"i)','re-match(null, #"albert"i)','re-match(1, #"albert"i)','re-match({}, #"albert"i)']}},replace:{evaluate:([e,t,r],n)=>{K(e,n),V(t,n),K(r,n);const o=G(t)?new RegExp(t.s,`${t.f}`):t;return e.replace(o,r)},arity:ae(3),docs:{category:"regular-expression",returns:{type:"any",array:!0},args:{a:{type:"string"},b:{type:["regexp","string"]},x:{type:"string"}},variants:[{argumentNames:["a","b","x"]}],description:"Returns a new string with first match of regular expression $b replaced by $x.",seeAlso:["replace-all","regexp","re-match","-short-regexp"],examples:['replace("Duck duck", "u", "i")','replace("Duck duck", #"u", "i")','replace("abcABC", regexp("a", "i"), "-")','replace("abcABC", regexp("a", "gi"), "-")','replace("abcABC", #"a"i, "-")','replace("abcABC", #"a"gi, "-")']}},"replace-all":{evaluate:([e,t,r],n)=>{K(e,n),V(t,n),K(r,n);const o=G(t)?new RegExp(t.s,`${t.f.includes("g")?t.f:`${t.f}g`}`):t;return e.replaceAll(o,r)},arity:ae(3),docs:{category:"regular-expression",returns:{type:"any",array:!0},args:{a:{type:"string"},b:{type:["regexp","string"]},x:{type:"string"}},variants:[{argumentNames:["a","b","x"]}],description:"Returns a new string with all matches of regular expression $b replaced by $x.",seeAlso:["replace","regexp","re-match","-short-regexp"],examples:['replace-all("Duck duck", "u", "i")','replace-all("Duck duck", regexp("u"), "i")','replace-all("abcABC", regexp("a", "i"), "-")','replace-all("abcABC", regexp("a", "gi"), "-")','replace-all("abcABC", #"a"i, "-")','replace-all("abcABC", #"a"gi, "-")']}}},vt=/^\s*$/,ft={str:{evaluate:e=>e.reduce((e,t)=>e+(null==t?"":O(t)||Array.isArray(t)?JSON.stringify(t):`${t}`),""),arity:{},docs:{category:"string",returns:{type:"string"},args:{values:{type:"any",rest:!0}},variants:[{argumentNames:["values"]}],description:"Concatenats $values into one string. If `value` equals `null` empty string is returned.",seeAlso:["++","join","string.template","string.string-repeat","number"],examples:['str("A string", ", and another string", " ...and more")','str("Just one string")',"str()",'str(0, false, true, null, #"^kalle", [1, 2, 3], {a: "a"})'],hideOperatorForm:!0}},number:{evaluate:([e],t)=>{K(e,t);const n=Number(e);if(Number.isNaN(n))throw new r(`Could not convert '${e}' to a number.`,t);return n},arity:ae(1),docs:{category:"string",returns:{type:"number"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Parses $s to a number.",seeAlso:["str","number?","integer?"],examples:['number("10")','number("010")','number("-1.01")']}},"lower-case":{evaluate:([e],t)=>(K(e,t),e.toLowerCase()),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns $s converted to lower case.",seeAlso:["upper-case","string.capitalize"],examples:['lower-case("Albert")','lower-case("")']}},"upper-case":{evaluate:([e],t)=>(K(e,t),e.toUpperCase()),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns $s converted to upper case.",seeAlso:["lower-case","string.capitalize"],examples:['upper-case("Albert")','upper-case("")']}},trim:{evaluate:([e],t)=>(K(e,t),e.trim()),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns a new string with leading and trailing whitespaces removed.",seeAlso:["string.trim-left","string.trim-right","blank?"],examples:['trim(" Albert ")','trim(" ")','trim("")']}},join:{evaluate:([e,t],r)=>(we(e,r),e.forEach(e=>X(e,r)),K(t,r),e.join(t)),arity:ae(2),docs:{category:"string",returns:{type:"string"},args:{a:{type:"array"},b:{type:"string"},arr:{type:"array"},delimiter:{type:"string"}},variants:[{argumentNames:["arr","delimiter"]}],description:"Returns a new string by concatenating all of the elements in $arr, separated by $delimiter.",seeAlso:["split","str","++","sequence.interpose"],examples:['map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str) join ", "','([0, 1, 2, 3, 4, 5, 6, 7, 8, 9] map str) join ", "','join(["Albert", 10], ", ")','join(["Albert", "Mojir"], " ")','join(map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str), ", ")']}},split:{evaluate:([e,t,r],n)=>{K(e,n),V(t,n),void 0!==r&&ee(r,n,{integer:!0,nonNegative:!0});const o="string"==typeof t?t:new RegExp(t.s,t.f);return e.split(o,r)},arity:{min:2,max:3},docs:{category:"string",returns:{type:"string"},args:{a:{type:"string"},b:{type:"string"},s:{type:"string"},delimiter:{type:"string"},limit:{type:"integer"}},variants:[{argumentNames:["s","delimiter"]},{argumentNames:["s","delimiter","limit"]}],description:"Divides $s into an array of substrings. The division is done by searching for `delimiter`. If `limit` as provided, at most `limit` number of substrings are returned.",seeAlso:["join","string.split-lines"],examples:['"Albert Mojir" split " "','split("Albert Mojir", " ")','split("abcdefghijklmnopqrstuvw", #"[aoueiy]")','split("0123456789", "")','split("0123456789", "", 5) map number']}},"blank?":{evaluate:([e],t)=>null===e||(K(e,t),vt.test(e)),arity:ae(1),docs:{category:"string",returns:{type:"boolean"},args:{s:{type:["string","null"]}},variants:[{argumentNames:["s"]}],description:"Returns true if $s is null or only contains whitespace characters.",seeAlso:["trim","empty?","string?"],examples:['blank?("")',"blank?(null)",'blank?("\n")','blank?(" ")','blank?(".")']}}},bt={"|>":{evaluate:([e,t],r,n,{executeFunction:o})=>(L(t,r),o(t,[e],n,r)),arity:ae(2),docs:{category:"functional",returns:{type:"any"},args:{a:{type:"any"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Takes a value $a and a function $b, and returns the result of applying $b to $a.",seeAlso:["apply","comp"],examples:["\n1 |> inc |> inc","range(10)\n |> map(_, -> $ ^ 2) // [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]\n |> filter(_, odd?) // [1, 9, 25, 49, 81]\n |> reduce(_, +, 0) // 165\n |> sqrt // 12.84523257866513\n |> round(_, 2)"]}},apply:{evaluate:([e,...t],r,n,{executeFunction:o})=>{L(e,r);const a=t[t.length-1];we(a,r);return o(e,[...t.slice(0,-1),...a],n,r)},arity:{min:2},docs:{category:"functional",returns:{type:"any"},args:{a:{type:"function"},b:{type:"array"},fun:{type:"function"},args:{type:"array"}},variants:[{argumentNames:["fun","args"]}],description:"Call supplied function $fun with specified arguments $args.",seeAlso:["|>"],examples:["\napply(+, [1, 2, 3])","\napply(\n (x, y) -> sqrt(x ^ 2 + y ^ 2),\n [3, 4]\n)","\n(x, y) -> sqrt(x ^ 2 + y ^ 2) apply [3, 4]"]}},identity:{evaluate:([e])=>pe(e),arity:ae(1),docs:{category:"functional",returns:{type:"any"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns $x.",seeAlso:["constantly","functional.fnull"],examples:["identity(1)",'identity("Albert")',"identity({ a: 1 })","identity(null)"]}},comp:{evaluate:(e,t)=>(e.forEach(e=>L(e,t)),{[u]:!0,sourceCodeInfo:t,functionType:"Comp",params:e,arity:e.length>0?re(e.at(-1)):{min:1,max:1}}),arity:{},docs:{category:"functional",returns:{type:"function"},args:{a:{type:"function"},b:{type:"function"},fns:{type:"function",rest:!0}},variants:[{argumentNames:["fns"]}],description:"Takes a variable number of functions and returns a function that is the composition of those.\n\n The returned function takes a variable number of arguments,\n applies the rightmost function to the args,\n the next function (right-to-left) to the result, etc.",seeAlso:["|>","functional.juxt","functional.complement"],examples:["\nlet negative-quotient = comp(-, /);\nnegative-quotient(9, 3)",'\nlet x = { bar: { foo: 42 } };\ncomp("foo", "bar")(x)']}},constantly:{evaluate:([e],t)=>({[u]:!0,sourceCodeInfo:t,functionType:"Constantly",value:pe(e),arity:{}}),arity:ae(1),docs:{category:"functional",returns:{type:"function"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns a function that takes any number of arguments and always returns $x.",seeAlso:["identity","functional.fnull"],examples:["\nlet always-true = constantly(true);\nalways-true(9, 3)"]}}};function xt(e){return xe(`\n ${e.title}\n\n ${e.description.replace(/`(.+?)`/g,"$1").replace(/\$(\w+)/g,"$1").replace(/\*\*\*(.+)\*\*\*/g,"$1").replace(/\*\*(.+)\*\*/g,"$1")}\n\n Signature:\n ${function({title:e,variants:t,args:r,returns:n,_isOperator:o}){const a=t.map(t=>`${` ${e}(${t.argumentNames.map(e=>{let t="";return r[e].rest&&(t+="..."),t+=e,t}).join(", ")})`} -> ${wt(n)}`),i=o?["","Operator:",` a ${e} b -> ${wt(n)}`]:[];return[...a,...i]}(e).join("\n ")}\n\n Arguments:\n ${function(e){return Object.entries(e.args).map(([e,t])=>`${e}: ${wt(t)}`)}(e).join("\n ")}\n\n Examples:\n${e.examples.map(e=>xe(e,4)).join("\n\n")}`)}function wt(e){const t=e.type,r=(Array.isArray(t)?t:[t]).join(" | ");return e.array||e.rest?`Array<${r}>`:r}function kt(e){return{doc:{evaluate:([t],r)=>{if(b(e),L(t,r),!w(t))return"";if("Builtin"===t.functionType){const r=e[t.name];return r?xt(r):""}return"UserDefined"===t.functionType||"NativeJsFunction"===t.functionType?t.docString:""},arity:ae(1),docs:{category:"meta",returns:{type:"string"},args:{fun:{type:"function"}},variants:[{argumentNames:["fun"]}],description:"Returns documentation string of the $fun.",seeAlso:["arity"],examples:["doc(+)",'\nlet add = (x, y) -> do\n """\n Adds two numbers.\n Args:\n x: First number.\n y: Second number.\n Returns:\n Sum of x and y.\n """;\n x + y;\nend;\n\ndoc(add)']}},arity:{evaluate:([e],t)=>(L(e,t),w(e)?e.arity:ae(1)),arity:ae(1),docs:{category:"meta",returns:{type:"object"},args:{fun:{type:"function"}},variants:[{argumentNames:["fun"]}],description:"Returns arity of the $fun. The arity is an object with the properties: `min` and `max`. If the function has fixed arity, `min` and `max` are equal to the number of required parameters. If no restrictions apply, empty object is returned.",seeAlso:["doc"],examples:["arity(+)","arity(defined?)","\nlet add = (x, y = 0) -> do\n x + y;\nend;\n\narity(add)","\nlet foo = (k, ...x) -> do\n k + x;\nend;\n arity(foo)"]}}}}const qt={sum:{evaluate:([e],t)=>(Ze(e,t),e.reduce((e,t)=>e+t,0)),arity:ae(1),docs:{category:"vector",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to sum."}},variants:[{argumentNames:["vector"]}],description:"Returns the **sum** of all elements in the `vector`. Returns `0` for an empty vector.",seeAlso:["prod","mean","median","vector.moving-sum","vector.centered-moving-sum","vector.running-sum","vector.cumsum"],examples:["sum([1, 2, 3, 4, 5])","sum([1, -2, 3])","sum([])"]}},prod:{evaluate:([e],t)=>(Ze(e,t),e.reduce((e,t)=>e*t,1)),arity:ae(1),docs:{category:"vector",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to multiply."}},variants:[{argumentNames:["vector"]}],description:"Returns the **product** of all elements in the `vector`. Returns `1` for an empty vector.",seeAlso:["sum","mean","median","vector.moving-prod","vector.centered-moving-prod","vector.running-prod","vector.cumprod"],examples:["prod([1, 2, 3, 4, 5])","prod([1, -2, 3])","prod([])"]}},mean:{evaluate:([e],t)=>(tt(e,t),e.reduce((e,t)=>e+t,0)/e.length),arity:ae(1),docs:{category:"vector",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to calculate the mean of."}},variants:[{argumentNames:["vector"]}],description:"Returns the arithmetic **mean** of all elements in the `vector`. Throws for an empty vector.",seeAlso:["median","sum","prod","vector.moving-mean","vector.centered-moving-mean","vector.running-mean","vector.geometric-mean","vector.harmonic-mean","vector.rms","vector.mode"],examples:["mean([1, 2, 3, 4, 5])","mean([1, -2, 3])"]}},median:{evaluate:([e],t)=>(tt(e,t),function(e){const t=[...e].sort((e,t)=>e-t),r=Math.floor(t.length/2);return t.length%2==0?(t[r-1]+t[r])/2:t[r]}(e)),arity:ae(1),docs:{category:"vector",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to calculate the median of."}},variants:[{argumentNames:["vector"]}],description:"Returns the **median** of all elements in the `vector`. For even-length vectors, returns the average of the two middle values. Throws for an empty vector.",seeAlso:["mean","sum","prod","vector.moving-median","vector.centered-moving-median","vector.running-median","vector.mode","vector.quartiles","vector.percentile","vector.iqr","vector.medad"],examples:["median([1, 2, 3, 4, 5])","median([1, 2, 3, 4])","median([3, 1, 4, 1, 5])"]}}},At={};const Nt={...Z,...se,...De,...We,...Ge,...ut,...kt(At),...gt,...ht,...dt,...yt,...ft,...bt,...qt};Object.entries(Nt).forEach(([e,t])=>{t.name=e});const $t={...Nt},Tt={},zt=[];Object.entries($t).forEach(([e,t],r)=>{Tt[e]=r,zt.push(t)});const St={arity:{},docs:{category:"special-expression",returns:{type:"any"},args:{a:{type:"any"},b:{type:"any"},c:{type:"any",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"\nComputes logical `and`. Evaluation of expressions starts from left.\nAs soon as an `expression` evaluates to a falsy value, the result is returned.\n\nIf all expressions evaluate to truthy values, the value of the last expression is returned.",examples:["true && 1","&&(1, 1)",'&&(3 > 2, "string")','&&(3 < 2, "string")',"&&(true, true, true, true)","&&(true, true, 0, true)"]},evaluate:(e,t,{evaluateNode:r})=>Te(e[1][1],(e,n)=>e?r(n,t):e,!0),evaluateAsNormalExpression:(e,t)=>{let r=!0;for(const n of e)if(r=M(n,t),!r)break;return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},Et={arity:{},docs:{category:"special-expression",customVariants:["cond cond-branch cond-branch ... end"],details:[["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."]],description:"Used for branching. `cond-branches` are tested sequentially from the top. If no branch is tested truthy, `null` is returned.",examples:['\ncond\n case false then write!("FALSE")\n case true then write!("TRUE")\nend','\ncond\n case false then write!("FALSE")\n case null then write!("null")\nend ?? write!("TRUE")','\ncond\n case false then write!("FALSE")\n case null then write!("null")\nend ?? write!("TRUE")']},evaluate:(e,t,{evaluateNode:r})=>{const n=e[1][1];return function e(o){if(o>=n.length)return null;const[a,i]=n[o];return Ae(r(a,t),n=>n?r(i,t):e(o+1))}(0)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1].flat(),t,n,o)};function jt(e){return"object"==typeof e&&null!==e&&"fn"in e&&"function"==typeof e.fn}const Mt=11,Ct=12,Pt=13,Rt=14,It=15,Ot=16;function Ft(e,t){if(e[0]===Pt)Object.values(e[1][0]).forEach(e=>{e[1][1]&&t(e[1][1]),Ft(e,t)});else if(e[0]===Rt)for(let r=0;r<e[1][0].length;r+=1){const n=e[1][0][r]??null;null!==n&&(n[1][1]&&t(n[1][1]),Ft(n,t))}}function Ut(e,t,r){const n=e[2],o={};return Ae(Dt(e,t,r,n,o),()=>o)}function Dt(e,t,n,o,a){if(e[0]===Pt){!function(e,t){if(!x(e))throw new r(`Expected UnknownRecord, got ${d(e)}.`,y(e,t))}(t,o);const i=new Set;let s;return Ae(Se(Object.entries(e[1][0]),([e,r])=>{if(r[0]===Ct)return void(s=r);i.add(e);const c=t[e];return Ae(void 0!==c?c:r[1][1]?n(r[1][1]):null,e=>{const t=e??null;return C(t,o),Dt(r,t,n,o,a)})}),()=>{if(s){const e=Object.entries(t).filter(([e])=>!i.has(e)).reduce((e,[t,r])=>(e[t]=M(r),e),{});a[s[1][0]]=e}})}if(e[0]===Rt){let r=null;we(t,o);const i=[];for(let t=0;t<e[1][0].length;t+=1){const n=e[1][0][t]??null;if(null!==n){if(n[0]===Ct){r=t;break}i.push({element:n,index:t})}}return Ae(Se(i,({element:e,index:r})=>{const i=t[r];return Ae(void 0!==i?i:e[1][1]?n(e[1][1]):null,t=>{const r=t??null;return C(r,o),Dt(e,r,n,o,a)})}),()=>{if(null!==r){const n=t.slice(r),o=e[1][0][r];a[o[1][0]]=n}})}e[0]===Ct?a[e[1][0]]=M(t):a[e[1][0][1]]=M(t)}function Wt(e){const t={};return Gt(e,t),t}function Gt(e,t){if(null!==e)if(e[0]===Rt)for(const r of e[1][0])Gt(r,t);else if(e[0]===Pt)for(const r of Object.values(e[1][0]))Gt(r,t);else if(e[0]===Ct){if(t[e[1][0]])throw new r(`Duplicate binding name: ${e[1][0]}`,e[2]);t[e[1][0]]=!0}else if(e[0]===Mt){if(t[e[1][0][1]])throw new r(`Duplicate binding name: ${e[1][0]}`,e[2]);t[e[1][0][1]]=!0}}function Vt(e,t,r){const n={};return Ae(Bt(e,t,r,n),e=>e?n:null)}function Bt(e,t,r,n){if(e[0]===Ot)return!0;if(e[0]===It){const n=e[1][0];return Ae(r(n),e=>me(t,e))}if(e[0]===Mt){const o=e[1][0],a=e[1][1];if(null==t){if(a)return Ae(r(a),e=>(n[o[1]]=M(e),!0));n[o[1]]=t??null}else n[o[1]]=M(t);return!0}if(e[0]===Pt){if(!x(t))return!1;const o=new Set;let a;const i=Object.entries(e[1][0]);let s=!0;for(const[e,c]of i)s=Ae(s,i=>{if(!i)return!1;if(c[0]===Ct)return a=c,!0;o.add(e);const s=t[e];if(void 0===s&&c[0]===It)return Ae(r(c[1][0]),e=>me(void 0,e));return Ae(void 0!==s?s:c[1]&&c[1][1]?r(c[1][1]):null,e=>Bt(c,e??null,r,n))});return Ae(s,e=>{if(!e)return!1;if(a){const e=Object.entries(t).filter(([e])=>!o.has(e)).reduce((e,[t,r])=>(e[t]=M(r),e),{});n[a[1][0]]=e}return!0})}{const o=e;if(!Array.isArray(t))return!1;const a=o[1][0];let i=null;for(let e=0;e<a.length;e+=1){const t=a[e];if(null!==t&&t[0]===Ct){i=e;break}}if(null===i&&t.length!==a.length)return!1;if(null!==i&&t.length<i)return!1;let s=!0;for(let e=0;e<a.length;e+=1){const o=a[e];if(null===o)continue;if(o[0]===Ct){n[o[1][0]]=t.slice(e);break}const i=o;s=Ae(s,o=>!!o&&Bt(i,M(t[e]),r,n))}return s}}const Lt={arity:{},docs:{category:"special-expression",customVariants:["match value match-branch match-branch ... end"],details:[["value","any","The value to match against patterns."],["match-branch","case pattern [when guard] then body","A branch of the match expression."],["pattern","pattern","A pattern to match: literal, variable, array destructuring, object destructuring, or wildcard (_)."],["guard","expression","An optional guard expression that must be truthy for the match to succeed."],["body","expressions","The expressions to evaluate if the pattern matches."]],description:"Pattern matching expression. Matches `value` against each `pattern` sequentially. If a pattern matches (and the optional `when` guard is truthy), the corresponding `body` is evaluated and its result returned. Bound variables from the pattern are available in the guard and body. If no pattern matches, `null` is returned.",examples:['\nmatch 1\n case 1 then "One"\n case 2 then "Two"\nend','\nmatch [1, 2, 3]\n case [x] then "one element"\n case [x, y] then "two elements"\n case [x, ...xs] then "first: " ++ str(x) ++ " rest: " ++ str(xs)\nend','\nmatch { type: "click", x: 10, y: 20 }\n case { type: "click", x, y } then "Click at " ++ str(x) ++ ", " ++ str(y)\n case { type: "keydown", key } then "Key: " ++ key\n case _ then "unknown event"\nend','\nmatch { role: "admin", name: "Alice" }\n case { role: "admin", name } then "Admin: " ++ name\n case { role, name } when role == "user" then "User: " ++ name\n case _ then "Unknown role"\nend']},evaluate:(e,t,{evaluateNode:r})=>{const[,n,o]=e[1];return Ae(r(n,t),e=>function n(a){if(a>=o.length)return null;const[i,s,c]=o[a];return Ae(Vt(i,e,e=>r(e,t)),e=>{if(null===e)return n(a+1);const o={};for(const[t,r]of Object.entries(e))o[t]={value:r};const i=t.create(o);return c?Ae(r(c,i),e=>e?r(s,i):n(a+1)):r(s,i)})}(0))},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>{const a=new Set;r([e[1][1]],t,n,o).forEach(e=>a.add(e));for(const[i,s,c]of e[1][2]){const e={};Object.assign(e,Wt(i));const l=t.create(e);c&&r([c],l,n,o).forEach(e=>a.add(e)),r([s],l,n,o).forEach(e=>a.add(e))}return a}};function _t(e){const t=e[0];return s.UserDefinedSymbol===t||s.NormalBuiltinSymbol===t||s.SpecialBuiltinSymbol===t}function Kt(e){return s.UserDefinedSymbol===e[0]}function Jt(e,t){return function(e,t){if(!Kt(e))throw v("UserDefinedSymbolNode",e,t)}(e,t),e}function Yt(e){return s.NormalBuiltinSymbol===e[0]}function Ht(e){return s.SpecialBuiltinSymbol===e[0]}function Xt(e){return!!function(e){return e[0]===s.NormalExpression}(e)&&_t(e[1][0])}function Zt(e){return e[0]===s.Spread}const Qt={category:"special-expression",returns:{type:"boolean"},args:{symbol:{type:"any"}},variants:[{argumentNames:["symbol"]}],description:"Returns `true` if `symbol` is defined, `false` otherwise.\n\nBuilt-in symbols are always considered defined. For user-defined symbols, checks if the symbol exists in the current scope.",examples:["let x = 42; defined?(x)","defined?(x)","defined?(+)"]},er={arity:ae(1),docs:Qt,evaluate:(e,t)=>{const r=e[1][1];if(function(e,t){if(!_t(e))throw v("SymbolNode",e,t)}(r),!Kt(r))return!0;return null!==t.lookUp(r)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r([e[1][1]],t,n,o)},tr={arity:{},docs:{category:"special-expression",customVariants:["do body end"],details:[["body","expressions","The expressions to evaluate."]],description:"Evaluates `body`. Resulting value is the value of the last expression.",examples:["\ndo\n let a = 1 + 2 + 3 + 4;\n let b = -> $ * ( $ + 1 );\n b(a)\nend"]},evaluate:(e,t,{evaluateNode:r})=>{const n=t.create({});return Te(e[1][1],(e,t)=>r(t,n),null)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t.create({}),n,o)},rr={arity:{},evaluate:(e,t,{builtin:r,getUndefinedSymbols:n,evaluateNode:o})=>{const a=e[1][1],i=e[1][2],s=function(e,t,r,n,o){const a={},i=e[0].reduce((e,t)=>(Object.keys(Wt(t)).forEach(t=>{e[t]={value:null}}),e),{}),s=n(e[1],t.new(i),r,o);s.forEach(e=>{const r=t.getValue(e);j(r)&&(a[e]={value:r})});const c=[e[0],e[1],a];return c}(a,t,r,n,o),c=s[0].filter(e=>e[0]!==Ct&&void 0===e[1][1]).length,l={min:c>0?c:void 0,max:s[0].some(e=>e[0]===Ct)?void 0:s[0].length};return{[u]:!0,sourceCodeInfo:e[2],functionType:"UserDefined",name:void 0,evaluatedfunction:s,arity:l,docString:i}},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>function(e,t,r,n,o){const a=new Set,i={self:{value:null}};e[0].forEach(e=>{Object.assign(i,Wt(e)),Ft(e,e=>{ye(a,r([e],t,n,o))})});const s=t.create(i),c=r(e[1],s,n,o);return ye(a,c),a}(e[1][1],t,r,n,o)};const nr={arity:{min:2,max:3},docs:{category:"special-expression",customVariants:["if test then true-expr else false-expr","if test then true-expr"],details:[["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."]],description:"Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is truthy. If $test is falsy `false-expr` is executed, if no `false-expr` exists, `null` is returned.",examples:['\nif true then\n write!("TRUE")\nelse\n write!("FALSE")\nend','if false then write!("TRUE") else write!("FALSE") end','if true then write!("TRUE") end','if false then write!("TRUE") end']},evaluate:(e,t,{evaluateNode:r})=>{const[n,o,a]=e[1][1];return Ae(r(n,t),e=>e?r(o,t):a?r(a,t):null)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1].filter(e=>!!e),t,n,o)},or={arity:{},docs:{category:"special-expression",customVariants:["unless test then true-expr else false-expr end","unless test true-expr end"],details:[["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."]],description:"Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is falsy. If $test is truthy `false-expr` is executed, if no `false-expr` exists, `null` is returned.",examples:['\nunless true then\n write!("TRUE")\nelse\n write!("FALSE")\nend','unless false then write!("TRUE") else write!("FALSE") end','unless true then write!("TRUE") end','unless false then write!("TRUE") end']},evaluate:(e,t,{evaluateNode:r})=>{const[n,o,a]=e[1][1];return Ae(r(n,t),e=>e?a?r(a,t):null:r(o,t))},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1].filter(e=>!!e),t,n,o)},ar={category:"special-expression",customVariants:["let s = value;"],details:[["s","symbol","The name of the variable to bind."],["value","any","The value to bind to the variable."]],description:"\n Binds local variables s to `value`. `value` can be any expression. The scope of the variables is the body of the let expression.",examples:['\nlet a = 1 + 2 + 3 + 4;\nlet b = -> $ * ( $ + 1 );\nwrite!("a", a, "b", b)']},ir={arity:ae(0),docs:ar,evaluate:(e,t,{evaluateNode:r})=>{const n=e[1][1],o=n[1][0],a=n[1][1];return Ae(r(a,t),e=>Ae(Ut(o,e,e=>r(e,t)),r=>(t.addValues(r,o[2]),e)))},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>{const a=e[1][1],i=a[1][0],s=a[1][1],c=r([s],t,n,o);return Ft(i,e=>{ye(c,r([e],t,n,o))}),t.addValues(Wt(i),i[2]),c}},sr={arity:{},docs:{category:"special-expression",customVariants:["loop (bindings) -> body"],details:[["bindings","binding pairs","Comma-separated bindings with initial values, e.g. `n = 10, acc = 0`."],["body","expression","The expression to evaluate repeatedly. Use `recur` to loop back with new values."]],description:"Creates a loop with initial bindings. Use `recur` inside the body to jump back to the loop head with new binding values.\n\nIf `recur` is not called, the loop terminates and returns the value of the body expression.",examples:["loop (n = 10, acc = 0) -> do\n if n == 0 then\n acc\n else\n recur(n - 1, acc + n)\n end\nend","loop (n = 5, acc = 1) -> do\n if n <= 1 then\n acc\n else\n recur(n - 1, acc * n)\n end\nend"]},evaluate:(e,n,{evaluateNode:o})=>{const a=e[1][1],i=Te(a,(e,t)=>Ae(o(t[1][1],n.create(e)),r=>Ae(Ut(t[1][0],r,e=>o(e,n)),t=>(Object.entries(t).forEach(([t,r])=>{e[t]={value:r}}),e))),{});return Ae(i,i=>{const s=n.create(i),c=e[1][2];function l(t){if(t.length!==a.length)throw new r(`recur expected ${a.length} parameters, got ${d(t.length)}`,e[2]);return Ae(Se(a,(e,r)=>Ae(Ut(e[1][0],M(t[r]),e=>o(e,n)),e=>{for(const[t,r]of Object.entries(e))i[t].value=r})),()=>m())}function m(){return je(()=>o(c,s),e=>{if(e instanceof t)return l(e.params);throw e})}for(;;)try{const e=o(c,s);return e instanceof Promise?e.catch(e=>{if(e instanceof t)return l(e.params);throw e}):e}catch(s){if(s instanceof t){const t=s.params;if(t.length!==a.length)throw new r(`recur expected ${a.length} parameters, got ${d(t.length)}`,e[2]);for(let e=0;e<a.length;e+=1){const r=Ut(a[e][1][0],M(t[e]),e=>o(e,n));if(r instanceof Promise)return r.then(r=>{for(const[e,t]of Object.entries(r))i[e].value=t;return Ae(Se(a.slice(e+1),(r,a)=>Ae(Ut(r[1][0],M(t[e+1+a]),e=>o(e,n)),e=>{for(const[t,r]of Object.entries(e))i[t].value=r})),()=>m())});for(const[e,t]of Object.entries(r))i[e].value=t}continue}throw s}})},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>{const a=e[1][1],i=a.reduce((e,t)=>{const r=Wt(t[1][0]);return Object.keys(r).forEach(t=>{e[t]={value:!0}}),e},{});return de(r(a.map(e=>e[1][1]),t,n,o),r([e[1][2]],t.create(i),n,o))}};function cr(e,t,r,n){const o=t[2],[,a,i]=t[1],s=[],c=a.map(()=>0);return function t(){const l={},m=r.create(l);return Ae(function e(t){if(t>=a.length)return"continue";const[r,i,s,u]=a[t],[p,g]=r[1];return Ae(n(g,m),r=>{const a=D(r,o),g=P(a)?a:Object.entries(a);if(0===g.length)return"abort";const h=f(c[t],o);if(h>=g.length)return 0===t?"abort":(c[t]=0,c[t-1]=f(c[t-1],o)+1,"skip");const d=M(g[h],o);return Ae(Ut(p,d,e=>n(e,m)),r=>(Object.entries(r).forEach(([e,t])=>{l[e]={value:t}}),Ae(i.length>0?function(e,t,r,n){let o;for(const a of e)o=Ae(o,()=>{const[e,o]=a[1];return Ae(n(o,r),o=>Ae(Ut(e,o,e=>n(e,r)),e=>{Object.entries(e).forEach(([e,r])=>{t[e]={value:r}})}))});return o}(i,l,m,n):void 0,()=>s?Ae(n(s,m),r=>r?u?Ae(n(u,m),r=>r?e(t+1):(c[t]=Number.POSITIVE_INFINITY,"skip")):e(t+1):(c[t]=f(c[t],o)+1,"skip")):u?Ae(n(u,m),r=>r?e(t+1):(c[t]=Number.POSITIVE_INFINITY,"skip")):e(t+1))))})}(0),r=>"abort"===r?e?s:null:"skip"===r?t():Ae(n(i,m),r=>(e&&s.push(r),c.length>0&&(c[c.length-1]+=1),t())))}()}function lr(e,t,r,n,o){const a=new Set,i={},[,s,c]=e[1];return s.forEach(e=>{const[s,c,l,m]=e,[u,p]=s[1];r([p],t.create(i),n,o).forEach(e=>a.add(e)),Object.assign(i,Wt(u)),c&&c.forEach(e=>{const[s,c]=e[1];r([c],t.create(i),n,o).forEach(e=>a.add(e)),Object.assign(i,Wt(s))}),l&&r([l],t.create(i),n,o).forEach(e=>a.add(e)),m&&r([m],t.create(i),n,o).forEach(e=>a.add(e))}),r([c],t.create(i),n,o).forEach(e=>a.add(e)),a}const mr={category:"special-expression",customVariants:["for (...binding) -> body"],details:[["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."]],returns:{type:"any",array:!0},description:"Iterates over `bindings`, evaluates `body` for each `binding` and returns an `array` of results.",examples:["\nfor (i in [1, 2, 3]) -> i * 2\n ","\nfor (\n i in range(10) let ii = i ^ 2 while ii < 40 when ii % 3 == 0,\n j in range(10) when j % 2 == 1\n) -> ii + j\n "]},ur={arity:ae(1),docs:mr,evaluate:(e,t,r)=>cr(!0,e,t,r.evaluateNode),getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>lr(e,t,r,n,o)},pr={category:"special-expression",customVariants:["doseq (...binding) -> body"],details:[["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."]],returns:{type:"null"},description:"Iterates over `bindings`, evaluates `body` for each `binding` and returns `null`. This is useful for side effects.",examples:["\ndoseq (i in [1, 2, 3]) -> write!(i * 2)\n "]},gr={arity:ae(1),docs:pr,evaluate:(e,t,r)=>Ae(cr(!1,e,t,r.evaluateNode),()=>null),getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>lr(e,t,r,n,o)},hr={arity:{},docs:{category:"special-expression",returns:{type:"boolean"},args:{a:{type:"any"},b:{type:"any"},c:{type:"any",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"\n Computes logical `or`. Evaluation of expressions evaluation starts from left.\n As soon as a `expression` evaluates to a truthy value, the result is returned.\n\n If all expressions evaluate to falsy values, the value of the last expression is returned.",examples:["false || 1","||(1, 1)",'||(3 > 2, "string")','||(3 < 2, "string")',"||(false, false, false, true)","||(1, 2, 3, 4)"]},evaluate:(e,t,{evaluateNode:r})=>Te(e[1][1],(e,n)=>e||r(n,t),!1),evaluateAsNormalExpression:(e,t)=>{let r=!1;for(const n of e)if(r=M(n,t),r)break;return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},dr={arity:{min:1},docs:{category:"special-expression",returns:{type:"any"},args:{a:{type:"any"},b:{type:"any"},c:{type:"any",rest:!0}},variants:[{argumentNames:["a"]},{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Nullish coalescing operator. Returns the first non-`null` value.\n\nEvaluation is short-circuited — as soon as a non-`null` value is found, the remaining expressions are not evaluated.\n\nIf all values are `null`, returns `null`.\n\nAlso works with undefined symbols — if a symbol is undefined, it is treated as `null`.",examples:["1 ?? 2","null ?? 2","??(null)",'??(null, "default")','??(1, "default")','false ?? "default"',"??(null, null, 3)"]},evaluate:(e,t,{evaluateNode:r})=>{const n=Symbol("qq-sentinel");return Ae(Te(e[1][1],(e,o)=>e!==n?e:Kt(o)&&null===t.lookUp(o)?n:Ae(r(o,t),e=>null!==e?e:n),n),e=>e===n?null:e)},evaluateAsNormalExpression:(e,t)=>{for(const r of e){const e=M(r,t);if(null!==e)return e}return null},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},yr={arity:{},docs:{category:"special-expression",customVariants:["recur(...recur-args)"],description:"Recursevly calls enclosing function or loop with its evaluated `recur-args`.",examples:["\nlet foo = (n) -> do\n write!(n);\n if not(zero?(n)) then\n recur(n - 1)\n end\nend;\nfoo(3)","\n(n -> do\n write!(n);\n if not(zero?(n)) then\n recur(n - 1)\n end\nend)(3)","\nloop (n = 3) -> do\n write!(n);\n if not(zero?(n)) then\n recur(n - 1)\n end\nend"]},evaluate:(e,r,{evaluateNode:n})=>Ae(Ne(e[1][1],e=>n(e,r)),e=>{throw new t(e)}),evaluateAsNormalExpression:e=>{throw new t(e)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},vr={arity:ae(1),docs:{category:"special-expression",returns:{type:"never"},args:{expr:{type:"any"}},variants:[{argumentNames:["expr"]}],description:"Throws `UserDefinedError` with message set to $expr evaluated. $expr must evaluate to a string.",examples:['try throw("You shall not pass!") catch(error) "Error: " ++ error.message end','try throw(slice("You shall not pass!", 0, 3)) catch(error) "Error: " ++ error.message end']},evaluate:(e,t,{evaluateNode:r})=>Ae(r(e[1][1],t),t=>{const r=J(t,e[2],{nonEmpty:!0});throw new n(r,e[2])}),evaluateAsNormalExpression:(e,t)=>{const r=J(e[0],t,{nonEmpty:!0});throw new n(r,void 0)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r([e[1][1]],t,n,o)},fr={arity:{},docs:{category:"special-expression",customVariants:["try { try-body } catch { catch-body }","try { try-body } catch(error) { catch-body }"],details:[["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."]],description:"Executes `try-body`. If that throws, the `catch-body` gets executed. See examples for details.",examples:['\ntry\n 2 / 4\ncatch\n "Oops!"\nend','\ntry\n foo()\ncatch(error)\n "Error: " ++ error.message\nend',"\ntry\n foo()\ncatch\n 42\nend"]},evaluate:(e,t,{evaluateNode:r})=>{const[,n,o,a]=e[1];return je(()=>r(n,t),e=>{const n=o?{[o[1]]:{value:e}}:{};return r(a,t.create(n))})},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>{const[,a,i,s]=e[1],c=r([a],t,n,o),l=i?{[i[1]]:{value:!0}}:{};return de(c,r([s],t.create(l),n,o))}},br={arity:{},docs:{category:"special-expression",returns:{type:"any",array:!0},args:{values:{type:"any",rest:!0}},variants:[{argumentNames:["values"]}],description:"Makes new array from $values.",examples:["array(1, 2, 3)","array(array(null, false, true))","[]","[1, 2, 3]","[1, 2, ...[3, 4, 5], 6]","[[null, false, true]]","[1, 2, 3][1]"],hideOperatorForm:!0},evaluate:(e,t,{evaluateNode:n})=>{const o=[];return Ae(Se(e[1][1],e=>Zt(e)?Ae(n(e[1],t),t=>{if(!Array.isArray(t))throw new r("Spread value is not an array",e[2]);o.push(...t)}):Ae(n(e,t),e=>{o.push(e)})),()=>o)},evaluateAsNormalExpression:(e,t)=>{const r=[];for(const n of e)r.push(M(n,t));return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},xr={arity:{},docs:{category:"special-expression",returns:{type:"object"},args:{kvps:{type:"any",rest:!0,description:"key - value pairs, where key is a string"}},variants:[{argumentNames:["kvps"]}],description:"Constructs a new object. Object members are created from the $kvps key-value pairs. Requires an even number of arguments.",examples:["object()",'\nlet default = {\n type: "Person",\n name: "John Doe",\n age: 42\n};\n\n{\n ...default,\n name: "Lisa"\n}','object("x", 10, "y", true, "z", "A string")',"{}","{ a: 1, b: 2 }"],hideOperatorForm:!0},evaluate:(e,t,{evaluateNode:n})=>{const o={},a=e[1][1];return function e(i){if(i>=a.length)return o;const s=a[i];if(Zt(s))return Ae(n(s[1],t),t=>{if(!x(t))throw new r("Spread value is not an object",s[2]);return Object.assign(o,t),e(i+1)});{const c=a[i+1];if(void 0===c)throw new r("Missing value for key",s[2]);return Ae(n(s,t),r=>Ae(n(c,t),t=>(K(r,s[2]),o[r]=t,e(i+2))))}}(0)},evaluateAsNormalExpression:(e,t)=>{const r={};for(let n=0;n<e.length;n+=2){const o=e[n],a=e[n+1];K(o,t),r[o]=a??null}return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},wr={arity:ae(1),docs:{category:"special-expression",description:"Imports all functions from a module as an object. Use destructuring to pick specific functions.",customVariants:["import(module-name)"],returns:{type:"object"},examples:["let v = import(vector); v.stdev([1, 2, 3, 4])","let { linspace } = import(vector); linspace(0, 10, 5)","let g = import(grid); g.row([[1, 2], [3, 4]], 0)"]},evaluate:(e,t)=>{const n=e[1][1],o=e[2],a=t.getValueModule(n);if(a.found)return a.value;const i=t.getModule(n);if(!i)throw new r(`Unknown module: '${n}'`,o);const s={};for(const[e,t]of Object.entries(i.functions))s[e]={[u]:!0,sourceCodeInfo:o,functionType:"Module",moduleName:n,functionName:e,arity:t.arity};return s},getUndefinedSymbols:()=>new Set},kr={"??":0,"&&":1,"||":2,array:3,cond:4,"defined?":5,block:6,doseq:7,"0_lambda":8,for:9,if:10,let:11,loop:12,object:13,recur:14,match:15,throw:16,try:17,unless:18,import:19},qr=[dr,St,hr,br,Et,er,tr,gr,rr,ur,nr,ir,sr,xr,yr,Lt,vr,fr,or,wr],Ar={normalExpressions:$t,specialExpressions:qr,allNormalExpressions:zt},Nr=Object.keys($t),$r=Object.keys(kr),Tr=["^","*","/","%","+","-","<<",">>",">>>","++","<","<=","≤",">",">=","≥","==","!=","!=","&","xor","|","&&","||","??","|>"],zr=[...Tr,"?",":","->","...",".",",","=",":",";"],Sr=new Set(["comment","cond","defined?","block","doseq","if","let","loop","recur","throw","try","unless","while"]);function Er(e){return!Sr.has(e)}const jr=new Set(Tr);function Mr(e){return jr.has(e)}const Cr=new Set(zr);function Pr(e){return Cr.has(e)}const Rr=["number","string","object","array","vector","matrix","grid","boolean","function","integer","any","null","collection","sequence","regexp","never"];function Ir(e){return Rr.includes(e)}function Or(e){return"args"in e&&"variants"in e}const Fr={"assert!=":{category:"assertion",description:"If $a is the same as $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert!= } = import(assertion);\ntry assert!=(0, 0, "Expected different values") catch (e) e.message end',"let { assert!= } = import(assertion);\ntry assert!=(0, 0) catch (e) e.message end","let { assert!= } = import(assertion);\ntry 0 assert!= 0 catch (e) e.message end","let { assert!= } = import(assertion);\ntry assert!=(0, 1) catch (e) e.message end"],seeAlso:["assertion.assert="],hideOperatorForm:!0},"assert=":{category:"assertion",description:"If $a is not structural equal to $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert= } = import(assertion);\ntry assert=({ "a": 1 }, { "a": 2 }, "Expected equal values") catch (e) e.message end','let { assert= } = import(assertion);\ntry assert=({ "a": 1 }, { "a": 2 }) catch (e) e.message end','let { assert= } = import(assertion);\ntry assert=({ "a": 1 }, { "a": 1 }) catch (e) e.message end'],seeAlso:["assertion.assert!="],hideOperatorForm:!0},"assert-gt":{category:"assertion",description:"If $a is not greater than $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert-gt } = import(assertion);\ntry assert-gt(0, 1, "Expected greater value") catch (e) e.message end',"let { assert-gt } = import(assertion);\ntry assert-gt(0, 0) catch (e) e.message end","let { assert-gt } = import(assertion);\ntry assert-gt(1, 0) catch (e) e.message end"],seeAlso:["assertion.assert-lt","assertion.assert-gte","assertion.assert-lte"],hideOperatorForm:!0},"assert-lt":{category:"assertion",description:"If $a is not less than $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert-lt } = import(assertion);\ntry assert-lt(1, 0, "Expected smaller value value") catch (e) e.message end',"let { assert-lt } = import(assertion);\ntry assert-lt(1, 1) catch (e) e.message end","let { assert-lt } = import(assertion);\ntry assert-lt(0, 1) catch (e) e.message end"],seeAlso:["assertion.assert-gt","assertion.assert-lte","assertion.assert-gte"],hideOperatorForm:!0},"assert-gte":{category:"assertion",description:"If $a is less than $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert-gte } = import(assertion);\ntry assert-gte(0, 1, "Expected greater value") catch (e) e.message end',"let { assert-gte } = import(assertion);\ntry assert-gte(0, 1) catch (e) e.message end","let { assert-gte } = import(assertion);\ntry assert-gte(1, 1) catch (e) e.message end"],seeAlso:["assertion.assert-lte","assertion.assert-gt","assertion.assert-lt"],hideOperatorForm:!0},"assert-lte":{category:"assertion",description:"If $a is grater than $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert-lte } = import(assertion);\ntry assert-lte(1, 0, "Expected smaller value value") catch (e) e.message end',"let { assert-lte } = import(assertion);\ntry assert-lte(1, 0) catch (e) e.message end","let { assert-lte } = import(assertion);\ntry assert-lte(1, 1) catch (e) e.message end"],seeAlso:["assertion.assert-gte","assertion.assert-lt","assertion.assert-gt"],hideOperatorForm:!0},"assert-true":{category:"assertion",description:"If $value is not `true` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-true } = import(assertion);\ntry assert-true(false, "Expected true") catch (e) e.message end',"let { assert-true } = import(assertion);\ntry assert-true(false) catch (e) e.message end","let { assert-true } = import(assertion);\ntry assert-true(true) catch (e) e.message end"],seeAlso:["assertion.assert-false","assertion.assert-truthy","assertion.assert-falsy","assert","assertion.assert-boolean"],hideOperatorForm:!0},"assert-false":{category:"assertion",description:"If $value is not `false` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-false } = import(assertion);\ntry assert-false(true, "Expected false") catch (e) e.message end',"let { assert-false } = import(assertion);\ntry assert-false(true) catch (e) e.message end","let { assert-false } = import(assertion);\ntry assert-false(false) catch (e) e.message end"],seeAlso:["assertion.assert-true","assertion.assert-falsy","assertion.assert-truthy","assertion.assert-boolean"],hideOperatorForm:!0},"assert-truthy":{category:"assertion",description:"If $value is not `truthy` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-truthy } = import(assertion);\ntry assert-truthy(false, "Expected truthy") catch (e) e.message end',"let { assert-truthy } = import(assertion);\ntry assert-truthy(false) catch (e) e.message end","let { assert-truthy } = import(assertion);\ntry assert-truthy(0) catch (e) e.message end","let { assert-truthy } = import(assertion);\ntry assert-truthy(null) catch (e) e.message end",'let { assert-truthy } = import(assertion);\ntry assert-truthy("") catch (e) e.message end',"let { assert-truthy } = import(assertion);\ntry assert-truthy(true) catch (e) e.message end","let { assert-truthy } = import(assertion);\ntry assert-truthy(1) catch (e) e.message end",'let { assert-truthy } = import(assertion);\ntry assert-truthy("x") catch (e) e.message end',"let { assert-truthy } = import(assertion);\ntry assert-truthy([]) catch (e) e.message end","let { assert-truthy } = import(assertion);\ntry assert-truthy(nd) catch (e) e.message end"],seeAlso:["assertion.assert-falsy","assertion.assert-true","assertion.assert-false","assert","assertion.assert-null"],hideOperatorForm:!0},"assert-falsy":{category:"assertion",description:"If $value is not `falsy` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-falsy } = import(assertion);\ntry assert-falsy(true, "Expected falsy") catch (e) e.message end','let { assert-falsy } = import(assertion);\ntry assert-falsy("x") catch (e) e.message end',"let { assert-falsy } = import(assertion);\ntry assert-falsy([]) catch (e) e.message end","let { assert-falsy } = import(assertion);\ntry assert-falsy(nd) catch (e) e.message end","let { assert-falsy } = import(assertion);\ntry assert-falsy(1) catch (e) e.message end","let { assert-falsy } = import(assertion);\ntry assert-falsy(false) catch (e) e.message end","let { assert-falsy } = import(assertion);\ntry assert-falsy(0) catch (e) e.message end","let { assert-falsy } = import(assertion);\ntry assert-falsy(null) catch (e) e.message end",'let { assert-falsy } = import(assertion);\ntry assert-falsy("") catch (e) e.message end'],seeAlso:["assertion.assert-truthy","assertion.assert-false","assertion.assert-true","assertion.assert-null"],hideOperatorForm:!0},"assert-null":{category:"assertion",description:"If $value is not `null` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-null } = import(assertion);\ntry assert-null(null) catch (e) e.message end",'let { assert-null } = import(assertion);\ntry assert-null(true, "Expected null") catch (e) e.message end','let { assert-null } = import(assertion);\ntry assert-null("x") catch (e) e.message end',"let { assert-null } = import(assertion);\ntry assert-null([]) catch (e) e.message end","let { assert-null } = import(assertion);\ntry assert-null(nd) catch (e) e.message end","let { assert-null } = import(assertion);\ntry assert-null(1) catch (e) e.message end","let { assert-null } = import(assertion);\ntry assert-null(false) catch (e) e.message end","let { assert-null } = import(assertion);\ntry assert-null(0) catch (e) e.message end",'let { assert-null } = import(assertion);\ntry assert-null("") catch (e) e.message end'],seeAlso:["assertion.assert-truthy","assertion.assert-falsy"],hideOperatorForm:!0},"assert-throws":{category:"assertion",description:"If $fun does not throw, it throws `AssertionError`.",returns:{type:"null"},args:{fun:{type:"function"},message:{type:"string"}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","message"]}],examples:['let { assert-throws } = import(assertion);\nassert-throws(-> throw("Error"))','let { assert-throws } = import(assertion);\ntry assert-throws(-> identity("Error")) catch (e) e.message end'],seeAlso:["assertion.assert-throws-error","assertion.assert-not-throws"],hideOperatorForm:!0},"assert-throws-error":{category:"assertion",description:"If $fun does not throw $error-message, it throws `AssertionError`.",returns:{type:"null"},args:{fun:{type:"function"},"error-message":{type:"string"},message:{type:"string"}},variants:[{argumentNames:["value","error-message"]},{argumentNames:["value","error-message","message"]}],examples:['let { assert-throws-error } = import(assertion);\ntry assert-throws-error(-> throw("Error"), "Error") catch (e) e.message end','let { assert-throws-error } = import(assertion);\ntry assert-throws-error(-> identity("Error"), "Error") catch (e) e.message end'],seeAlso:["assertion.assert-throws","assertion.assert-not-throws"],hideOperatorForm:!0},"assert-not-throws":{category:"assertion",description:"If $fun throws, it throws `AssertionError`.",returns:{type:"null"},args:{fun:{type:"function"},message:{type:"string"}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","message"]}],examples:['let { assert-not-throws } = import(assertion);\ntry assert-not-throws(-> identity("Error")) catch (e) e.message end','let { assert-not-throws } = import(assertion);\ntry assert-not-throws(-> throw("Error")) catch (e) e.message end'],seeAlso:["assertion.assert-throws","assertion.assert-throws-error"],hideOperatorForm:!0},"assert-array":{category:"assertion",description:"If $value is not an `array` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-array } = import(assertion);\ntry assert-array([1, 2, 3]) catch (e) e.message end",'let { assert-array } = import(assertion);\ntry assert-array("string") catch (e) e.message end','let { assert-array } = import(assertion);\ntry assert-array(42, "Expected an array") catch (e) e.message end'],seeAlso:["assertion.assert-object","assertion.assert-collection","assertion.assert-sequence"],hideOperatorForm:!0},"assert-boolean":{category:"assertion",description:"If $value is not a `boolean` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-boolean } = import(assertion);\ntry assert-boolean(true) catch (e) e.message end","let { assert-boolean } = import(assertion);\ntry assert-boolean(false) catch (e) e.message end",'let { assert-boolean } = import(assertion);\ntry assert-boolean(1, "Expected a boolean") catch (e) e.message end'],seeAlso:["assertion.assert-true","assertion.assert-false","assertion.assert-number","assertion.assert-string"],hideOperatorForm:!0},"assert-collection":{category:"assertion",description:"If $value is not a `collection` (array, object, or string) it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-collection } = import(assertion);\ntry assert-collection([1, 2]) catch (e) e.message end","let { assert-collection } = import(assertion);\ntry assert-collection({ a: 1 }) catch (e) e.message end",'let { assert-collection } = import(assertion);\ntry assert-collection("hello") catch (e) e.message end','let { assert-collection } = import(assertion);\ntry assert-collection(42, "Expected a collection") catch (e) e.message end'],seeAlso:["assertion.assert-sequence","assertion.assert-array","assertion.assert-object"],hideOperatorForm:!0},"assert-function":{category:"assertion",description:"If $value is not a `function` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-function } = import(assertion);\ntry assert-function(-> $ + 1) catch (e) e.message end",'let { assert-function } = import(assertion);\ntry assert-function(42, "Expected a function") catch (e) e.message end'],seeAlso:["assertion.assert-number","assertion.assert-string"],hideOperatorForm:!0},"assert-grid":{category:"assertion",description:"If $value is not a `grid` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-grid } = import(assertion);\ntry assert-grid([[1, 2], [3, 4]]) catch (e) e.message end",'let { assert-grid } = import(assertion);\ntry assert-grid([1, 2], "Expected a grid") catch (e) e.message end'],seeAlso:["assertion.assert-matrix","assertion.assert-vector"],hideOperatorForm:!0},"assert-integer":{category:"assertion",description:"If $value is not an `integer` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-integer } = import(assertion);\ntry assert-integer(42) catch (e) e.message end",'let { assert-integer } = import(assertion);\ntry assert-integer(3.14, "Expected an integer") catch (e) e.message end'],seeAlso:["assertion.assert-number"],hideOperatorForm:!0},"assert-matrix":{category:"assertion",description:"If $value is not a `matrix` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-matrix } = import(assertion);\ntry assert-matrix([[1, 2], [3, 4]]) catch (e) e.message end",'let { assert-matrix } = import(assertion);\ntry assert-matrix([1, 2], "Expected a matrix") catch (e) e.message end'],seeAlso:["assertion.assert-vector","assertion.assert-grid"],hideOperatorForm:!0},"assert-number":{category:"assertion",description:"If $value is not a `number` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-number } = import(assertion);\ntry assert-number(42) catch (e) e.message end",'let { assert-number } = import(assertion);\ntry assert-number("hello", "Expected a number") catch (e) e.message end'],seeAlso:["assertion.assert-integer","assertion.assert-boolean","assertion.assert-string","assertion.assert-function"],hideOperatorForm:!0},"assert-object":{category:"assertion",description:"If $value is not an `object` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-object } = import(assertion);\ntry assert-object({ a: 1 }) catch (e) e.message end",'let { assert-object } = import(assertion);\ntry assert-object([1, 2], "Expected an object") catch (e) e.message end'],seeAlso:["assertion.assert-array","assertion.assert-collection"],hideOperatorForm:!0},"assert-regexp":{category:"assertion",description:"If $value is not a `regexp` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-regexp } = import(assertion);\ntry assert-regexp(#"^start") catch (e) e.message end','let { assert-regexp } = import(assertion);\ntry assert-regexp("hello", "Expected a regexp") catch (e) e.message end'],seeAlso:["assertion.assert-string"],hideOperatorForm:!0},"assert-sequence":{category:"assertion",description:"If $value is not a `sequence` (array or string) it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-sequence } = import(assertion);\ntry assert-sequence([1, 2]) catch (e) e.message end",'let { assert-sequence } = import(assertion);\ntry assert-sequence("hello") catch (e) e.message end','let { assert-sequence } = import(assertion);\ntry assert-sequence({ a: 1 }, "Expected a sequence") catch (e) e.message end'],seeAlso:["assertion.assert-collection","assertion.assert-array"],hideOperatorForm:!0},"assert-string":{category:"assertion",description:"If $value is not a `string` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-string } = import(assertion);\ntry assert-string("hello") catch (e) e.message end','let { assert-string } = import(assertion);\ntry assert-string(42, "Expected a string") catch (e) e.message end'],seeAlso:["assertion.assert-number","assertion.assert-boolean","assertion.assert-regexp","assertion.assert-function"],hideOperatorForm:!0},"assert-vector":{category:"assertion",description:"If $value is not a `vector` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-vector } = import(assertion);\ntry assert-vector([1, 2, 3]) catch (e) e.message end",'let { assert-vector } = import(assertion);\ntry assert-vector(["a", "b"], "Expected a vector") catch (e) e.message end'],seeAlso:["assertion.assert-matrix","assertion.assert-grid"],hideOperatorForm:!0}},Ur={"assert=":{evaluate:([e,t,r],n)=>{if(void 0!==r&&(K(r,n),r=` ${r}`),r??="",!me(M(e,n),M(t,n),n))throw new o(`Expected ${JSON.stringify(e,null,2)} to deep equal ${JSON.stringify(t,null,2)}.${r}`,n);return null},arity:{min:2,max:3}},"assert!=":{evaluate:([e,t,r],n)=>{if(void 0!==r&&(K(r,n),r=` ${r}`),r??="",me(M(e,n),M(t,n),n))throw new o(`Expected ${JSON.stringify(e)} not to deep equal ${JSON.stringify(t)}.${r}`,n);return null},arity:{min:2,max:3}},"assert-gt":{evaluate:([e,t,r],n)=>{if(X(e,n),X(t,n),void 0!==r&&(K(r,n),r=` ${r}`),r??="",le(e,t,n)<=0)throw new o(`Expected ${e} to be grater than ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-gte":{evaluate:([e,t,r],n)=>{if(X(e,n),X(t,n),void 0!==r&&(K(r,n),r=` ${r}`),r??="",le(e,t,n)<0)throw new o(`Expected ${e} to be grater than or equal to ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-lt":{evaluate:([e,t,r],n)=>{if(X(e,n),X(t,n),void 0!==r&&(K(r,n),r=` ${r}`),r??="",le(e,t,n)>=0)throw new o(`Expected ${e} to be less than ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-lte":{evaluate:([e,t,r],n)=>{if(X(e,n),X(t,n),void 0!==r&&(K(r,n),r=` ${r}`),r??="",le(e,t,n)>0)throw new o(`Expected ${e} to be less than or equal to ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-true":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!0!==e)throw new o(`Expected ${e} to be true.${t}`,r);return null},arity:{min:1,max:2}},"assert-false":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!1!==e)throw new o(`Expected ${e} to be false.${t}`,r);return null},arity:{min:1,max:2}},"assert-truthy":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!e)throw new o(`Expected ${e} to be truthy.${t}`,r);return null},arity:{min:1,max:2}},"assert-falsy":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",e)throw new o(`Expected ${e} to be falsy.${t}`,r);return null},arity:{min:1,max:2}},"assert-null":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",null!==e)throw new o(`Expected ${e} to be null.${t}`,r);return null},arity:{min:1,max:2}},"assert-throws":{evaluate:([e,t],r,n,{executeFunction:a})=>(void 0!==t&&(K(t,r),t=` ${t}`),t??="",L(e,r),je(()=>Ae(a(e,[],n,r),()=>{throw new o(`Expected function to throw.${t}`,r)}),()=>null)),arity:{min:1,max:2}},"assert-throws-error":{evaluate:([e,t,r],n,a,{executeFunction:i})=>(void 0!==r&&(K(r,n),r=` ${r}`),r??="",K(t,n),L(e,n),je(()=>Ae(i(e,[],a,n),()=>{throw new o(`Expected function to throw "${t}".${r}`,n)}),e=>{const a=e.shortMessage;if(a!==t)throw new o(`Expected function to throw "${t}", but thrown "${a}".${r}`,n);return null})),arity:{min:2,max:3}},"assert-not-throws":{evaluate:([e,t],r,n,{executeFunction:a})=>(void 0!==t&&(K(t,r),t=` ${t}`),t??="",L(e,r),je(()=>Ae(a(e,[],n,r),()=>null),()=>{throw new o(`Expected function not to throw.${t}`,r)})),arity:{min:1,max:2}},"assert-array":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!Array.isArray(e))throw new o(`Expected ${JSON.stringify(e)} to be an array.${t}`,r);return null},arity:{min:1,max:2}},"assert-boolean":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="","boolean"!=typeof e)throw new o(`Expected ${JSON.stringify(e)} to be a boolean.${t}`,r);return null},arity:{min:1,max:2}},"assert-collection":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!U(e))throw new o(`Expected ${JSON.stringify(e)} to be a collection.${t}`,r);return null},arity:{min:1,max:2}},"assert-function":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!w(e))throw new o(`Expected ${JSON.stringify(e)} to be a function.${t}`,r);return null},arity:{min:1,max:2}},"assert-grid":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!rt(e))throw new o(`Expected ${JSON.stringify(e)} to be a grid.${t}`,r);return null},arity:{min:1,max:2}},"assert-integer":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="","number"!=typeof e||!Q(e,{integer:!0}))throw new o(`Expected ${JSON.stringify(e)} to be an integer.${t}`,r);return null},arity:{min:1,max:2}},"assert-matrix":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!ot(e))throw new o(`Expected ${JSON.stringify(e)} to be a matrix.${t}`,r);return null},arity:{min:1,max:2}},"assert-number":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="","number"!=typeof e)throw new o(`Expected ${JSON.stringify(e)} to be a number.${t}`,r);return null},arity:{min:1,max:2}},"assert-object":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!O(e))throw new o(`Expected ${JSON.stringify(e)} to be an object.${t}`,r);return null},arity:{min:1,max:2}},"assert-regexp":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!G(e))throw new o(`Expected ${JSON.stringify(e)} to be a regexp.${t}`,r);return null},arity:{min:1,max:2}},"assert-sequence":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!P(e))throw new o(`Expected ${JSON.stringify(e)} to be a sequence.${t}`,r);return null},arity:{min:1,max:2}},"assert-string":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="","string"!=typeof e)throw new o(`Expected ${JSON.stringify(e)} to be a string.${t}`,r);return null},arity:{min:1,max:2}},"assert-vector":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!Xe(e))throw new o(`Expected ${JSON.stringify(e)} to be a vector.${t}`,r);return null},arity:{min:1,max:2}}};for(const[e,t]of Object.entries(Fr))Ur[e]&&(Ur[e].docs=t);const Dr={name:"assertion",functions:Ur},Wr={"cell-every?":{category:"grid",description:"Checks if all elements in a grid satisfy a predicate. Returns true only if the predicate returns true for every element in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { cell-every? } = import(grid);\ncell-every?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], string?)','let { cell-every? } = import(grid);\ncell-every?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], string?)',"let { cell-every? } = import(grid);\ncell-every?([\n [1, 2],\n [3, 4],\n], string?)"],seeAlso:["collection.every?","grid.some?","grid.every-row?","grid.every-col?"]},"some?":{category:"grid",description:"Checks if any element in a grid satisfies a predicate. Returns true if the predicate returns true for at least one element in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { some? } = import(grid);\nsome?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], string?)','let { some? } = import(grid);\nsome?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], string?)',"let { some? } = import(grid);\nsome?([\n [1, 2],\n [3, 4],\n], string?)"],seeAlso:["collection.any?","grid.cell-every?","grid.some-row?","grid.some-col?"]},"every-row?":{category:"grid",description:"Checks if all rows in a grid satisfy a predicate. Returns true only if the predicate returns true for every row in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { every-row? } = import(grid);\nevery-row?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> string?($[0]))','let { every-row? } = import(grid);\nevery-row?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> string?($[0]))',"let { every-row? } = import(grid);\nevery-row?([\n [1, 2],\n [3, 4],\n], -> string?($[0]))"],seeAlso:["grid.some-row?","grid.every-col?","grid.cell-every?"]},"some-row?":{category:"grid",description:"Checks if any row in a grid satisfies a predicate. Returns true if the predicate returns true for at least one row in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { some-row? } = import(grid);\nsome-row?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $ contains? "Albert")','let { some-row? } = import(grid);\nsome-row?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> $ contains? "Albert")','let { some-row? } = import(grid);\nsome-row?([\n [1, 2],\n [3, 4],\n], -> $ contains? "Albert")'],seeAlso:["grid.every-row?","grid.some-col?","grid.some?"]},"every-col?":{category:"grid",description:"Checks if all columns in a grid satisfy a predicate. Returns true only if the predicate returns true for every column in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { every-col? } = import(grid);\nevery-col?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> string?($[0]))','let { every-col? } = import(grid);\nevery-col?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> string?($[0]))',"let { every-col? } = import(grid);\nevery-col?([\n [1, 2],\n [3, 4],\n], -> string?($[0]))"],seeAlso:["grid.some-col?","grid.every-row?","grid.cell-every?"]},"some-col?":{category:"grid",description:"Checks if any column in a grid satisfies a predicate. Returns true if the predicate returns true for at least one column in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { some-col? } = import(grid);\nsome-col?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $ contains? "Albert")','let { some-col? } = import(grid);\nsome-col?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> $ contains? "Albert")','let { some-col? } = import(grid);\nsome-col?([\n [1, 2],\n [3, 4],\n], -> $ contains? "Albert")'],seeAlso:["grid.every-col?","grid.some-row?","grid.some?"]},row:{category:"grid",description:"Returns the row at index $a in the grid $b.",returns:{type:"any"},args:{a:{type:"grid"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:['let { row } = import(grid);\nrow([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 0)','let { row } = import(grid);\nrow([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)','let { row } = import(grid);\nrow([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 2)'],seeAlso:["grid.col","grid.shape"]},col:{category:"grid",description:"Returns the column at index $a in the grid $b.",returns:{type:"any"},args:{a:{type:"grid"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:['let { col } = import(grid);\ncol([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 0)','let { col } = import(grid);\ncol([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)','let { col } = import(grid);\ncol([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 2)'],seeAlso:["grid.row","grid.shape"]},shape:{category:"grid",description:"Returns the shape of the grid `g` as a `vector` of two numbers, where the first number is the number of rows and the second number is the number of columns.",returns:{type:"vector"},args:{g:{type:"grid",description:"The grid to get the shape of."}},variants:[{argumentNames:["g"]}],examples:['let { shape } = import(grid);\nshape([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { shape } = import(grid);\nshape([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { shape } = import(grid);\nshape([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.row","grid.col","grid.reshape"]},fill:{category:"grid",description:"Creates a grid of the specified size, filled with the specified value.",returns:{type:"grid"},args:{rows:{type:"integer",description:"The number of rows in the grid."},cols:{type:"integer",description:"The number of columns in the grid."},value:{type:"any",description:"The value to fill the grid with."}},variants:[{argumentNames:["rows","cols","value"]}],examples:["let { fill } = import(grid);\nfill(2, 3, 0)",'let { fill } = import(grid);\nfill(2, 3, "x")'],seeAlso:["grid.generate","grid.from-array"]},generate:{category:"grid",description:"Generates a grid of the specified size, where each element is generated by the provided function.",returns:{type:"grid"},args:{rows:{type:"number",description:"The number of rows in the grid."},cols:{type:"number",description:"The number of columns in the grid."},fn:{type:"function",description:"The function to generate the grid. It takes two arguments: the row index and the column index."}},variants:[{argumentNames:["rows","cols","fn"]}],examples:["let { generate } = import(grid);\ngenerate(3, 3, (i, j) -> i + j)"],seeAlso:["grid.fill","grid.from-array"]},reshape:{category:"grid",description:"Reshapes the grid `a` into a new grid with the specified number of rows `b`. The number of columns is automatically calculated based on the total number of elements in the grid.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:['let { reshape } = import(grid);\nreshape([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], 2)'],seeAlso:["grid.shape","grid.from-array"]},transpose:{category:"grid",description:"Transposes the grid `g`, swapping its rows and columns.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to transpose."}},variants:[{argumentNames:["g"]}],examples:['let { transpose } = import(grid);\ntranspose([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { transpose } = import(grid);\ntranspose([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { transpose } = import(grid);\ntranspose([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.flip-h","grid.flip-v","grid.rotate"]},"flip-h":{category:"grid",description:"Flips the grid `g` horizontally.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to flip horizontally."}},variants:[{argumentNames:["g"]}],examples:['let { flip-h } = import(grid);\nflip-h([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { flip-h } = import(grid);\nflip-h([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { flip-h } = import(grid);\nflip-h([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.flip-v","grid.transpose","grid.rotate"]},"flip-v":{category:"grid",description:"Flips the grid `g` vertically.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to flip vertically."}},variants:[{argumentNames:["g"]}],examples:['let { flip-v } = import(grid);\nflip-v([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { flip-v } = import(grid);\nflip-v([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { flip-v } = import(grid);\nflip-v([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.flip-h","grid.transpose","grid.rotate"]},rotate:{category:"grid",description:"Rotates the grid `g` by the specified angle. The angle is given in terms of 90-degree rotations. Positive values rotate the grid clockwise, while negative values rotate it counterclockwise.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 1)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 2)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 3)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 4)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], -1)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], -2)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], -3)"],seeAlso:["grid.transpose","grid.flip-h","grid.flip-v"]},crop:{category:"grid",description:"Crops the grid `g` from the starting index `begin` to the optional ending index `stop`. The crop is inclusive of the starting index and exclusive of the ending index.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to slice."},begin:{type:"vector",description:"The starting index of the slice as a vector of two numbers: `[row, col]`."},stop:{type:"vector",description:"Optional ending index of the slice as a vector of two numbers: `[row, col]`."}},variants:[{argumentNames:["g","begin"]},{argumentNames:["g","begin","stop"]}],examples:['let { crop } = import(grid);\ncrop([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [1, 1], [2, 2])','let { crop } = import(grid);\ncrop([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [1, 1])'],hideOperatorForm:!0,seeAlso:["grid.slice-rows","grid.slice-cols"]},"slice-rows":{category:"grid",description:"Slices rows of the grid `g` from the starting index `begin` to the optional ending index `stop`. The slice is inclusive of the starting index and exclusive of the ending index.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to slice."},begin:{type:"number",description:"The starting index of the slice."},stop:{type:"number",description:"Optional ending index of the slice."}},variants:[{argumentNames:["g","begin"]},{argumentNames:["g","begin","stop"]}],examples:['let { slice-rows } = import(grid);\nslice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { slice-rows } = import(grid);\nslice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)'],hideOperatorForm:!0,seeAlso:["grid.crop","grid.slice-cols","grid.splice-rows"]},"slice-cols":{category:"grid",description:"Slices columns of the grid `g` from the starting index `begin` to the optional ending index `stop`. The slice is inclusive of the starting index and exclusive of the ending index.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to slice."},begin:{type:"number",description:"The starting index of the slice."},stop:{type:"number",description:"Optional ending index of the slice."}},variants:[{argumentNames:["g","begin"]},{argumentNames:["g","begin","stop"]}],examples:['let { slice-cols } = import(grid);\nslice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { slice-cols } = import(grid);\nslice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)'],hideOperatorForm:!0,seeAlso:["grid.crop","grid.slice-rows","grid.splice-cols"]},"splice-rows":{category:"grid",description:"Splices rows of the grid `g` starting from the index `begin`. Deletes `deleteCount` rows and inserts the specified `items` at that position.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to splice."},begin:{type:"number",description:"The starting index of the splice."},deleteCount:{type:"number",description:"The number of rows to delete."},items:{type:"array",rest:!0,description:"The rows to insert."}},variants:[{argumentNames:["g","begin","deleteCount"]},{argumentNames:["g","begin","deleteCount","items"]}],examples:['let { splice-rows } = import(grid);\nsplice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { splice-rows } = import(grid);\nsplice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 1, ["Nazanin", "mother", 40])'],hideOperatorForm:!0,seeAlso:["grid.splice-cols","grid.slice-rows"]},"splice-cols":{category:"grid",description:"Splices columns of the grid `g` starting from the index `begin`. Deletes `deleteCount` columns and inserts the specified `items` at that position.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to splice."},begin:{type:"number",description:"The starting index of the splice."},deleteCount:{type:"number",description:"The number of columns to delete."},items:{type:"array",rest:!0,description:"The columns to insert."}},variants:[{argumentNames:["g","begin","deleteCount"]},{argumentNames:["g","begin","deleteCount","items"]}],examples:['let { splice-cols } = import(grid);\nsplice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { splice-cols } = import(grid);\nsplice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 1, ["f", "m", "s"])'],hideOperatorForm:!0,seeAlso:["grid.splice-rows","grid.slice-cols"]},"concat-rows":{category:"grid",description:"Concatenates two grids `a` and `b` by rows. The number of columns in both grids must be the same.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"grid"}},variants:[{argumentNames:["a","b"]}],examples:['let { concat-rows } = import(grid);\nconcat-rows([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], [\n [1, 2],\n [3, 4],\n])'],seeAlso:["grid.concat-cols","grid.push-rows"]},"concat-cols":{category:"grid",description:"Concatenates two grids `a` and `b` by columns. The number of rows in both grids must be the same.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"grid"}},variants:[{argumentNames:["a","b"]}],examples:['let { concat-cols } = import(grid);\nconcat-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])'],seeAlso:["grid.concat-rows","grid.push-cols"]},"cell-map":{category:"grid",description:"Maps a function `a` over each element of the grid `b`, returning a new grid with the results.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { cell-map } = import(grid);\ncell-map([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], str)'],seeAlso:["map","grid.cell-mapi","grid.cell-reduce"]},"cell-mapi":{category:"grid",description:"Maps a function `a` over each element of the grid `b`, passing the row and column index as additional arguments to the function.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { cell-mapi } = import(grid);\ncell-mapi([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $1 ++ "(" ++ $2 ++ ", " ++ $3 ++ ")")'],seeAlso:["grid.cell-map","grid.cell-reducei","map"]},"cell-reduce":{category:"grid",description:"Reduces the grid `a` using the function `b`, returning a single value.",returns:{type:"any"},args:{g:{type:"grid",description:"The grid to reduce."},fn:{type:"function",description:"The function to reduce the grid. It takes two arguments: the accumulator and the current element."},"initial-value":{type:"any",description:"The initial value for the accumulator."}},variants:[{argumentNames:["g","fn","initial-value"]}],examples:['// Using "as" alias because "reduce" shadows a builtin function\nlet { cell-reduce } = import(grid);\ncell-reduce([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ++, "")'],seeAlso:["reduce","grid.cell-reducei","grid.cell-map"]},"cell-reducei":{category:"grid",description:"Reduces the grid `a` using the function `b`, passing the row and column indices as additional arguments to the function.",returns:{type:"any"},args:{g:{type:"grid",description:"The grid to reduce."},fn:{type:"function",description:"The function to reduce the grid. It takes four arguments: the accumulator, the current element, the row index, and the column index."},"initial-value":{type:"any",description:"The initial value for the accumulator."}},variants:[{argumentNames:["g","fn","initial-value"]}],examples:['// Using "as" alias because "reducei" shadows a builtin function\nlet { cell-reducei } = import(grid);\ncell-reducei([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ++, "")'],seeAlso:["grid.cell-reduce","grid.cell-mapi","reduce"]},"push-rows":{category:"grid",description:"Pushes the specified rows into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to push rows into."},rows:{type:"array",rest:!0,description:"The rows to push into the grid."}},variants:[{argumentNames:["g","rows"]}],examples:['let { push-rows } = import(grid);\npush-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["Nazanin", "mother", 40])'],hideOperatorForm:!0,seeAlso:["grid.unshift-rows","grid.pop-row","grid.shift-row","grid.concat-rows"]},"unshift-rows":{category:"grid",description:"Unshifts the specified rows into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to unshift rows into."},rows:{type:"array",rest:!0,description:"The rows to unshift into the grid."}},variants:[{argumentNames:["g","rows"]}],examples:['let { unshift-rows } = import(grid);\nunshift-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["Nazanin", "mother", 40])'],hideOperatorForm:!0,seeAlso:["grid.push-rows","grid.shift-row","grid.pop-row"]},"pop-row":{category:"grid",description:"Pops the last row from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to pop a row from."}},variants:[{argumentNames:["g"]}],examples:['let { pop-row } = import(grid);\npop-row([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.shift-row","grid.push-rows","grid.unshift-rows"]},"shift-row":{category:"grid",description:"Shifts the first row from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to shift a row from."}},variants:[{argumentNames:["g"]}],examples:['let { shift-row } = import(grid);\nshift-row([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.pop-row","grid.push-rows","grid.unshift-rows"]},"push-cols":{category:"grid",description:"Pushes the specified columns into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to push columns into."},cols:{type:"array",rest:!0,description:"The columns to push into the grid."}},variants:[{argumentNames:["g","cols"]}],examples:['let { push-cols } = import(grid);\npush-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["f", "m", "s"])'],hideOperatorForm:!0,seeAlso:["grid.unshift-cols","grid.pop-col","grid.shift-col","grid.concat-cols"]},"unshift-cols":{category:"grid",description:"Unshifts the specified columns into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to unshift columns into."},cols:{type:"array",rest:!0,description:"The columns to unshift into the grid."}},variants:[{argumentNames:["g","cols"]}],examples:['let { unshift-cols } = import(grid);\nunshift-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["f", "m", "s"])'],hideOperatorForm:!0,seeAlso:["grid.push-cols","grid.shift-col","grid.pop-col"]},"pop-col":{category:"grid",description:"Pops the last column from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to pop a column from."}},variants:[{argumentNames:["g"]}],examples:['let { pop-col } = import(grid);\npop-col([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.shift-col","grid.push-cols","grid.unshift-cols"]},"shift-col":{category:"grid",description:"Shifts the first column from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to shift a column from."}},variants:[{argumentNames:["g"]}],examples:['let { shift-col } = import(grid);\nshift-col([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.pop-col","grid.push-cols","grid.unshift-cols"]},"from-array":{category:"grid",description:"Creates a grid from a flat array with specified dimensions. The array is reshaped into the specified number of rows, and the number of columns is automatically calculated based on the total number of elements in the array.",returns:{type:"grid"},args:{a:{type:"array"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:["let { from-array } = import(grid);\nfrom-array([1, 2, 3, 4], 2)","let { from-array } = import(grid);\nfrom-array([1, 2, 3, 4], 4)"],seeAlso:["grid.fill","grid.generate","grid.reshape"]}};function Gr(e){const t=[];for(let r=0;r<e[0].length;r+=1){const n=[];for(let t=0;t<e.length;t+=1)n.push(e[t][r]);t.push(n)}return t}const Vr={"cell-every?":{evaluate:([e,t],r,n,{executeFunction:o})=>{nt(e,r),L(t,r);const a=[];for(const t of e)for(const e of t)a.push(e);return Pe(a,e=>o(t,[e],n,r))},arity:ae(2)},"some?":{evaluate:([e,t],r,n,{executeFunction:o})=>{nt(e,r),L(t,r);const a=[];for(const t of e)for(const e of t)a.push(e);return Me(a,e=>o(t,[e],n,r))},arity:ae(2)},"every-row?":{evaluate:([e,t],r,n,{executeFunction:o})=>(nt(e,r),L(t,r),Pe(Array.from(e),e=>o(t,[e],n,r))),arity:ae(2)},"some-row?":{evaluate:([e,t],r,n,{executeFunction:o})=>(nt(e,r),L(t,r),Me(Array.from(e),e=>o(t,[e],n,r))),arity:ae(2)},"every-col?":{evaluate:([e,t],r,n,{executeFunction:o})=>{nt(e,r),L(t,r);const a=Gr(e);return Pe(Array.from(a),e=>o(t,[e],n,r))},arity:ae(2)},"some-col?":{evaluate:([e,t],r,n,{executeFunction:o})=>{nt(e,r),L(t,r);const a=Gr(e);return Me(Array.from(a),e=>o(t,[e],n,r))},arity:ae(2)},row:{evaluate:([e,t],r)=>(nt(e,r),ee(t,r,{integer:!0,nonNegative:!0,lt:e.length}),e[t]),arity:ae(2)},col:{evaluate:([e,t],r)=>(nt(e,r),ee(t,r,{integer:!0,nonNegative:!0,lt:e[0].length}),e.map(e=>e[t])),arity:ae(2)},shape:{evaluate:([e],t)=>(nt(e,t),[e.length,e[0].length]),arity:ae(1)},fill:{evaluate:([e,t,r],n)=>{ee(e,n,{integer:!0,positive:!0}),ee(t,n,{integer:!0,positive:!0}),C(r,n);const o=[];for(let n=0;n<e;n+=1){const e=[];for(let n=0;n<t;n+=1)e.push(r);o.push(e)}return o},arity:ae(3)},generate:{evaluate:([e,t,r],n,o,{executeFunction:a})=>(ee(e,n,{integer:!0,positive:!0}),ee(t,n,{integer:!0,positive:!0}),L(r,n),Ne(Array.from({length:e}),(e,i)=>Ne(Array.from({length:t}),(e,t)=>Ae(a(r,[i,t],o,n),e=>(C(e,n),e))))),arity:ae(3)},reshape:{evaluate:([e,t],n)=>{nt(e,n),ee(t,n,{integer:!0,positive:!0});const o=e.flat();if(o.length%t!==0)throw new r(`The number of elements in the grid must be divisible by rows, but got ${o.length} and ${t}`,n);const a=o.length/t,i=[];for(let e=0;e<t;e+=1){const t=[];for(let r=0;r<a;r+=1)t.push(o[e*a+r]);i.push(t)}return i},arity:ae(2)},transpose:{evaluate:([e],t)=>(nt(e,t),Gr(e)),arity:ae(1)},"flip-h":{evaluate:([e],t)=>(nt(e,t),e.map(e=>e.reverse())),arity:ae(1)},"flip-v":{evaluate:([e],t)=>(nt(e,t),e.reverse()),arity:ae(1)},rotate:{evaluate:([e,t],r)=>{if(nt(e,r),ee(t,r,{integer:!0}),0===(t=(t%4+4)%4)||0===e.length)return e.map(e=>[...e]);const n=e.length,o=e[0].length;let a;switch(t){case 1:a=Array(o).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<o;r++)a[r][n-1-t]=e[t][r];break;case 2:a=Array(n).fill(null).map(()=>Array(o).fill(null));for(let t=0;t<n;t++)for(let r=0;r<o;r++)a[n-1-t][o-1-r]=e[t][r];break;case 3:a=Array(o).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<o;r++)a[o-1-r][t]=e[t][r]}return a},arity:ae(2)},crop:{evaluate:([e,t,n],o)=>{if(nt(e,o),Ze(t,o),2!==t.length)throw new r(`The start vector must have 2 elements, but got ${t.length}`,o);const[a,i]=t;if(ee(a,o,{integer:!0,nonNegative:!0,lt:e.length}),ee(i,o,{integer:!0,nonNegative:!0,lt:e[0].length}),n??=[e.length,e[0].length],Ze(n,o),2!==n.length)throw new r(`The end vector must have 2 elements, but got ${n.length}`,o);const[s,c]=n;ee(s,o,{gt:a,lte:e.length}),ee(c,o,{gt:i,lte:e[0].length});const l=[];for(let t=a;t<s;t+=1){const r=[];for(let n=i;n<c;n+=1)r.push(e[t][n]);l.push(r)}return l},arity:{min:2,max:3}},"slice-rows":{evaluate:([e,t,r],n)=>(nt(e,n),void 0===r?(ee(t,n,{integer:!0,lte:e.length,gte:-e.length}),t<0?e.slice(e.length+t):e.slice(t)):(ee(t,n,{integer:!0,nonNegative:!0,lte:e.length}),ee(r,n,{integer:!0}),ee(r=r<0?e.length+r:r,n,{gt:t,lte:e.length}),e.slice(t,r))),arity:{min:2,max:3}},"slice-cols":{evaluate:([e,t,r],n)=>{nt(e,n);const o=Gr(e);return void 0===r?(ee(t,n,{integer:!0,lte:o.length,gte:-o.length}),Gr(t<0?o.slice(o.length+t):o.slice(t))):(ee(t,n,{integer:!0,nonNegative:!0,lte:o.length}),ee(r,n,{integer:!0}),ee(r=r<0?o.length+r:r,n,{gt:t,lte:o.length}),Gr(o.slice(t,r)))},arity:{min:2,max:3}},"splice-rows":{evaluate:([e,t,n,...o],a)=>{nt(e,a),ee(t,a,{integer:!0,nonNegative:!0,lte:e.length}),ee(n,a,{integer:!0,nonNegative:!0}),0!==o.length&&(nt(o,a),o.every(t=>{if(we(t,a),e[0].length!==t.length)throw new r(`All rows must have the same length as the number of columns in grid, but got ${t.length}`,a);return!0}));const i=[];for(let r=0;r<t;r+=1)i.push(e[r]);o.length>0&&i.push(...o);for(let r=t+n;r<e.length;r+=1)i.push(e[r]);return i},arity:{min:3}},"splice-cols":{evaluate:([e,t,n,...o],a)=>{nt(e,a);const i=Gr(e);ee(t,a,{integer:!0,nonNegative:!0,lte:i.length}),ee(n,a,{integer:!0,nonNegative:!0}),0!==o.length&&(nt(o,a),o.every(e=>{if(we(e,a),i[0].length!==e.length)throw new r(`All rows must have the same length as the number of rows in grid, but got ${e.length}`,a);return!0}));const s=[];for(let e=0;e<t;e+=1)s.push(i[e]);s.push(...o);for(let e=t+n;e<i.length;e+=1)s.push(i[e]);return Gr(s)},arity:{min:3}},"concat-rows":{evaluate:(e,t)=>{we(e,t),e.every(e=>nt(e,t));const n=e[0][0].length;e.slice(1).every(e=>{if(e[0].length!==n)throw new r(`All grids must have the same number of columns, but got ${n} and ${e[0].length}`,t);return!0});const o=[];return e.forEach(e=>{e.forEach(e=>{o.push(e)})}),o},arity:{min:1}},"concat-cols":{evaluate:(e,t)=>{we(e,t),e.every(e=>nt(e,t));const n=e[0].length;e.slice(1).every(e=>{if(e.length!==n)throw new r(`All grids must have the same number of rows, but got ${n} and ${e.length}`,t);return!0});const o=[];for(let t=0;t<n;t+=1){const r=[];e.forEach(e=>{r.push(...e[t])}),o.push(r)}return o},arity:{min:1}},"cell-map":{evaluate:(e,t,n,{executeFunction:o})=>{const a=B(e.at(-1),t),i=e.slice(0,-1);nt(i[0],t);const s=i[0].length,c=i[0][0].length;return i.slice(1).forEach(e=>{if(nt(e,t),e.length!==s)throw new r(`All grids must have the same number of rows, but got ${s} and ${e.length}`,t);if(e[0].length!==c)throw new r(`All grids must have the same number of columns, but got ${c} and ${e[0].length}`,t)}),Ne(Array.from({length:s}),(e,r)=>Ne(Array.from({length:c}),(e,s)=>{const c=i.map(e=>e[r][s]);return Ae(o(a,c,n,t),e=>M(e))}))},arity:{min:2}},"cell-mapi":{evaluate:([e,t],r,n,{executeFunction:o})=>{nt(e,r),L(t,r);const a=e.length,i=e[0].length;return Ne(Array.from({length:a}),(a,s)=>Ne(Array.from({length:i}),(a,i)=>Ae(o(t,[e[s][i],s,i],n,r),e=>M(e))))},arity:ae(2)},"cell-reduce":{evaluate:([e,t,r],n,o,{executeFunction:a})=>{nt(e,n),L(t,n);const i=[];for(const t of e)for(const e of t)i.push(e);return Te(i,(e,r)=>a(t,[e,r],o,n),M(r))},arity:ae(3)},"cell-reducei":{evaluate:([e,t,r],n,o,{executeFunction:a})=>{nt(e,n),L(t,n);const i=[];for(let t=0;t<e.length;t+=1)for(let r=0;r<e[t].length;r+=1)i.push({cell:e[t][r],i:t,j:r});return Te(i,(e,{cell:r,i:i,j:s})=>a(t,[e,r,i,s],o,n),M(r))},arity:ae(3)},"push-rows":{evaluate:([e,...t],n)=>{if(nt(e,n),nt(t,n),e[0].length!==t[0].length)throw new r(`All rows must have the same length as the number of columns in grid, but got ${e[0].length} and ${t[0].length}`,n);return[...e,...t]},arity:{min:2}},"unshift-rows":{evaluate:([e,...t],n)=>{if(nt(e,n),nt(t,n),e[0].length!==t[0].length)throw new r(`All rows must have the same length as the number of columns in grid, but got ${e[0].length} and ${t[0].length}`,n);return[...t,...e]},arity:{min:2}},"pop-row":{evaluate:([e],t)=>(nt(e,t),1===e.length?null:e.slice(0,-1)),arity:ae(1)},"shift-row":{evaluate:([e],t)=>(nt(e,t),1===e.length?null:e.slice(1)),arity:ae(1)},"push-cols":{evaluate:([e,...t],n)=>{if(nt(e,n),nt(t,n),e.length!==t[0].length)throw new r(`All columns must have the same length as the number of rows in grid, but got ${t.length}`,n);const o=[];for(let r=0;r<e.length;r+=1){const n=[];n.push(...e[r]),t.forEach(e=>{n.push(e[r])}),o.push(n)}return o},arity:{min:2}},"unshift-cols":{evaluate:([e,...t],n)=>{if(nt(e,n),nt(t,n),e.length!==t[0].length)throw new r(`All columns must have the same length as the number of rows in grid, but got ${t.length}`,n);const o=[];for(let r=0;r<e.length;r+=1){const n=[];t.forEach(e=>{n.push(e[r])}),n.push(...e[r]),o.push(n)}return o},arity:{min:2}},"pop-col":{evaluate:([e],t)=>(nt(e,t),1===e[0].length?null:e.map(e=>e.slice(0,-1))),arity:ae(1)},"shift-col":{evaluate:([e],t)=>(nt(e,t),1===e[0].length?null:e.map(e=>e.slice(1))),arity:ae(1)},"from-array":{evaluate:([e,t],n)=>{if(we(e,n),ee(t,n,{integer:!0,positive:!0}),e.length%t!==0)throw new r(`The number of elements in the array must be divisible by rows, but got ${e.length} and ${t}`,n);return function(e,t){const r=[],n=e.length/t;for(let o=0;o<t;o++){const t=o*n,a=t+n;r.push(e.slice(t,a))}return r}(e,t)},arity:ae(2)}};for(const[e,t]of Object.entries(Wr))Vr[e]&&(Vr[e].docs=t);const Br={name:"grid",functions:Vr},Lr={"random!":{category:"random",description:"Returns a random number between 0 and 1.",returns:{type:"number"},args:{},variants:[{argumentNames:[]}],examples:["let { random! } = import(random);\nrandom!()"],seeAlso:["random.random-float!","random.random-int!","random.random-boolean!"]},"random-int!":{category:"random",description:"Returns a random integer between min and max (exclusive).",returns:{type:"integer"},args:{a:{type:"integer",description:"The minimum value."},b:{type:"integer",description:"The maximum value (exclusive)."}},variants:[{argumentNames:["a","b"]}],examples:["let { random-int! } = import(random);\nrandom-int!(0, 10)","let { random-int! } = import(random);\nrandom-int!(1, 100)"],seeAlso:["random.random-int-inclusive!","random.random-float!","random.random!"]},"random-int-inclusive!":{category:"random",description:"Returns a random integer between min and max (inclusive).",returns:{type:"integer"},args:{a:{type:"integer",description:"The minimum value."},b:{type:"integer",description:"The maximum value (inclusive)."}},variants:[{argumentNames:["a","b"]}],examples:["let { random-int-inclusive! } = import(random);\nrandom-int-inclusive!(0, 10)"],seeAlso:["random.random-int!","random.random-float!"]},"random-float!":{category:"random",description:"Returns a random float between min and max.",returns:{type:"number"},args:{a:{type:"number",description:"The minimum value."},b:{type:"number",description:"The maximum value."}},variants:[{argumentNames:["a","b"]}],examples:["let { random-float! } = import(random);\nrandom-float!(0, 10)","let { random-float! } = import(random);\nrandom-float!(1, 100)"],seeAlso:["random.random!","random.random-int!","random.random-int-inclusive!"]},"random-boolean!":{category:"random",description:"Returns a random boolean.",returns:{type:"boolean"},args:{prob:{type:"number",description:"The probability of returning true (between 0 and 1)."}},variants:[{argumentNames:["prob"]}],examples:["let { random-boolean! } = import(random);\nrandom-boolean!()","let { random-boolean! } = import(random);\nrandom-boolean!(0.99)"],seeAlso:["random.random!"]},"random-item!":{category:"random",description:"Returns a random item from the array.",returns:{type:"any"},args:{a:{type:"array",description:"The array to sample from."}},variants:[{argumentNames:["a"]}],examples:["let { random-item! } = import(random);\nrandom-item!([1, 2, 3, 4, 5])",'let { random-item! } = import(random);\nrandom-item!(["apple", "banana", "cherry"])'],seeAlso:["random.random-sample!","random.random-sample-unique!","random.random-char!"]},"random-sample-unique!":{category:"random",description:"Returns a random sample of n unique items from the array.",returns:{type:"array"},args:{a:{type:"array",description:"The array to sample from."},b:{type:"integer",description:"The number of items to sample."}},variants:[{argumentNames:["a","b"]}],examples:["let { random-sample-unique! } = import(random);\nrandom-sample-unique!([1, 2, 3, 4, 5], 3)",'let { random-sample-unique! } = import(random);\nrandom-sample-unique!(["apple", "banana", "cherry"], 2)'],seeAlso:["random.random-sample!","random.random-item!","random.shuffle!"]},"random-sample!":{category:"random",description:"Returns a random sample of n items from the array.",returns:{type:"array"},args:{a:{type:"array",description:"The array to sample from."},b:{type:"integer",description:"The number of items to sample."}},variants:[{argumentNames:["a","b"]}],examples:["let { random-sample! } = import(random);\nrandom-sample!([1, 2, 3, 4, 5], 3)",'let { random-sample! } = import(random);\nrandom-sample!(["apple", "banana", "cherry"], 10)'],seeAlso:["random.random-sample-unique!","random.random-item!","random.shuffle!"]},"shuffle!":{category:"random",description:"Returns a shuffled version of the array.",returns:{type:"array"},args:{a:{type:"array",description:"The array to shuffle."}},variants:[{argumentNames:["a"]}],examples:["let { shuffle! } = import(random);\nshuffle!([1, 2, 3, 4, 5])",'let { shuffle! } = import(random);\nshuffle!(["apple", "banana", "cherry"])'],seeAlso:["random.random-sample!","random.random-sample-unique!"]},"random-normal!":{category:"random",description:"Returns a random number from a normal distribution with the given mean and standard deviation.",returns:{type:"number"},args:{mean:{type:"number",description:"The mean of the normal distribution."},stdDev:{type:"number",description:"The standard deviation of the normal distribution."}},variants:[{argumentNames:["mean","stdDev"]}],examples:["let { random-normal! } = import(random);\nrandom-normal!(0, 1)","let { random-normal! } = import(random);\nrandom-normal!(5, 2)"],seeAlso:["random.random-exponential!","random.random-binomial!","random.random-poisson!"],hideOperatorForm:!0},"random-exponential!":{category:"random",description:"Returns a random number from an exponential distribution with the given rate parameter.",returns:{type:"number"},args:{lambda:{type:"number",description:"The rate parameter of the exponential distribution."}},variants:[{argumentNames:["lambda"]}],examples:["let { random-exponential! } = import(random);\nrandom-exponential!(1)","let { random-exponential! } = import(random);\nrandom-exponential!(0.5)"],seeAlso:["random.random-normal!","random.random-poisson!","random.random-gamma!","random.random-pareto!"]},"random-binomial!":{category:"random",description:"Returns a random number from a binomial distribution with the given number of trials and probability of success.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number of trials."},p:{type:"number",description:"The probability of success on each trial."}},variants:[{argumentNames:["n","p"]}],examples:["let { random-binomial! } = import(random);\nrandom-binomial!(10, 0.5)","let { random-binomial! } = import(random);\nrandom-binomial!(20, 0.3)"],seeAlso:["random.random-normal!","random.random-poisson!"],hideOperatorForm:!0},"random-poisson!":{category:"random",description:"Returns a random number from a Poisson distribution with the given rate parameter.",returns:{type:"integer"},args:{lambda:{type:"number",description:"The rate parameter of the Poisson distribution."}},variants:[{argumentNames:["lambda"]}],examples:["let { random-poisson! } = import(random);\nrandom-poisson!(1)","let { random-poisson! } = import(random);\nrandom-poisson!(5)"],seeAlso:["random.random-binomial!","random.random-normal!","random.random-exponential!"]},"random-gamma!":{category:"random",description:"Returns a random number from a gamma distribution with the given shape and scale parameters.",returns:{type:"number"},args:{shape:{type:"number",description:"The shape parameter of the gamma distribution."},scale:{type:"number",description:"The scale parameter of the gamma distribution."}},variants:[{argumentNames:["shape","scale"]}],examples:["let { random-gamma! } = import(random);\nrandom-gamma!(2, 2)","let { random-gamma! } = import(random);\nrandom-gamma!(5, 1)"],seeAlso:["random.random-exponential!","random.random-pareto!"],hideOperatorForm:!0},"random-pareto!":{category:"random",description:"Returns a random number from a Pareto distribution with the given shape parameter.",returns:{type:"number"},args:{alpha:{type:"number",description:"The shape parameter of the Pareto distribution."}},variants:[{argumentNames:["alpha"]}],examples:["let { random-pareto! } = import(random);\nrandom-pareto!(1)","let { random-pareto! } = import(random);\nrandom-pareto!(2)"],seeAlso:["random.random-gamma!","random.random-exponential!"]},"uuid!":{category:"random",description:"Returns a random UUID v4 (Universally Unique Identifier).",returns:{type:"string"},args:{},variants:[{argumentNames:[]}],examples:["let { uuid! } = import(random);\nuuid!()"],seeAlso:["random.random-id!","random.random-string!"]},"random-char!":{category:"random",description:"Returns a random character from the given string.",returns:{type:"string"},args:{charSet:{type:"string",description:"The string to sample from."}},variants:[{argumentNames:["charSet"]}],examples:['let { random-char! } = import(random);\nrandom-char!("abcde")','let { random-char! } = import(random);\nrandom-char!("ABCDEFGHIJKLMNOPQRSTUVWXYZ")'],seeAlso:["random.random-string!","random.random-item!"]},"random-string!":{category:"random",description:"Returns a random string of the given length from the given string.",returns:{type:"string"},args:{length:{type:"integer",description:"The length of the random string."},charSet:{type:"string",description:"The string to sample from."}},variants:[{argumentNames:["length","charSet"]}],examples:['let { random-string! } = import(random);\nrandom-string!(10, "abcde")','let { random-string! } = import(random);\nrandom-string!(5, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")'],seeAlso:["random.random-char!","random.random-id!","random.uuid!"],hideOperatorForm:!0},"random-id!":{category:"random",description:"Returns a random ID of the given length.",returns:{type:"string"},args:{length:{type:"integer",description:"The length of the random ID."}},variants:[{argumentNames:["length"]}],examples:["let { random-id! } = import(random);\nrandom-id!(10)","let { random-id! } = import(random);\nrandom-id!(5)"],seeAlso:["random.random-string!","random.uuid!"]},"random-color!":{category:"random",description:"Returns a random color in hex format.",returns:{type:"string"},args:{},variants:[{argumentNames:[]}],examples:["let { random-color! } = import(random);\nrandom-color!()"]}},_r={"random!":{evaluate:()=>Math.random(),pure:!1,arity:ae(0)},"random-int!":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0,gt:e}),Math.floor(Math.random()*(t-e))+e),pure:!1,arity:ae(2)},"random-int-inclusive!":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0,gte:e}),Math.floor(Math.random()*(t-e+1))+e),pure:!1,arity:ae(2)},"random-float!":{evaluate:([e,t],r)=>(ee(e,r),ee(t,r,{gt:e}),Math.random()*(t-e)+e),pure:!1,arity:ae(2)},"random-boolean!":{evaluate:([e],t)=>{const r=e??.5;return ee(r,t,{gte:0,lte:1}),Math.random()<r},pure:!1,arity:{min:0,max:1}},"random-item!":{evaluate:([e],t)=>{we(e,t);return M(e[Math.floor(Math.random()*e.length)])},pure:!1,arity:ae(1)},"random-sample!":{evaluate:([e,t],n)=>{if(we(e,n),ee(t,n,{integer:!0,nonNegative:!0}),0===e.length)throw new r("Cannot sample from an empty array.",n);const o=[];for(let r=0;r<t;r++){const t=Math.floor(Math.random()*e.length);o.push(e[t])}return o},pure:!1,arity:ae(2)},"random-sample-unique!":{evaluate:([e,t],n)=>{if(we(e,n),ee(t,n,{integer:!0,nonNegative:!0,lte:e.length}),0===e.length)throw new r("Cannot sample from an empty array.",n);const o=[],a=[...e];for(let e=0;e<t;e++){const e=Math.floor(Math.random()*a.length);o.push(a[e]),a.splice(e,1)}return o},pure:!1,arity:ae(2)},"shuffle!":{evaluate:([e],t)=>{we(e,t);const r=[...e];for(let e=r.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1));[r[e],r[t]]=[r[t],r[e]]}return r},pure:!1,arity:ae(1)},"random-normal!":{evaluate:([e,t],r)=>{ee(e,r),ee(t,r,{gt:0});const n=Math.random(),o=Math.random();return Math.sqrt(-2*Math.log(n))*Math.cos(2*Math.PI*o)*t+e},pure:!1,arity:ae(2)},"random-exponential!":{evaluate:([e],t)=>{ee(e,t,{gt:0});const r=Math.random();return-Math.log(r)/e},pure:!1,arity:ae(1)},"random-binomial!":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0,nonNegative:!0}),ee(t,r,{gte:0,lte:1});let n=0;for(let r=0;r<e;r++)Math.random()<t&&n++;return n},pure:!1,arity:ae(2)},"random-poisson!":{evaluate:([e],t)=>{ee(e,t,{gt:0});const r=Math.exp(-e);let n=0,o=1;do{n++,o*=Math.random()}while(o>r);return n-1},pure:!1,arity:ae(1)},"random-gamma!":{evaluate:([e,t],r)=>(ee(e,r,{gt:0}),ee(t,r,{gt:0}),Kr(e,t)),pure:!1,arity:ae(2)},"random-pareto!":{evaluate:([e],t)=>{ee(e,t,{gt:0});return(1/Math.random())**(1/e)},pure:!1,arity:ae(1)},"uuid!":{evaluate:()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),pure:!1,arity:ae(0)},"random-char!":{evaluate:([e],t)=>{if(K(e,t),0===e.length)throw new r("Character set cannot be empty.",t);return e[Math.floor(Math.random()*e.length)]},pure:!1,arity:ae(1)},"random-string!":{evaluate:([e,t],n)=>{if(ee(e,n,{integer:!0,positive:!0}),K(t,n),0===t.length)throw new r("Character set cannot be empty.",n);let o="";for(let r=0;r<e;r++){o+=t[Math.floor(Math.random()*t.length)]}return o},pure:!1,arity:ae(2)},"random-id!":{evaluate:([e],t)=>{ee(e,t,{integer:!0,positive:!0});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let n="";for(let t=0;t<e;t++){n+=r[Math.floor(62*Math.random())]}return n},pure:!1,arity:ae(1)},"random-color!":{evaluate:()=>`#${Math.floor(16777216*Math.random()).toString(16).padStart(6,"0")}`,pure:!1,arity:ae(0)}};function Kr(e,t=1){if(e<1){return Kr(e+1-1/3,t)*Math.random()**(1/e)}const r=e-1/3,n=1/Math.sqrt(9*r);let o,a,i;for(;;){do{o=Jr(),a=1+n*o}while(a<=0);if(a*=a*a,i=Math.random(),i<1-.0331*o*o*o*o)return t*r*a;if(Math.log(i)<.5*o*o+r*(1-a+Math.log(a)))return t*r*a}}function Jr(){let e=0,t=0;for(;0===e;)e=Math.random();for(;0===t;)t=Math.random();return Math.sqrt(-2*Math.log(e))*Math.cos(2*Math.PI*t)}for(const[e,t]of Object.entries(Lr))_r[e]&&(_r[e].docs=t);const Yr={name:"random",functions:_r},Hr={"moving-mean":{category:"vector",description:"Returns the **moving mean** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving mean** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-mean } = import(vector);\nmoving-mean([1, 2, 3, 4, 5], 3)","let { moving-mean } = import(vector);\nmoving-mean([1, 2, 3, 4, 5], 5)"],seeAlso:["moving-fn","mean","vector.centered-moving-mean","vector.running-mean"]},"centered-moving-mean":{category:"vector",description:"Returns the **centered moving mean** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving mean** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-mean } = import(vector);\ncentered-moving-mean([1, 2, 3, 4, 5], 3)","let { centered-moving-mean } = import(vector);\ncentered-moving-mean([1, 2, 3, 4, 5], 3, 0, 10)","let { centered-moving-mean } = import(vector);\ncentered-moving-mean([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["mean","vector.moving-mean","vector.running-mean"]},"running-mean":{category:"vector",description:"Returns the **running mean** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-mean } = import(vector);\nrunning-mean([1, 2, 3, 4, 5])"],seeAlso:["running-fn","mean","vector.moving-mean","vector.centered-moving-mean"]},"geometric-mean":{category:"vector",description:"Returns the **geometric mean** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **geometric mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { geometric-mean } = import(vector);\ngeometric-mean([1, 2, 3])","let { geometric-mean } = import(vector);\ngeometric-mean([1, 2, 9])"],seeAlso:["vector.moving-geometric-mean","vector.centered-moving-geometric-mean","vector.running-geometric-mean","mean","vector.harmonic-mean"]},"moving-geometric-mean":{category:"vector",description:"Returns the **moving geometric mean** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving geometric mean** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-geometric-mean } = import(vector);\nmoving-geometric-mean([1, 2, 3, 4, 5], 3)","let { moving-geometric-mean } = import(vector);\nmoving-geometric-mean([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.geometric-mean","vector.centered-moving-geometric-mean","vector.running-geometric-mean"]},"centered-moving-geometric-mean":{category:"vector",description:"Returns the **centered moving geometric mean** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving geometric mean** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-geometric-mean } = import(vector);\ncentered-moving-geometric-mean([1, 2, 3, 4, 5], 3)","let { centered-moving-geometric-mean } = import(vector);\ncentered-moving-geometric-mean([1, 2, 3, 4, 5], 3, 0, 10)","let { centered-moving-geometric-mean } = import(vector);\ncentered-moving-geometric-mean([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["vector.geometric-mean","vector.moving-geometric-mean","vector.running-geometric-mean"]},"running-geometric-mean":{category:"vector",description:"Returns the **running geometric mean** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running geometric mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-geometric-mean } = import(vector);\nrunning-geometric-mean([1, 2, 3, 4, 5])"],seeAlso:["vector.geometric-mean","vector.moving-geometric-mean","vector.centered-moving-geometric-mean"]},"harmonic-mean":{category:"vector",description:"Returns the **harmonic mean** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **harmonic mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { harmonic-mean } = import(vector);\nharmonic-mean([1, 2, 3])","let { harmonic-mean } = import(vector);\nharmonic-mean([1, 2, 9])"],seeAlso:["vector.moving-harmonic-mean","vector.centered-moving-harmonic-mean","vector.running-harmonic-mean","mean","vector.geometric-mean"]},"moving-harmonic-mean":{category:"vector",description:"Returns the **moving harmonic mean** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving harmonic mean** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-harmonic-mean } = import(vector);\nmoving-harmonic-mean([1, 2, 3, 4, 5], 3)","let { moving-harmonic-mean } = import(vector);\nmoving-harmonic-mean([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.harmonic-mean","vector.centered-moving-harmonic-mean","vector.running-harmonic-mean"]},"centered-moving-harmonic-mean":{category:"vector",description:"Returns the **centered moving harmonic mean** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving harmonic mean** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-harmonic-mean } = import(vector);\ncentered-moving-harmonic-mean([1, 2, 3, 4, 5], 3)","let { centered-moving-harmonic-mean } = import(vector);\ncentered-moving-harmonic-mean([1, 2, 3, 4, 5], 3, 0, 10)","let { centered-moving-harmonic-mean } = import(vector);\ncentered-moving-harmonic-mean([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["vector.harmonic-mean","vector.moving-harmonic-mean","vector.running-harmonic-mean"]},"running-harmonic-mean":{category:"vector",description:"Returns the **running harmonic mean** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running harmonic mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-harmonic-mean } = import(vector);\nrunning-harmonic-mean([1, 2, 3, 4, 5])"],seeAlso:["vector.harmonic-mean","vector.moving-harmonic-mean","vector.centered-moving-harmonic-mean"]},"moving-median":{category:"vector",description:"Returns the **moving median** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving median** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-median } = import(vector);\nmoving-median([1, 2, 3, 4, 5], 3)","let { moving-median } = import(vector);\nmoving-median([1, 2, 3, 4, 5], 5)"],seeAlso:["median","vector.centered-moving-median","vector.running-median"]},"centered-moving-median":{category:"vector",description:"Returns the **centered moving median** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving median** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-median } = import(vector);\ncentered-moving-median([1, 2, 3, 4, 5], 3)","let { centered-moving-median } = import(vector);\ncentered-moving-median([1, 2, 3, 4, 5], 3, 0, 10)","let { centered-moving-median } = import(vector);\ncentered-moving-median([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["median","vector.moving-median","vector.running-median"]},"running-median":{category:"vector",description:"Returns the **running median** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running median** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-median } = import(vector);\nrunning-median([1, 2, 3, 4, 5])"],seeAlso:["median","vector.moving-median","vector.centered-moving-median"]},variance:{category:"vector",description:"Returns the **variance** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **variance** of."}},variants:[{argumentNames:["vector"]}],examples:["let { variance } = import(vector);\nvariance([1, 2, 3])","let { variance } = import(vector);\nvariance([1, 2, -3])"],seeAlso:["linear-algebra.cov","vector.moving-variance","vector.centered-moving-variance","vector.running-variance","vector.stdev","vector.sample-variance","vector.mad"]},"moving-variance":{category:"vector",description:"Returns the **moving variance** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving variance** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-variance } = import(vector);\nmoving-variance([1, 2, 3, 4, 5], 3)","let { moving-variance } = import(vector);\nmoving-variance([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.variance","vector.centered-moving-variance","vector.running-variance"]},"centered-moving-variance":{category:"vector",description:"Returns the **centered moving variance** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving variance** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-variance } = import(vector);\ncentered-moving-variance([1, 2, 3, 4, 5], 3)","let { centered-moving-variance } = import(vector);\ncentered-moving-variance([1, 2, 3, 4, 5], 3, 1)","let { centered-moving-variance } = import(vector);\ncentered-moving-variance([1, 2, 3, 4, 5], 3, 1, 5)","let { centered-moving-variance } = import(vector);\ncentered-moving-variance([1, 2, 3, 4, 5], 3, 0, 6)"],seeAlso:["vector.variance","vector.moving-variance","vector.running-variance"]},"running-variance":{category:"vector",description:"Returns the **running variance** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running variance** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-variance } = import(vector);\nrunning-variance([1, 2, 3, 4, 5])"],seeAlso:["vector.variance","vector.moving-variance","vector.centered-moving-variance"]},"sample-variance":{category:"vector",description:"Returns the sample variance of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the sample variance of."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-variance } = import(vector);\nsample-variance([1, 2, 3])","let { sample-variance } = import(vector);\nsample-variance([1, 2, -3])","let { sample-variance } = import(vector);\nsample-variance([1, 2, 3, 4])","let { sample-variance } = import(vector);\nsample-variance([1, 2, -3, 4])","let { sample-variance } = import(vector);\nsample-variance([1, 2, 3, 40, 50])"],seeAlso:["vector.moving-sample-variance","vector.centered-moving-sample-variance","vector.running-sample-variance","vector.variance","vector.sample-stdev"]},"moving-sample-variance":{category:"vector",description:"Returns the **moving sample variance** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample variance** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-variance } = import(vector);\nmoving-sample-variance([1, 2, 3, 4, 5], 3)","let { moving-sample-variance } = import(vector);\nmoving-sample-variance([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.sample-variance","vector.centered-moving-sample-variance","vector.running-sample-variance"]},"centered-moving-sample-variance":{category:"vector",description:"Returns the **centered moving sample variance** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample variance** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-variance } = import(vector);\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3)","let { centered-moving-sample-variance } = import(vector);\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3, 1)","let { centered-moving-sample-variance } = import(vector);\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3, 1, 5)","let { centered-moving-sample-variance } = import(vector);\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3, 0, 6)"],seeAlso:["vector.sample-variance","vector.moving-sample-variance","vector.running-sample-variance"]},"running-sample-variance":{category:"vector",description:"Returns the **running sample variance** of the `vector`.",returns:{type:"array"},args:{vector:{type:"vector",description:"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."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-variance } = import(vector);\nrunning-sample-variance([1, 2, 3, 4, 5])"],seeAlso:["vector.sample-variance","vector.moving-sample-variance","vector.centered-moving-sample-variance"]},stdev:{category:"vector",description:"Returns the standard deviation of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the standard deviation of."}},variants:[{argumentNames:["vector"]}],examples:["let { stdev } = import(vector);\nstdev([1, 2, 3])","let { stdev } = import(vector);\nstdev([1, 2, -3])","let { stdev } = import(vector);\nstdev([1, 2, 3, 4])","let { stdev } = import(vector);\nstdev([1, 2, -3, 4])","let { stdev } = import(vector);\nstdev([1, 2, 3, 40, 50])"],seeAlso:["vector.moving-stdev","vector.centered-moving-stdev","vector.running-stdev","vector.variance","vector.sample-stdev","vector.rms","vector.mad"]},"moving-stdev":{category:"vector",description:"Returns the **moving standard deviation** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving standard deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-stdev } = import(vector);\nmoving-stdev([1, 2, 3, 4, 5], 3)","let { moving-stdev } = import(vector);\nmoving-stdev([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.stdev","vector.centered-moving-stdev","vector.running-stdev"]},"centered-moving-stdev":{category:"vector",description:"Returns the **centered moving standard deviation** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving standard deviation** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-stdev } = import(vector);\ncentered-moving-stdev([1, 2, 3, 4, 5], 3)","let { centered-moving-stdev } = import(vector);\ncentered-moving-stdev([1, 2, 3, 4, 5], 3, 1)","let { centered-moving-stdev } = import(vector);\ncentered-moving-stdev([1, 2, 3, 4, 5], 3, 1, 5)","let { centered-moving-stdev } = import(vector);\ncentered-moving-stdev([1, 2, 3, 4, 5], 3, 0, 6)"],seeAlso:["vector.stdev","vector.moving-stdev","vector.running-stdev"]},"running-stdev":{category:"vector",description:"Returns the **running standard deviation** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running standard deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-stdev } = import(vector);\nrunning-stdev([1, 2, 3, 4, 5])"],seeAlso:["vector.stdev","vector.moving-stdev","vector.centered-moving-stdev"]},"sample-stdev":{category:"vector",description:"Returns the sample standard deviation of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the sample standard deviation of."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-stdev } = import(vector);\nsample-stdev([1, 2, 3])","let { sample-stdev } = import(vector);\nsample-stdev([1, 2, -3])","let { sample-stdev } = import(vector);\nsample-stdev([1, 2, 3, 4])","let { sample-stdev } = import(vector);\nsample-stdev([1, 2, -3, 4])","let { sample-stdev } = import(vector);\nsample-stdev([1, 2, 3, 40, 50])"],seeAlso:["vector.moving-sample-stdev","vector.centered-moving-sample-stdev","vector.running-sample-stdev","vector.stdev","vector.sample-variance"]},"moving-sample-stdev":{category:"vector",description:"Returns the **moving sample standard deviation** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample standard deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-stdev } = import(vector);\nmoving-sample-stdev([1, 2, 3, 4, 5], 3)","let { moving-sample-stdev } = import(vector);\nmoving-sample-stdev([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.sample-stdev","vector.centered-moving-sample-stdev","vector.running-sample-stdev"]},"centered-moving-sample-stdev":{category:"vector",description:"Returns the **centered moving sample standard deviation** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample standard deviation** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-stdev } = import(vector);\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3)","let { centered-moving-sample-stdev } = import(vector);\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3, 1)","let { centered-moving-sample-stdev } = import(vector);\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3, 1, 5)","let { centered-moving-sample-stdev } = import(vector);\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3, 0, 6)"],seeAlso:["vector.sample-stdev","vector.moving-sample-stdev","vector.running-sample-stdev"]},"running-sample-stdev":{category:"vector",description:"Returns the **running sample standard deviation** of the `vector`.",returns:{type:"array"},args:{vector:{type:"vector",description:"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."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-stdev } = import(vector);\nrunning-sample-stdev([1, 2, 3, 4, 5])"],seeAlso:["vector.sample-stdev","vector.moving-sample-stdev","vector.centered-moving-sample-stdev"]},iqr:{category:"vector",description:"Calculates the **interquartile range** of a `vector`. Returns the difference between the third and first quartiles.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **interquartile range** of. Minimum length is 4."}},variants:[{argumentNames:["vector"]}],examples:["let { iqr } = import(vector);\niqr([1, 2, 3, 4])","let { iqr } = import(vector);\niqr([5, 4, 3, 2, 1, 2, 3, 4, 5])","let { iqr } = import(vector);\niqr(range(1, 1000))","let { iqr } = import(vector);\niqr(map(range(1000), -> 1e6 / ($ + 1) ^ 2))","let { iqr } = import(vector);\nlet { ln } = import(math);\niqr(map(range(1000), -> ln($ + 1)))"],seeAlso:["vector.moving-iqr","vector.centered-moving-iqr","vector.running-iqr","vector.quartiles","median","vector.mad","vector.medad","vector.outliers?","vector.outliers"]},"moving-iqr":{category:"vector",description:"Calculates the **moving interquartile range** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving interquartile range** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-iqr } = import(vector);\nmoving-iqr([1, 2, 4, 7, 11, 16], 4)","let { moving-iqr } = import(vector);\nmoving-iqr([1, 2, 4, 7, 11, 16], 5)","let { moving-iqr } = import(vector);\nmoving-iqr([1, 2, 4, 7, 11, 16], 6)"],seeAlso:["vector.iqr","vector.centered-moving-iqr","vector.running-iqr"]},"centered-moving-iqr":{category:"vector",description:"Calculates the **centered moving interquartile range** of a `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving interquartile range** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-iqr } = import(vector);\ncentered-moving-iqr([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-iqr } = import(vector);\ncentered-moving-iqr([1, 2, 4, 7, 11, 16], 4, 0, 0)"],seeAlso:["vector.iqr","vector.moving-iqr","vector.running-iqr"]},"running-iqr":{category:"vector",description:"Calculates the **running interquartile range** of a `vector`. First three element in result is `null` since **running interquartile range** is not defined for less than four elements.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running interquartile range** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-iqr } = import(vector);\nrunning-iqr([1, 2, 3, 4, 5, 6])","let { running-iqr } = import(vector);\nrunning-iqr([-1, -2, -3, 1, 2, 3])"],seeAlso:["vector.iqr","vector.moving-iqr","vector.centered-moving-iqr"]},"moving-sum":{category:"vector",description:"Returns the **moving sum** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sum** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sum } = import(vector);\nmoving-sum([1, 2, 3, 4, 5], 3)","let { moving-sum } = import(vector);\nmoving-sum([1, 2, 3, 4, 5], 5)"],seeAlso:["sum","vector.centered-moving-sum","vector.running-sum"]},"centered-moving-sum":{category:"vector",description:"Returns the **centered moving sum** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sum** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sum } = import(vector);\ncentered-moving-sum([1, 2, 3, 4, 5], 3)","let { centered-moving-sum } = import(vector);\ncentered-moving-sum([1, 2, 3, 4, 5], 3, 0, 0)","let { centered-moving-sum } = import(vector);\ncentered-moving-sum([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["sum","vector.moving-sum","vector.running-sum"]},"running-sum":{category:"vector",description:"Returns the **running sum** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sum** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sum } = import(vector);\nrunning-sum([1, 2, 3])","let { running-sum } = import(vector);\nrunning-sum([1, -2, -3])"],seeAlso:["sum","vector.moving-sum","vector.centered-moving-sum","vector.cumsum"]},"moving-prod":{category:"vector",description:"Returns the **moving product** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving product** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-prod } = import(vector);\nmoving-prod([1, 2, 3, 4, 5], 3)","let { moving-prod } = import(vector);\nmoving-prod([1, 2, 3, 4, 5], 5)"],seeAlso:["prod","vector.centered-moving-prod","vector.running-prod"]},"centered-moving-prod":{category:"vector",description:"Returns the **centered moving product** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving product** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-prod } = import(vector);\ncentered-moving-prod([1, 2, 3, 4, 5], 3)","let { centered-moving-prod } = import(vector);\ncentered-moving-prod([1, 2, 3, 4, 5], 3, 0, 0)"],seeAlso:["prod","vector.moving-prod","vector.running-prod"]},"running-prod":{category:"vector",description:"Returns the **running product** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running product** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-prod } = import(vector);\nrunning-prod([1, 2, 3, 4, 5])","let { running-prod } = import(vector);\nrunning-prod([1, -2, -3])"],seeAlso:["prod","vector.moving-prod","vector.centered-moving-prod","vector.cumprod"]},span:{category:"vector",description:"Returns the difference between the maximum and minimum values in a vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to calculate the span of."}},variants:[{argumentNames:["vector"]}],examples:["let { span } = import(vector);\nspan([1, 2, 3])","let { span } = import(vector);\nspan([1, 1, 2, 3, 3])","let { span } = import(vector);\nspan([1, 2, -3])"],seeAlso:["vector.moving-span","vector.centered-moving-span","vector.running-span","min","max"]},"moving-span":{category:"vector",description:"Calculates the **moving span** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving span** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-span } = import(vector);\nmoving-span([1, 2, 4, 7, 11, 16], 4)","let { moving-span } = import(vector);\nmoving-span([1, 2, 4, 7, 11, 16], 5)","let { moving-span } = import(vector);\nmoving-span([1, 2, 4, 7, 11, 16], 6)"],seeAlso:["vector.span","vector.centered-moving-span","vector.running-span"]},"centered-moving-span":{category:"vector",description:"Calculates the **centered moving span** of a `vector` with a given window size. The result is padded with `leftPadding` on the left and right.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving span** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"The value to pad the result with on the left."},rightPadding:{type:"number",description:"The value to pad the result with on the right."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-span } = import(vector);\ncentered-moving-span([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-span } = import(vector);\ncentered-moving-span([1, 2, 4, 7, 11, 16], 3, 0, 100)"],seeAlso:["vector.span","vector.moving-span","vector.running-span"]},"running-span":{category:"vector",description:"Calculates the **running span** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running span** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-span } = import(vector);\nrunning-span([1, 2, 4])"],seeAlso:["vector.span","vector.moving-span","vector.centered-moving-span"]},skewness:{category:"vector",description:"Calculates the **skewness** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **skewness** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { skewness } = import(vector);\nskewness([1, 2, 3, 6, 20])","let { skewness } = import(vector);\nskewness([1, 2, 2, 3])"],seeAlso:["vector.moving-skewness","vector.centered-moving-skewness","vector.running-skewness","vector.kurtosis","vector.sample-skewness","vector.excess-kurtosis"]},"moving-skewness":{category:"vector",description:"Calculates the **moving skewness** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving skewness** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-skewness } = import(vector);\nmoving-skewness([1, 2, 4, 7, 11, 16], 4)","let { moving-skewness } = import(vector);\nmoving-skewness([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.skewness","vector.centered-moving-skewness","vector.running-skewness"]},"centered-moving-skewness":{category:"vector",description:"Calculates the **centered moving skewness** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving skewness** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-skewness } = import(vector);\ncentered-moving-skewness([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-skewness } = import(vector);\ncentered-moving-skewness([1, 2, 4, 7, 11, 16], 4, 0, 0)"],seeAlso:["vector.skewness","vector.moving-skewness","vector.running-skewness"]},"running-skewness":{category:"vector",description:"Calculates the **running skewness** of a `vector` with a given window size. First two element in result is `null` since **running skewness** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running skewness** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-skewness } = import(vector);\nrunning-skewness([1, 2, 4, 7, 11])"],seeAlso:["vector.skewness","vector.moving-skewness","vector.centered-moving-skewness"]},"sample-skewness":{category:"vector",description:"Calculates the **sample skewness** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **sample skewness** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-skewness } = import(vector);\nsample-skewness([1, 2, 3, 6, 20])","let { sample-skewness } = import(vector);\nsample-skewness([1, 2, 2, 3])"],seeAlso:["vector.moving-sample-skewness","vector.centered-moving-sample-skewness","vector.running-sample-skewness","vector.skewness","vector.sample-kurtosis"]},"moving-sample-skewness":{category:"vector",description:"Calculates the **moving sample skewness** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample skewness** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-skewness } = import(vector);\nmoving-sample-skewness([1, 2, 4, 7, 11, 16], 4)","let { moving-sample-skewness } = import(vector);\nmoving-sample-skewness([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.sample-skewness","vector.centered-moving-sample-skewness","vector.running-sample-skewness"]},"centered-moving-sample-skewness":{category:"vector",description:"Calculates the **centered moving sample skewness** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample skewness** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-skewness } = import(vector);\ncentered-moving-sample-skewness([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-sample-skewness } = import(vector);\ncentered-moving-sample-skewness([1, 2, 4, 7, 11, 16], 3, 0, 100)"],seeAlso:["vector.sample-skewness","vector.moving-sample-skewness","vector.running-sample-skewness"]},"running-sample-skewness":{category:"vector",description:"Calculates the **running sample skewness** of a `vector` with a given window size. First two element in result is `null` since **running sample skewness** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sample skewness** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-skewness } = import(vector);\nrunning-sample-skewness([1, 2, 4, 7, 11])"],seeAlso:["vector.sample-skewness","vector.moving-sample-skewness","vector.centered-moving-sample-skewness"]},"excess-kurtosis":{category:"vector",description:"Calculates the **excess kurtosis** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **excess kurtosis** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { excess-kurtosis } = import(vector);\nexcess-kurtosis([1, 2, 3, 6, 20])","let { excess-kurtosis } = import(vector);\nexcess-kurtosis([1, 2, 2, 3])"],seeAlso:["vector.moving-excess-kurtosis","vector.centered-moving-excess-kurtosis","vector.running-excess-kurtosis","vector.kurtosis","vector.sample-excess-kurtosis","vector.skewness"]},"moving-excess-kurtosis":{category:"vector",description:"Calculates the **moving excess kurtosis** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving excess kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-excess-kurtosis } = import(vector);\nmoving-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { moving-excess-kurtosis } = import(vector);\nmoving-excess-kurtosis([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.excess-kurtosis","vector.centered-moving-excess-kurtosis","vector.running-excess-kurtosis"]},"centered-moving-excess-kurtosis":{category:"vector",description:"Calculates the **centered moving excess kurtosis** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving excess kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-excess-kurtosis } = import(vector);\ncentered-moving-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-excess-kurtosis } = import(vector);\ncentered-moving-excess-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 0)"],seeAlso:["vector.excess-kurtosis","vector.moving-excess-kurtosis","vector.running-excess-kurtosis"]},"running-excess-kurtosis":{category:"vector",description:"Calculates the **running excess kurtosis** of a `vector` with a given window size. First two element in result is `null` since **running excess kurtosis** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running excess kurtosis** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-excess-kurtosis } = import(vector);\nrunning-excess-kurtosis([1, 2, 4, 7, 11])"],seeAlso:["vector.excess-kurtosis","vector.moving-excess-kurtosis","vector.centered-moving-excess-kurtosis"]},kurtosis:{category:"vector",description:"Calculates the **kurtosis** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **kurtosis** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { kurtosis } = import(vector);\nkurtosis([1, 2, 3, 6, 20])","let { kurtosis } = import(vector);\nkurtosis([1, 2, 2, 3])"],seeAlso:["vector.moving-kurtosis","vector.centered-moving-kurtosis","vector.running-kurtosis","vector.excess-kurtosis","vector.sample-kurtosis","vector.skewness"]},"moving-kurtosis":{category:"vector",description:"Calculates the **moving kurtosis** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-kurtosis } = import(vector);\nmoving-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { moving-kurtosis } = import(vector);\nmoving-kurtosis([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.kurtosis","vector.centered-moving-kurtosis","vector.running-kurtosis"]},"centered-moving-kurtosis":{category:"vector",description:"Calculates the **centered moving kurtosis** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-kurtosis } = import(vector);\ncentered-moving-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-kurtosis } = import(vector);\ncentered-moving-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 0)"],seeAlso:["vector.kurtosis","vector.moving-kurtosis","vector.running-kurtosis"]},"running-kurtosis":{category:"vector",description:"Calculates the **running kurtosis** of a `vector` with a given window size. First two element in result is `null` since **running kurtosis** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running kurtosis** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-kurtosis } = import(vector);\nrunning-kurtosis([1, 2, 4, 7, 11])"],seeAlso:["vector.kurtosis","vector.moving-kurtosis","vector.centered-moving-kurtosis"]},"sample-excess-kurtosis":{category:"vector",description:"Calculates the **sample excess kurtosis** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **sample excess kurtosis** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-excess-kurtosis } = import(vector);\nsample-excess-kurtosis([1, 2, 3, 6, 20])","let { sample-excess-kurtosis } = import(vector);\nsample-excess-kurtosis([1, 2, 2, 3])"],seeAlso:["vector.moving-sample-excess-kurtosis","vector.centered-moving-sample-excess-kurtosis","vector.running-sample-excess-kurtosis","vector.sample-kurtosis","vector.excess-kurtosis"]},"moving-sample-excess-kurtosis":{category:"vector",description:"Calculates the **moving sample excess kurtosis** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample excess kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-excess-kurtosis } = import(vector);\nmoving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { moving-sample-excess-kurtosis } = import(vector);\nmoving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.sample-excess-kurtosis","vector.centered-moving-sample-excess-kurtosis","vector.running-sample-excess-kurtosis"]},"centered-moving-sample-excess-kurtosis":{category:"vector",description:"Calculates the **centered moving sample excess kurtosis** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample excess kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-excess-kurtosis } = import(vector);\ncentered-moving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-sample-excess-kurtosis } = import(vector);\ncentered-moving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 100)"],seeAlso:["vector.sample-excess-kurtosis","vector.moving-sample-excess-kurtosis","vector.running-sample-excess-kurtosis"]},"running-sample-excess-kurtosis":{category:"vector",description:"Calculates the **running sample excess kurtosis** of a `vector` with a given window size. First two element in result is `null` since **running sample excess kurtosis** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sample excess kurtosis** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-excess-kurtosis } = import(vector);\nrunning-sample-excess-kurtosis([1, 2, 4, 7, 11])"],seeAlso:["vector.sample-excess-kurtosis","vector.moving-sample-excess-kurtosis","vector.centered-moving-sample-excess-kurtosis"]},"sample-kurtosis":{category:"vector",description:"Calculates the **sample kurtosis** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **sample kurtosis** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-kurtosis } = import(vector);\nsample-kurtosis([1, 2, 3, 6, 20])","let { sample-kurtosis } = import(vector);\nsample-kurtosis([1, 2, 2, 3])"],seeAlso:["vector.moving-sample-kurtosis","vector.centered-moving-sample-kurtosis","vector.running-sample-kurtosis","vector.sample-excess-kurtosis","vector.kurtosis","vector.sample-skewness"]},"moving-sample-kurtosis":{category:"vector",description:"Calculates the **moving sample kurtosis** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-kurtosis } = import(vector);\nmoving-sample-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { moving-sample-kurtosis } = import(vector);\nmoving-sample-kurtosis([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.sample-kurtosis","vector.centered-moving-sample-kurtosis","vector.running-sample-kurtosis"]},"centered-moving-sample-kurtosis":{category:"vector",description:"Calculates the **centered moving sample kurtosis** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-kurtosis } = import(vector);\ncentered-moving-sample-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-sample-kurtosis } = import(vector);\ncentered-moving-sample-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 100)"],seeAlso:["vector.sample-kurtosis","vector.moving-sample-kurtosis","vector.running-sample-kurtosis"]},"running-sample-kurtosis":{category:"vector",description:"Calculates the **running sample kurtosis** of a `vector` with a given window size. First two element in result is `null` since **running sample kurtosis** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sample kurtosis** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-kurtosis } = import(vector);\nrunning-sample-kurtosis([1, 2, 4, 7, 11])"],seeAlso:["vector.sample-kurtosis","vector.moving-sample-kurtosis","vector.centered-moving-sample-kurtosis"]},rms:{category:"vector",description:"Calculates the **root mean square** of a `vector`. Returns the square root of the average of the squares of the elements.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **root mean square** of. Minimum length is 1."}},variants:[{argumentNames:["vector"]}],examples:["let { rms } = import(vector);\nrms([1, 2, 3, 4])","let { rms } = import(vector);\nrms([5, 4, 3, 2, 1])","let { rms } = import(vector);\nrms(range(1, 1000))","let { rms } = import(vector);\nrms(map(range(1000), -> 1e6 / ($ + 1) ^ 2))","let { rms } = import(vector);\nlet { ln } = import(math);\nrms(map(range(1000), -> ln($ + 1)))"],seeAlso:["vector.moving-rms","vector.centered-moving-rms","vector.running-rms","mean","vector.stdev"]},"moving-rms":{category:"vector",description:"Calculates the **moving root mean square** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving root mean square** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-rms } = import(vector);\nmoving-rms([1, 2, 4, 7, 11, 16], 4)","let { moving-rms } = import(vector);\nmoving-rms([1, 2, 4, 7, 11, 16], 5)","let { moving-rms } = import(vector);\nmoving-rms([1, 2, 4, 7, 11, 16], 6)"],seeAlso:["vector.rms","vector.centered-moving-rms","vector.running-rms"]},"centered-moving-rms":{category:"vector",description:"Calculates the **centered moving root mean square** of a `vector` with a given window size and padding value.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving root mean square** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-rms } = import(vector);\ncentered-moving-rms([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-rms } = import(vector);\ncentered-moving-rms([1, 2, 4, 7, 11, 16], 5, 0)","let { centered-moving-rms } = import(vector);\ncentered-moving-rms([1, 2, 4, 7, 11, 16], 6, 0, 0)"],seeAlso:["vector.rms","vector.moving-rms","vector.running-rms"]},"running-rms":{category:"vector",description:"Calculates the **running root mean square** of a `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running root mean square** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-rms } = import(vector);\nrunning-rms([1, 2, 3, 4, 5, 6])","let { running-rms } = import(vector);\nrunning-rms([1, -3, 2])","let { running-rms } = import(vector);\nrunning-rms([-1, -2, -3])","let { running-rms } = import(vector);\nrunning-rms([0])"],seeAlso:["vector.rms","vector.moving-rms","vector.centered-moving-rms"]},mad:{category:"vector",description:"Returns the **mean absolute deviation** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **mean absolute deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { mad } = import(vector);\nmad([1, 2, 3])","let { mad } = import(vector);\nmad([1, 2, -3])"],seeAlso:["vector.moving-mad","vector.centered-moving-mad","vector.running-mad","vector.medad","vector.stdev","vector.variance","vector.iqr"]},"moving-mad":{category:"vector",description:"Returns the **moving mean absolute deviation** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving mean absolute deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-mad } = import(vector);\nmoving-mad([1, 2, 3, 4, 5], 3)","let { moving-mad } = import(vector);\nmoving-mad([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.mad","vector.centered-moving-mad","vector.running-mad"]},"centered-moving-mad":{category:"vector",description:"Returns the **centered moving mean absolute deviation** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving mean absolute deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-mad } = import(vector);\ncentered-moving-mad([1, 2, 3, 4, 5], 3)","let { centered-moving-mad } = import(vector);\ncentered-moving-mad([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.mad","vector.moving-mad","vector.running-mad"]},"running-mad":{category:"vector",description:"Returns the **running mean absolute deviation** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running mean absolute deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-mad } = import(vector);\nrunning-mad([1, 2, 3])","let { running-mad } = import(vector);\nrunning-mad([1, 2, -3])"],seeAlso:["vector.mad","vector.moving-mad","vector.centered-moving-mad"]},medad:{category:"vector",description:"Returns the **median absolute deviation** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **median absolute deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { medad } = import(vector);\nmedad([1, 2, 3])","let { medad } = import(vector);\nmedad([1, 2, -3])"],seeAlso:["vector.moving-medad","vector.centered-moving-medad","vector.running-medad","vector.mad","median","vector.iqr"]},"moving-medad":{category:"vector",description:"Returns the **moving median absolute deviation** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving median absolute deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-medad } = import(vector);\nmoving-medad([1, 2, 3, 4, 5], 3)","let { moving-medad } = import(vector);\nmoving-medad([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.medad","vector.centered-moving-medad","vector.running-medad"]},"centered-moving-medad":{category:"vector",description:"Returns the **centered moving median absolute deviation** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving median absolute deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-medad } = import(vector);\ncentered-moving-medad([1, 2, 3, 4, 5], 3)","let { centered-moving-medad } = import(vector);\ncentered-moving-medad([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.medad","vector.moving-medad","vector.running-medad"]},"running-medad":{category:"vector",description:"Returns the **running median absolute deviation** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running median absolute deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-medad } = import(vector);\nrunning-medad([1, 2, 3])","let { running-medad } = import(vector);\nrunning-medad([1, 2, -3])"],seeAlso:["vector.medad","vector.moving-medad","vector.centered-moving-medad"]},"gini-coefficient":{category:"vector",description:"Returns the **gini coefficient** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **gini coefficient** of."}},variants:[{argumentNames:["vector"]}],examples:["let { gini-coefficient } = import(vector);\ngini-coefficient([1, 2, 3])","let { gini-coefficient } = import(vector);\ngini-coefficient([1, 1, 3])"],seeAlso:["vector.moving-gini-coefficient","vector.centered-moving-gini-coefficient","vector.running-gini-coefficient","vector.entropy"]},"moving-gini-coefficient":{category:"vector",description:"Returns the **moving gini coefficient** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving gini coefficient** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-gini-coefficient } = import(vector);\nmoving-gini-coefficient([1, 2, 3], 2)","let { moving-gini-coefficient } = import(vector);\nmoving-gini-coefficient([1, 1, 3], 2)"],seeAlso:["vector.gini-coefficient","vector.centered-moving-gini-coefficient","vector.running-gini-coefficient"]},"centered-moving-gini-coefficient":{category:"vector",description:"Returns the **centered moving gini coefficient** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving gini coefficient** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-gini-coefficient } = import(vector);\ncentered-moving-gini-coefficient([1, 2, 3], 2)","let { centered-moving-gini-coefficient } = import(vector);\ncentered-moving-gini-coefficient([1, 1, 3], 2)"],seeAlso:["vector.gini-coefficient","vector.moving-gini-coefficient","vector.running-gini-coefficient"]},"running-gini-coefficient":{category:"vector",description:"Returns the **running gini coefficient** of the `vector`.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running gini coefficient** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-gini-coefficient } = import(vector);\nrunning-gini-coefficient([1, 2, 3])","let { running-gini-coefficient } = import(vector);\nrunning-gini-coefficient([1, 1, 3])"],seeAlso:["vector.gini-coefficient","vector.moving-gini-coefficient","vector.centered-moving-gini-coefficient"]},entropy:{category:"vector",description:"Calculates the **entropy** of a `vector`. The entropy is a measure of the uncertainty associated with a random variable.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **entropy** of. Minimum length is 1."}},variants:[{argumentNames:["vector"]}],examples:["let { entropy } = import(vector);\nentropy([1, 1, 2, 3, 3, 3])","let { entropy } = import(vector);\nentropy([1, 2, 3])","let { entropy } = import(vector);\nentropy([1, 2, 2, 3])","let { entropy } = import(vector);\nentropy([0])","let { entropy } = import(vector);\nentropy([1])","let { entropy } = import(vector);\nentropy([1, 2])"],seeAlso:["vector.moving-entropy","vector.centered-moving-entropy","vector.running-entropy","vector.gini-coefficient"]},"moving-entropy":{category:"vector",description:"Calculates the **moving entropy** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving entropy** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-entropy } = import(vector);\nmoving-entropy([1, 1, 2, 3, 3, 3], 4)","let { moving-entropy } = import(vector);\nmoving-entropy([1, 1, 2, 3, 3, 3], 3)","let { moving-entropy } = import(vector);\nmoving-entropy([1, 2], 2)"],seeAlso:["vector.entropy","vector.centered-moving-entropy","vector.running-entropy"]},"centered-moving-entropy":{category:"vector",description:"Calculates the **centered moving entropy** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving entropy** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-entropy } = import(vector);\ncentered-moving-entropy([1, 1, 2, 3, 3, 3], 4)","let { centered-moving-entropy } = import(vector);\ncentered-moving-entropy([1, 1, 2, 3, 3, 3], 3)","let { centered-moving-entropy } = import(vector);\ncentered-moving-entropy([1, 2], 2)"],seeAlso:["vector.entropy","vector.moving-entropy","vector.running-entropy"]},"running-entropy":{category:"vector",description:"Calculates the **running entropy** of a `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running entropy** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-entropy } = import(vector);\nrunning-entropy([1, 1, 2, 3, 3, 3])","let { running-entropy } = import(vector);\nrunning-entropy([1, 2])"],seeAlso:["vector.entropy","vector.moving-entropy","vector.centered-moving-entropy"]},"monotonic?":{category:"vector",description:"Checks if a vector is monotonic.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { monotonic? } = import(vector);\nmonotonic?([1, 2, 3])","let { monotonic? } = import(vector);\nmonotonic?([1, 2, 2, 3])","let { monotonic? } = import(vector);\nmonotonic?([3, 2, 1])","let { monotonic? } = import(vector);\nmonotonic?([3, 2, 1, 1])","let { monotonic? } = import(vector);\nmonotonic?([3, 2, 1, 2])","let { monotonic? } = import(vector);\nmonotonic?([1])","let { monotonic? } = import(vector);\nmonotonic?([])"],seeAlso:["vector.strictly-monotonic?","vector.increasing?","vector.decreasing?"]},"strictly-monotonic?":{category:"vector",description:"Checks if a vector is strictly monotonic.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([1, 2, 3])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([1, 2, 2, 3])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([3, 2, 1])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([3, 2, 1, 1])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([3, 2, 1, 2])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([1])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([])"],seeAlso:["vector.monotonic?","vector.strictly-increasing?","vector.strictly-decreasing?"]},"increasing?":{category:"vector",description:"Checks if a vector is increasing.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { increasing? } = import(vector);\nincreasing?([1, 2, 3])","let { increasing? } = import(vector);\nincreasing?([1, 2, 2, 3])","let { increasing? } = import(vector);\nincreasing?([3, 2, 1])","let { increasing? } = import(vector);\nincreasing?([3, 2, 1, 1])","let { increasing? } = import(vector);\nincreasing?([3, 2, 1, 2])","let { increasing? } = import(vector);\nincreasing?([1])","let { increasing? } = import(vector);\nincreasing?([])"],seeAlso:["vector.strictly-increasing?","vector.decreasing?","vector.strictly-decreasing?","vector.monotonic?"]},"decreasing?":{category:"vector",description:"Checks if a vector is decreasing.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { decreasing? } = import(vector);\ndecreasing?([1, 2, 3])","let { decreasing? } = import(vector);\ndecreasing?([1, 2, 2, 3])","let { decreasing? } = import(vector);\ndecreasing?([3, 2, 1])","let { decreasing? } = import(vector);\ndecreasing?([3, 2, 1, 1])","let { decreasing? } = import(vector);\ndecreasing?([3, 2, 1, 2])","let { decreasing? } = import(vector);\ndecreasing?([1])","let { decreasing? } = import(vector);\ndecreasing?([])"],seeAlso:["vector.strictly-decreasing?","vector.increasing?","vector.strictly-increasing?","vector.monotonic?"]},"strictly-increasing?":{category:"vector",description:"Checks if a vector is strictly increasing.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { strictly-increasing? } = import(vector);\nstrictly-increasing?([1, 2, 3])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([1, 2, 2, 3])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([3, 2, 1])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([3, 2, 1, 1])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([3, 2, 1, 2])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([1])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([])"],seeAlso:["vector.increasing?","vector.decreasing?","vector.strictly-decreasing?","vector.strictly-monotonic?"]},"strictly-decreasing?":{category:"vector",description:"Checks if a vector is strictly decreasing.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([1, 2, 3])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([1, 2, 2, 3])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([3, 2, 1])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([3, 2, 1, 1])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([3, 2, 1, 2])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([1])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([])"],seeAlso:["vector.increasing?","vector.strictly-increasing?","vector.decreasing?","vector.strictly-monotonic?"]},mode:{category:"vector",description:"Returns the mode of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to calculate the mode of."}},variants:[{argumentNames:["vector"]}],examples:["let { mode } = import(vector);\nmode([1, 2, 3])","let { mode } = import(vector);\nmode([1, 2, -3, 1])","let { mode } = import(vector);\nmode([2, 2, 3, 3, 4])","let { mode } = import(vector);\nmode([2, 2, 3, 3])","let { mode } = import(vector);\nmode([1, 2, 3, 2, 1, 2])"],seeAlso:["mean","median"]},"min-index":{category:"vector",description:"Returns the index of the minimum value of all elements in the vector.",returns:{type:"integer"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the minimum index of."}},variants:[{argumentNames:["vector"]}],examples:["let { min-index } = import(vector);\nmin-index([1, 2, 3])","let { min-index } = import(vector);\nmin-index([1, 1, 2, 3, 3])","let { min-index } = import(vector);\nmin-index([1, 2, -3])","let { min-index } = import(vector);\nmin-index([1, 2, 3, 4])","let { min-index } = import(vector);\nmin-index([1, 2, -3, 4])"],seeAlso:["vector.max-index","min"]},"max-index":{category:"vector",description:"Returns the index of the maximum value of all elements in the vector.",returns:{type:"integer"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the maximum index of."}},variants:[{argumentNames:["vector"]}],examples:["let { max-index } = import(vector);\nmax-index([1, 2, 3])","let { max-index } = import(vector);\nmax-index([1, 1, 2, 3, 3])","let { max-index } = import(vector);\nmax-index([1, 2, -3])","let { max-index } = import(vector);\nmax-index([1, 2, 3, 4])","let { max-index } = import(vector);\nmax-index([1, 2, -3, 4])"],seeAlso:["vector.min-index","max"]},"sort-indices":{category:"vector",description:"Returns the indices of the elements in the vector sorted in ascending order.",returns:{type:"vector"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the sorted indices of."}},variants:[{argumentNames:["vector"]}],examples:["let { sort-indices } = import(vector);\nsort-indices([1, 2, 3])","let { sort-indices } = import(vector);\nsort-indices([1, 1, 2, 3, 3])","let { sort-indices } = import(vector);\nsort-indices([1, 2, -3])","let { sort-indices } = import(vector);\nsort-indices([1, 2, 3, 4])","let { sort-indices } = import(vector);\nsort-indices([1, 2, -3, 4])"],seeAlso:["sort"]},"count-values":{category:"vector",description:"Counts the number of occurrences of each value in the vector.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"Vector to count the values of."}},variants:[{argumentNames:["vector"]}],examples:["let { count-values } = import(vector);\ncount-values([1, 2, 3])","let { count-values } = import(vector);\ncount-values([1, 1, 2, 3, 3])","let { count-values } = import(vector);\ncount-values([1, 2, -3])","let { count-values } = import(vector);\ncount-values([1, 2, 2, 1, 3, 2, 4, 2, 1, 2, 2, 1, 3, 2, 4])"],seeAlso:["sequence.frequencies","vector.bincount"]},linspace:{category:"vector",description:"Generates a vector of evenly spaced numbers between two values.",returns:{type:"number",array:!0},args:{start:{type:"number",description:"The starting value."},stop:{type:"number",description:"The ending value."},n:{type:"integer",description:"The number of values to generate."}},variants:[{argumentNames:["start","stop","n"]}],examples:["let { linspace } = import(vector);\nlinspace(0, 10, 6)","let { linspace } = import(vector);\nlinspace(10, 20, 25)"],seeAlso:["range"]},cumsum:{category:"vector",description:"Calculates the cumulative sum of a vector.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The vector to calculate the cumulative sum of."}},variants:[{argumentNames:["vector"]}],examples:["let { cumsum } = import(vector);\ncumsum([1, 2, 3])","let { cumsum } = import(vector);\ncumsum([1, 2, -3])","let { cumsum } = import(vector);\ncumsum([])"],seeAlso:["vector.cumprod","sum","vector.running-sum"]},cumprod:{category:"vector",description:"Calculates the cumulative product of a vector.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The vector to calculate the cumulative product of."}},variants:[{argumentNames:["vector"]}],examples:["let { cumprod } = import(vector);\ncumprod([1, 2, 3])","let { cumprod } = import(vector);\ncumprod([1, 2, -3, 0, 10])","let { cumprod } = import(vector);\ncumprod([])"],seeAlso:["vector.cumsum","prod","vector.running-prod"]},quartiles:{category:"vector",description:"Calculates the quartiles of a vector. Returns an array containing the first, second (median), and third quartiles.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The vector to calculate the quartiles of. Minimum length is 4."}},variants:[{argumentNames:["vector"]}],examples:["let { quartiles } = import(vector);\nquartiles([1, 2, 3, 4])","let { quartiles } = import(vector);\nquartiles([5, 4, 3, 2, 1, 2, 3, 4, 5])","let { quartiles } = import(vector);\nquartiles(range(1, 1000))","let { quartiles } = import(vector);\nquartiles(map(range(1000), -> 1e6 / ($ + 1) ^ 2))","let { quartiles } = import(vector);\nlet { ln } = import(math);\nquartiles(map(range(1000), -> ln($ + 1)))"],seeAlso:["vector.percentile","vector.quantile","median","vector.iqr"]},percentile:{category:"vector",description:"Calculates the percentile of a vector. Returns the value at the specified percentile.",returns:{type:"number"},args:{vector:{type:"vector",description:"The non empty vector to calculate the percentile of."},percentile:{type:"number",description:"The percentile to calculate. Must be between 0 and 1."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["vector","percentile"]}],examples:["let { percentile } = import(vector);\npercentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 35)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 0)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 10)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 20)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 30)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 40)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 50)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 60)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 70)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 80)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 90)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 100)"],seeAlso:["vector.quantile","vector.quartiles","median","vector.ecdf","vector.winsorize"]},quantile:{category:"vector",description:"Calculates the quantile of a vector. Returns the value at the specified quantile.",returns:{type:"number"},args:{vector:{type:"vector",description:"The non empty vector to calculate the quantile of."},quantile:{type:"number",description:"The quantile to calculate. Must be between 0 and 1."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["vector","quantile"]}],examples:["let { quantile } = import(vector);\nquantile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0.35)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.1)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.2)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.3)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.4)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.5)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.6)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.7)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.8)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.9)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 1)"],seeAlso:["vector.percentile","vector.quartiles","vector.ecdf"]},histogram:{category:"vector",description:"Creates a histogram from a numeric `array` by dividing the data range into the specified number of bins. Returns an `array` of `[binStart, binEnd, count]` tuples representing each bin's range and the number of values within it. Handles empty arrays, identical values, and properly places maximum values in the last bin.",returns:{type:"array",array:!0},args:{vector:{type:"vector",description:"The numeric array to create a histogram from."},bins:{type:"integer",description:"The number of bins to divide the data range into."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["vector","bins"]}],examples:["let { histogram } = import(vector);\nhistogram([1, 2, 2, 3, 2, 6, 4, 3, 2, 4, 1, 3, 2, 9], 3)","let { histogram } = import(vector);\nhistogram([1, 2, 3, 4, 5], 5)","let { histogram } = import(vector);\nhistogram([1, 2, 3, 4, 5], 10)","let { histogram } = import(vector);\nhistogram([1, 2, 3, 4, 5], 1)"],seeAlso:["vector.bincount","vector.ecdf"]},ecdf:{category:"vector",description:"Calculates the empirical cumulative distribution function value for a given threshold in a non empty dataset. Returns the proportion of values in the `array` that are less than or equal to the specified threshold.",returns:{type:"number"},args:{vector:{type:"vector",description:"The numeric array to calculate the ECDF from."},threshold:{type:"number",description:"The threshold value to calculate the ECDF for."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["vector","threshold"]}],examples:["let { ecdf } = import(vector);\necdf([1, 2, 2, 3, 2, 6, 4, 3, 2, 4, 1, 3, 2, 9, 10, 12], 5)","let { ecdf } = import(vector);\necdf([1, 2, 3, 4, 5], 3)","let { ecdf } = import(vector);\necdf([1, 2, 3, 4, 5], 0)","let { ecdf } = import(vector);\necdf([1, 2, 3, 4, 5], 10)","let { ecdf } = import(vector);\necdf([1, 2, 3, 4, 5], 2)"],seeAlso:["vector.histogram","vector.percentile","vector.quantile"]},"outliers?":{category:"vector",description:"Checks if the `vector` contains outliers based on the interquartile range (IQR) method. Returns `true` if outliers are present, `false` otherwise.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The `vector` to check for outliers."}},variants:[{argumentNames:["vector"]}],examples:["let { outliers? } = import(vector);\noutliers?([1, 2, 3])","let { outliers? } = import(vector);\noutliers?([1, 2, -3])","let { outliers? } = import(vector);\noutliers?([1, 2, 3, 2, 4, 120])"],seeAlso:["vector.outliers","vector.winsorize","vector.iqr"]},outliers:{category:"vector",description:"Identifies outliers in the `vector` based on the interquartile range (IQR) method. Returns an array of outlier values.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The `vector` to check for outliers."}},variants:[{argumentNames:["vector"]}],examples:["let { outliers } = import(vector);\noutliers([1, 2, 3])","let { outliers } = import(vector);\noutliers([1, 2, -3])","let { outliers } = import(vector);\noutliers([1, 2, 3, 2, 4, 120])"],seeAlso:["vector.outliers?","vector.winsorize","vector.iqr"]},bincount:{category:"vector",description:"counts occurrences of each `integer` in a vector, returning an array where index `i` contains the count of value `i`, with optional **minimum size** and **weights parameters**.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The vector to count occurrences in."},minSize:{type:"integer",description:"Optional minimum size of the output array."},weights:{type:"number",array:!0,description:"Optional weights for each element in the vector."}},variants:[{argumentNames:["vector"]},{argumentNames:["vector","minSize"]},{argumentNames:["vector","minSize","weights"]}],examples:["let { bincount } = import(vector);\nbincount([1, 2, 3])","let { bincount } = import(vector);\nbincount([1, 2, 2, 3, 3])"],seeAlso:["vector.count-values","vector.histogram"],hideOperatorForm:!0},winsorize:{category:"vector",description:"Limits extreme values in a `vector` by replacing values below the **lower quantile** and above the **upper quantile** with the values at those quantiles. The function takes a `vector` of values and **quantile thresholds** (between 0 and 1), with the upper quantile. Winsorization reduces the influence of outliers while preserving the overall distribution shape, making statistical analyses more robust.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The vector to winsorize."},"lower-quantile":{type:"number",description:"The lower quantile threshold (between 0 and 1)."},"upper-quantile":{type:"number",description:"Optional Upper quantile threshold (between 0 and 1). Defaults to `(1 - lower-quantile)` if `lower-quantile <= 0.5` otherwise `1`."}},variants:[{argumentNames:["vector","lower-quantile"]},{argumentNames:["vector","lower-quantile","upper-quantile"]}],examples:["let { winsorize } = import(vector);\nwinsorize([2, 5, 8, 10, 15, 18, 20, 35, 60, 100], 0.25)","let { winsorize } = import(vector);\nwinsorize([2, 5, 8, 10, 15, 18, 20, 35, 60, 100], 0.25, 0.75)","let { winsorize } = import(vector);\nwinsorize([2, 5, 8, 10, 15, 18, 20, 35, 60, 100], 0.25, 0.5)"],seeAlso:["vector.outliers","vector.outliers?","vector.percentile"],hideOperatorForm:!0},mse:{category:"vector",description:"Calculates the **Mean Squared Error (MSE)** between two vectors. Returns the average of the squared differences between corresponding elements.",returns:{type:"number"},args:{a:{type:"vector",description:"The first vector."},b:{type:"vector",description:"The second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { mse } = import(vector);\nmse([1, 2, 3], [1, 2, 3])","let { mse } = import(vector);\nmse([1, 2, 3], [4, 5, 6])","let { mse } = import(vector);\nmse([1, 2, 3], [2, 2, 2])","let { mse } = import(vector);\nmse([1, 2], [3, 3])","let { mse } = import(vector);\nmse([1], [3])"],seeAlso:["vector.rmse","vector.mae","vector.smape"]},rmse:{category:"vector",description:"Calculates the **Root Mean Squared Error (RMSE)** between two vectors. Returns the square root of the average of the squared differences between corresponding elements.",returns:{type:"number"},args:{a:{type:"vector",description:"The first vector."},b:{type:"vector",description:"The second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { rmse } = import(vector);\nrmse([1, 2, 3], [1, 2, 3])","let { rmse } = import(vector);\nrmse([1, 2, 3], [4, 5, 6])","let { rmse } = import(vector);\nrmse([1, 2, 3], [2, 2, 2])","let { rmse } = import(vector);\nrmse([1, 2], [3, 3])","let { rmse } = import(vector);\nrmse([1], [3])"],seeAlso:["vector.mse","vector.mae","vector.smape"]},mae:{category:"vector",description:"Calculates the **Mean Absolute Error (MAE)** between two vectors. Returns the average of the absolute differences between corresponding elements.",returns:{type:"number"},args:{a:{type:"vector",description:"The first vector."},b:{type:"vector",description:"The second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { mae } = import(vector);\nmae([1, 2, 3], [1, 2, 3])","let { mae } = import(vector);\nmae([1, 2, 3], [4, 5, 6])","let { mae } = import(vector);\nmae([1, 2, 3], [2, 2, 2])","let { mae } = import(vector);\nmae([1, 2], [3, 3])","let { mae } = import(vector);\nmae([1], [3])"],seeAlso:["vector.mse","vector.rmse","vector.smape"]},smape:{category:"vector",description:"Calculates the **Symmetric Mean Absolute Percentage Error (SMAPE)** between two vectors. Returns the average of the absolute percentage differences between corresponding elements.",returns:{type:"number"},args:{a:{type:"vector",description:"The first vector."},b:{type:"vector",description:"The second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { smape } = import(vector);\nsmape([1, 2, 3], [1, 2, 3])","let { smape } = import(vector);\nsmape([1, 2, 3], [4, 5, 6])","let { smape } = import(vector);\nsmape([1, 2, 3], [2, 2, 2])","let { smape } = import(vector);\nsmape([1, 2], [3, 3])","let { smape } = import(vector);\nsmape([1], [3])"],seeAlso:["vector.mse","vector.rmse","vector.mae"]}};function Xr(e){if(e.length<=1)return[];const t=[...e].sort((e,t)=>e-t),r=Math.floor(.25*t.length),n=t.length%4==0?(t[r-1]+t[r])/2:t[r],o=Math.floor(.75*t.length),a=t.length%4==0?(t[o-1]+t[o])/2:t[o],i=a-n,s=n-1.5*i,c=a+1.5*i;return e.filter(e=>e<s||e>c)}function Zr(e,t){const r=[...e].sort((e,t)=>e-t);if(0===t)return r[0];if(100===t)return r[r.length-1];const n=t/100*(r.length-1);if(Number.isInteger(n))return r[n];const o=Math.floor(n),a=Math.ceil(n),i=n-o;return r[o]*(1-i)+r[a]*i}function Qr(e){const t=[...e].sort((e,t)=>e-t),r=t.length/2;let n;n=t.length%2==0?(t[r-1]+t[r])/2:t[Math.floor(r)];const o=t.slice(0,Math.floor(t.length/2)),a=t.slice(Math.ceil(t.length/2));let i,s;if(o.length%2==0){const e=o.length/2;i=(o[e-1]+o[e])/2}else i=o[Math.floor(o.length/2)];if(a.length%2==0){const e=a.length/2;s=(a[e-1]+a[e])/2}else s=a[Math.floor(a.length/2)];return[i,n,s]}function en(e){if(0===e.length)return 0;return e.reduce((e,t)=>e+t,0)/e.length}const tn={"geometric-mean":e=>{if(e.some(e=>e<0))throw new Error("Geometric mean is not defined for non-positive numbers");return Math.exp(e.reduce((e,t)=>e+Math.log(t),0)/e.length)}};function rn(e){const t=[...e].sort((e,t)=>e-t),r=Math.floor(t.length/2);return t.length%2==0?(t[r-1]+t[r])/2:t[r]}const nn={median:e=>rn(e)};function on(e,t){const r=t??en(e);return e.reduce((e,t)=>e+(t-r)**2,0)/e.length}const an={variance:e=>on(e)},sn={"sample-variance":e=>function(e){const t=en(e);return e.reduce((e,r)=>e+(r-t)**2,0)/(e.length-1)}(e),minLength:2};function cn(e,t){const r=on(e,t);return Math.sqrt(r)}const ln={stdev:e=>cn(e)},mn={"sample-stdev":e=>function(e,t){const r=on(e,t);return Math.sqrt(r*(e.length/(e.length-1)))}(e),minLength:2},un={iqr:e=>{const[t,,r]=Qr(e);return r-t},minLength:4},pn={span:e=>0===e.length?0:Math.max(...e)-Math.min(...e),minLength:0};const gn={skewness:e=>function(e){const t=en(e),r=cn(e);if(0===r)throw new Error("Standard deviation is zero, skewness is undefined");return e.reduce((e,r)=>e+(r-t)**3,0)/(e.length*r**3)}(e),minLength:3},hn={"sample-skewness":e=>function(e){const t=e.length,r=e.reduce((e,t)=>e+t,0)/t;let n=0,o=0;for(const t of e){const e=t-r;n+=e*e,o+=e*e*e}const a=n/(t-1),i=Math.sqrt(a);if(0===i)throw new Error("Cannot calculate sample skewness when standard deviation is 0");return t/((t-1)*(t-2))*o/i**3}(e),minLength:3};function dn(e){const t=en(e),r=cn(e);if(0===r)throw new Error("Standard deviation is zero, kurtosis is undefined");return e.reduce((e,r)=>e+(r-t)**4,0)/(e.length*r**4)}const yn={kurtosis:e=>dn(e),minLength:4},vn={"excess-kurtosis":e=>function(e){return dn(e)-3}(e),minLength:4},fn={"sample-kurtosis":e=>function(e){const t=e.length,r=e.reduce((e,t)=>e+t,0)/t,n=e.reduce((e,t)=>e+(t-r)**2,0)/(t-1);if(0===n)throw new Error("Variance is zero, kurtosis is undefined");return t*(t+1)*e.reduce((e,t)=>e+(t-r)**4,0)/((t-1)*(t-2)*(t-3)*n**2)}(e),minLength:4},bn={"sample-excess-kurtosis":e=>function(e){const t=e.length,r=e.reduce((e,t)=>e+t,0)/t,n=e.reduce((e,t)=>e+(t-r)**2,0)/(t-1);if(0===n)throw new Error("Variance is zero, kurtosis is undefined");return t*(t+1)*e.reduce((e,t)=>e+(t-r)**4,0)/((t-1)*(t-2)*(t-3)*n**2)-3*(t-1)*(t-1)/((t-2)*(t-3))}(e),minLength:4},xn={rms:e=>Math.sqrt(e.reduce((e,t)=>e+t**2,0)/e.length)};const wn={mad:e=>function(e){const t=rn(e);return e.reduce((e,r)=>e+Math.abs(r-t),0)/e.length}(e)};function kn(e){const t=rn(e);return 1.4826*rn(e.map(e=>Math.abs(e-t)))}const qn={medad:e=>kn(e)},An={"gini-coefficient":e=>{if(e.some(e=>e<0))throw new Error("Gini coefficient is not defined for negative values");const t=[...e].sort((e,t)=>e-t),r=t.length,n=t.reduce((e,t)=>e+t,0);if(0===n)return 0;return 2*t.reduce((e,t,r)=>e+(r+1)*t,0)/(r*n)-(r+1)/r},minLength:1};const Nn={entropy:e=>function(e){const t=new Map;for(const r of e)t.set(r,(t.get(r)||0)+1);const r=e.length;let n=0;for(const e of t.values()){const t=e/r;t>0&&(n-=t*Math.log2(t))}return n}(e),minLength:1},$n={};function Tn(e){for(const[t,r]of Object.entries(e)){if($n[t])throw new Error(`Duplicate normal expression key found: ${t}`);if("minLength"!==t&&"padding"!==t&&"function"==typeof r){const n=r,o=t.replace(/^/,""),a=`moving-${o}`,i=`centered-moving-${o}`,s=`running-${o}`,c=e.minLength??1;ee(c,void 0,{integer:!0,finite:!0,gte:0}),$n[t]=zn(n,c),$n[a]=Sn(n,c),$n[i]=En(n,c,e.padding??null),$n[s]=jn(n,c)}}}function zn(e,t){return{evaluate:([n],o)=>{if(Ze(n,o),n.length<t)throw new r(`Vector length must be at least ${t}`,o);try{return e(n)}catch(e){throw new r(e,o)}},arity:ae(1)}}function Sn(e,t){return{evaluate:([n,o],a)=>{if(Ze(n,a),ee(o,a,{integer:!0,finite:!0,gte:t,lte:n.length}),0===n.length)return[];try{if(o>=n.length)return[e(n)];const t=[];for(let r=0;r<n.length-o+1;r+=1)t.push(e(n.slice(r,r+o)));return t}catch(e){throw new r(e,a)}},arity:ae(2)}}function En(e,t,n){return{evaluate:([o,a,i,s],c)=>{if(Ze(o,c),o.length<t)throw new r(`Vector length must be at least ${t}`,c);if(ee(a,c,{integer:!0,finite:!0,gte:t,lte:o.length}),null!==(i=i??n)&&ee(i,c,{finite:!0}),null!==(s=s??n)&&ee(s,c,{finite:!0}),0===o.length)return[];const l=Math.floor(a/2),m=[...Array(l).fill(i),...o,...Array(l).fill(s)],u="number"==typeof i?0:l,p=o.length-("number"==typeof s?0:a-l-1),g=[...Array(u).fill(null)];try{for(let t=u;t<p;t+=1)g.push(e(m.slice(t,t+a)))}catch(e){throw new r(e,c)}return g.push(...Array(o.length-p).fill(null)),g},arity:{min:2,max:4}}}function jn(e,t){return{evaluate:([n],o)=>{if(Ze(n,o),n.length<t)throw new r(`Vector length must be at least ${t}`,o);if(0===n.length)return[];try{const r=Math.max(t-1,0),o=Array(r).fill(null);for(let t=r;t<n.length;t+=1)o.push(e(n.slice(0,t+1)));return o}catch(e){throw new r(e,o)}},arity:ae(1)}}Tn({mean:e=>en(e)}),Tn(tn),Tn({"harmonic-mean":e=>e.length/e.reduce((e,t)=>e+1/t,0)}),Tn(nn),Tn({sum:e=>e.reduce((e,t)=>e+t,0),minLength:0}),Tn({prod:e=>e.reduce((e,t)=>e*t,1),padding:1,minLength:0}),Tn(an),Tn(sn),Tn(ln),Tn(mn),Tn(un),Tn(pn),Tn(gn),Tn(hn),Tn(vn),Tn(yn),Tn(bn),Tn(fn),Tn(xn),Tn(wn),Tn(qn),Tn(An),Tn(Nn),delete $n.sum,delete $n.prod,delete $n.mean,delete $n.median;const Mn={"monotonic?":{evaluate:([e],t)=>(Ze(e,t),e.every((t,r)=>0===r||t>=e[r-1])||e.every((t,r)=>0===r||t<=e[r-1])),arity:ae(1)},"strictly-monotonic?":{evaluate:([e],t)=>(Ze(e,t),e.every((t,r)=>0===r||t>e[r-1])||e.every((t,r)=>0===r||t<e[r-1])),arity:ae(1)},"increasing?":{evaluate:([e],t)=>(Ze(e,t),e.every((t,r)=>0===r||t>=e[r-1])),arity:ae(1)},"decreasing?":{evaluate:([e],t)=>(Ze(e,t),e.every((t,r)=>0===r||t<=e[r-1])),arity:ae(1)},"strictly-increasing?":{evaluate:([e],t)=>(Ze(e,t),e.every((t,r)=>0===r||t>e[r-1])),arity:ae(1)},"strictly-decreasing?":{evaluate:([e],t)=>(Ze(e,t),e.every((t,r)=>0===r||t<e[r-1])),arity:ae(1)},mode:{evaluate:([e],t)=>(tt(e,t),function(e){const t=new Map;for(const r of e)t.set(r,(t.get(r)||0)+1);let r=0;for(const e of t.values())e>r&&(r=e);if(1===r)return e;const n=[];for(const[e,o]of t.entries())o===r&&n.push(e);return n}(e)),arity:ae(1)},"min-index":{evaluate:([e],t)=>(tt(e,t),e.reduce((t,r,n)=>r<e[t]?n:t,0)),arity:ae(1)},"max-index":{evaluate:([e],t)=>(tt(e,t),e.reduce((t,r,n)=>r>e[t]?n:t,0)),arity:ae(1)},"sort-indices":{evaluate:([e],t)=>(Ze(e,t),[...e.keys()].sort((t,r)=>e[t]-e[r])),arity:ae(1)},"count-values":{evaluate:([e],t)=>{Ze(e,t);const r=new Map;for(const t of e)r.set(t,(r.get(t)||0)+1);return[...r.entries()].sort((e,t)=>{const r=t[1]-e[1];return 0!==r?r:e[0]-t[0]})},arity:ae(1)},linspace:{evaluate:([e,t,r],n)=>{if(ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),ee(r,n,{integer:!0,nonNegative:!0}),0===r)return[];if(1===r)return[e];const o=(t-e)/(r-1);return Array.from({length:r},(t,r)=>e+r*o)},arity:ae(3)},cumsum:{evaluate:([e],t)=>(Ze(e,t),e.reduce((e,t)=>{const r=e[e.length-1]??0;return e.push(r+t),e},[])),arity:ae(1)},cumprod:{evaluate:([e],t)=>(Ze(e,t),e.reduce((e,t)=>{const r=e[e.length-1]??1;return e.push(r*t),e},[])),arity:ae(1)},quartiles:{evaluate:([e],t)=>{if(Ze(e,t),e.length<4)throw new r("Quartiles require at least four values",t);return Qr(e)},arity:ae(1)},percentile:{evaluate:([e,t],r)=>(tt(e,r),ee(t,r,{finite:!0,nonNegative:!0,lte:100}),Zr(e,t)),arity:ae(2)},quantile:{evaluate:([e,t],r)=>(Ze(e,r),ee(t,r,{finite:!0,nonNegative:!0,lte:1}),Zr(e,100*t)),arity:ae(2)},histogram:{evaluate:([e,t],r)=>(Ze(e,r),ee(t,r,{integer:!0,positive:!0}),function(e,t){if(0===e.length){const e=[];for(let r=0;r<t;r++)e.push([0,0,0]);return e}const r=Math.min(...e),n=Math.max(...e);if(r===n){const n=[];for(let e=0;e<t;e++)n.push([r,r,0]);return n[0][2]=e.length,n}const o=(n-r)/t,a=[];for(let e=0;e<t;e++){const i=r+e*o,s=e===t-1?n:r+(e+1)*o;a.push([i,s,0])}for(const i of e)i===n?a[t-1][2]+=1:a[Math.min(Math.floor((i-r)/o),t-1)][2]+=1;return a}(e,t)),arity:ae(2)},ecdf:{evaluate:([e,t],r)=>{tt(e,r),ee(t,r,{finite:!0});const n=[...e].sort((e,t)=>e-t),o=n.findIndex(e=>e>t);return-1===o?1:o/n.length},arity:ae(2)},"outliers?":{evaluate:([e],t)=>(Ze(e,t),function(e){return Xr(e).length>0}(e)),arity:ae(1)},outliers:{evaluate:([e],t)=>(Ze(e,t),Xr(e)),arity:ae(1)},bincount:{evaluate:(e,t)=>{const n=e[0];Ze(n,t),n.forEach(e=>ee(e,t,{finite:!0,integer:!0,nonNegative:!0}));const o=e[1]??0;ee(o,t,{integer:!0,nonNegative:!0});const a=e[2]??void 0;if(void 0!==a){if(Ze(a,t),a.length!==n.length)throw new r("Weights vector must be the same length as the input vector",t);a.forEach(e=>ee(e,t,{finite:!0}))}return function(e,t=0,r){if(0===e.length)return Array.from({length:t},()=>0);const n=Math.max(...e),o=Math.max(n+1,t),a=Array.from({length:o},()=>0);for(let t=0;t<e.length;t++){const n=Math.floor(e[t]);n<o&&(a[n]+=r?r[t]:1)}return a}(n,o,a)},arity:{min:1,max:3}},winsorize:{evaluate:([e,t,r],n)=>{if(Ze(e,n),ee(t,n,{finite:!0,gte:0,lte:1}),r??=t>.5?1:1-t,ee(r,n,{finite:!0,gte:t,lte:1}),0===e.length)return[];const o=[...e].sort((e,t)=>e-t),a=Math.max(0,Math.floor(t*e.length)),i=Math.min(e.length-1,Math.max(0,Math.floor(r*e.length)-1)),s=o[a],c=o[i];return e.map(e=>Math.max(s,Math.min(e,c)))},arity:{min:2,max:3}},mse:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+(r-t[n])**2,0)/e.length},arity:ae(2)},rmse:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return Math.sqrt(e.reduce((e,r,n)=>e+(r-t[n])**2,0)/e.length)},arity:ae(2)},mae:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+Math.abs(r-t[n]),0)/e.length},arity:ae(2)},smape:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>{const o=Math.abs(r-t[n]),a=(Math.abs(r)+Math.abs(t[n]))/2;return e+(0===a?0:o/a)},0)/e.length},arity:ae(2)}};!function(e){for(const[t,r]of Object.entries(e)){if(Mn[t])throw new Error(`Duplicate normal expression key found: ${t}`);Mn[t]=r}}($n);for(const[e,t]of Object.entries(Hr))Mn[e]&&(Mn[e].docs=t);const Cn={name:"vector",functions:Mn},Pn={reflect:{category:"linear-algebra",description:"Reflects a vector across a given axis.",returns:{type:"vector"},args:{a:{type:"vector",description:"Vector to reflect."},b:{type:"vector",description:"Axis of reflection."}},variants:[{argumentNames:["a","b"]}],examples:["let { reflect } = import(linear-algebra);\nreflect([1, 2], [0, 1])","let { reflect } = import(linear-algebra);\nreflect([1, 2, 3], [0, 0, 1])"],seeAlso:["linear-algebra.refract","linear-algebra.projection"]},refract:{category:"linear-algebra",description:"Refracts a vector across a given axis.",returns:{type:"vector"},args:{vector:{type:"vector",description:"Vector to refract."},axis:{type:"vector",description:"Axis of refraction."},eta:{type:"number",description:"Refraction index."}},variants:[{argumentNames:["vector","axis","eta"]}],examples:["let { refract } = import(linear-algebra);\nrefract([1, 2], [0, 1], 1.5)","let { refract } = import(linear-algebra);\nrefract([1, 2, 3], [0, 0, 1], 1.5)"],seeAlso:["linear-algebra.reflect"]},lerp:{category:"linear-algebra",description:"Performs linear interpolation between two vectors.",returns:{type:"vector"},args:{a:{type:"vector",description:"Start vector."},b:{type:"vector",description:"End vector."},t:{type:"number",description:"Interpolation factor (0 to 1)."}},variants:[{argumentNames:["a","b","t"]}],examples:["let { lerp } = import(linear-algebra);\nlerp([1, 2], [3, 4], 0.5)","let { lerp } = import(linear-algebra);\nlerp([1, 2], [3, 4], 2)","let { lerp } = import(linear-algebra);\nlerp([1, 2], [3, 4], -1)","let { lerp } = import(linear-algebra);\nlerp([1, 2, 3], [4, 5, 6], 0.25)"],seeAlso:["linear-algebra.projection"]},rotate2d:{category:"linear-algebra",description:"Rotates a 2D vector by a given angle in radians.",returns:{type:"vector"},args:{a:{type:"vector",description:"Vector to rotate."},b:{type:"number",description:"Angle in b."}},variants:[{argumentNames:["a","b"]}],examples:["let { rotate2d } = import(linear-algebra);\nrotate2d([1, 0], PI / 2)","let { rotate2d } = import(linear-algebra);\nrotate2d([0, 1], PI)"],seeAlso:["linear-algebra.rotate3d","linear-algebra.angle"]},rotate3d:{category:"linear-algebra",description:"Rotates a 3D vector around a given axis by a given angle in radians.",returns:{type:"vector"},args:{v:{type:"vector",description:"Vector to rotate."},axis:{type:"vector",description:"Axis of rotation."},radians:{type:"number",description:"Angle in radians."}},variants:[{argumentNames:["v","axis","radians"]}],examples:["let { rotate3d } = import(linear-algebra);\nrotate3d([1, 0, 0], [0, 1, 0], PI / 2)","let { rotate3d } = import(linear-algebra);\nrotate3d([0, 1, 0], [1, 0, 0], PI)"],seeAlso:["linear-algebra.rotate2d","linear-algebra.angle"]},dot:{category:"linear-algebra",description:"Calculates the dot product of two vectors. The result is a scalar.",returns:{type:"number"},args:{a:{type:"vector",description:"First vector."},b:{type:"vector",description:"Second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { dot } = import(linear-algebra);\ndot([1, 2], [3, 4])","let { dot } = import(linear-algebra);\ndot([1, 2, 3], [4, 5, 6])"],seeAlso:["linear-algebra.cross","linear-algebra.cosine-similarity","linear-algebra.angle","linear-algebra.projection","linear-algebra.orthogonal?"]},cross:{category:"linear-algebra",description:"Calculates the cross product of two 3D vectors. The result is a vector perpendicular to both input vectors.",returns:{type:"vector"},args:{a:{type:"vector",description:"First vector (3D)."},b:{type:"vector",description:"Second vector (3D)."}},variants:[{argumentNames:["a","b"]}],examples:["let { cross } = import(linear-algebra);\ncross([1, 2, 3], [4, 5, 6])","let { cross } = import(linear-algebra);\ncross([1, 0, 0], [0, 1, 0])","let { cross } = import(linear-algebra);\ncross([0, 0, 1], [1, 0, 0])","let { cross } = import(linear-algebra);\ncross([1, 2, 3], [0, 0, 0])","let { cross } = import(linear-algebra);\ncross([0, 0, 0], [1, 2, 3])"],seeAlso:["linear-algebra.dot"]},"normalize-minmax":{category:"linear-algebra",description:"Normalizes the vector using min-max normalization. The result is a vector with values between 0 and 1.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, 3])","let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, -3])","let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, 3, 4])","let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, -3, 4])","let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-zscore","linear-algebra.normalize-robust","linear-algebra.normalize-l1","linear-algebra.normalize-l2","linear-algebra.normalize-log"]},"normalize-zscore":{category:"linear-algebra",description:"Normalizes the vector using z-score normalization. The result is a vector with mean 0 and standard deviation 1.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, 3])","let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, -3])","let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, 3, 4])","let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, -3, 4])","let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-minmax","linear-algebra.normalize-robust","linear-algebra.normalize-l1","linear-algebra.normalize-l2","linear-algebra.normalize-log"]},"normalize-robust":{category:"linear-algebra",description:"Normalizes the vector using robust normalization. The result is a vector with median 0 and median absolute deviation 1.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, 3])","let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, -3])","let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, 3, 4])","let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, -3, 4])","let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-minmax","linear-algebra.normalize-zscore"]},"normalize-l1":{category:"linear-algebra",description:"Normalizes the vector using L1 normalization. The result is a vector with L1 norm equal to 1.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, 3])","let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, -3])","let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, 3, 4])","let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, -3, 4])","let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-l2","linear-algebra.normalize-minmax","linear-algebra.manhattan-norm","linear-algebra.normalize-zscore"]},"normalize-l2":{category:"linear-algebra",description:"Normalizes the vector using L2 normalization. The result is a vector with L2 norm equal to 1.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, 3])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, 3])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, -3])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, 3, 4])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, -3, 4])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-l1","linear-algebra.normalize-minmax","linear-algebra.euclidean-norm","linear-algebra.normalize-zscore"]},"normalize-log":{category:"linear-algebra",description:"Normalizes the vector using natural log normalization. The result is a vector with log-transformed values.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-log } = import(linear-algebra);\nnormalize-log([1, 2, 3])","let { normalize-log } = import(linear-algebra);\nnormalize-log([1, 2, 3, 4])","let { normalize-log } = import(linear-algebra);\nnormalize-log([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-minmax","linear-algebra.normalize-zscore"]},angle:{category:"linear-algebra",description:"Calculates the **angle** between two vectors in radians.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { angle } = import(linear-algebra);\nangle([1, 0], [0, 1])","let { angle } = import(linear-algebra);\nangle([1, 0, 1], [0, 1, 0])"],seeAlso:["linear-algebra.dot","linear-algebra.collinear?","linear-algebra.orthogonal?","linear-algebra.rotate2d","linear-algebra.rotate3d","linear-algebra.parallel?","linear-algebra.cosine-similarity","linear-algebra.to-polar"]},projection:{category:"linear-algebra",description:"Calculates the **projection** of vector `a` onto vector `b`.",returns:{type:"vector"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { projection } = import(linear-algebra);\nprojection([1, 2], [3, 4])","let { projection } = import(linear-algebra);\nprojection([1, 2, 3], [4, 5, 6])"],seeAlso:["linear-algebra.dot","linear-algebra.reflect","linear-algebra.lerp"]},"collinear?":{category:"linear-algebra",description:"Checks if two vectors are **collinear**.",returns:{type:"boolean"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { collinear? } = import(linear-algebra);\ncollinear?([1, 2], [2, 4])","let { collinear? } = import(linear-algebra);\ncollinear?([1, 2], [-2, -4])","let { collinear? } = import(linear-algebra);\ncollinear?([1, 2, 3], [2, 4, 6])"],seeAlso:["linear-algebra.parallel?","linear-algebra.orthogonal?","linear-algebra.angle"]},"parallel?":{category:"linear-algebra",description:"Checks if two vectors are **parallel**.",returns:{type:"boolean"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { parallel? } = import(linear-algebra);\nparallel?([1, 2], [2, 4])","let { parallel? } = import(linear-algebra);\nparallel?([1, 2], [-2, -4])","let { parallel? } = import(linear-algebra);\nparallel?([1, 2, 3], [2, 4, 6])","let { parallel? } = import(linear-algebra);\nparallel?([1, 2], [3, 4])"],seeAlso:["linear-algebra.collinear?","linear-algebra.orthogonal?","linear-algebra.angle"]},"orthogonal?":{category:"linear-algebra",description:"Checks if two vectors are **orthogonal**.",returns:{type:"boolean"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { orthogonal? } = import(linear-algebra);\northogonal?([1, 0], [0, 1])","let { orthogonal? } = import(linear-algebra);\northogonal?([1, 0, 1], [0, 1, 0])","let { orthogonal? } = import(linear-algebra);\northogonal?([1, 2], [2, -1])"],seeAlso:["linear-algebra.collinear?","linear-algebra.parallel?","linear-algebra.dot","matrix.orthogonal-matrix?","linear-algebra.angle"]},"cosine-similarity":{category:"linear-algebra",description:"Calculates the **cosine similarity** between two vectors. The result is a value between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { cosine-similarity } = import(linear-algebra);\ncosine-similarity([1, 2], [3, 4])","let { cosine-similarity } = import(linear-algebra);\ncosine-similarity([1, 2, 3], [4, 5, 6])","let { cosine-similarity } = import(linear-algebra);\ncosine-similarity([1, 0], [0, 1])"],seeAlso:["linear-algebra.dot","linear-algebra.angle","linear-algebra.euclidean-distance"]},"euclidean-distance":{category:"linear-algebra",description:"Calculates the **Euclidean distance** between two vectors. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { euclidean-distance } = import(linear-algebra);\neuclidean-distance([1, 2], [3, 4])","let { euclidean-distance } = import(linear-algebra);\neuclidean-distance([1, 2, 3], [4, 5, 6])","let { euclidean-distance } = import(linear-algebra);\neuclidean-distance([1, 0], [0, 1])"],seeAlso:["linear-algebra.manhattan-distance","linear-algebra.chebyshev-distance","linear-algebra.minkowski-distance","linear-algebra.euclidean-norm","linear-algebra.cosine-similarity","linear-algebra.hamming-distance"]},"euclidean-norm":{category:"linear-algebra",description:"Calculates the **Euclidean norm** (L2 norm) of a vector. The result is a non-negative number.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to calculate the norm for."}},variants:[{argumentNames:["v"]}],examples:["let { euclidean-norm } = import(linear-algebra);\neuclidean-norm([1, 2])","let { euclidean-norm } = import(linear-algebra);\neuclidean-norm([3, 4])","let { euclidean-norm } = import(linear-algebra);\neuclidean-norm([1, 2, 3])"],seeAlso:["linear-algebra.manhattan-norm","linear-algebra.chebyshev-norm","linear-algebra.minkowski-norm","linear-algebra.euclidean-distance","linear-algebra.normalize-l2","linear-algebra.hamming-norm"]},"manhattan-distance":{category:"linear-algebra",description:"Calculates the **Manhattan distance** between two vectors. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { manhattan-distance } = import(linear-algebra);\nmanhattan-distance([1, 2], [3, 4])","let { manhattan-distance } = import(linear-algebra);\nmanhattan-distance([1, 2, 3], [4, 5, 6])","let { manhattan-distance } = import(linear-algebra);\nmanhattan-distance([1, 0], [0, 1])"],seeAlso:["linear-algebra.euclidean-distance","linear-algebra.chebyshev-distance","linear-algebra.minkowski-distance","linear-algebra.manhattan-norm","linear-algebra.hamming-distance"]},"manhattan-norm":{category:"linear-algebra",description:"Calculates the **Manhattan norm** (L1 norm) of a vector. The result is a non-negative number.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to calculate the norm for."}},variants:[{argumentNames:["v"]}],examples:["let { manhattan-norm } = import(linear-algebra);\nmanhattan-norm([1, 2])","let { manhattan-norm } = import(linear-algebra);\nmanhattan-norm([3, 4])","let { manhattan-norm } = import(linear-algebra);\nmanhattan-norm([1, 2, 3])"],seeAlso:["linear-algebra.euclidean-norm","linear-algebra.chebyshev-norm","linear-algebra.minkowski-norm","linear-algebra.manhattan-distance","linear-algebra.normalize-l1","linear-algebra.hamming-norm"]},"hamming-distance":{category:"linear-algebra",description:"Calculates the **Hamming distance** between two vectors. The result is a non-negative integer.",returns:{type:"integer"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { hamming-distance } = import(linear-algebra);\nhamming-distance([1, 2], [3, 4])","let { hamming-distance } = import(linear-algebra);\nhamming-distance([1, 2, 3], [4, 5, 6])","let { hamming-distance } = import(linear-algebra);\nhamming-distance([1, 0], [0, 1])"],seeAlso:["linear-algebra.euclidean-distance","linear-algebra.manhattan-distance","linear-algebra.hamming-norm"]},"hamming-norm":{category:"linear-algebra",description:"Calculates the **Hamming norm** of a vector. The result is a non-negative integer.",returns:{type:"integer"},args:{v:{type:"vector",description:"Vector to calculate the norm for."}},variants:[{argumentNames:["v"]}],examples:["let { hamming-norm } = import(linear-algebra);\nhamming-norm([1, 2])","let { hamming-norm } = import(linear-algebra);\nhamming-norm([3, 4])","let { hamming-norm } = import(linear-algebra);\nhamming-norm([1, 2, 3])"],seeAlso:["linear-algebra.euclidean-norm","linear-algebra.manhattan-norm","linear-algebra.hamming-distance"]},"chebyshev-distance":{category:"linear-algebra",description:"Calculates the **Chebyshev distance** between two vectors. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { chebyshev-distance } = import(linear-algebra);\nchebyshev-distance([1, 2], [3, 4])","let { chebyshev-distance } = import(linear-algebra);\nchebyshev-distance([1, 2, 3], [4, 5, 6])","let { chebyshev-distance } = import(linear-algebra);\nchebyshev-distance([1, 0], [0, 1])"],seeAlso:["linear-algebra.euclidean-distance","linear-algebra.manhattan-distance","linear-algebra.minkowski-distance","linear-algebra.chebyshev-norm"]},"chebyshev-norm":{category:"linear-algebra",description:"Calculates the **Chebyshev norm** of a vector. The result is a non-negative number.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to calculate the norm for."}},variants:[{argumentNames:["v"]}],examples:["let { chebyshev-norm } = import(linear-algebra);\nchebyshev-norm([1, 2])","let { chebyshev-norm } = import(linear-algebra);\nchebyshev-norm([3, 4])","let { chebyshev-norm } = import(linear-algebra);\nchebyshev-norm([1, 2, 3])"],seeAlso:["linear-algebra.euclidean-norm","linear-algebra.manhattan-norm","linear-algebra.minkowski-norm","linear-algebra.chebyshev-distance"]},"minkowski-distance":{category:"linear-algebra",description:"Calculates the **Minkowski distance** between two vectors. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"},p:{type:"number",description:"Order of the norm (p)."}},variants:[{argumentNames:["a","b","p"]}],examples:["let { minkowski-distance } = import(linear-algebra);\nminkowski-distance([1, 2], [3, 4], 2)","let { minkowski-distance } = import(linear-algebra);\nminkowski-distance([1, 2, 3], [4, 5, 6], 3)","let { minkowski-distance } = import(linear-algebra);\nminkowski-distance([1, 0], [0, 1], 1)"],seeAlso:["linear-algebra.euclidean-distance","linear-algebra.manhattan-distance","linear-algebra.chebyshev-distance","linear-algebra.minkowski-norm"]},"minkowski-norm":{category:"linear-algebra",description:"Calculates the **Minkowski norm** of a vector. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector",description:"Vector to calculate the norm for."},b:{type:"number",description:"Order of the norm (p)."}},variants:[{argumentNames:["a","b"]}],examples:["let { minkowski-norm } = import(linear-algebra);\nminkowski-norm([1, 2], 2)","let { minkowski-norm } = import(linear-algebra);\nminkowski-norm([3, 4], 3)","let { minkowski-norm } = import(linear-algebra);\nminkowski-norm([1, 2, 3], 4)"],seeAlso:["linear-algebra.euclidean-norm","linear-algebra.manhattan-norm","linear-algebra.chebyshev-norm","linear-algebra.minkowski-distance"]},cov:{category:"linear-algebra",description:"Calculates the **covariance** between two vectors. The result is a number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { cov } = import(linear-algebra);\ncov([1, 2], [3, 4])","let { cov } = import(linear-algebra);\ncov([1, 2, 3], [4, 5, 6])","let { cov } = import(linear-algebra);\ncov([1, 0], [0, 1])"],seeAlso:["linear-algebra.corr","linear-algebra.pearson-corr","vector.variance"]},corr:{category:"linear-algebra",description:"Calculates the **correlation** between two vectors. The result is a number between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { corr } = import(linear-algebra);\ncorr([1, 2], [3, 4])","let { corr } = import(linear-algebra);\ncorr([1, 2, 3], [4, 5, 6])","let { corr } = import(linear-algebra);\ncorr([1, 0], [0, 1])"],seeAlso:["linear-algebra.cov","linear-algebra.pearson-corr","linear-algebra.spearman-corr","linear-algebra.kendall-tau","linear-algebra.autocorrelation","linear-algebra.cross-correlation"]},"spearman-corr":{category:"linear-algebra",description:"Calculates the **Spearman rank correlation** between two vectors. The result is a number between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { spearman-corr } = import(linear-algebra);\nspearman-corr([1, 2], [3, 4])","let { spearman-corr } = import(linear-algebra);\nspearman-corr([1, 2, 3], [4, 5, 6])","let { spearman-corr } = import(linear-algebra);\nspearman-corr([1, 0], [0, 1])"],seeAlso:["linear-algebra.pearson-corr","linear-algebra.kendall-tau","linear-algebra.corr"]},"pearson-corr":{category:"linear-algebra",description:"Calculates the **Pearson correlation** between two vectors. The result is a number between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { pearson-corr } = import(linear-algebra);\npearson-corr([1, 2], [3, 4])","let { pearson-corr } = import(linear-algebra);\npearson-corr([1, 2, 3], [4, 5, 6])","let { pearson-corr } = import(linear-algebra);\npearson-corr([1, 0], [0, 1])"],seeAlso:["linear-algebra.spearman-corr","linear-algebra.kendall-tau","linear-algebra.corr","linear-algebra.cov"]},"kendall-tau":{category:"linear-algebra",description:"Calculates the **Kendall Tau** rank correlation coefficient between two vectors. The result is a number between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { kendall-tau } = import(linear-algebra);\nkendall-tau([1, 2], [3, 4])","let { kendall-tau } = import(linear-algebra);\nkendall-tau([1, 2, 3], [4, 5, 6])","let { kendall-tau } = import(linear-algebra);\nkendall-tau([1, 0], [0, 1])"],seeAlso:["linear-algebra.spearman-corr","linear-algebra.pearson-corr","linear-algebra.corr"]},autocorrelation:{category:"linear-algebra",description:"Calculates the **autocorrelation** of a vector. The result is a vector of autocorrelation coefficients.",returns:{type:"vector"},args:{a:{type:"vector",description:"Vector to calculate the autocorrelation for."},b:{type:"integer",description:"Lag value for the autocorrelation."}},variants:[{argumentNames:["a","b"]}],examples:["let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], -2)","let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], -1)","let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], 0)","let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], 1)","let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], 2)"],seeAlso:["linear-algebra.cross-correlation","linear-algebra.corr"]},"cross-correlation":{category:"linear-algebra",description:"Calculates the **cross-correlation** between two vectors. The result is a vector of cross-correlation coefficients.",returns:{type:"vector"},args:{a:{type:"vector"},b:{type:"vector"},lag:{type:"integer",description:"Lag value for the cross-correlation."}},variants:[{argumentNames:["a","b","lag"]}],examples:["let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], -2)","let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], -1)","let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], 0)","let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], 1)","let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], 2)"],seeAlso:["linear-algebra.autocorrelation","linear-algebra.corr"]},rref:{category:"linear-algebra",description:"Calculates the **Reduced Row Echelon Form** (RREF) of a matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"Matrix to calculate the RREF for."}},variants:[{argumentNames:["m"]}],examples:["let { rref } = import(linear-algebra);\nrref([[1, 2], [3, 4]])","let { rref } = import(linear-algebra);\nrref([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { rref } = import(linear-algebra);\nrref([[1, 2, 3], [7, 8, 9], [4, 5, 7]])"],seeAlso:["linear-algebra.solve","matrix.rank"]},solve:{category:"linear-algebra",description:"Solves a system of linear equations represented by a matrix and a vector.",returns:{type:"vector"},args:{a:{type:"matrix"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { solve } = import(linear-algebra);\nsolve([\n [2, 1, -1, 1], \n [4, 5, -3, 2], \n [6, -2, 5, -3], \n [8, 3, 2, 4]\n], [5, 10, 2, 17])","let { solve } = import(linear-algebra);\nsolve([[2, 0, 0], [3, 1, 0], [4, 5, 6]], [4, 5, 38])","let { solve } = import(linear-algebra);\nsolve([[2, 3], [1, -1]], [8, 2])"],seeAlso:["linear-algebra.rref","matrix.inv"]},"to-polar":{category:"linear-algebra",description:"Converts a 2D vector to polar coordinates.",returns:{type:"vector"},args:{vector:{type:"vector",description:"2D Vector to convert."}},variants:[{argumentNames:["vector"]}],examples:["let { to-polar } = import(linear-algebra);\nto-polar([1, 2])","let { to-polar } = import(linear-algebra);\nto-polar([3, 4])"],seeAlso:["linear-algebra.from-polar","linear-algebra.angle"]},"from-polar":{category:"linear-algebra",description:"Converts polar coordinates to a 2D vector.",returns:{type:"vector"},args:{polar:{type:"vector",description:"Polar coordinates to convert."}},variants:[{argumentNames:["polar"]}],examples:["let { from-polar } = import(linear-algebra);\nfrom-polar([1, PI / 4])","let { from-polar } = import(linear-algebra);\nfrom-polar([1, 0])","let { from-polar } = import(linear-algebra);\nfrom-polar([1, -PI / 2])"],seeAlso:["linear-algebra.to-polar"]}};function Rn(e){const t=e.map(e=>[...e]),r=t.length,n=t[0].length;let o=0,a=0;for(let e=0;e<n;e++){let i=-1;for(let n=a;n<r;n++)if(!be(t[n][e])){i=n;break}if(-1===i)continue;o+=1,i!==a&&([t[i],t[a]]=[t[a],t[i]]);const s=t[a][e];for(let r=e;r<n;r++)t[a][r]/=s;for(let o=0;o<r;o++)if(o!==a&&!be(t[o][e])){const r=t[o][e];for(let i=e;i<n;i++)t[o][i]-=r*t[a][i]}if(a++,a===r)break}return[t,o]}function In(e,t){const r=e=>e.every(e=>be(e));if(r(e)||r(t))return!0;let n=0;for(;n<e.length&&be(e[n]);)n++;const o=t[n]/e[n];for(let r=0;r<e.length;r++)if(!be(e[r])||!be(t[r])){if(be(e[r]))return!1;if(!fe(t[r]/e[r],o))return!1}return!0}function On(e){return e.every(e=>be(e))}function Fn(e,t){const r=en(e),n=en(t);let o=0,a=0,i=0;for(let s=0;s<e.length;s++){const c=e[s]-r,l=t[s]-n;o+=c*l,a+=c*c,i+=l*l}if(0===a||0===i)throw new Error("Cannot calculate Pearson correlation coefficient: one of the vectors has zero variance.");return o/(Math.sqrt(a)*Math.sqrt(i))}function Un(e){const t=[...e.keys()].sort((t,r)=>e[t]-e[r]),r=Array.from({length:e.length}).fill(0);let n=1,o=0;for(;o<t.length;){const a=e[t[o]];let i=o;for(;i<t.length&&e[t[i]]===a;)i++;const s=n+(i-o-1)/2;for(let e=o;e<i;e++)r[t[e]]=s;n+=i-o,o=i}return r}function Dn(e,t){const r=en(e),n=en(t);let o=0;for(let a=0;a<e.length;a++)o+=(e[a]-r)*(t[a]-n);return o/e.length}function Wn(e,t){if(0===e.length)return e;const n=Math.sqrt(e.reduce((e,t)=>e+t**2,0));if(be(n))throw new r("The vector must not be zero",t);return e.map(e=>e/n)}function Gn(e,t){return e.reduce((e,r,n)=>e+r*t[n],0)}function Vn(e,t){return e.map((e,r)=>e-t[r])}function Bn(e,t){return e.map(e=>e*t)}const Ln={rotate2d:{evaluate:([e,t],r)=>{if(Qe(e,r),On(e))return e;ee(t,r,{finite:!0});const n=Math.cos(t),o=Math.sin(t);return[e[0]*n-e[1]*o,e[0]*o+e[1]*n]},arity:ae(2)},rotate3d:{evaluate:([e,t,n],o)=>{if(et(e,o),On(e))return e;if(ee(n,o,{finite:!0}),et(t,o),On(t))throw new r("Rotation axis must not be zero",o);const a=Math.cos(n),i=Math.sin(n),[s,c,l]=Wn(t,o),m=e[0]*s+e[1]*c+e[2]*l;return[m*s*(1-a)+e[0]*a+(-l*e[1]+c*e[2])*i,m*c*(1-a)+e[1]*a+(l*e[0]-s*e[2])*i,m*l*(1-a)+e[2]*a+(-c*e[0]+s*e[1])*i]},arity:ae(3)},reflect:{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);if(On(t))throw new r("Reflection normal must not be zero",n);if(On(e))return e;const o=Wn(t,n);return Vn(e,Bn(o,2*Gn(e,o)))},arity:ae(2)},refract:{evaluate:([e,t,n],o)=>{if(Ze(e,o),Ze(t,o),ee(n,o,{finite:!0,positive:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",o);if(On(t))throw new r("Refraction normal must not be zero",o);if(On(e))return e;const a=Wn(e,o),i=Wn(t,o),s=Gn(a,i),c=1-n*n*(1-s*s);if(c<0)return e;return Vn(Bn(a,n),Bn(i,n*s+Math.sqrt(c)))},arity:ae(3)},lerp:{evaluate:([e,t,n],o)=>{if(Ze(e,o),Ze(t,o),ee(n,o,{finite:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",o);return e.map((e,r)=>e+(t[r]-e)*n)},arity:ae(3)},dot:{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return Gn(e,t)},arity:ae(2)},cross:{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),3!==e.length||3!==t.length)throw new r("Cross product is only defined for 3D vectors",n);return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]},arity:ae(2)},"normalize-minmax":{evaluate:([e],t)=>{if(Ze(e,t),0===e.length)return[];const r=e.reduce((e,t)=>t<e?t:e,e[0]),n=e.reduce((e,t)=>t>e?t:e,e[0]);return r===n?e.map(()=>0):e.map(e=>(e-r)/(n-r))},arity:ae(1)},"normalize-robust":{evaluate:([e],t)=>{if(Ze(e,t),0===e.length)return[];const r=rn(e),n=kn(e);return 0===n?e.map(e=>e-r):e.map(e=>(e-r)/n)},arity:ae(1)},"normalize-zscore":{evaluate:([e],t)=>{Ze(e,t);const r=en(e),n=cn(e);return 0===n?e.map(()=>0):e.map(e=>(e-r)/n)},arity:ae(1)},"normalize-l1":{evaluate:([e],t)=>{if(Ze(e,t),0===e.length)return[];const r=e.reduce((e,t)=>e+Math.abs(t),0);return 0===r?e.map(()=>0):e.map(e=>e/r)},arity:ae(1)},"normalize-l2":{evaluate:([e],t)=>(Ze(e,t),Wn(e,t)),arity:ae(1)},"normalize-log":{evaluate:([e],t)=>{if(Ze(e,t),0===e.length)return[];const n=Math.min(...e);if(n<=0)throw new r("Log normalization requires all values to be positive",t);return e.map(e=>Math.log(e/n))},arity:ae(1)},angle:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),On(e)||On(t))throw new r("Cannot calculate angle with zero-length vector",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);const o=e.reduce((e,r,n)=>e+r*t[n],0),a=Math.sqrt(e.reduce((e,t)=>e+t*t,0)),i=Math.sqrt(t.reduce((e,t)=>e+t*t,0));return Math.acos(o/(a*i))},arity:ae(2)},projection:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),On(t))throw new r("Cannot project onto zero-length vector",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);const o=e.reduce((e,r,n)=>e+r*t[n],0),a=Math.sqrt(t.reduce((e,t)=>e+t*t,0));return t.map(e=>o/a**2*e)},arity:ae(2)},"orthogonal?":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return 0===e.reduce((e,r,n)=>e+r*t[n],0)},arity:ae(2)},"parallel?":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return function(e,t){if(!In(e,t))return!1;for(let r=0;r<e.length;r++)if(!be(e[r])&&!be(t[r]))return Math.sign(e[r])===Math.sign(t[r]);return!0}(e,t)},arity:ae(2)},"collinear?":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return In(e,t)},arity:ae(2)},"cosine-similarity":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),On(e)||On(t))throw new r("Cannot calculate cosine similarity with zero-length vector",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+r*t[n],0)/(Math.sqrt(e.reduce((e,t)=>e+t*t,0))*Math.sqrt(t.reduce((e,t)=>e+t*t,0)))},arity:ae(2)},"euclidean-distance":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return Math.sqrt(e.reduce((e,r,n)=>e+(r-t[n])**2,0))},arity:ae(2)},"euclidean-norm":{evaluate:([e],t)=>(tt(e,t),function(e){return Math.sqrt(e.reduce((e,t)=>e+t**2,0))}(e)),arity:ae(1)},"manhattan-distance":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+Math.abs(r-t[n]),0)},arity:ae(2)},"manhattan-norm":{evaluate:([e],t)=>(tt(e,t),e.reduce((e,t)=>e+Math.abs(t),0)),arity:ae(1)},"hamming-distance":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+(r!==t[n]?1:0),0)},arity:ae(2)},"hamming-norm":{evaluate:([e],t)=>(tt(e,t),e.reduce((e,t)=>e+(0!==t?1:0),0)),arity:ae(1)},"chebyshev-distance":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return Math.max(...e.map((e,r)=>Math.abs(e-t[r])))},arity:ae(2)},"chebyshev-norm":{evaluate:([e],t)=>(tt(e,t),Math.max(...e.map(e=>Math.abs(e)))),arity:ae(1)},"minkowski-distance":{evaluate:([e,t,n],o)=>{if(tt(e,o),tt(t,o),ee(n,o,{finite:!0,positive:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",o);return e.reduce((e,r,o)=>e+Math.abs(r-t[o])**n,0)**(1/n)},arity:ae(3)},"minkowski-norm":{evaluate:([e,t],r)=>(tt(e,r),ee(t,r,{finite:!0,positive:!0}),e.reduce((e,r)=>e+Math.abs(r)**t,0)**(1/t)),arity:ae(2)},cov:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return 1===e.length?0:Dn(e,t)},arity:ae(2)},corr:{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length<=1)throw new r("Vectors must have at least 2 elements for corr",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);const o=en(e),a=en(t);return e.reduce((e,r,n)=>e+(r-o)*(t[n]-a),0)/Math.sqrt(e.reduce((e,t)=>e+(t-o)**2,0)*t.reduce((e,t)=>e+(t-a)**2,0))},arity:ae(2)},"spearman-corr":{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length<=1)throw new r("Vectors must have at least 2 elements for corr",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);const o=Un(e),a=Un(t);try{return Fn(o,a)}catch(e){throw new r(e,n)}},arity:ae(2)},"pearson-corr":{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length<=1)throw new r("Vectors must have at least 2 elements for pearson-corr",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);try{return Fn(e,t)}catch(e){throw new r(e,n)}},arity:ae(2)},"kendall-tau":{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length<2)throw new r("Vectors must have at least 2 elements for kendall-tau",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);try{return function(e,t,r=1e-10){let n=0,o=0,a=0,i=0;for(let s=0;s<e.length;s++)for(let c=s+1;c<e.length;c++){const l=e[s]-e[c],m=t[s]-t[c],u=Math.abs(l)<r,p=Math.abs(m)<r;u&&p||(u?a+=1:p?i+=1:l*m>0?n+=1:o+=1)}const s=n+o+a,c=n+o+i;if(0===s||0===c)throw new Error("Not enough data to calculate Kendall's Tau");return(n-o)/Math.sqrt(s*c)}(e,t)}catch(e){throw new r(e,n)}},arity:ae(2)},autocorrelation:{evaluate:([e,t],n)=>{if(Ze(e,n),e.length<2)throw new r("Vector must have at least 2 elements for autocorrelation",n);if(ee(t,n,{integer:!0,lt:e.length,gt:-e.length}),0===t)return 1;const o=Math.abs(t),a=en(e);let i=0;const s=e.length;for(let r=0;r<s-o;r++){const n=t<0?r:r+o;i+=(e[t<0?r+o:r]-a)*(e[n]-a)}let c=0;for(let t=0;t<s;t++)c+=(e[t]-a)**2;return 0===c?0:i/c},arity:ae(2)},"cross-correlation":{evaluate:([e,t,n],o)=>{if(Ze(e,o),Ze(t,o),e.length<2)throw new r("Vectors must have at least 2 elements",o);if(e.length!==t.length)throw new r("Vectors must be of the same length",o);if(ee(n,o,{integer:!0,lt:e.length,gt:-e.length}),0===n&&e.length===t.length&&e.every((e,r)=>e===t[r]))return 1;const[a,i]=function(e,t,r){const n=Math.abs(r),o=e.length-n;let a=[],i=[];return r>=0?(a=e.slice(0,o),i=t.slice(r,r+o)):(a=e.slice(n),i=t.slice(0,o)),[a,i]}(e,t,n);return function(e,t){const r=en(e),n=en(t),o=cn(e,r),a=cn(t,n);return 0===o||0===a?0===o&&0===a&&r===n?1:0:Dn(e,t)/(o*a)}(a,i)},arity:ae(3)},rref:{evaluate:([e],t)=>{at(e,t);const[r]=Rn(e);return r},arity:ae(1)},solve:{evaluate:([e,t],n)=>{if(it(e,n),Ze(t,n),e.length!==t.length)throw new r(`The number of rows in the matrix must be equal to the length of the vector, but got ${e.length} and ${t.length}`,n);return function(e,t){const r=e.length,n=e.map((e,r)=>[...e,t[r]]),[o]=Rn(n);for(let e=0;e<r;e+=1)if(be(o[e][e]))return null;const a=Array.from({length:r},()=>0);for(let e=r-1;e>=0;e--){let t=0;for(let n=e+1;n<r;n++)t+=o[e][n]*a[n];a[e]=(o[e][r]-t)/o[e][e]}return a}(e,t)},arity:ae(2)},"to-polar":{evaluate:([e],t)=>{if(Qe(e,t),On(e))return[0,0];return[Math.sqrt(e[0]**2+e[1]**2),Math.atan2(e[1],e[0])]},arity:ae(1)},"from-polar":{evaluate:([e],t)=>{Qe(e,t);const[r,n]=e;return 0===r?[0,0]:[r*Math.cos(n),r*Math.sin(n)]},arity:ae(1)}};for(const[e,t]of Object.entries(Pn))Ln[e]&&(Ln[e].docs=t);const _n={name:"linear-algebra",functions:Ln},Kn={mul:{category:"matrix",description:"Multiplies two `matrices` using standard `matrix` multiplication based on **dot products** of rows and columns.",returns:{type:"matrix"},args:{a:{type:"matrix"},b:{type:"matrix"}},variants:[{argumentNames:["a","b"]}],examples:["let { mul } = import(matrix);\nmul([[1, 2], [3, 4]], [[5, 6], [7, 8]])","let { mul } = import(matrix);\nmul([[1, 2, 3], [4, 5, 6]], [[7, 8], [9, 10], [11, 12]])"],seeAlso:["matrix.det","matrix.inv"]},det:{category:"matrix",description:"Calculates the **determinant** of a square matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the determinant of."}},variants:[{argumentNames:["m"]}],examples:["let { det } = import(matrix);\ndet([[1, 2], [3, 4]])","let { det } = import(matrix);\ndet([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.inv","matrix.cofactor","matrix.adj","matrix.trace","matrix.rank","matrix.invertible?","matrix.mul","matrix.minor"]},inv:{category:"matrix",description:"Calculates the **inverse** of a square matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"The `matrix` to calculate the inverse of."}},variants:[{argumentNames:["m"]}],examples:["let { inv } = import(matrix);\ninv([[1, 2], [3, 4]])","let { inv } = import(matrix);\ninv([[1, 2, 3], [4, 5, 7], [7, 8, 10]])"],seeAlso:["matrix.det","matrix.adj","matrix.invertible?","linear-algebra.solve","matrix.mul","matrix.orthogonal-matrix?"]},adj:{category:"matrix",description:"Calculates the **adjugate** of a square matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"The `matrix` to calculate the adjugate of."}},variants:[{argumentNames:["m"]}],examples:["let { adj } = import(matrix);\nadj([[1, 2], [3, 4]])","let { adj } = import(matrix);\nadj([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { adj } = import(matrix);\nadj([[1, 2, 3], [7, 8, 9], [4, 5, 6]])"],seeAlso:["matrix.cofactor","matrix.det","matrix.inv"]},cofactor:{category:"matrix",description:"Calculates the **cofactor** of a square matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"The `matrix` to calculate the cofactor of."}},variants:[{argumentNames:["m"]}],examples:["let { cofactor } = import(matrix);\ncofactor([[1, 2], [3, 4]])","let { cofactor } = import(matrix);\ncofactor([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { cofactor } = import(matrix);\ncofactor([[1, 2, 3], [7, 8, 9], [4, 5, 6]])"],seeAlso:["matrix.adj","matrix.minor","matrix.det"]},minor:{category:"matrix",description:"Calculates the **minor** of a square matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"The `matrix` to calculate the minor of."},row:{type:"integer",description:"The row index of the element to calculate the minor for."},col:{type:"integer",description:"The column index of the element to calculate the minor for."}},variants:[{argumentNames:["m","row","col"]}],examples:["let { minor } = import(matrix);\nminor([[1, 2], [3, 4]], 0, 1)","let { minor } = import(matrix);\nminor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 1, 1)"],seeAlso:["matrix.cofactor","matrix.det"]},trace:{category:"matrix",description:"Calculates the **trace** of a square matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the trace of."}},variants:[{argumentNames:["m"]}],examples:["let { trace } = import(matrix);\ntrace([[1, 2], [3, 4]])","let { trace } = import(matrix);\ntrace([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.det","matrix.diagonal?"]},"symmetric?":{category:"matrix",description:"Checks if a `matrix` is **symmetric**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for symmetry."}},variants:[{argumentNames:["m"]}],examples:["let { symmetric? } = import(matrix);\nsymmetric?([[1, 2], [2, 1]])","let { symmetric? } = import(matrix);\nsymmetric?([[1, 2, 3], [2, 1, 4], [3, 4, 1]])"],seeAlso:["matrix.orthogonal-matrix?","matrix.diagonal?","matrix.square?","matrix.hilbert"]},"triangular?":{category:"matrix",description:"Checks if a `matrix` is **triangular**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for triangularity."}},variants:[{argumentNames:["m"]}],examples:["let { triangular? } = import(matrix);\ntriangular?([[2, 0], [0, 1]])","let { triangular? } = import(matrix);\ntriangular?([[1, 2, 3], [0, 4, 5], [0, 0, 6]])"],seeAlso:["matrix.upper-triangular?","matrix.lower-triangular?","matrix.diagonal?","matrix.banded?"]},"upper-triangular?":{category:"matrix",description:"Checks if a `matrix` is **upper triangular**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for upper triangularity."}},variants:[{argumentNames:["m"]}],examples:["let { upper-triangular? } = import(matrix);\nupper-triangular?([[1, 2], [0, 3]])","let { upper-triangular? } = import(matrix);\nupper-triangular?([[1, 2, 3], [0, 4, 5], [0, 0, 6]])"],seeAlso:["matrix.lower-triangular?","matrix.triangular?","matrix.diagonal?"]},"lower-triangular?":{category:"matrix",description:"Checks if a `matrix` is **lower triangular**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for lower triangularity."}},variants:[{argumentNames:["m"]}],examples:["let { lower-triangular? } = import(matrix);\nlower-triangular?([[1, 0], [2, 3]])","let { lower-triangular? } = import(matrix);\nlower-triangular?([[1, 0, 0], [2, 3, 0], [4, 5, 6]])"],seeAlso:["matrix.upper-triangular?","matrix.triangular?","matrix.diagonal?"]},"diagonal?":{category:"matrix",description:"Checks if a `matrix` is **diagonal**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for diagonal property."}},variants:[{argumentNames:["m"]}],examples:["let { diagonal? } = import(matrix);\ndiagonal?([[1, 0], [0, 2]])","let { diagonal? } = import(matrix);\ndiagonal?([[1, 0, 0], [0, 2, 0], [0, 0, 3]])","let { diagonal? } = import(matrix);\ndiagonal?([[1, 0, 0], [2, 2, 2], [0, 0, 3]])"],seeAlso:["matrix.identity?","matrix.symmetric?","matrix.triangular?","matrix.trace","matrix.upper-triangular?","matrix.lower-triangular?","matrix.band","matrix.banded?"]},"square?":{category:"matrix",description:"Checks if a `matrix` is **square**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for square property."}},variants:[{argumentNames:["m"]}],examples:["let { square? } = import(matrix);\nsquare?([[1, 2], [3, 4]])","let { square? } = import(matrix);\nsquare?([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { square? } = import(matrix);\nsquare?([[1, 2, 3], [4, 5, 6]])"],seeAlso:["matrix.symmetric?","matrix.identity?","matrix.invertible?"]},"orthogonal-matrix?":{category:"matrix",description:"Checks if a `matrix` is **orthogonal**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for **orthogonality**."}},variants:[{argumentNames:["m"]}],examples:["let { orthogonal-matrix? } = import(matrix);\northogonal-matrix?([[1, 0], [0, 1]])","let { orthogonal-matrix? } = import(matrix);\northogonal-matrix?([[1, 0], [0, -1]])","let { orthogonal-matrix? } = import(matrix);\northogonal-matrix?([[1, 2], [3, 4]])"],seeAlso:["matrix.symmetric?","matrix.inv","matrix.identity?","linear-algebra.orthogonal?"]},"identity?":{category:"matrix",description:"Checks if a `matrix` is an **identity matrix**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for identity property."}},variants:[{argumentNames:["m"]}],examples:["let { identity? } = import(matrix);\nidentity?([[1, 0], [0, 1]])","let { identity? } = import(matrix);\nidentity?([[1, 0, 0], [0, 1, 0], [0, 0, 1]])","let { identity? } = import(matrix);\nidentity?([[1, 0, 0], [0, 1, 0], [0, 0, 0]])"],seeAlso:["matrix.diagonal?","matrix.square?","matrix.orthogonal-matrix?"]},"invertible?":{category:"matrix",description:"Checks if a `matrix` is **invertible**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for invertibility."}},variants:[{argumentNames:["m"]}],examples:["let { invertible? } = import(matrix);\ninvertible?([[1, 2], [3, 4]])","let { invertible? } = import(matrix);\ninvertible?([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { invertible? } = import(matrix);\ninvertible?([[1, 2], [2, 4]])"],seeAlso:["matrix.det","matrix.inv","matrix.rank","matrix.square?"]},hilbert:{category:"matrix",description:"Generates a **Hilbert matrix** of size `n`.",returns:{type:"matrix"},args:{n:{type:"integer",description:"The size of the Hilbert matrix."}},variants:[{argumentNames:["n"]}],examples:["let { hilbert } = import(matrix);\nhilbert(3)","let { hilbert } = import(matrix);\nhilbert(4)"],seeAlso:["matrix.vandermonde","matrix.symmetric?"]},vandermonde:{category:"matrix",description:"Generates a **Vandermonde matrix** from a vector.",returns:{type:"matrix"},args:{v:{type:"vector",description:"The vector to generate the Vandermonde matrix from."}},variants:[{argumentNames:["v"]}],examples:["let { vandermonde } = import(matrix);\nvandermonde([1, 2, 3])","let { vandermonde } = import(matrix);\nvandermonde([1, 0, 1])"],seeAlso:["matrix.hilbert","matrix.band"]},band:{category:"matrix",description:"Generates a **banded matrix** of size `n` with lower band index `lband` and upper band index `uband`.",returns:{type:"matrix"},args:{n:{type:"integer",description:"The size of the banded matrix."},lband:{type:"integer",description:"The lower band index."},uband:{type:"integer",description:"The upper band index."}},variants:[{argumentNames:["n","lband","uband"]}],examples:["let { band } = import(matrix);\nband(3, 1, 1)","let { band } = import(matrix);\nband(4, 1, 2)"],seeAlso:["matrix.banded?","matrix.diagonal?","matrix.vandermonde"]},"banded?":{category:"matrix",description:"Checks if a `matrix` is **banded** with lower band index `lband` and upper band index `uband`.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for **banded** property."},lband:{type:"integer",description:"The lower band index."},uband:{type:"integer",description:"The upper band index."}},variants:[{argumentNames:["m","lband","uband"]}],examples:["let { banded? } = import(matrix);\nbanded?([\n [1, 1, 1, 0],\n [1, 1, 1, 1],\n [1, 1, 1, 1],\n [0, 1, 1, 1],\n], 2, 2)","let { banded? } = import(matrix);\nbanded?([\n [1, 1, 1, 0],\n [1, 1, 1, 1],\n [1, 1, 1, 1],\n [0, 1, 1, 1],\n], 1, 1)"],seeAlso:["matrix.band","matrix.triangular?","matrix.diagonal?"]},rank:{category:"matrix",description:"Calculates the **rank** of a matrix using **Gaussian elimination**.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the rank of."}},variants:[{argumentNames:["m"]}],examples:["let { rank } = import(matrix);\nrank([[1, 0, 0], [0, 1, 0], [0, 0, 1]])","let { rank } = import(matrix);\nrank([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { rank } = import(matrix);\nrank([[2, 4, 6], [3, 6, 9], [4, 8, 12]])"],seeAlso:["matrix.det","matrix.invertible?","linear-algebra.rref"]},"frobenius-norm":{category:"matrix",description:"Calculates the **Frobenius norm** of a matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the Frobenius norm of."}},variants:[{argumentNames:["m"]}],examples:["let { frobenius-norm } = import(matrix);\nfrobenius-norm([[1, 2], [3, 4]])","let { frobenius-norm } = import(matrix);\nfrobenius-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.one-norm","matrix.inf-norm","matrix.max-norm"]},"one-norm":{category:"matrix",description:"Calculates the **one-norm** (column norm) of a matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the one-norm of."}},variants:[{argumentNames:["m"]}],examples:["let { one-norm } = import(matrix);\none-norm([[1, 2], [3, 4]])","let { one-norm } = import(matrix);\none-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.frobenius-norm","matrix.inf-norm","matrix.max-norm"]},"inf-norm":{category:"matrix",description:"Calculates the **infinity norm** of a matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the infinity norm of."}},variants:[{argumentNames:["m"]}],examples:["let { inf-norm } = import(matrix);\ninf-norm([[1, 2], [3, 4]])","let { inf-norm } = import(matrix);\ninf-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.frobenius-norm","matrix.one-norm","matrix.max-norm"]},"max-norm":{category:"matrix",description:"Calculates the **max norm** of a matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the max norm of."}},variants:[{argumentNames:["m"]}],examples:["let { max-norm } = import(matrix);\nmax-norm([[1, 2], [3, 4]])","let { max-norm } = import(matrix);\nmax-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.frobenius-norm","matrix.one-norm","matrix.inf-norm"]}};function Jn(e){const t=e.length,r=[];for(let n=0;n<t;n++)r[n]=[...e[n]];if(1===t)return r[0][0];if(2===t)return r[0][0]*r[1][1]-r[0][1]*r[1][0];let n=1;for(let e=0;e<t-1;e+=1){let o=e;for(let n=e+1;n<t;n+=1)Math.abs(r[n][e])>Math.abs(r[o][e])&&(o=n);if(be(r[o][e]))return 0;o!==e&&([r[e],r[o]]=[r[o],r[e]],n=-n);for(let n=e+1;n<t;n+=1){const o=r[n][e]/r[e][e];for(let a=e;a<t;a++)r[n][a]-=o*r[e][a]}}let o=n;for(let e=0;e<t;e++)o*=r[e][e];return o}function Yn(e,t,r){const n=e.length,o=[];for(let a=0;a<n;a++)if(a!==t){const t=[];for(let o=0;o<n;o++)o!==r&&t.push(e[a][o]);o.push(t)}return o}function Hn(e){const t=e.length,r=[];for(let n=0;n<t;n++){r[n]=[];for(let o=0;o<t;o++){const t=(-1)**(n+o)*Jn(Yn(e,o,n));r[n][o]=t}}return r}function Xn(e){return e.length===e[0].length}function Zn(e){if(!Xn(e))return!1;const t=e.length;for(let r=0;r<t;r++)for(let n=0;n<t;n++)if(r===n){if(!fe(e[r][n],1))return!1}else if(!be(e[r][n]))return!1;return!0}function Qn(e,t){if(0===e.length||0===t.length||e[0].length!==t.length)throw new Error("Matrix dimensions do not match for multiplication");const r=e.length,n=e[0].length,o=t[0].length,a=Array(r).fill(0).map(()=>Array(o).fill(0));for(let i=0;i<r;i++)for(let r=0;r<n;r++){const n=e[i][r];for(let e=0;e<o;e++)a[i][e]+=n*t[r][e]}return a}const eo={mul:{evaluate:([e,t],n)=>{at(e,n),at(t,n);try{return Qn(e,t)}catch(o){throw new r(`The number of columns in the first matrix must be equal to the number of rows in the second matrix, but got ${e[0].length} and ${t.length}`,n)}},arity:ae(2)},det:{evaluate:([e],t)=>(it(e,t),Jn(e)),arity:ae(1)},inv:{evaluate:([e],t)=>{it(e,t);const n=function(e){const t=e.length;if(1===t){const t=e[0][0];return be(t)?null:[[1/t]]}const r=Jn(e);if(be(r))return null;const n=Hn(e),o=[];for(let e=0;e<t;e++){o[e]=[];for(let a=0;a<t;a++)o[e][a]=n[e][a]/r}return o}(e);if(null===n)throw new r("The matrix must be invertible",t);return n},arity:ae(1)},adj:{evaluate:([e],t)=>(it(e,t),Hn(e)),arity:ae(1)},cofactor:{evaluate:([e],t)=>(it(e,t),function(e){const t=e.length,r=[];for(let n=0;n<t;n++){r[n]=[];for(let o=0;o<t;o++){const t=Yn(e,n,o),a=(-1)**(n+o);r[n][o]=a*Jn(t)}}return r}(e)),arity:ae(1)},minor:{evaluate:([e,t,r],n)=>(at(e,n),ee(t,n,{integer:!0,nonNegative:!0,lte:e.length}),ee(r,n,{integer:!0,nonNegative:!0,lte:e[0].length}),Yn(e,t,r)),arity:ae(3)},trace:{evaluate:([e],t)=>(it(e,t),function(e){return e.reduce((e,t,r)=>e+t[r],0)}(e)),arity:ae(1)},"symmetric?":{evaluate:([e],t)=>(at(e,t),function(e){const t=e.length;if(!Xn(e))return!1;for(let r=0;r<t;r+=1)for(let t=0;t<r;t+=1)if(e[r][t]!==e[t][r])return!1;return!0}(e)),arity:ae(1)},"triangular?":{evaluate:([e],t)=>(at(e,t),function(e){if(!Xn(e))return!1;const t=e.length;let r=!0,n=!0;for(let o=0;o<t;o++)for(let a=0;a<t;a++){if(o>a&&0!==e[o][a]&&(r=!1,!n))return!1;o<a&&0!==e[o][a]&&(n=!1)}return r||n}(e)),arity:ae(1)},"upper-triangular?":{evaluate:([e],t)=>(at(e,t),function(e){if(!Xn(e))return!1;const t=e.length;for(let r=0;r<t;r++)for(let t=0;t<r;t++)if(0!==e[r][t])return!1;return!0}(e)),arity:ae(1)},"lower-triangular?":{evaluate:([e],t)=>(at(e,t),function(e){if(!Xn(e))return!1;const t=e.length;if(!e.every(e=>e.length===t))return!1;for(let r=0;r<t;r++)for(let n=r+1;n<t;n++)if(0!==e[r][n])return!1;return!0}(e)),arity:ae(1)},"diagonal?":{evaluate:([e],t)=>(at(e,t),function(e){if(!Xn(e))return!1;const t=e.length;for(let r=0;r<t;r+=1)for(let n=0;n<t;n+=1)if(r!==n&&0!==e[r][n])return!1;return!0}(e)),arity:ae(1)},"square?":{evaluate:([e],t)=>(at(e,t),Xn(e)),arity:ae(1)},"orthogonal-matrix?":{evaluate:([e],t)=>(at(e,t),function(e){return!!Xn(e)&&Zn(Qn(e,Gr(e)))}(e)),arity:ae(1)},"identity?":{evaluate:([e],t)=>(at(e,t),Zn(e)),arity:ae(1)},"invertible?":{evaluate:([e],t)=>(at(e,t),!!function(e){return!!ot(e)&&e.length===e[0].length}(e)&&!be(Jn(e))),arity:ae(1)},hilbert:{evaluate:([e],t)=>{ee(e,t,{integer:!0,positive:!0});const r=[];for(let t=0;t<e;t+=1){const n=[];for(let r=0;r<e;r+=1)n.push(1/(t+r+1));r.push(n)}return r},arity:ae(1)},vandermonde:{evaluate:([e],t)=>{Ze(e,t);const r=[];for(let t=0;t<e.length;t+=1){const n=[];for(let r=0;r<e.length;r+=1)n.push(e[t]**r);r.push(n)}return r},arity:ae(1)},band:{evaluate:([e,t,r],n)=>(ee(e,n,{integer:!0,positive:!0}),ee(t,n,{integer:!0,nonNegative:!0,lt:e}),ee(r,n,{integer:!0,nonNegative:!0,lte:e}),function(e,t,r){const n=Array.from({length:e},()=>Array.from({length:e},()=>0));for(let o=0;o<e;o++)for(let a=Math.max(0,o-t);a<=Math.min(e-1,o+r);a++)n[o][a]=1;return n}(e,t,r)),arity:ae(3)},"banded?":{evaluate:([e,t,r],n)=>{at(e,n);const o=Math.max(e.length,e[0].length);return ee(t,n,{integer:!0,nonNegative:!0,lt:o}),ee(r,n,{integer:!0,nonNegative:!0,lt:o}),function(e,t,r){const n=e.length,o=e[0].length;for(let a=0;a<n;a++)for(let n=0;n<o;n++)if(0!==e[a][n]&&(a-n>t||n-a>r))return!1;return!0}(e,t,r)},arity:ae(3)},rank:{evaluate:([e],t)=>{at(e,t);const[,r]=Rn(e);return r},arity:ae(1)},"frobenius-norm":{evaluate:([e],t)=>(at(e,t),Math.sqrt(e.reduce((e,t)=>e+t.reduce((e,t)=>e+t*t,0),0))),arity:ae(1)},"one-norm":{evaluate:([e],t)=>(at(e,t),function(e){const t=e.length,r=e[0].length;let n=0;for(let o=0;o<r;o+=1){let r=0;for(let n=0;n<t;n+=1)r+=Math.abs(e[n][o]);n=Math.max(n,r)}return n}(e)),arity:ae(1)},"inf-norm":{evaluate:([e],t)=>(at(e,t),e.reduce((e,t)=>Math.max(e,t.reduce((e,t)=>e+Math.abs(t),0)),0)),arity:ae(1)},"max-norm":{evaluate:([e],t)=>(at(e,t),e.reduce((e,t)=>{const r=t.reduce((e,t)=>Math.max(e,Math.abs(t)),0);return Math.max(e,r)},0)),arity:ae(1)}};for(const[e,t]of Object.entries(Kn))eo[e]&&(eo[e].docs=t);const to={name:"matrix",functions:eo},ro={"abundant-seq":{category:"number-theory",description:"Generates the abundant numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { abundant-seq } = import(number-theory);\nabundant-seq(1)","let { abundant-seq } = import(number-theory);\nabundant-seq(5)"],seeAlso:["number-theory.abundant-nth","number-theory.abundant-take-while","number-theory.abundant?","number-theory.deficient-seq","number-theory.perfect-seq"]},"abundant-take-while":{category:"number-theory",description:"Generates the abundant numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { abundant-take-while } = import(number-theory);\nabundant-take-while(-> $ < 100)"],seeAlso:["number-theory.abundant-seq","number-theory.abundant-nth","number-theory.abundant?"]},"abundant-nth":{category:"number-theory",description:"Generates the nth term of the abundant numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the number in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { abundant-nth } = import(number-theory);\nabundant-nth(1)","let { abundant-nth } = import(number-theory);\nabundant-nth(5)"],seeAlso:["number-theory.abundant-seq","number-theory.abundant-take-while","number-theory.abundant?"]},"abundant?":{category:"number-theory",description:"Checks if a number is abundant.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { abundant? } = import(number-theory);\nabundant?(12)","let { abundant? } = import(number-theory);\nabundant?(15)"],seeAlso:["number-theory.abundant-seq","number-theory.abundant-nth","number-theory.deficient?","number-theory.perfect?","number-theory.sigma","number-theory.divisors","number-theory.abundant-take-while"]},"arithmetic-seq":{category:"number-theory",description:"Generates the arithmetic sequence for a given $start, $step, and $length.",returns:{type:"integer",array:!0},args:{start:{type:"number",description:"The starting term of the sequence."},step:{type:"number",description:"The common difference of the sequence."},length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["start","step","length"]}],examples:["let { arithmetic-seq } = import(number-theory);\narithmetic-seq(3, 2, 2)","let { arithmetic-seq } = import(number-theory);\narithmetic-seq(2, 3, 2)","let { arithmetic-seq } = import(number-theory);\narithmetic-seq(1, 2, 2)","let { arithmetic-seq } = import(number-theory);\narithmetic-seq(1, 1.5, 12)"],seeAlso:["number-theory.arithmetic-nth","number-theory.arithmetic-take-while","number-theory.arithmetic?","number-theory.geometric-seq"]},"arithmetic-take-while":{category:"number-theory",description:"Generates the arithmetic sequence while a condition is met.",returns:{type:"integer",array:!0},args:{start:{type:"number",description:"The starting term of the sequence."},step:{type:"number",description:"The common difference of the sequence."},takeWhile:{type:"function",description:"A function that takes a number and an index and returns a boolean."}},variants:[{argumentNames:["start","step","takeWhile"]}],examples:["let { arithmetic-take-while } = import(number-theory);\narithmetic-take-while(1, 0.25, -> $ < 3)"],seeAlso:["number-theory.arithmetic-seq","number-theory.arithmetic-nth","number-theory.arithmetic?"]},"arithmetic-nth":{category:"number-theory",description:"Generates the nth term of the arithmetic sequence.",returns:{type:"integer"},args:{start:{type:"number",description:"The starting term of the sequence."},step:{type:"number",description:"The common difference of the sequence."},n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["start","step","n"]}],examples:["let { arithmetic-nth } = import(number-theory);\narithmetic-nth(3, 2, 2)","let { arithmetic-nth } = import(number-theory);\narithmetic-nth(2, 3, 2)","let { arithmetic-nth } = import(number-theory);\narithmetic-nth(1, 2, 2)","let { arithmetic-nth } = import(number-theory);\narithmetic-nth(1, 1.5, 12)"],seeAlso:["number-theory.arithmetic-seq","number-theory.arithmetic-take-while","number-theory.arithmetic?"]},"arithmetic?":{category:"number-theory",description:"Checks if a number is part of the arithmetic sequence.",returns:{type:"boolean"},args:{start:{type:"number",description:"The starting term of the sequence."},step:{type:"number",description:"The common difference of the sequence."},n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["start","step","n"]}],examples:["let { arithmetic? } = import(number-theory);\narithmetic?(3, 2, 2)","let { arithmetic? } = import(number-theory);\narithmetic?(2, 3, 2)","let { arithmetic? } = import(number-theory);\narithmetic?(1, 2, 2)","let { arithmetic? } = import(number-theory);\narithmetic?(1, 1.5, 12)"],seeAlso:["number-theory.arithmetic-seq","number-theory.arithmetic-nth","number-theory.geometric?","number-theory.arithmetic-take-while"]},"bell-seq":{category:"number-theory",description:"Generates the Bell sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 22 (the maximum length of the pre-calculated bell numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { bell-seq } = import(number-theory);\nbell-seq(5)","let { bell-seq } = import(number-theory);\nbell-seq(10)","let { bell-seq } = import(number-theory);\nbell-seq()"],seeAlso:["number-theory.bell-nth","number-theory.bell-take-while","number-theory.bell?","number-theory.catalan-seq","number-theory.stirling-second","number-theory.stirling-first"]},"bell-take-while":{category:"number-theory",description:"Generates the Bell sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { bell-take-while } = import(number-theory);\nbell-take-while(-> $ < 1000)"],seeAlso:["number-theory.bell-seq","number-theory.bell-nth","number-theory.bell?"]},"bell-nth":{category:"number-theory",description:"Generates the nth term of the Bell sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { bell-nth } = import(number-theory);\nbell-nth(5)","let { bell-nth } = import(number-theory);\nbell-nth(10)"],seeAlso:["number-theory.bell-seq","number-theory.bell-take-while","number-theory.bell?"]},"bell?":{category:"number-theory",description:"Checks if a number is in the Bell sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { bell? } = import(number-theory);\nbell?(1)","let { bell? } = import(number-theory);\nbell?(27644437)","let { bell? } = import(number-theory);\nbell?(27644436)"],seeAlso:["number-theory.bell-seq","number-theory.bell-nth","number-theory.catalan?","number-theory.bell-take-while"]},"bernoulli-seq":{category:"number-theory",description:"Generates the Bernoulli sequence up to a specified length.",returns:{type:"number",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { bernoulli-seq } = import(number-theory);\nbernoulli-seq(5)","let { bernoulli-seq } = import(number-theory);\nbernoulli-seq(10)"],seeAlso:["number-theory.bernoulli-nth","number-theory.bernoulli-take-while"]},"bernoulli-take-while":{category:"number-theory",description:"Generates the Bernoulli sequence while a condition is met.",returns:{type:"number",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { bernoulli-take-while } = import(number-theory);\nbernoulli-take-while(-> abs($) < 100)"],seeAlso:["number-theory.bernoulli-seq","number-theory.bernoulli-nth"]},"bernoulli-nth":{category:"number-theory",description:"Generates the nth term of the Bernoulli sequence.",returns:{type:"number"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { bernoulli-nth } = import(number-theory);\nbernoulli-nth(5)","let { bernoulli-nth } = import(number-theory);\nbernoulli-nth(10)","let { bernoulli-nth } = import(number-theory);\nbernoulli-nth(23)"],seeAlso:["number-theory.bernoulli-seq","number-theory.bernoulli-take-while"]},"catalan-seq":{category:"number-theory",description:"Generates the Catalan sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 30 (the maximum length of the pre-calculated catalan numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { catalan-seq } = import(number-theory);\ncatalan-seq(5)","let { catalan-seq } = import(number-theory);\ncatalan-seq(10)","let { catalan-seq } = import(number-theory);\ncatalan-seq()"],seeAlso:["number-theory.catalan-nth","number-theory.catalan-take-while","number-theory.catalan?","number-theory.bell-seq"]},"catalan-take-while":{category:"number-theory",description:"Generates the Catalan sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { catalan-take-while } = import(number-theory);\ncatalan-take-while(-> $ < 1000)"],seeAlso:["number-theory.catalan-seq","number-theory.catalan-nth","number-theory.catalan?"]},"catalan-nth":{category:"number-theory",description:"Generates the nth term of the Catalan sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { catalan-nth } = import(number-theory);\ncatalan-nth(5)","let { catalan-nth } = import(number-theory);\ncatalan-nth(10)"],seeAlso:["number-theory.catalan-seq","number-theory.catalan-take-while","number-theory.catalan?"]},"catalan?":{category:"number-theory",description:"Determines if a number is in the Catalan sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { catalan? } = import(number-theory);\ncatalan?(5)","let { catalan? } = import(number-theory);\ncatalan?(10)"],seeAlso:["number-theory.catalan-seq","number-theory.catalan-nth","number-theory.bell?","number-theory.catalan-take-while"]},"collatz-seq":{category:"number-theory",description:"Generates the collatz sequence starting from a given integer.",returns:{type:"integer",array:!0},args:{start:{type:"integer",description:"The starting integer for the collatz sequence."}},variants:[{argumentNames:["start"]}],examples:["let { collatz-seq } = import(number-theory);\ncollatz-seq(3)","let { collatz-seq } = import(number-theory);\ncollatz-seq(11)"],seeAlso:["number-theory.juggler-seq"]},"composite-seq":{category:"number-theory",description:"Generates the composite sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { composite-seq } = import(number-theory);\ncomposite-seq(1)","let { composite-seq } = import(number-theory);\ncomposite-seq(2)","let { composite-seq } = import(number-theory);\ncomposite-seq(10)"],seeAlso:["number-theory.composite-nth","number-theory.composite-take-while","number-theory.composite?","number-theory.prime-seq"]},"composite-take-while":{category:"number-theory",description:"Generates the composite sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { composite-take-while } = import(number-theory);\ncomposite-take-while(-> $ < 50)"],seeAlso:["number-theory.composite-seq","number-theory.composite-nth","number-theory.composite?"]},"composite-nth":{category:"number-theory",description:"Generates the nth term of the composite sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the composite number to retrieve."}},variants:[{argumentNames:["n"]}],examples:["let { composite-nth } = import(number-theory);\ncomposite-nth(1)","let { composite-nth } = import(number-theory);\ncomposite-nth(2)","let { composite-nth } = import(number-theory);\ncomposite-nth(10)"],seeAlso:["number-theory.composite-seq","number-theory.composite-take-while","number-theory.composite?"]},"composite?":{category:"number-theory",description:"Determines if a number is composite.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { composite? } = import(number-theory);\ncomposite?(4)","let { composite? } = import(number-theory);\ncomposite?(5)","let { composite? } = import(number-theory);\ncomposite?(11)"],seeAlso:["number-theory.composite-seq","number-theory.composite-nth","number-theory.prime?","number-theory.prime-factors","number-theory.composite-take-while"]},"deficient-seq":{category:"number-theory",description:"Generates the deficient numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { deficient-seq } = import(number-theory);\ndeficient-seq(1)","let { deficient-seq } = import(number-theory);\ndeficient-seq(5)"],seeAlso:["number-theory.deficient-nth","number-theory.deficient-take-while","number-theory.deficient?","number-theory.abundant-seq","number-theory.perfect-seq"]},"deficient-take-while":{category:"number-theory",description:"Generates the deficient numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { deficient-take-while } = import(number-theory);\ndeficient-take-while(-> $ < 100)"],seeAlso:["number-theory.deficient-seq","number-theory.deficient-nth","number-theory.deficient?"]},"deficient-nth":{category:"number-theory",description:"Generates the nth term of the deficient numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the number in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { deficient-nth } = import(number-theory);\ndeficient-nth(5)","let { deficient-nth } = import(number-theory);\ndeficient-nth(12)"],seeAlso:["number-theory.deficient-seq","number-theory.deficient-take-while","number-theory.deficient?"]},"deficient?":{category:"number-theory",description:"Checks if a number is deficient.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { deficient? } = import(number-theory);\ndeficient?(12)","let { deficient? } = import(number-theory);\ndeficient?(15)"],seeAlso:["number-theory.deficient-seq","number-theory.deficient-nth","number-theory.abundant?","number-theory.perfect?","number-theory.sigma","number-theory.divisors","number-theory.deficient-take-while"]},"factorial-seq":{category:"number-theory",description:"Generates the factorial sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 19 (the maximum length of the pre-calculated factorial numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { factorial-seq } = import(number-theory);\nfactorial-seq(1)","let { factorial-seq } = import(number-theory);\nfactorial-seq(2)","let { factorial-seq } = import(number-theory);\nfactorial-seq(3)","let { factorial-seq } = import(number-theory);\nfactorial-seq(4)","let { factorial-seq } = import(number-theory);\nfactorial-seq(5)","let { factorial-seq } = import(number-theory);\nfactorial-seq(10)"],seeAlso:["number-theory.factorial-nth","number-theory.factorial-take-while","number-theory.factorial?","number-theory.factorial"]},"factorial-take-while":{category:"number-theory",description:"Generates the factorial sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { factorial-take-while } = import(number-theory);\nfactorial-take-while(-> $ < 1000)"],seeAlso:["number-theory.factorial-seq","number-theory.factorial-nth","number-theory.factorial?"]},"factorial-nth":{category:"number-theory",description:"Generates the nth term of the factorial sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { factorial-nth } = import(number-theory);\nfactorial-nth(1)","let { factorial-nth } = import(number-theory);\nfactorial-nth(2)","let { factorial-nth } = import(number-theory);\nfactorial-nth(3)","let { factorial-nth } = import(number-theory);\nfactorial-nth(4)","let { factorial-nth } = import(number-theory);\nfactorial-nth(5)","let { factorial-nth } = import(number-theory);\nfactorial-nth(10)"],seeAlso:["number-theory.factorial-seq","number-theory.factorial-take-while","number-theory.factorial?","number-theory.factorial"]},"factorial?":{category:"number-theory",description:"Checks if a number is in the factorial sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { factorial? } = import(number-theory);\nfactorial?(1)","let { factorial? } = import(number-theory);\nfactorial?(2)","let { factorial? } = import(number-theory);\nfactorial?(3)","let { factorial? } = import(number-theory);\nfactorial?(4)","let { factorial? } = import(number-theory);\nfactorial?(5)","let { factorial? } = import(number-theory);\nfactorial?(6)","let { factorial? } = import(number-theory);\nfactorial?(7)","let { factorial? } = import(number-theory);\nfactorial?(8)","let { factorial? } = import(number-theory);\nfactorial?(9)","let { factorial? } = import(number-theory);\nfactorial?(3628800)"],seeAlso:["number-theory.factorial-seq","number-theory.factorial-nth","number-theory.factorial","number-theory.factorial-take-while"]},"fibonacci-seq":{category:"number-theory",description:"Generates the fibonacci sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 79 (the maximum length of the pre-calculated Fibonacci numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { fibonacci-seq } = import(number-theory);\nfibonacci-seq(1)","let { fibonacci-seq } = import(number-theory);\nfibonacci-seq(2)","let { fibonacci-seq } = import(number-theory);\nfibonacci-seq()"],seeAlso:["number-theory.fibonacci-nth","number-theory.fibonacci-take-while","number-theory.fibonacci?","number-theory.lucas-seq","number-theory.tribonacci-seq","number-theory.pell-seq","number-theory.padovan-seq"]},"fibonacci-take-while":{category:"number-theory",description:"Generates the fibonacci sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { fibonacci-take-while } = import(number-theory);\nfibonacci-take-while(-> $ < 100)"],seeAlso:["number-theory.fibonacci-seq","number-theory.fibonacci-nth","number-theory.fibonacci?"]},"fibonacci-nth":{category:"number-theory",description:"Generates the nth term of the fibonacci sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { fibonacci-nth } = import(number-theory);\nfibonacci-nth(5)","let { fibonacci-nth } = import(number-theory);\nfibonacci-nth(50)"],seeAlso:["number-theory.fibonacci-seq","number-theory.fibonacci-take-while","number-theory.fibonacci?"]},"fibonacci?":{category:"number-theory",description:"Determines if a number is in the fibonacci sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { fibonacci? } = import(number-theory);\nfibonacci?(0)","let { fibonacci? } = import(number-theory);\nfibonacci?(1)","let { fibonacci? } = import(number-theory);\nfibonacci?(2)","let { fibonacci? } = import(number-theory);\nfibonacci?(3)","let { fibonacci? } = import(number-theory);\nfibonacci?(4)","let { fibonacci? } = import(number-theory);\nfibonacci?(5)","let { fibonacci? } = import(number-theory);\nfibonacci?(6)","let { fibonacci? } = import(number-theory);\nfibonacci?(7)","let { fibonacci? } = import(number-theory);\nfibonacci?(8)","let { fibonacci? } = import(number-theory);\nfibonacci?(9)"],seeAlso:["number-theory.fibonacci-seq","number-theory.fibonacci-nth","number-theory.lucas?","number-theory.fibonacci-take-while","number-theory.tribonacci?","number-theory.padovan?","number-theory.pell?"]},"geometric-seq":{category:"number-theory",description:"Generates the geometric sequence for a given $start, $ratio, and $length.",returns:{type:"integer",array:!0},args:{start:{type:"number",description:"The starting term of the sequence."},ratio:{type:"number",description:"The common ratio of the sequence."},length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["start","ratio","length"]}],examples:["let { geometric-seq } = import(number-theory);\ngeometric-seq(3, 2, 2)","let { geometric-seq } = import(number-theory);\ngeometric-seq(2, 3, 2)","let { geometric-seq } = import(number-theory);\ngeometric-seq(1, 2, 2)","let { geometric-seq } = import(number-theory);\ngeometric-seq(1, 1.5, 12)"],seeAlso:["number-theory.geometric-nth","number-theory.geometric-take-while","number-theory.geometric?","number-theory.arithmetic-seq"]},"geometric-take-while":{category:"number-theory",description:"Generates the geometric sequence while a condition is met.",returns:{type:"integer",array:!0},args:{start:{type:"number",description:"The starting term of the sequence."},ratio:{type:"number",description:"The common ratio of the sequence."},takeWhile:{type:"function",description:"A function that takes a number and an index and returns a boolean."}},variants:[{argumentNames:["start","ratio","takeWhile"]}],examples:["let { geometric-take-while } = import(number-theory);\ngeometric-take-while(1, 1.5, -> $ < 10)"],seeAlso:["number-theory.geometric-seq","number-theory.geometric-nth","number-theory.geometric?"]},"geometric-nth":{category:"number-theory",description:"Generates the nth term of the geometric sequence.",returns:{type:"integer"},args:{start:{type:"number",description:"The starting term of the sequence."},ratio:{type:"number",description:"The common ratio of the sequence."},n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["start","ratio","n"]}],examples:["let { geometric-nth } = import(number-theory);\ngeometric-nth(3, 2, 2)","let { geometric-nth } = import(number-theory);\ngeometric-nth(2, 3, 2)","let { geometric-nth } = import(number-theory);\ngeometric-nth(1, 2, 2)","let { geometric-nth } = import(number-theory);\ngeometric-nth(1, 1.5, 4)"],seeAlso:["number-theory.geometric-seq","number-theory.geometric-take-while","number-theory.geometric?"]},"geometric?":{category:"number-theory",description:"Checks if a number is in the geometric sequence.",returns:{type:"boolean"},args:{start:{type:"number",description:"The starting term of the sequence."},ratio:{type:"number",description:"The common ratio of the sequence."},n:{type:"number",description:"The number to check."}},variants:[{argumentNames:["start","ratio","n"]}],examples:["let { geometric? } = import(number-theory);\ngeometric?(1, 2, 1)","let { geometric? } = import(number-theory);\ngeometric?(2, 3, 2)","let { geometric? } = import(number-theory);\ngeometric?(3, 2, 2)","let { geometric? } = import(number-theory);\ngeometric?(1, 1.5, 2.25)","let { geometric? } = import(number-theory);\ngeometric?(1, 1.5, -4)"],seeAlso:["number-theory.geometric-seq","number-theory.geometric-nth","number-theory.arithmetic?","number-theory.geometric-take-while"]},"golomb-seq":{category:"number-theory",description:"Generates the Golomb sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { golomb-seq } = import(number-theory);\ngolomb-seq(5)","let { golomb-seq } = import(number-theory);\ngolomb-seq(20)"],seeAlso:["number-theory.golomb-nth","number-theory.golomb-take-while","number-theory.golomb?","number-theory.recaman-seq"]},"golomb-take-while":{category:"number-theory",description:"Generates the Golomb sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { golomb-take-while } = import(number-theory);\ngolomb-take-while(-> $ <= 10)"],seeAlso:["number-theory.golomb-seq","number-theory.golomb-nth","number-theory.golomb?"]},"golomb-nth":{category:"number-theory",description:"Generates the nth term of the Golomb sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { golomb-nth } = import(number-theory);\ngolomb-nth(5)","let { golomb-nth } = import(number-theory);\ngolomb-nth(1000)"],seeAlso:["number-theory.golomb-seq","number-theory.golomb-take-while","number-theory.golomb?"]},"golomb?":{category:"number-theory",description:"Checks if a number is in the Golomb sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { golomb? } = import(number-theory);\ngolomb?(1)","let { golomb? } = import(number-theory);\ngolomb?(2)","let { golomb? } = import(number-theory);\ngolomb?(3345)","let { golomb? } = import(number-theory);\ngolomb?(67867864)"],seeAlso:["number-theory.golomb-seq","number-theory.golomb-nth","number-theory.golomb-take-while"]},"happy-seq":{category:"number-theory",description:"Generates the happy sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 20 (the maximum length of the pre-calculated happy numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { happy-seq } = import(number-theory);\nhappy-seq(1)","let { happy-seq } = import(number-theory);\nhappy-seq(2)","let { happy-seq } = import(number-theory);\nhappy-seq(20)"],seeAlso:["number-theory.happy-nth","number-theory.happy-take-while","number-theory.happy?","number-theory.lucky-seq"]},"happy-take-while":{category:"number-theory",description:"Generates the happy sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { happy-take-while } = import(number-theory);\nhappy-take-while(-> $ < 100)"],seeAlso:["number-theory.happy-seq","number-theory.happy-nth","number-theory.happy?"]},"happy-nth":{category:"number-theory",description:"Generates the nth term of the happy sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the happy number to return."}},variants:[{argumentNames:["n"]}],examples:["let { happy-nth } = import(number-theory);\nhappy-nth(1)","let { happy-nth } = import(number-theory);\nhappy-nth(2)","let { happy-nth } = import(number-theory);\nhappy-nth(20)"],seeAlso:["number-theory.happy-seq","number-theory.happy-take-while","number-theory.happy?"]},"happy?":{category:"number-theory",description:"Determines if a number is a happy number.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { happy? } = import(number-theory);\nhappy?(1)","let { happy? } = import(number-theory);\nhappy?(2)","let { happy? } = import(number-theory);\nhappy?(100)"],seeAlso:["number-theory.happy-seq","number-theory.happy-nth","number-theory.happy-take-while"]},"juggler-seq":{category:"number-theory",description:"Generates the Juggler sequence starting from a given integer.",returns:{type:"integer",array:!0},args:{start:{type:"integer",description:"The starting integer for the Juggler sequence."}},variants:[{argumentNames:["start"]}],examples:["let { juggler-seq } = import(number-theory);\njuggler-seq(3)","let { juggler-seq } = import(number-theory);\njuggler-seq(5)"],seeAlso:["number-theory.collatz-seq"]},"look-and-say-seq":{category:"number-theory",description:"Generates the Look-and-Say sequence up to a specified length.",returns:{type:"string",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { look-and-say-seq } = import(number-theory);\nlook-and-say-seq(5)"],seeAlso:["number-theory.look-and-say-nth","number-theory.look-and-say-take-while","number-theory.look-and-say?"]},"look-and-say-take-while":{category:"number-theory",description:"Generates the Look-and-Say sequence while a condition is met.",returns:{type:"string",array:!0},args:{takeWhile:{type:"function",description:"A function that takes a string and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { look-and-say-take-while } = import(number-theory);\nlook-and-say-take-while((term, index) -> count(term) < 10)","let { look-and-say-take-while } = import(number-theory);\nlook-and-say-take-while(-> $2 <= 10)"],seeAlso:["number-theory.look-and-say-seq","number-theory.look-and-say-nth","number-theory.look-and-say?"]},"look-and-say-nth":{category:"number-theory",description:"Generates the nth term of the Look-and-Say sequence.",returns:{type:"string"},args:{n:{type:"integer",description:"The index of the term in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { look-and-say-nth } = import(number-theory);\nlook-and-say-nth(5)"],seeAlso:["number-theory.look-and-say-seq","number-theory.look-and-say-take-while","number-theory.look-and-say?"]},"look-and-say?":{category:"number-theory",description:"Checks if a string is a valid Look-and-Say term.",returns:{type:"boolean"},args:{term:{type:"string",description:"The term to check."}},variants:[{argumentNames:["term"]}],examples:['let { look-and-say? } = import(number-theory);\nlook-and-say?("111221")','let { look-and-say? } = import(number-theory);\nlook-and-say?("123")'],seeAlso:["number-theory.look-and-say-seq","number-theory.look-and-say-nth","number-theory.look-and-say-take-while"]},"lucas-seq":{category:"number-theory",description:"Generates the lucas sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 77 (the maximum length of the pre-calculated Lucas numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { lucas-seq } = import(number-theory);\nlucas-seq(1)","let { lucas-seq } = import(number-theory);\nlucas-seq(2)","let { lucas-seq } = import(number-theory);\nlucas-seq()"],seeAlso:["number-theory.lucas-nth","number-theory.lucas-take-while","number-theory.lucas?","number-theory.fibonacci-seq"]},"lucas-take-while":{category:"number-theory",description:"Generates the lucas sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { lucas-take-while } = import(number-theory);\nlucas-take-while(-> $ < 100)"],seeAlso:["number-theory.lucas-seq","number-theory.lucas-nth","number-theory.lucas?"]},"lucas-nth":{category:"number-theory",description:"Generates the nth term of the lucas sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { lucas-nth } = import(number-theory);\nlucas-nth(1)","let { lucas-nth } = import(number-theory);\nlucas-nth(2)","let { lucas-nth } = import(number-theory);\nlucas-nth(10)"],seeAlso:["number-theory.lucas-seq","number-theory.lucas-take-while","number-theory.lucas?"]},"lucas?":{category:"number-theory",description:"Determines if a number is in the lucas sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { lucas? } = import(number-theory);\nlucas?(1)","let { lucas? } = import(number-theory);\nlucas?(2)","let { lucas? } = import(number-theory);\nlucas?(10)"],seeAlso:["number-theory.lucas-seq","number-theory.lucas-nth","number-theory.fibonacci?","number-theory.lucas-take-while"]},"lucky-seq":{category:"number-theory",description:"Generates the lucky sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { lucky-seq } = import(number-theory);\nlucky-seq(1)","let { lucky-seq } = import(number-theory);\nlucky-seq(2)","let { lucky-seq } = import(number-theory);\nlucky-seq(20)"],seeAlso:["number-theory.lucky-nth","number-theory.lucky-take-while","number-theory.lucky?","number-theory.happy-seq","number-theory.prime-seq"]},"lucky-take-while":{category:"number-theory",description:"Generates the lucky sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { lucky-take-while } = import(number-theory);\nlucky-take-while(-> $ < 100)"],seeAlso:["number-theory.lucky-seq","number-theory.lucky-nth","number-theory.lucky?"]},"lucky-nth":{category:"number-theory",description:"Generates the nth term of the lucky sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The position in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { lucky-nth } = import(number-theory);\nlucky-nth(1)","let { lucky-nth } = import(number-theory);\nlucky-nth(2)","let { lucky-nth } = import(number-theory);\nlucky-nth(20)"],seeAlso:["number-theory.lucky-seq","number-theory.lucky-take-while","number-theory.lucky?"]},"lucky?":{category:"number-theory",description:"Checks if a number is a lucky number.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { lucky? } = import(number-theory);\nlucky?(4)","let { lucky? } = import(number-theory);\nlucky?(7)","let { lucky? } = import(number-theory);\nlucky?(33)"],seeAlso:["number-theory.lucky-seq","number-theory.lucky-nth","number-theory.prime?","number-theory.lucky-take-while"]},"mersenne-seq":{category:"number-theory",description:"Generates the Mersenne sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 9 (the maximum length of the pre-calculated mersenne numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { mersenne-seq } = import(number-theory);\nmersenne-seq(1)","let { mersenne-seq } = import(number-theory);\nmersenne-seq(5)","let { mersenne-seq } = import(number-theory);\nmersenne-seq()"],seeAlso:["number-theory.mersenne-nth","number-theory.mersenne-take-while","number-theory.mersenne?","number-theory.prime-seq"]},"mersenne-take-while":{category:"number-theory",description:"Generates the Mersenne sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { mersenne-take-while } = import(number-theory);\nmersenne-take-while(-> $ < 1000)"],seeAlso:["number-theory.mersenne-seq","number-theory.mersenne-nth","number-theory.mersenne?"]},"mersenne-nth":{category:"number-theory",description:"Generates the nth term of the Mersenne sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { mersenne-nth } = import(number-theory);\nmersenne-nth(1)","let { mersenne-nth } = import(number-theory);\nmersenne-nth(5)"],seeAlso:["number-theory.mersenne-seq","number-theory.mersenne-take-while","number-theory.mersenne?"]},"mersenne?":{category:"number-theory",description:"Checks if a number is in the Mersenne sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { mersenne? } = import(number-theory);\nmersenne?(3)","let { mersenne? } = import(number-theory);\nmersenne?(4)","let { mersenne? } = import(number-theory);\nmersenne?(7)"],seeAlso:["number-theory.mersenne-seq","number-theory.mersenne-nth","number-theory.prime?","number-theory.mersenne-take-while"]},"padovan-seq":{category:"number-theory",description:"Generates the Padovan sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { padovan-seq } = import(number-theory);\npadovan-seq(5)","let { padovan-seq } = import(number-theory);\npadovan-seq(10)","let { padovan-seq } = import(number-theory);\npadovan-seq(20)"],seeAlso:["number-theory.padovan-nth","number-theory.padovan-take-while","number-theory.padovan?","number-theory.fibonacci-seq"]},"padovan-take-while":{category:"number-theory",description:"Generates the Padovan sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { padovan-take-while } = import(number-theory);\npadovan-take-while(-> $ < 1000)"],seeAlso:["number-theory.padovan-seq","number-theory.padovan-nth","number-theory.padovan?"]},"padovan-nth":{category:"number-theory",description:"Generates the nth term of the Padovan sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { padovan-nth } = import(number-theory);\npadovan-nth(5)","let { padovan-nth } = import(number-theory);\npadovan-nth(10)","let { padovan-nth } = import(number-theory);\npadovan-nth(20)"],seeAlso:["number-theory.padovan-seq","number-theory.padovan-take-while","number-theory.padovan?"]},"padovan?":{category:"number-theory",description:"Checks if a number is in the Padovan sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { padovan? } = import(number-theory);\npadovan?(1)","let { padovan? } = import(number-theory);\npadovan?(265)","let { padovan? } = import(number-theory);\npadovan?(6)"],seeAlso:["number-theory.padovan-seq","number-theory.padovan-nth","number-theory.fibonacci?","number-theory.padovan-take-while"]},"partition-seq":{category:"number-theory",description:"Generates the partition numbers up to a specified length. If no length is provided, it defaults to 299 (the maximum length of the pre-calculated partition numbers).",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { partition-seq } = import(number-theory);\npartition-seq(1)","let { partition-seq } = import(number-theory);\npartition-seq(10)","let { partition-seq } = import(number-theory);\npartition-seq()"],seeAlso:["number-theory.partition-nth","number-theory.partition-take-while","number-theory.partition?","number-theory.partitions","number-theory.count-partitions"]},"partition-take-while":{category:"number-theory",description:"Generates the partition numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { partition-take-while } = import(number-theory);\npartition-take-while(-> $ < 1000)"],seeAlso:["number-theory.partition-seq","number-theory.partition-nth","number-theory.partition?"]},"partition-nth":{category:"number-theory",description:"Generates the nth term of the partition numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the partition number to generate."}},variants:[{argumentNames:["n"]}],examples:["let { partition-nth } = import(number-theory);\npartition-nth(1)","let { partition-nth } = import(number-theory);\npartition-nth(5)"],seeAlso:["number-theory.partition-seq","number-theory.partition-take-while","number-theory.partition?"]},"partition?":{category:"number-theory",description:"Checks if a number is in the partition numbers.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { partition? } = import(number-theory);\npartition?(0)","let { partition? } = import(number-theory);\npartition?(1)","let { partition? } = import(number-theory);\npartition?(2)","let { partition? } = import(number-theory);\npartition?(3)","let { partition? } = import(number-theory);\npartition?(4)","let { partition? } = import(number-theory);\npartition?(5)"],seeAlso:["number-theory.partition-seq","number-theory.partition-nth","number-theory.partitions","number-theory.partition-take-while"]},"pell-seq":{category:"number-theory",description:"Generates the Pell sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 42 (the maximum length of the pre-calculated Pell numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { pell-seq } = import(number-theory);\npell-seq(5)","let { pell-seq } = import(number-theory);\npell-seq(10)","let { pell-seq } = import(number-theory);\npell-seq()"],seeAlso:["number-theory.pell-nth","number-theory.pell-take-while","number-theory.pell?","number-theory.fibonacci-seq"]},"pell-take-while":{category:"number-theory",description:"Generates the Pell sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { pell-take-while } = import(number-theory);\npell-take-while(-> $ < 1000)"],seeAlso:["number-theory.pell-seq","number-theory.pell-nth","number-theory.pell?"]},"pell-nth":{category:"number-theory",description:"Generates the nth term of the Pell sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { pell-nth } = import(number-theory);\npell-nth(5)","let { pell-nth } = import(number-theory);\npell-nth(10)","let { pell-nth } = import(number-theory);\npell-nth(20)"],seeAlso:["number-theory.pell-seq","number-theory.pell-take-while","number-theory.pell?"]},"pell?":{category:"number-theory",description:"Checks if a number is a Pell number.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { pell? } = import(number-theory);\npell?(1)","let { pell? } = import(number-theory);\npell?(470832)","let { pell? } = import(number-theory);\npell?(10)"],seeAlso:["number-theory.pell-seq","number-theory.pell-nth","number-theory.fibonacci?","number-theory.pell-take-while"]},"perfect-seq":{category:"number-theory",description:"Generates the perfect numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"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)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { perfect-seq } = import(number-theory);\nperfect-seq(1)","let { perfect-seq } = import(number-theory);\nperfect-seq(5)","let { perfect-seq } = import(number-theory);\nperfect-seq()"],seeAlso:["number-theory.perfect-nth","number-theory.perfect-take-while","number-theory.perfect?","number-theory.abundant-seq","number-theory.deficient-seq","number-theory.amicable?"]},"perfect-take-while":{category:"number-theory",description:"Generates the perfect numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { perfect-take-while } = import(number-theory);\nperfect-take-while(-> $ < 1000)"],seeAlso:["number-theory.perfect-seq","number-theory.perfect-nth","number-theory.perfect?"]},"perfect-nth":{category:"number-theory",description:"Generates the nth term of the perfect numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the perfect number to generate."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-nth } = import(number-theory);\nperfect-nth(1)","let { perfect-nth } = import(number-theory);\nperfect-nth(5)"],seeAlso:["number-theory.perfect-seq","number-theory.perfect-take-while","number-theory.perfect?"]},"perfect?":{category:"number-theory",description:"Checks if a number is in the perfect numbers.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect? } = import(number-theory);\nperfect?(0)","let { perfect? } = import(number-theory);\nperfect?(1)","let { perfect? } = import(number-theory);\nperfect?(2)","let { perfect? } = import(number-theory);\nperfect?(3)","let { perfect? } = import(number-theory);\nperfect?(4)","let { perfect? } = import(number-theory);\nperfect?(5)","let { perfect? } = import(number-theory);\nperfect?(6)","let { perfect? } = import(number-theory);\nperfect?(7)","let { perfect? } = import(number-theory);\nperfect?(8)","let { perfect? } = import(number-theory);\nperfect?(9)"],seeAlso:["number-theory.perfect-seq","number-theory.perfect-nth","number-theory.abundant?","number-theory.deficient?","number-theory.sigma","number-theory.perfect-take-while","number-theory.amicable?","number-theory.proper-divisors"]},"perfect-square-seq":{category:"number-theory",description:"Generates the perfect square numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { perfect-square-seq } = import(number-theory);\nperfect-square-seq(5)","let { perfect-square-seq } = import(number-theory);\nperfect-square-seq(20)"],seeAlso:["number-theory.perfect-square-nth","number-theory.perfect-square-take-while","number-theory.perfect-square?","number-theory.perfect-cube-seq","number-theory.perfect-power-seq","number-theory.polygonal-seq"]},"perfect-square-take-while":{category:"number-theory",description:"Generates the perfect square numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { perfect-square-take-while } = import(number-theory);\nperfect-square-take-while(-> $ <= 100)"],seeAlso:["number-theory.perfect-square-seq","number-theory.perfect-square-nth","number-theory.perfect-square?"]},"perfect-square-nth":{category:"number-theory",description:"Generates the nth term of the perfect square numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-square-nth } = import(number-theory);\nperfect-square-nth(1)","let { perfect-square-nth } = import(number-theory);\nperfect-square-nth(5)"],seeAlso:["number-theory.perfect-square-seq","number-theory.perfect-square-take-while","number-theory.perfect-square?"]},"perfect-square?":{category:"number-theory",description:"Checks if a number is a perfect square.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-square? } = import(number-theory);\nperfect-square?(16)","let { perfect-square? } = import(number-theory);\nperfect-square?(20)"],seeAlso:["number-theory.perfect-square-seq","number-theory.perfect-square-nth","number-theory.perfect-cube?","number-theory.perfect-power?","number-theory.perfect-square-take-while","number-theory.perfect-power","number-theory.polygonal?"]},"perfect-cube-seq":{category:"number-theory",description:"Generates the perfect cube numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { perfect-cube-seq } = import(number-theory);\nperfect-cube-seq(5)","let { perfect-cube-seq } = import(number-theory);\nperfect-cube-seq(20)"],seeAlso:["number-theory.perfect-cube-nth","number-theory.perfect-cube-take-while","number-theory.perfect-cube?","number-theory.perfect-square-seq","number-theory.perfect-power-seq"]},"perfect-cube-take-while":{category:"number-theory",description:"Generates the perfect cube numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { perfect-cube-take-while } = import(number-theory);\nperfect-cube-take-while(-> $ <= 100)"],seeAlso:["number-theory.perfect-cube-seq","number-theory.perfect-cube-nth","number-theory.perfect-cube?"]},"perfect-cube-nth":{category:"number-theory",description:"Generates the nth term of the perfect cube numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-cube-nth } = import(number-theory);\nperfect-cube-nth(1)","let { perfect-cube-nth } = import(number-theory);\nperfect-cube-nth(5)"],seeAlso:["number-theory.perfect-cube-seq","number-theory.perfect-cube-take-while","number-theory.perfect-cube?"]},"perfect-cube?":{category:"number-theory",description:"Checks if a number is in the perfect cube numbers.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-cube? } = import(number-theory);\nperfect-cube?(7)","let { perfect-cube? } = import(number-theory);\nperfect-cube?(8)","let { perfect-cube? } = import(number-theory);\nperfect-cube?(9)"],seeAlso:["number-theory.perfect-cube-seq","number-theory.perfect-cube-nth","number-theory.perfect-square?","number-theory.perfect-power?","number-theory.perfect-cube-take-while","number-theory.perfect-power"]},"perfect-power-seq":{category:"number-theory",description:"Generates the perfect power numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { perfect-power-seq } = import(number-theory);\nperfect-power-seq(5)","let { perfect-power-seq } = import(number-theory);\nperfect-power-seq(20)"],seeAlso:["number-theory.perfect-power-nth","number-theory.perfect-power-take-while","number-theory.perfect-power?","number-theory.perfect-power","number-theory.perfect-square-seq","number-theory.perfect-cube-seq"]},"perfect-power-take-while":{category:"number-theory",description:"Generates the perfect power numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { perfect-power-take-while } = import(number-theory);\nperfect-power-take-while(-> $ <= 100)"],seeAlso:["number-theory.perfect-power-seq","number-theory.perfect-power-nth","number-theory.perfect-power?"]},"perfect-power-nth":{category:"number-theory",description:"Generates the nth term of the perfect power numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-power-nth } = import(number-theory);\nperfect-power-nth(3)","let { perfect-power-nth } = import(number-theory);\nperfect-power-nth(15)"],seeAlso:["number-theory.perfect-power-seq","number-theory.perfect-power-take-while","number-theory.perfect-power?"]},"perfect-power?":{category:"number-theory",description:"Checks if a number is in the perfect power numbers.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-power? } = import(number-theory);\nperfect-power?(7)","let { perfect-power? } = import(number-theory);\nperfect-power?(8)","let { perfect-power? } = import(number-theory);\nperfect-power?(9)","let { perfect-power? } = import(number-theory);\nperfect-power?(10)"],seeAlso:["number-theory.perfect-power-seq","number-theory.perfect-power-nth","number-theory.perfect-power","number-theory.perfect-square?","number-theory.perfect-cube?","number-theory.perfect-power-take-while"]},"polygonal-seq":{category:"number-theory",description:"Generates the polygonal sequence for a given number of sides and length.",returns:{type:"integer",array:!0},args:{sides:{type:"integer",description:"The number of sides of the polygon."},length:{type:"integer",description:"The length of the sequence to generate."},a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["sides","length"]}],examples:["let { polygonal-seq } = import(number-theory);\npolygonal-seq(3, 2)","let { polygonal-seq } = import(number-theory);\npolygonal-seq(4, 2)","let { polygonal-seq } = import(number-theory);\npolygonal-seq(5, 3)","let { polygonal-seq } = import(number-theory);\npolygonal-seq(6, 5)","let { polygonal-seq } = import(number-theory);\npolygonal-seq(100, 10)"],seeAlso:["number-theory.polygonal-nth","number-theory.polygonal-take-while","number-theory.polygonal?","number-theory.perfect-square-seq"]},"polygonal-take-while":{category:"number-theory",description:"Generates the polygonal sequence while a condition is met.",returns:{type:"integer",array:!0},args:{sides:{type:"integer",description:"The number of sides of the polygon."},takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."},a:{type:"integer"},b:{type:"function"}},variants:[{argumentNames:["sides","takeWhile"]}],examples:["let { polygonal-take-while } = import(number-theory);\npolygonal-take-while(15, -> $ < 1000)"],seeAlso:["number-theory.polygonal-seq","number-theory.polygonal-nth","number-theory.polygonal?"]},"polygonal-nth":{category:"number-theory",description:"Generates the nth term of the polygonal sequence.",returns:{type:"integer"},args:{sides:{type:"integer",description:"The number of sides of the polygon."},n:{type:"integer",description:"The index of the term to generate."},a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["sides","n"]}],examples:["let { polygonal-nth } = import(number-theory);\npolygonal-nth(3, 9)","let { polygonal-nth } = import(number-theory);\npolygonal-nth(4, 5)","let { polygonal-nth } = import(number-theory);\npolygonal-nth(5, 5)"],seeAlso:["number-theory.polygonal-seq","number-theory.polygonal-take-while","number-theory.polygonal?"]},"polygonal?":{category:"number-theory",description:"Checks if a number is in the polygonal sequence.",returns:{type:"boolean"},args:{sides:{type:"integer",description:"The number of sides of the polygon."},n:{type:"integer",description:"The number to check."},a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["sides","n"]}],examples:["let { polygonal? } = import(number-theory);\npolygonal?(3, 10)","let { polygonal? } = import(number-theory);\npolygonal?(3, 9)","let { polygonal? } = import(number-theory);\npolygonal?(4, 10000)","let { polygonal? } = import(number-theory);\npolygonal?(4, 1000)","let { polygonal? } = import(number-theory);\npolygonal?(6, 45)"],seeAlso:["number-theory.polygonal-seq","number-theory.polygonal-nth","number-theory.perfect-square?","number-theory.polygonal-take-while"]},"prime-seq":{category:"number-theory",description:"Generates the prime sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { prime-seq } = import(number-theory);\nprime-seq(1)","let { prime-seq } = import(number-theory);\nprime-seq(2)","let { prime-seq } = import(number-theory);\nprime-seq(10)"],seeAlso:["number-theory.prime-nth","number-theory.prime-take-while","number-theory.prime?","number-theory.composite-seq","number-theory.mersenne-seq","number-theory.lucky-seq"]},"prime-take-while":{category:"number-theory",description:"Generates the prime sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { prime-take-while } = import(number-theory);\nprime-take-while(-> $ < 50)"],seeAlso:["number-theory.prime-seq","number-theory.prime-nth","number-theory.prime?"]},"prime-nth":{category:"number-theory",description:"Generates the nth term of the prime sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { prime-nth } = import(number-theory);\nprime-nth(1)","let { prime-nth } = import(number-theory);\nprime-nth(2)","let { prime-nth } = import(number-theory);\nprime-nth(10)"],seeAlso:["number-theory.prime-seq","number-theory.prime-take-while","number-theory.prime?"]},"prime?":{category:"number-theory",description:"Determines if a number is prime.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { prime? } = import(number-theory);\nprime?(1)","let { prime? } = import(number-theory);\nprime?(2)","let { prime? } = import(number-theory);\nprime?(3)","let { prime? } = import(number-theory);\nprime?(4)","let { prime? } = import(number-theory);\nprime?(997)","let { prime? } = import(number-theory);\nprime?(1001)"],seeAlso:["number-theory.prime-seq","number-theory.prime-nth","number-theory.composite?","number-theory.prime-factors","number-theory.mersenne?","number-theory.prime-take-while","number-theory.lucky?"]},"recaman-seq":{category:"number-theory",description:"Generates the Recaman sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { recaman-seq } = import(number-theory);\nrecaman-seq(5)","let { recaman-seq } = import(number-theory);\nrecaman-seq(10)","let { recaman-seq } = import(number-theory);\nrecaman-seq(20)"],seeAlso:["number-theory.recaman-nth","number-theory.recaman-take-while","number-theory.recaman?","number-theory.golomb-seq"]},"recaman-take-while":{category:"number-theory",description:"Generates the Recaman sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { recaman-take-while } = import(number-theory);\nrecaman-take-while(-> $ < 10)"],seeAlso:["number-theory.recaman-seq","number-theory.recaman-nth","number-theory.recaman?"]},"recaman-nth":{category:"number-theory",description:"Generates the nth term of the Recaman sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { recaman-nth } = import(number-theory);\nrecaman-nth(5)","let { recaman-nth } = import(number-theory);\nrecaman-nth(10)","let { recaman-nth } = import(number-theory);\nrecaman-nth(20)"],seeAlso:["number-theory.recaman-seq","number-theory.recaman-take-while","number-theory.recaman?"]},"recaman?":{category:"number-theory",description:"Checks if a number is in the Recaman sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { recaman? } = import(number-theory);\nrecaman?(5)","let { recaman? } = import(number-theory);\nrecaman?(10)","let { recaman? } = import(number-theory);\nrecaman?(20)"],seeAlso:["number-theory.recaman-seq","number-theory.recaman-nth","number-theory.recaman-take-while"]},"sylvester-seq":{category:"number-theory",description:"Generates the Sylvester sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 6 (the maximum length of the pre-calculated Sylvester numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { sylvester-seq } = import(number-theory);\nsylvester-seq(5)","let { sylvester-seq } = import(number-theory);\nsylvester-seq()","let { sylvester-seq } = import(number-theory);\nsylvester-seq()"],seeAlso:["number-theory.sylvester-nth","number-theory.sylvester-take-while","number-theory.sylvester?"]},"sylvester-take-while":{category:"number-theory",description:"Generates the Sylvester sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { sylvester-take-while } = import(number-theory);\nsylvester-take-while(-> $ < 100000)"],seeAlso:["number-theory.sylvester-seq","number-theory.sylvester-nth","number-theory.sylvester?"]},"sylvester-nth":{category:"number-theory",description:"Generates the nth term of the Sylvester sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { sylvester-nth } = import(number-theory);\nsylvester-nth(1)","let { sylvester-nth } = import(number-theory);\nsylvester-nth(5)"],seeAlso:["number-theory.sylvester-seq","number-theory.sylvester-take-while","number-theory.sylvester?"]},"sylvester?":{category:"number-theory",description:"Checks if a number is in the Sylvester sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { sylvester? } = import(number-theory);\nsylvester?(2)","let { sylvester? } = import(number-theory);\nsylvester?(3)","let { sylvester? } = import(number-theory);\nsylvester?(6)"],seeAlso:["number-theory.sylvester-seq","number-theory.sylvester-nth","number-theory.sylvester-take-while"]},"thue-morse-seq":{category:"number-theory",description:"Generates the Thue-Morse sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { thue-morse-seq } = import(number-theory);\nthue-morse-seq(5)","let { thue-morse-seq } = import(number-theory);\nthue-morse-seq(10)","let { thue-morse-seq } = import(number-theory);\nthue-morse-seq(20)"],seeAlso:["number-theory.thue-morse-nth","number-theory.thue-morse-take-while","number-theory.thue-morse?"]},"thue-morse-take-while":{category:"number-theory",description:"Generates the Thue-Morse sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { thue-morse-take-while } = import(number-theory);\nthue-morse-take-while(-> $2 < 10)"],seeAlso:["number-theory.thue-morse-seq","number-theory.thue-morse-nth","number-theory.thue-morse?"]},"thue-morse-nth":{category:"number-theory",description:"Generates the nth term of the Thue-Morse sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { thue-morse-nth } = import(number-theory);\nthue-morse-nth(5)","let { thue-morse-nth } = import(number-theory);\nthue-morse-nth(10)","let { thue-morse-nth } = import(number-theory);\nthue-morse-nth(20)"],seeAlso:["number-theory.thue-morse-seq","number-theory.thue-morse-take-while","number-theory.thue-morse?"]},"thue-morse?":{category:"number-theory",description:"Checks if a number is part of the Thue-Morse sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { thue-morse? } = import(number-theory);\nthue-morse?(1)","let { thue-morse? } = import(number-theory);\nthue-morse?(2)"],seeAlso:["number-theory.thue-morse-seq","number-theory.thue-morse-nth","number-theory.thue-morse-take-while"]},"tribonacci-seq":{category:"number-theory",description:"Generates the tribonacci sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { tribonacci-seq } = import(number-theory);\ntribonacci-seq(1)","let { tribonacci-seq } = import(number-theory);\ntribonacci-seq(2)","let { tribonacci-seq } = import(number-theory);\ntribonacci-seq(10)"],seeAlso:["number-theory.tribonacci-nth","number-theory.tribonacci-take-while","number-theory.tribonacci?","number-theory.fibonacci-seq"]},"tribonacci-take-while":{category:"number-theory",description:"Generates the tribonacci sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { tribonacci-take-while } = import(number-theory);\ntribonacci-take-while(-> $ < 100)"],seeAlso:["number-theory.tribonacci-seq","number-theory.tribonacci-nth","number-theory.tribonacci?"]},"tribonacci-nth":{category:"number-theory",description:"Generates the nth term of the tribonacci sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { tribonacci-nth } = import(number-theory);\ntribonacci-nth(1)","let { tribonacci-nth } = import(number-theory);\ntribonacci-nth(2)","let { tribonacci-nth } = import(number-theory);\ntribonacci-nth(10)"],seeAlso:["number-theory.tribonacci-seq","number-theory.tribonacci-take-while","number-theory.tribonacci?"]},"tribonacci?":{category:"number-theory",description:"Determines if a number is in the tribonacci sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { tribonacci? } = import(number-theory);\ntribonacci?(0)","let { tribonacci? } = import(number-theory);\ntribonacci?(1)","let { tribonacci? } = import(number-theory);\ntribonacci?(2)","let { tribonacci? } = import(number-theory);\ntribonacci?(3)","let { tribonacci? } = import(number-theory);\ntribonacci?(4)","let { tribonacci? } = import(number-theory);\ntribonacci?(5)","let { tribonacci? } = import(number-theory);\ntribonacci?(6)","let { tribonacci? } = import(number-theory);\ntribonacci?(7)","let { tribonacci? } = import(number-theory);\ntribonacci?(8)","let { tribonacci? } = import(number-theory);\ntribonacci?(9)","let { tribonacci? } = import(number-theory);\ntribonacci?(10)"],seeAlso:["number-theory.tribonacci-seq","number-theory.tribonacci-nth","number-theory.fibonacci?","number-theory.tribonacci-take-while"]},"count-combinations":{category:"number-theory",description:"Calculates the number of combinations of n items taken k at a time.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { count-combinations } = import(number-theory);\ncount-combinations(5, 3)","let { count-combinations } = import(number-theory);\ncount-combinations(10, 2)"],seeAlso:["number-theory.combinations","number-theory.count-permutations","number-theory.factorial","number-theory.multinomial","number-theory.stirling-second","number-theory.count-partitions","number-theory.count-power-set"]},combinations:{category:"number-theory",description:"Generates all possible combinations of a specified size from a collection.",returns:{type:"array",array:!0},args:{set:{type:"array",array:!0,description:"The input collection to generate combinations from."},n:{type:"integer",description:"The size of each combination."},a:{type:"array"},b:{type:"integer"}},variants:[{argumentNames:["set","n"]}],examples:["let { combinations } = import(number-theory);\ncombinations([1, 2, 3], 2)",'let { combinations } = import(number-theory);\ncombinations(["a", "b", "c"], 2)',"let { combinations } = import(number-theory);\ncombinations([1, 2, 3], 0)","let { combinations } = import(number-theory);\ncombinations([1, 2, 3], 1)","let { combinations } = import(number-theory);\ncombinations([1, 2, 3], 3)"],seeAlso:["number-theory.count-combinations","number-theory.permutations","number-theory.power-set","number-theory.cartesian-product","number-theory.partitions"]},"count-derangements":{category:"number-theory",description:"Calculates the number of derangements (permutations where no element appears in its original position) of n items.",returns:{type:"integer"},args:{n:{type:"integer",description:"The total number of items."}},variants:[{argumentNames:["n"]}],examples:["let { count-derangements } = import(number-theory);\ncount-derangements(4)","let { count-derangements } = import(number-theory);\ncount-derangements(5)"],seeAlso:["number-theory.derangements","number-theory.count-permutations","number-theory.factorial"]},derangements:{category:"number-theory",description:"Generates all derangements (permutations where no element appears in its original position) of a set.",returns:{type:"array",array:!0},args:{set:{type:"array",array:!0,description:"The input collection to generate derangements from."}},variants:[{argumentNames:["set"]}],examples:["let { derangements } = import(number-theory);\nderangements([1, 2, 3, 4])",'let { derangements } = import(number-theory);\nderangements(["a", "b", "c"])'],seeAlso:["number-theory.count-derangements","number-theory.permutations"]},divisors:{category:"number-theory",description:"Returns the divisors of a number.",returns:{type:"integer",array:!0},args:{n:{type:"integer",description:"The number to find divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { divisors } = import(number-theory);\ndivisors(12)","let { divisors } = import(number-theory);\ndivisors(100)","let { divisors } = import(number-theory);\ndivisors(37)"],seeAlso:["number-theory.count-divisors","number-theory.proper-divisors","number-theory.sigma","number-theory.prime-factors","number-theory.divisible-by?","number-theory.lcm","number-theory.abundant?","number-theory.deficient?","number-theory.count-proper-divisors"]},"count-divisors":{category:"number-theory",description:"Returns the number of divisors of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { count-divisors } = import(number-theory);\ncount-divisors(12)","let { count-divisors } = import(number-theory);\ncount-divisors(100)","let { count-divisors } = import(number-theory);\ncount-divisors(37)"],seeAlso:["number-theory.divisors","number-theory.count-proper-divisors","number-theory.sigma"]},"proper-divisors":{category:"number-theory",description:"Returns the proper divisors of a number.",returns:{type:"integer",array:!0},args:{n:{type:"integer",description:"The number to find proper divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { proper-divisors } = import(number-theory);\nproper-divisors(12)","let { proper-divisors } = import(number-theory);\nproper-divisors(100)","let { proper-divisors } = import(number-theory);\nproper-divisors(37)"],seeAlso:["number-theory.count-proper-divisors","number-theory.divisors","number-theory.amicable?","number-theory.perfect?"]},"count-proper-divisors":{category:"number-theory",description:"Returns the number of proper divisors of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count proper divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { count-proper-divisors } = import(number-theory);\ncount-proper-divisors(12)","let { count-proper-divisors } = import(number-theory);\ncount-proper-divisors(100)","let { count-proper-divisors } = import(number-theory);\ncount-proper-divisors(37)"],seeAlso:["number-theory.proper-divisors","number-theory.count-divisors","number-theory.divisors"]},factorial:{category:"number-theory",description:"Calculates the factorial of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the factorial for."}},variants:[{argumentNames:["n"]}],examples:["let { factorial } = import(number-theory);\nfactorial(5)","let { factorial } = import(number-theory);\nfactorial(0)","let { factorial } = import(number-theory);\nfactorial(10)","let { factorial } = import(number-theory);\nfactorial(20)"],seeAlso:["number-theory.factorial-seq","number-theory.factorial-nth","number-theory.factorial?","number-theory.count-combinations","number-theory.count-permutations","number-theory.multinomial","number-theory.count-derangements"]},partitions:{category:"number-theory",description:"Generates all partitions of a number.",returns:{type:"array",array:!0},args:{n:{type:"integer",description:"The number to partition."}},variants:[{argumentNames:["n"]}],examples:["let { partitions } = import(number-theory);\npartitions(4)","let { partitions } = import(number-theory);\npartitions(8)"],seeAlso:["number-theory.count-partitions","number-theory.partition-seq","number-theory.combinations","number-theory.partition?"]},"count-partitions":{category:"number-theory",description:"Returns the number of partitions of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count partitions for."}},variants:[{argumentNames:["n"]}],examples:["let { count-partitions } = import(number-theory);\ncount-partitions(4)","let { count-partitions } = import(number-theory);\ncount-partitions(8)","let { count-partitions } = import(number-theory);\ncount-partitions(15)"],seeAlso:["number-theory.partitions","number-theory.partition-seq","number-theory.count-combinations"]},permutations:{category:"number-theory",description:"Generates all permutations of a collection.",returns:{type:"array",array:!0},args:{set:{type:"array",array:!0,description:"The input collection to generate permutations from."}},variants:[{argumentNames:["set"]}],examples:["let { permutations } = import(number-theory);\npermutations([1, 2, 3])",'let { permutations } = import(number-theory);\npermutations(["a", "b", "c"])',"let { permutations } = import(number-theory);\npermutations([1, 2, 3, 4])","let { permutations } = import(number-theory);\npermutations([1, 2])","let { permutations } = import(number-theory);\npermutations([1])","let { permutations } = import(number-theory);\npermutations([])"],seeAlso:["number-theory.count-permutations","number-theory.combinations","number-theory.derangements","number-theory.cartesian-product"]},"count-permutations":{category:"number-theory",description:"Returns the number of permutations of n items taken k at a time.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { count-permutations } = import(number-theory);\ncount-permutations(5, 3)","let { count-permutations } = import(number-theory);\ncount-permutations(10, 2)","let { count-permutations } = import(number-theory);\ncount-permutations(10, 10)","let { count-permutations } = import(number-theory);\ncount-permutations(10, 0)","let { count-permutations } = import(number-theory);\ncount-permutations(10, 1)"],seeAlso:["number-theory.permutations","number-theory.count-combinations","number-theory.factorial","number-theory.multinomial","number-theory.stirling-first","number-theory.count-derangements"]},"power-set":{category:"number-theory",description:"Generates the power set of a collection.",returns:{type:"array",array:!0},args:{set:{type:"any",array:!0,description:"The input collection to generate the power set from."}},variants:[{argumentNames:["set"]}],examples:['let { power-set } = import(number-theory);\npower-set(["a", "b", "c"])',"let { power-set } = import(number-theory);\npower-set([1, 2])","let { power-set } = import(number-theory);\npower-set([1])","let { power-set } = import(number-theory);\npower-set([])"],seeAlso:["number-theory.count-power-set","number-theory.combinations","number-theory.cartesian-product"]},"count-power-set":{category:"number-theory",description:"Returns the number of subsets of a set.",returns:{type:"integer"},args:{n:{type:"integer",description:"The size of the set."}},variants:[{argumentNames:["n"]}],examples:["let { count-power-set } = import(number-theory);\ncount-power-set(3)","let { count-power-set } = import(number-theory);\ncount-power-set(5)","let { count-power-set } = import(number-theory);\ncount-power-set(10)"],seeAlso:["number-theory.power-set","number-theory.count-combinations"]},"prime-factors":{category:"number-theory",description:"Returns the prime factors of a number.",returns:{type:"integer",array:!0},args:{n:{type:"integer",description:"The number to factor."}},variants:[{argumentNames:["n"]}],examples:["let { prime-factors } = import(number-theory);\nprime-factors(12)","let { prime-factors } = import(number-theory);\nprime-factors(100)","let { prime-factors } = import(number-theory);\nprime-factors(37)"],seeAlso:["number-theory.count-prime-factors","number-theory.distinct-prime-factors","number-theory.prime?","number-theory.divisors","number-theory.euler-totient","number-theory.mobius","number-theory.composite?","number-theory.count-distinct-prime-factors"]},"count-prime-factors":{category:"number-theory",description:"Returns the number of prime factors of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count prime factors for."}},variants:[{argumentNames:["n"]}],examples:["let { count-prime-factors } = import(number-theory);\ncount-prime-factors(12)","let { count-prime-factors } = import(number-theory);\ncount-prime-factors(100)","let { count-prime-factors } = import(number-theory);\ncount-prime-factors(37)"],seeAlso:["number-theory.prime-factors","number-theory.distinct-prime-factors","number-theory.count-distinct-prime-factors"]},"distinct-prime-factors":{category:"number-theory",description:"Returns the distinct prime factors of a number.",returns:{type:"integer",array:!0},args:{n:{type:"integer",description:"The number to find distinct prime factors for."}},variants:[{argumentNames:["n"]}],examples:["let { distinct-prime-factors } = import(number-theory);\ndistinct-prime-factors(12)","let { distinct-prime-factors } = import(number-theory);\ndistinct-prime-factors(100)","let { distinct-prime-factors } = import(number-theory);\ndistinct-prime-factors(37)"],seeAlso:["number-theory.prime-factors","number-theory.count-distinct-prime-factors","number-theory.count-prime-factors"]},"count-distinct-prime-factors":{category:"number-theory",description:"Returns the number of distinct prime factors of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count distinct prime factors for."}},variants:[{argumentNames:["n"]}],examples:["let { count-distinct-prime-factors } = import(number-theory);\ncount-distinct-prime-factors(12)","let { count-distinct-prime-factors } = import(number-theory);\ncount-distinct-prime-factors(100)","let { count-distinct-prime-factors } = import(number-theory);\ncount-distinct-prime-factors(37)"],seeAlso:["number-theory.distinct-prime-factors","number-theory.prime-factors","number-theory.count-prime-factors"]},"coprime?":{category:"number-theory",description:"Checks if two numbers are coprime (i.e., their GCD is 1).",returns:{type:"boolean"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { coprime? } = import(number-theory);\ncoprime?(12, 8)","let { coprime? } = import(number-theory);\ncoprime?(12, 5)","let { coprime? } = import(number-theory);\ncoprime?(37, 1)","let { coprime? } = import(number-theory);\ncoprime?(0, 0)","let { coprime? } = import(number-theory);\ncoprime?(0, 5)","let { coprime? } = import(number-theory);\ncoprime?(5, 0)","let { coprime? } = import(number-theory);\ncoprime?(1, 0)","let { coprime? } = import(number-theory);\ncoprime?(0, 1)","let { coprime? } = import(number-theory);\ncoprime?(1, 1)","let { coprime? } = import(number-theory);\ncoprime?(2, 3)"],seeAlso:["number-theory.gcd","number-theory.euler-totient","number-theory.divisible-by?","number-theory.lcm","number-theory.carmichael-lambda"]},"divisible-by?":{category:"number-theory",description:"Checks if a number is divisible by another number.",returns:{type:"boolean"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { divisible-by? } = import(number-theory);\ndivisible-by?(12, 4)","let { divisible-by? } = import(number-theory);\ndivisible-by?(12, 5)","let { divisible-by? } = import(number-theory);\ndivisible-by?(37, 1)","let { divisible-by? } = import(number-theory);\ndivisible-by?(0, 0)","let { divisible-by? } = import(number-theory);\ndivisible-by?(0, 5)","let { divisible-by? } = import(number-theory);\ndivisible-by?(5, 0)"],seeAlso:["number-theory.divisors","number-theory.gcd","number-theory.coprime?"]},gcd:{category:"number-theory",description:"Calculates the greatest common divisor (GCD) of two numbers.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { gcd } = import(number-theory);\ngcd(100, 25)","let { gcd } = import(number-theory);\ngcd(37, 1)","let { gcd } = import(number-theory);\ngcd(0, 0)","let { gcd } = import(number-theory);\ngcd(0, 5)","let { gcd } = import(number-theory);\ngcd(5, 0)"],seeAlso:["number-theory.lcm","number-theory.extended-gcd","number-theory.coprime?","number-theory.divisible-by?"]},lcm:{category:"number-theory",description:"Calculates the least common multiple (LCM) of two numbers.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { lcm } = import(number-theory);\nlcm(100, 25)","let { lcm } = import(number-theory);\nlcm(37, 1)","let { lcm } = import(number-theory);\nlcm(0, 5)","let { lcm } = import(number-theory);\nlcm(5, 0)"],seeAlso:["number-theory.gcd","number-theory.divisors","number-theory.coprime?"]},multinomial:{category:"number-theory",description:"Calculates the multinomial coefficient from of a list of numbers representing the sizes of each group.",returns:{type:"integer"},args:{args:{type:"integer",rest:!0,description:"The numbers representing the sizes of each group."}},variants:[{argumentNames:["args"]}],examples:["let { multinomial } = import(number-theory);\nmultinomial(5, 2, 3)","let { multinomial } = import(number-theory);\nmultinomial(10, 2, 3, 5)"],seeAlso:["number-theory.count-combinations","number-theory.factorial","number-theory.count-permutations"],hideOperatorForm:!0},"amicable?":{category:"number-theory",description:"Checks if two numbers are amicable (i.e., the sum of the proper divisors of each number equals the other number).",returns:{type:"boolean"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { amicable? } = import(number-theory);\namicable?(220, 284)","let { amicable? } = import(number-theory);\namicable?(1184, 1210)","let { amicable? } = import(number-theory);\namicable?(2620, 2924)","let { amicable? } = import(number-theory);\namicable?(5020, 5564)","let { amicable? } = import(number-theory);\namicable?(6232, 6368)"],seeAlso:["number-theory.proper-divisors","number-theory.perfect?","number-theory.sigma","number-theory.perfect-seq"]},"euler-totient":{category:"number-theory",description:"Calculates the Euler's totient function (φ(n)) of a number, which counts the integers up to n that are coprime to n.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the totient for."}},variants:[{argumentNames:["n"]}],examples:["let { euler-totient } = import(number-theory);\neuler-totient(1)","let { euler-totient } = import(number-theory);\neuler-totient(2)","let { euler-totient } = import(number-theory);\neuler-totient(10)","let { euler-totient } = import(number-theory);\neuler-totient(20)"],seeAlso:["number-theory.coprime?","number-theory.carmichael-lambda","number-theory.mobius","number-theory.prime-factors","number-theory.mertens"]},mobius:{category:"number-theory",description:"Calculates the Möbius function (μ(n)) of a number, which is used in number theory.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the Möbius function for."}},variants:[{argumentNames:["n"]}],examples:["let { mobius } = import(number-theory);\nmobius(1)","let { mobius } = import(number-theory);\nmobius(2)","let { mobius } = import(number-theory);\nmobius(3)","let { mobius } = import(number-theory);\nmobius(4)","let { mobius } = import(number-theory);\nmobius(6)","let { mobius } = import(number-theory);\nmobius(12)","let { mobius } = import(number-theory);\nmobius(30)"],seeAlso:["number-theory.mertens","number-theory.euler-totient","number-theory.prime-factors"]},mertens:{category:"number-theory",description:"Calculates the Mertens function (M(n)) of a number, which is the sum of the Möbius function up to n.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the Mertens function for."}},variants:[{argumentNames:["n"]}],examples:["let { mobius } = import(number-theory);\nmobius(1)","let { mobius } = import(number-theory);\nmobius(2)","let { mobius } = import(number-theory);\nmobius(3)","let { mobius } = import(number-theory);\nmobius(4)","let { mobius } = import(number-theory);\nmobius(6)","let { mobius } = import(number-theory);\nmobius(12)","let { mobius } = import(number-theory);\nmobius(30)"],seeAlso:["number-theory.mobius","number-theory.euler-totient"]},sigma:{category:"number-theory",description:"Calculates the sum of divisors function (σ(n)) of a number, which is the sum of all positive divisors of n.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the sum of divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { sigma } = import(number-theory);\nsigma(1)","let { sigma } = import(number-theory);\nsigma(2)","let { sigma } = import(number-theory);\nsigma(3)","let { sigma } = import(number-theory);\nsigma(4)","let { sigma } = import(number-theory);\nsigma(6)","let { sigma } = import(number-theory);\nsigma(12)","let { sigma } = import(number-theory);\nsigma(30)"],seeAlso:["number-theory.divisors","number-theory.perfect?","number-theory.abundant?","number-theory.deficient?","number-theory.amicable?","number-theory.count-divisors"]},"carmichael-lambda":{category:"number-theory",description:"Calculates the Carmichael function (λ(n)) of a number, which is the smallest positive integer m such that a^m ≡ 1 (mod n) for all integers a coprime to n.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the Carmichael function for."}},variants:[{argumentNames:["n"]}],examples:["let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(1)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(2)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(3)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(4)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(6)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(12)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(30)"],seeAlso:["number-theory.euler-totient","number-theory.mod-exp","number-theory.coprime?"]},"cartesian-product":{category:"number-theory",description:"Calculates the Cartesian product of two or more sets.",returns:{type:"array",array:!0},args:{sets:{type:"array",array:!0,description:"The input collections to calculate the Cartesian product from."},a:{type:"array"},b:{type:"array"}},variants:[{argumentNames:["sets"]}],examples:['let { cartesian-product } = import(number-theory);\ncartesian-product([1, 2], ["a", "b"])','let { cartesian-product } = import(number-theory);\ncartesian-product([1, 2], ["a", "b"], [true, false])','let { cartesian-product } = import(number-theory);\ncartesian-product([1, 2, 3], ["x", "y", "z"])'],seeAlso:["number-theory.combinations","number-theory.power-set","number-theory.permutations"]},"perfect-power":{category:"number-theory",description:"Returns a tuple of the base and exponent if the number is a perfect power, otherwise returns null.",returns:{type:"array",array:!0},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-power } = import(number-theory);\nperfect-power(1)","let { perfect-power } = import(number-theory);\nperfect-power(2)","let { perfect-power } = import(number-theory);\nperfect-power(4)","let { perfect-power } = import(number-theory);\nperfect-power(8)","let { perfect-power } = import(number-theory);\nperfect-power(9)","let { perfect-power } = import(number-theory);\nperfect-power(16)","let { perfect-power } = import(number-theory);\nperfect-power(19)"],seeAlso:["number-theory.perfect-power?","number-theory.perfect-power-seq","number-theory.perfect-square?","number-theory.perfect-cube?"]},"mod-exp":{category:"number-theory",description:"Calculates the modular exponentiation of a base raised to an exponent modulo a modulus.",returns:{type:"integer"},args:{base:{type:"integer"},exponent:{type:"integer"},modulus:{type:"integer"}},variants:[{argumentNames:["base","exponent","modulus"]}],examples:["let { mod-exp } = import(number-theory);\nmod-exp(2, 3, 5)","let { mod-exp } = import(number-theory);\nmod-exp(3, 4, 7)","let { mod-exp } = import(number-theory);\nmod-exp(5, 6, 11)","let { mod-exp } = import(number-theory);\nmod-exp(7, 8, 13)"],seeAlso:["number-theory.mod-inv","number-theory.carmichael-lambda","number-theory.chinese-remainder"]},"mod-inv":{category:"number-theory",description:"Calculates the modular multiplicative inverse of a number modulo another number.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","m"]}],examples:["let { mod-inv } = import(number-theory);\nmod-inv(3, 11)","let { mod-inv } = import(number-theory);\nmod-inv(10, 17)","let { mod-inv } = import(number-theory);\nmod-inv(5, 13)","let { mod-inv } = import(number-theory);\nmod-inv(7, 19)"],seeAlso:["number-theory.mod-exp","number-theory.extended-gcd","number-theory.chinese-remainder"]},"extended-gcd":{category:"number-theory",description:"Calculates the extended greatest common divisor (GCD) of two numbers, returning the GCD and the coefficients of Bézout's identity.",returns:{type:"integer",array:!0},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { extended-gcd } = import(number-theory);\nextended-gcd(30, 12)","let { extended-gcd } = import(number-theory);\nextended-gcd(56, 98)","let { extended-gcd } = import(number-theory);\nextended-gcd(101, 10)","let { extended-gcd } = import(number-theory);\nextended-gcd(17, 13)"],seeAlso:["number-theory.gcd","number-theory.mod-inv","number-theory.chinese-remainder"]},"chinese-remainder":{category:"number-theory",description:"Solves a system of simultaneous congruences using the Chinese Remainder Theorem.",returns:{type:"integer"},args:{remainders:{type:"integer",array:!0,description:"The remainders of the congruences."},moduli:{type:"integer",array:!0,description:"The moduli of the congruences."},a:{type:"array"},b:{type:"array"}},variants:[{argumentNames:["remainders","moduli"]}],examples:["let { chinese-remainder } = import(number-theory);\nchinese-remainder([2, 3], [3, 5])","let { chinese-remainder } = import(number-theory);\nchinese-remainder([1, 2], [3, 4])","let { chinese-remainder } = import(number-theory);\nchinese-remainder([0, 1], [2, 3])","let { chinese-remainder } = import(number-theory);\nchinese-remainder([1, 2, 3], [4, 5, 7])"],seeAlso:["number-theory.mod-exp","number-theory.mod-inv","number-theory.extended-gcd"]},"stirling-first":{category:"number-theory",description:"Calculates the Stirling numbers of the first kind, which count the number of permutations of n elements with k cycles.",returns:{type:"integer"},args:{a:{type:"integer",description:"The number of elements."},b:{type:"integer",description:"The number of cycles."}},variants:[{argumentNames:["a","b"]}],examples:["let { stirling-first } = import(number-theory);\nstirling-first(5, 2)","let { stirling-first } = import(number-theory);\nstirling-first(4, 3)","let { stirling-first } = import(number-theory);\nstirling-first(6, 1)","let { stirling-first } = import(number-theory);\nstirling-first(7, 4)","let { stirling-first } = import(number-theory);\nstirling-first(8, 5)"],seeAlso:["number-theory.stirling-second","number-theory.bell-seq","number-theory.count-permutations"]},"stirling-second":{category:"number-theory",description:"Calculates the Stirling numbers of the second kind, which count the number of ways to partition n elements into k non-empty subsets.",returns:{type:"integer"},args:{a:{type:"integer",description:"The number of elements."},b:{type:"integer",description:"The number of subsets."}},variants:[{argumentNames:["a","b"]}],examples:["let { stirling-second } = import(number-theory);\nstirling-second(5, 2)","let { stirling-second } = import(number-theory);\nstirling-second(4, 3)","let { stirling-second } = import(number-theory);\nstirling-second(6, 1)","let { stirling-second } = import(number-theory);\nstirling-second(7, 4)","let { stirling-second } = import(number-theory);\nstirling-second(8, 5)"],seeAlso:["number-theory.stirling-first","number-theory.bell-seq","number-theory.count-combinations"]}};function no(e,t){if(0===t||t===e)return 1;let r=1;for(let n=0;n<t;n++)r*=(e-n)/(n+1);return r}function oo(e,t){if(1===t)return e.map(e=>[e]);const r=[];for(let n=0;n<=e.length-t;n++){const o=e[n],a=oo(e.slice(n+1),t-1);for(const e of a)r.push([o,...e])}return r}const ao={combinations:{evaluate:([e,t],r)=>(we(e,r),ee(t,r,{integer:!0,nonNegative:!0,lte:e.length}),0===t?[[]]:oo(e,t)),arity:ae(2)},"count-combinations":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0,nonNegative:!0}),ee(t,r,{integer:!0,nonNegative:!0,lte:e}),no(e,t)),arity:ae(2)}};const io={derangements:{evaluate:([e],t)=>(we(e,t),function(e){const t=e.length,r=[],n=Array.from({length:t},()=>!1),o=Array.from({length:t});return function a(i){if(i!==t)for(let r=0;r<t;r++)n[r]||r===i||(n[r]=!0,o[i]=e[r],a(i+1),n[r]=!1);else r.push([...o])}(0),r}(e)),arity:ae(1)},"count-derangements":{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),function(e){if(1===e)return 0;let t=1,r=0,n=0;for(let o=2;o<=e;o++)n=(o-1)*(t+r),t=r,r=n;return n}(e)),arity:ae(1)}};function so(e){const t=[];for(let r=1;r<=Math.sqrt(e);r++)e%r===0&&(t.push(r),r!==e/r&&t.push(e/r));return t}function co(e){return so(e).sort((e,t)=>e-t)}function lo(e){return co(e).slice(0,-1)}const mo={divisors:{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),co(e)),arity:ae(1)},"count-divisors":{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),so(e).length),arity:ae(1)},"proper-divisors":{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),lo(e)),arity:ae(1)},"count-proper-divisors":{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),so(e).length-1),arity:ae(1)}},uo=[1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368e3,20922789888e3,355687428096e3,6402373705728e3];function po(e){if(e<0)throw new Error("Factorial is not defined for negative numbers");if(0===e||1===e)return 1;if(e<=18)return uo[e];let t=uo[18];for(let r=19;r<=e;r++)t*=r;return t}const go={factorial:{evaluate:([e],t)=>(ee(e,t,{integer:!0,nonNegative:!0,lte:170}),po(e)),arity:ae(1)}},ho=[1,2,3,5,7,11,15,22,30,42,56,77,101,135,176,231,297,385,490,627,792,1002,1255,1575,1958,2436,3010,3718,4565,5604,6842,8349,10143,12310,14883,17977,21637,26015,31185,37338,44583,53174,63261,75175,89134,105558,124754,147273,173525,204226,239943,281589,329931,386155,451276,526823,614154,715220,831820,966467,1121505,1300156,1505499,1741630,2012558,2323520,2679689,3087735,3554345,4087968,4697205,5392783,6185689,7089500,8118264,9289091,10619863,12132164,13848650,15796476,18004327,20506255,23338469,26543660,30167357,34262962,38887673,44108109,49995925,56634173,64112359,72533807,82010177,92669720,104651419,118114304,133230930,150198136,169229875,190569292,214481126,241265379,271248950,304801365,342325709,384276336,431149389,483502844,541946240,607163746,679903203,761002156,851376628,952050665,1064144451,1188908248,1327710076,1482074143,1653668665,1844349560,2056148051,2291320912,2552338241,2841940500,3163127352,3519222692,3913864295,4351078600,4835271870,5371315400,5964539504,6620830889,7346629512,8149040695,9035836076,10015581680,11097645016,12292341831,13610949895,15065878135,16670689208,18440293320,20390982757,22540654445,24908858009,27517052599,30388671978,33549419497,37027355200,40853235313,45060624582,49686288421,54770336324,60356673280,66493182097,73232243759,80630964769,88751778802,97662728555,107438159466,118159068427,129913904637,142798995930,156919475295,172389800255,189334822579,207890420102,228204732751,250438925115,274768617130,301384802048,330495499613,362326859895,397125074750,435157697830,476715857290,522115831195,571701605655,625846753120,684957390936,749474411781,819876908323,896684817527,980462880430,0xf98dace281,1171432692373,1280011042268,1398341745571,1527273599625,1667727404093,1820701100652,1987276856363,2168627105469,2366022741845,2580840212973,2814570987591,3068829878530,3345365983698,3646072432125,3972999029388,4328363658647,4714566886083,5134205287973,5590088317495,6085253859260,6622987708040,7206841706490,7840656226137,8528581302375,9275102575355,0x92c1cc50847,0x9f8afdf968b,0xad6918d4f36,0xbc72dde1287,0xccc0de0d1d7,0xde6da02b061,0xf195c5ba10a,18028182516671,19573856161145,21248279009367,23061871173849,25025873760111,27152408925615,29454549941750,31946390696157,34643126322519,37561133582570,40718063627362,44132934884255,47826239745920,51820051838712,56138148670947,60806135438329,65851585970275,71304185514919,77195892663512,83561103925871,90436839668817,97862933703585,0x604ca1b434ad,0x682ca0bc6d4e,0x70ad06a4328b,0x79da3e8e4df8,0x83c1a359c63d,0x8e7190d8114a,0x99f976fff202,0xa669edb53a4a,0xb3d4caca1bc8,0xc24d38b78151,0xd1e7cfd30909,0xe2bab064772f,0xf4dd9f8523e3,290726957916112,313891991306665,338854264248680,365749566870782,394723676655357,425933084409356,459545750448675,495741934760846,534715062908609,576672674947168,621837416509615,670448123060170,722760953690372,779050629562167,839611730366814,904760108316360,974834369944625,0x3bb262854d36d,0x404dafd2efa2e,0x4541ae2536f6d,0x4a94ddd83ba57,0x504e363fd1eca,0x56752ddfc97e7,0x5d11c356f6b53,0x642c86bff69f5,0x6bcea3db036a0,0x7401ecbfdbd63,0x7cd0e571c49d4,0x8646d010a1b6f,0x906fba0855202,0x9b5889f52508f,0xa70f0ea631153,0xb3a20ef033ec5,0xc1215ac210755,0xcf9ddd28cfa8d,0xdf29afbd9f60e,0xefd82f26a7157,4534253126900886,4872038056472084,5234371069753672,5622992691950605,6039763882095515,6486674127079088,6965850144195831,7479565078510584,8030248384943040,8620496275465025];const yo={partitions:{evaluate:([e],t)=>(ee(e,t,{integer:!0,nonNegative:!0}),function(e){if(e<=0)return[[]];if(1===e)return[[1]];const t=[];return function e(r,n,o){if(0!==r)for(let t=Math.min(n,r);t>=1;t--)o.push(t),e(r-t,t,o),o.pop();else t.push([...o])}(e,e,[]),t}(e)),arity:ae(1)},"count-partitions":{evaluate:([e],t)=>{if(ee(e,t,{integer:!0,nonNegative:!0}),0===e)return 1;if(e>ho.length)throw new r(`n is too large. The maximum value is ${ho.length-1}.`,t);return ho[e-1]},arity:ae(1)}};function vo(e){if(0===e.length)return[[]];const t=[];for(let r=0;r<e.length;r++){const n=e[r],o=vo([...e.slice(0,r),...e.slice(r+1)]);for(const e of o)t.push([n,...e])}return t}const fo={permutations:{evaluate:([e],t)=>(we(e,t),vo(e)),arity:ae(1)},"count-permutations":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0,nonNegative:!0}),ee(t,r,{integer:!0,nonNegative:!0,lte:e}),po(e)/po(e-t)),arity:ae(2)}};const bo={"power-set":{evaluate:([e],t)=>(we(e,t),function(e){const t=[[]];for(const r of e){const e=t.map(e=>[...e,r]);t.push(...e)}return t}(e)),arity:ae(1)},"count-power-set":{evaluate:([e],t)=>(ee(e,t,{integer:!0,nonNegative:!0}),e>=53?1/0:2**e),arity:ae(1)}};function xo(e){if(1===e)return[];const t=[];let r=2;for(;e>1;)e%r===0?(t.push(r),e/=r):r++;return t}const wo={"prime-factors":{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),xo(e)),arity:ae(1)},"distinct-prime-factors":{evaluate:([e],t)=>{ee(e,t,{finite:!0,integer:!0,positive:!0});const r=xo(e),n=new Set(r);return Array.from(n)},arity:ae(1)},"count-prime-factors":{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),xo(e).length),arity:ae(1)},"count-distinct-prime-factors":{evaluate:([e],t)=>{ee(e,t,{finite:!0,integer:!0,positive:!0});const r=xo(e);return new Set(r).size},arity:ae(1)}};function ko(e){return lo(e).reduce((e,t)=>e+t,0)>e}const qo={"abundant-seq":e=>{const t=[];let r=2;for(;t.length<e;)ko(r)&&t.push(r),r+=1;return t},"abundant?":e=>ko(e),"abundant-take-while":e=>{const t=[];return function r(n){return ko(n)?Ae(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(2)}};const Ao={"arithmetic-seq":{evaluate:([e,t,r],n)=>(ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),ee(r,n,{integer:!0,positive:!0}),Array.from({length:r},(r,n)=>e+n*t)),arity:ae(3)},"arithmetic-take-while":{evaluate:([e,t,r],n,o,{executeFunction:a})=>{ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),L(r,n);const i=e,s=t,c=r,l=[];return function e(t){const r=i+t*s;return Ae(a(c,[r,t],o,n),n=>n?(l.push(r),e(t+1)):l)}(0)},arity:ae(3)},"arithmetic-nth":{evaluate:([e,t,r],n)=>(ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),ee(r,n,{integer:!0,positive:!0}),e+(r-1)*t),arity:ae(3)},"arithmetic?":{evaluate:([e,t,r],n)=>(ee(r,n),ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),function(e,t,r){if(0===t)return fe(r,e);const n=(r-e)/t;if(n<0)return!1;const o=Math.round(n),a=e+t*o;return fe(n,o)&&fe(a,r)}(e,t,r)),arity:ae(3)}};function No(e){const t=[1];for(let r=1;r<e;r+=1){let e=0;for(let n=0;n<r;n+=1)e+=no(r+1,n)*t[n];t[r]=r>1&&r%2==1?0:-e/(r+1)}return t}const $o={"bernoulli-seq":{evaluate:([e],t)=>(ee(e,t,{integer:!0,positive:!0}),No(e)),arity:ae(1)},"bernoulli-nth":{evaluate:([e],t)=>{ee(e,t,{integer:!0,positive:!0});return No(e)[e-1]},arity:ae(1)},"bernoulli-take-while":{evaluate:([e],t,r,{executeFunction:n})=>{L(e,t);const o=e;return function(e){const t=[1];return function r(n){let o=0;for(let e=0;e<n;e++)o+=no(n+1,e)*t[e];const a=n>1&&n%2==1?0:-o/(n+1);return Ae(e(a,n),e=>e?(t.push(a),r(n+1)):t)}(1)}((e,t)=>Ae(n(o,[e,t],r),e=>!!e))},arity:ae(1)}};function To(e){if(e<=1)return!1;if(e<=3)return!0;if(e%2==0||e%3==0)return!1;for(let t=5;t*t<=e;t+=6)if(e%t===0||e%(t+2)===0)return!1;return!0}const zo={"prime-seq":e=>{const t=[];let r=2;for(;t.length<e;)To(r)&&t.push(r),r+=1;return t},"prime?":e=>To(e),"prime-take-while":e=>{const t=[];return function r(n){return To(n)?Ae(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(2)}};function So(e){return!(e<=1)&&!To(e)}const Eo={"composite-seq":e=>{const t=[];let r=2;for(;t.length<e;)So(r)&&t.push(r),r+=1;return t},"composite?":e=>So(e),"composite-take-while":e=>{const t=[];return function r(n){return So(n)?Ae(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(4)}};function jo(e){return lo(e).reduce((e,t)=>e+t,0)<e}const Mo={"deficient-seq":e=>{const t=[];let r=1;for(;t.length<e;)jo(r)&&t.push(r),r+=1;return t},"deficient?":e=>jo(e),"deficient-take-while":e=>{const t=[];return function r(n){return jo(n)?Ae(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(1)}};const Co={"geometric-seq":{evaluate:([e,t,r],n)=>(ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),ee(r,n,{integer:!0,positive:!0}),Array.from({length:r},(r,n)=>e*t**n)),arity:ae(3)},"geometric-take-while":{evaluate:([e,t,r],n,o,{executeFunction:a})=>{ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),L(r,n);const i=e,s=t,c=r,l=[];return function e(t){const r=i*s**t;return Ae(a(c,[r,t],o,n),n=>n?(l.push(r),e(t+1)):l)}(0)},arity:ae(3)},"geometric-nth":{evaluate:([e,t,r],n)=>(ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),ee(r,n,{integer:!0,positive:!0}),e*t**(r-1)),arity:ae(3)},"geometric?":{evaluate:([e,t,r],n)=>(ee(r,n),ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),function(e,t,r){if(fe(e,0))return fe(r,0);if(fe(t,1))return fe(r,e);if(fe(t,0))return fe(r,0)||fe(r,e);if(fe(r,e))return!0;if(fe(t,-1))return fe(r,e)||fe(r,-e);if(t<0){const n=Math.log(Math.abs(r/e))/Math.log(Math.abs(t)),o=Math.round(n);if(!fe(o,n)||o<0)return!1;const a=o%2==0?Math.sign(e):Math.sign(e)*Math.sign(t);return Math.sign(r)===a}if(t>1&&r<e||t<1&&r>e)return!1;const n=Math.log(r/e)/Math.log(t),o=Math.round(n);return!(!fe(o,n)||o<0)&&fe(e*t**o,r)}(e,t,r)),arity:ae(3)}};const Po={"golomb-seq":e=>function(e){const t=[0,1];for(let r=2;r<=e;r+=1)t.push(1+t[r-t[t[r-1]]]);return t.slice(1)}(e),"golomb?":()=>!0,"golomb-take-while":e=>function(e){const t=[0,1];return Ae(e(1,0),r=>r?function r(n){const o=1+t[n-t[t[n-1]]];return Ae(e(o,n-1),e=>e?(t.push(o),r(n+1)):t.slice(1))}(2):[])}(e)};function Ro(e){if(e<=0)return!1;const t=new Set;for(;1!==e&&!t.has(e);)t.add(e),e=Io(e);return 1===e}function Io(e){let t=0;for(;e>0;){const r=e%10;t+=r*r,e=Math.floor(e/10)}return t}const Oo={"happy-seq":e=>{const t=[];for(let r=1;t.length<e;r++){let e=r;const n=new Set;for(;1!==e&&!n.has(e);)n.add(e),e=String(e).split("").reduce((e,t)=>e+Number(t)**2,0);1===e&&t.push(r)}return t},"happy?":e=>Ro(e),"happy-take-while":e=>{const t=[];return function r(n){return Ro(n)?Ae(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(1)}},Fo={"juggler-seq":e=>{let t=e;const r=[t];for(;t>1;)t=t%2==0?Math.floor(Math.sqrt(t)):Math.floor(t**1.5),r.push(t);return r},noNth:!0};function Uo(e){let t="",r=1;for(let n=0;n<e.length;n++)n+1<e.length&&e[n]===e[n+1]?r++:(t+=r.toString()+e[n],r=1);return t}const Do={string:!0,"look-and-say-seq":e=>{const t=["1"];for(let r=1;r<e;r+=1){const e=t[r-1].replace(/(\d)\1*/g,e=>`${e.length}${e[0]}`);t[r]=e}return t},"look-and-say-take-while":e=>{const t=[];return Ae(e("1",0),r=>{if(!r)return t;return t.push("1"),function r(n){const o=t[n-1].replace(/(\d)\1*/g,e=>`${e.length}${e[0]}`);return Ae(e(o,n),e=>e?(t.push(o),r(n+1)):t)}(1)})},"look-and-say?":e=>function(e){let t="1";if(t===e)return!0;for(;;){if(t=Uo(t),t===e)return!0;if(t.length>e.length)return!1}}(e)};function Wo(e){const t=[];for(let e=1;e<=2e3;e++)t.push(e);let r=[1];for(let e=1;e<t.length;e++)t[e]%2!=0&&r.push(t[e]);const n=[1];let o=1;return Ae(e(1,0),t=>{if(!t)return[];let a=1;return function t(){const i=r[a];return Ae(e(i,o),e=>{if(!e)return n;n.push(i),o++;const s=i,c=[];for(let e=0;e<r.length;e++)(e+1)%s!==0&&c.push(r[e]);if(r=c,a++,a>=r.length-5){let e=r[r.length-1]+2;for(;r.length<a+1e3;)r.push(e),e+=2}return t()})}()})}const Go={"lucky-seq":e=>function(e){const t=[];let r=1;const n=e*(e<100?20:30);for(;t.length<n;)t.push(r),r+=2;let o=1;for(;o<t.length&&o<e;){const e=t[o];let r=0;for(let n=0;n<t.length;n++)(n+1)%e!==0&&(t[r++]=t[n]);t.length=r,o<t.length&&o++}return t.slice(0,e)}(e),"lucky?":e=>Wo(t=>t<=e).includes(e),"lucky-take-while":e=>Wo(e)};const Vo={"padovan-seq":e=>{const t=[1,1,1];for(let r=3;r<e;r+=1)t[r]=t[r-2]+t[r-3];return t.slice(0,e)},"padovan?":e=>function(e){if(!Number.isInteger(e)||e<=0)return!1;if(1===e)return!0;const t=[1,1,1,2,2,3,4,5,7,9,12,16,21,28,37,49,65,86,114,151,200,265,351,465,616,816,1081,1432,1897,2513,3329,4410,5842,7739,10252,13581,17991,23833,31572,41824,55405,73396,97229];if(t.includes(e))return!0;if(e>t[t.length-1]&&e<=Number.MAX_SAFE_INTEGER){let r,n=t[t.length-3],o=t[t.length-2],a=t[t.length-1];for(;a<e;){if(r=n+o,n=o,o=a,a=r,a===e)return!0;if(!Number.isSafeInteger(a))return!1}}return!1}(e),"padovan-take-while":e=>{const t=[];return Ae(e(1,0),r=>r?(t.push(1),Ae(e(1,1),r=>r?(t.push(1),Ae(e(1,2),r=>{if(!r)return t;t.push(1);let n=1,o=1,a=1;return function r(i){const s=n+o;return n=o,o=a,a=s,Ae(e(a,i),e=>e?(t.push(a),r(i+1)):t)}(4)})):t)):t)}},Bo={"perfect-cube-seq":e=>{const t=[];for(let r=1;r<=e;r++)t.push(r**3);return t},"perfect-cube?":e=>e>0&&Number.isInteger(Math.cbrt(e)),"perfect-cube-take-while":e=>{const t=[];return function r(n){const o=n**3;return Ae(e(o,n),e=>e?(t.push(o),r(n+1)):t)}(1)}};function Lo(e){if(e<2)return 1===e?[1,2]:null;const t=Math.floor(Math.log2(e))+1;for(let r=2;r<=t;r++){const t=e**(1/r),n=Math.round(t);if(fe(n**r,e))return[n,r]}return null}const _o={"perfect-power-seq":e=>{const t=[];for(let r=1;t.length<e;r++)Lo(r)&&t.push(r);return t},"perfect-power?":e=>null!==Lo(e),"perfect-power-take-while":e=>{const t=[];return function r(n){return Lo(n)?Ae(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(1)}},Ko={"perfect-square-seq":e=>{const t=[];for(let r=1;r<=e;r++)t.push(r**2);return t},"perfect-square?":e=>e>0&&Number.isInteger(Math.sqrt(e)),"perfect-square-take-while":e=>{const t=[];return function r(n){const o=n**2;return Ae(e(o,n),e=>e?(t.push(o),r(n+1)):t)}(1)}},Jo={"polygonal-seq":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0,gte:3}),ee(t,r,{integer:!0,positive:!0});const n=[];for(let r=1;r<=t;r+=1)n[r-1]=(r*r*(e-2)-r*(e-4))/2;return n},arity:ae(2)},"polygonal-take-while":{evaluate:([e,t],r,n,{executeFunction:o})=>{ee(e,r,{integer:!0,gte:3}),L(t,r);const a=e,i=t,s=[];return function e(t){const c=(t*t*(a-2)-t*(a-4))/2;return Ae(o(i,[c,t],n,r),r=>r?(s.push(c),e(t+1)):s)}(1)},arity:ae(2)},"polygonal-nth":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0,gte:3}),ee(t,r,{integer:!0,positive:!0}),(t*t*(e-2)-t*(e-4))/2),arity:ae(2)},"polygonal?":{evaluate:([e,t],r)=>{if(ee(t,r,{integer:!0}),ee(e,r,{integer:!0,gte:3}),t<=0)return!1;const n=e-2,o=e-4,a=8*n*t+o*o,i=Math.sqrt(a);if(!Number.isInteger(i))return!1;const s=i+o;if(s%(2*n)!=0)return!1;const c=s/(2*n);return Number.isInteger(c)&&c>0},arity:ae(2)}};const Yo={"recaman-seq":e=>function(e){if(1===e)return[0];const t=[0],r=new Set([0]);for(let n=1;n<e;n++){let e=t[n-1]-n;(e<=0||r.has(e))&&(e=t[n-1]+n),t.push(e),r.add(e)}return t}(e),"recaman-take-while":e=>{const t=[],r=new Set([0]);return Ae(e(0,0),n=>{if(!n)return t;return t.push(0),function n(o){let a=t[o-1]-o;return(a<=0||r.has(a))&&(a=t[o-1]+o),Ae(e(a,o),e=>e?(t.push(a),r.add(a),n(o+1)):t)}(1)})},"recaman?":()=>!0},Ho={"thue-morse-seq":e=>{const t=[];for(let r=0;r<e;r+=1)t[r]=Xo(r)%2;return t},"thue-morse-take-while":e=>{const t=[];return function r(n){const o=Xo(n)%2;return Ae(e(o,n),e=>e?(t.push(o),r(n+1)):t)}(0)},"thue-morse?":e=>1===e||0===e};function Xo(e){let t=0;for(;e;)t+=1&e,e>>=1;return t}const Zo={};function Qo(e){for(const[t,r]of Object.entries(e)){if(Zo[t])throw new Error(`Duplicate normal expression key found: ${t}`);Zo[t]=r}}function ea(e,t){return{[`${e}-seq`]:ra(e=>t.slice(0,e),t.length),[`${e}-take-while`]:na(e=>function r(n){return n>=t.length?t.slice(0,n):Ae(e(t[n],n),e=>e?r(n+1):t.slice(0,n))}(0),t.length),[`${e}-nth`]:oa(()=>t,t.length),[`${e}?`]:aa(e=>t.includes(e))}}function ta(e){for(const[t,r]of Object.entries(e)){if(Zo[t])throw new Error(`Duplicate normal expression key found: ${t}`);t.endsWith("seq")?(Zo[t]=ra(r,e.maxLength),e.noNth||(Zo[t.replace(/seq$/,"nth")]=oa(r,e.maxLength))):t.endsWith("take-while")?Zo[t]=na(r,e.maxLength):t.endsWith("?")&&(e.string?Zo[t]=ia(r):Zo[t]=aa(r))}}function ra(e,t){return{evaluate:(n,o)=>{const a=n[0]??t;ee(a,o,{integer:!0,positive:!0,lte:t});const i=e(a,o);if("number"==typeof i[0]&&i.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",o);return i},arity:"number"==typeof t?{max:1}:ae(1)}}function na(e,t){return{evaluate:(t,n,o,{executeFunction:a})=>{const i=t[0];L(i,n);const s=e((e,t)=>Ae(a(i,[e,t],o),e=>!!e),n);return Ae(s,e=>{if("number"==typeof e[0]&&e.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",n);return e})},arity:"number"==typeof t?{max:1}:ae(1)}}function oa(e,t){return{evaluate:(n,o)=>{const a=n[0];ee(a,o,{integer:!0,positive:!0,lte:t});const i=e(a,o);if("number"==typeof i[0]&&i.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",o);return i[a-1]},arity:ae(1)}}function aa(e){return{evaluate:(t,r)=>{const n=t[0];return ee(n,r),e(n,r)},arity:ae(1)}}function ia(e){return{evaluate:(t,r)=>{const n=t[0];return K(n,r),e(n,r)},arity:ae(1)}}function sa(e,t){for(;0!==t;){const r=t;t=e%t,e=r}return Math.abs(e)}function ca(e,t){return Math.floor(e*t/sa(e,t))}function la(e){if(1===e)return 1;const t=xo(e);return new Set(t).size!==t.length?0:t.length%2==0?1:-1}function ma(e,t){if(0===t)return[e,1,0];const[r,n,o]=ma(t,e%t);return[r,o,n-Math.floor(e/t)*o]}function ua(e,t){const[r,n]=ma(e,t);if(1!==r)throw new Error(`Modular inverse does not exist (gcd(${e}, ${t}) = ${r})`);return(n%t+t)%t}ta(qo),ta({"collatz-seq":e=>{let t=e;const r=[t];for(;1!==t;)t%2==0?t/=2:t=3*t+1,r.push(t);return r},noNth:!0}),ta(Eo),ta(Mo),ta(Po),ta(Oo),ta(Fo),ta(Do),ta(Go),ta(Vo),ta(Ko),ta(Bo),ta(_o),ta(zo),ta(Yo),ta(Ho),Qo(ea("tribonacci",[0,1,1,2,4,7,13,24,44,81,149,274,504,927,1705,3136,5768,10609,19513,35890,66012,121415,223317,410744,755476,1389537,2555757,4700770,8646064,15902591,29249425,53798080,98950096,181997601,334745777,615693474,1132436852,2082876103,3831006429,7046319384,12960201916,23837527729,43844049029,80641778674,148323355432,272809183135,501774317241,922906855808,1697490356184,3122171529233,5742568741225,0x99b36012952,19426970897100,35731770264967,65720971788709,0x6df08059d9f8,0xca35cf00a924,408933139743937,752145307699165,0x4ea34736b35c2,0x90a3317d5c260,4680045560037375,8607945812375585])),Qo(ea("catalan",[1,2,5,14,42,132,429,1430,4862,16796,58786,208012,742900,2674440,9694845,35357670,129644790,477638700,1767263190,6564120420,24466267020,91482563640,343059613650,1289904147324,4861946401452,18367353072152,69533550916004,0xefe09af96cd8,0x38f88b34d6a68,0xd8db5c347b610])),Qo(ea("factorial",uo)),Qo(ea("fibonacci",[0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,1134903170,1836311903,2971215073,4807526976,7778742049,12586269025,20365011074,32951280099,53316291173,86267571272,139583862445,225851433717,365435296162,591286729879,956722026041,1548008755920,2504730781961,4052739537881,6557470319842,0x9a661ca20bb,0xf9d297a859d,27777890035288,44945570212853,72723460248141,0x6b04f4c2fe42,0xad2934c6d08f,308061521170129,498454011879264,806515533049393,0x4a2dce62b0d91,0x780626e057bc2,0xc233f54308953,5527939700884757,8944394323791464])),Qo(ea("lucas",[2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,0xd55fbe3dc94,23725150497407,38388099893011,62113250390418,0x5b67cb4878a5,0x93e5a9822a37,0xef4d74caa2dc,425730551631123,688846502588399,0x3f5b3b1643d02,0x66834447bacf1,0xa5de7f5dfe9f3,4721424167835364,7639424778862807])),Qo(ea("mersenne",[3,7,31,127,2047,8191,131071,524287,2147483647])),Qo(ea("partition",ho)),Qo(ea("pell",[1,2,5,12,29,70,169,408,985,2378,5741,13860,33461,80782,195025,470832,1136689,2744210,6625109,15994428,38613965,93222358,225058681,543339720,1311738121,3166815962,7645370045,18457556052,44560482149,107578520350,259717522849,627013566048,1513744654945,3654502875938,8822750406821,21300003689580,51422757785981,0x70e8e1937766,299713796309065,723573111879672,0x634c28af7f039,0xefb9b143d586a])),Qo(ea("perfect",[6,28,496,8128,33550336,8589869056,137438691328])),Qo(ea("sylvester",[2,6,42,1806,3263442,0x9afa8dc8416])),Qo(ea("bell",[1,2,5,15,52,203,877,4140,21147,115975,678570,4213597,27644437,190899322,1382958545,10480142147,82864869804,682076806159,5832742205057,51724158235372,474869816156751,4506715738447323])),Qo(Ao),Qo($o),Qo(Co),Qo(Jo);const pa={"coprime?":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0}),1===sa(e,t)),arity:ae(2)},"divisible-by?":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0}),0!==t&&e%t===0),arity:ae(2)},gcd:{evaluate:([e,t],r)=>(ee(e,r),ee(t,r),sa(e,t)),arity:ae(2)},lcm:{evaluate:([e,t],r)=>(ee(e,r),ee(t,r),ca(e,t)),arity:ae(2)},multinomial:{evaluate:([...e],t)=>{Ze(e,t);return po(e.reduce((e,r)=>(ee(r,t,{integer:!0,nonNegative:!0}),e+r),0))/e.reduce((e,t)=>e*po(t),1)},arity:{min:1}},"amicable?":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0,positive:!0}),ee(t,r,{integer:!0,positive:!0});const n=lo(e).reduce((e,t)=>e+t,0),o=lo(t).reduce((e,t)=>e+t,0);return n===t&&o===e&&e!==t},arity:ae(2)},"euler-totient":{evaluate:([e],t)=>{ee(e,t,{integer:!0,positive:!0});let r=e;for(let t=2;t*t<=e;t+=1)if(e%t===0){for(;e%t===0;)e/=t;r-=r/t}return e>1&&(r-=r/e),r},arity:ae(1)},mobius:{evaluate:([e],t)=>{if(ee(e,t,{integer:!0,positive:!0}),1===e)return 1;const r=xo(e);return new Set(r).size!==r.length?0:r.length%2==0?1:-1},arity:ae(1)},mertens:{evaluate:([e],t)=>{if(ee(e,t,{integer:!0,positive:!0}),1===e)return 1;let r=0;for(let t=1;t<=e;t++){r+=la(t)}return r},arity:ae(1)},sigma:{evaluate:([e],t)=>(ee(e,t,{integer:!0,positive:!0}),co(e).reduce((e,t)=>e+t,0)),arity:ae(1)},"carmichael-lambda":{evaluate:([e],t)=>{if(ee(e,t,{integer:!0,positive:!0}),1===e)return 1;const r=xo(e),n=new Map;for(const e of r)n.set(e,(n.get(e)||0)+1);const o=[];for(const[e,t]of n.entries())2===e?1===t?o.push(1):2===t?o.push(2):o.push(2**(t-2)):o.push((e-1)*e**(t-1));return o.reduce((e,t)=>ca(e,t),1)},arity:ae(1)},"cartesian-product":{evaluate:(e,t)=>{e.forEach(e=>{we(e,t)});return e.reduce((e,t)=>{const r=[];return e.forEach(e=>{t.forEach(t=>{r.push([...e,t])})}),r},[[]])},arity:{min:1}},"perfect-power":{evaluate:([e],t)=>{ee(e,t,{integer:!0,positive:!0});return Lo(e)||null},arity:ae(1)},"mod-exp":{evaluate:([e,t,r],n)=>(ee(e,n,{finite:!0}),ee(t,n,{integer:!0,positive:!0}),ee(r,n,{integer:!0,positive:!0}),function(e,t,r){if(1===r)return 0;let n=1;for(e%=r;t>0;)t%2==1&&(n=n*e%r),t>>=1,e=e*e%r;return n}(e,t,r)),arity:ae(3)},"mod-inv":{evaluate:([e,t],n)=>{ee(e,n,{integer:!0,positive:!0}),ee(t,n,{integer:!0,positive:!0});try{return ua(e,t)}catch(e){throw new r(e,n)}},arity:ae(2)},"extended-gcd":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0}),ma(e,t)),arity:ae(2)},"chinese-remainder":{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length!==t.length)throw new r("Remainders and moduli must have the same length.",n);try{return function(e,t){for(let e=0;e<t.length;e++)for(let r=e+1;r<t.length;r++){const n=ma(t[e],t[r])[0];if(1!==n)throw new Error(`Moduli must be pairwise coprime, but gcd(${t[e]}, ${t[r]}) = ${n}`)}const r=t.reduce((e,t)=>e*t,1);let n=0;for(let o=0;o<e.length;o++){const a=e[o],i=t[o],s=r/i;n=(n+a*s*ua(s,i))%r}return n}(e,t)}catch(e){throw new r(e.message,n)}},arity:ae(2)},"stirling-first":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0,positive:!0}),ee(t,r,{integer:!0,positive:!0,lte:e});const n=Array.from({length:e+1},()=>Array(t+1).fill(0));n[0][0]=1;for(let r=1;r<=e;r++)for(let e=1;e<=Math.min(r,t);e++)n[r][e]=n[r-1][e-1]+(r-1)*n[r-1][e];return n[e][t]},arity:ae(2)},"stirling-second":{evaluate:([e,t],r)=>{if(ee(e,r,{integer:!0,positive:!0}),ee(t,r,{integer:!0,positive:!0,lte:e}),1===t)return 1;if(t===e)return 1;const n=Array.from({length:e+1},()=>Array(t+1).fill(0));n[0][0]=1;for(let r=1;r<=e;r++)for(let e=1;e<=Math.min(r,t);e++)n[r][e]=e*n[r-1][e]+n[r-1][e-1];return n[e][t]},arity:ae(2)}};function ga(e){for(const[t,r]of Object.entries(e)){if(pa[t])throw new Error(`Duplicate normal expression key found: ${t}`);pa[t]=r}}!function(e){for(const[t,r]of Object.entries(e)){if(pa[t])throw new Error(`Duplicate normal expression key found: ${t}`);pa[t]=r}}(Zo),ga(go),ga(mo),ga(ao),ga(fo),ga(yo),ga(wo),ga(io),ga(bo);for(const[e,t]of Object.entries(ro))pa[e]&&(pa[e].docs=t);const ha={name:"number-theory",functions:pa},da={"string-repeat":{evaluate:([e,t],r)=>(K(e,r),ee(t,r,{integer:!0,nonNegative:!0}),e.repeat(t)),arity:ae(2),docs:{category:"string",returns:{type:"number"},args:{a:{type:"string"},b:{type:"integer"},s:{type:"string"},n:{type:"integer"}},variants:[{argumentNames:["s","n"]}],description:"Repeates $s $n times.",seeAlso:["str","repeat"],examples:['let { string-repeat } = import(string);\n"*" string-repeat 10','let { string-repeat } = import(string);\nstring-repeat("*", 10)','let { string-repeat } = import(string);\nstring-repeat("***", 0)']}},"from-char-code":{evaluate:([e],t)=>{ee(e,t,{finite:!0});const n=ue(e);try{return String.fromCodePoint(n)}catch(e){throw new r(e,t)}},arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{code:{type:"number"}},variants:[{argumentNames:["code"]}],description:"Return character for code point $code.",seeAlso:["string.to-char-code"],examples:["let { from-char-code } = import(string);\nfrom-char-code(65)","let { from-char-code } = import(string);\nfrom-char-code(0)"]}},"to-char-code":{evaluate:([e],t)=>(K(e,t,{nonEmpty:!0}),f(e.codePointAt(0),t)),arity:ae(1),docs:{category:"string",returns:{type:"number"},args:{c:{type:"string"}},variants:[{argumentNames:["c"]}],description:"Return code point for first character in $c.",seeAlso:["string.from-char-code"],examples:['let { to-char-code } = import(string);\nto-char-code("A")','let { to-char-code } = import(string);\nto-char-code("Albert")']}},"trim-left":{evaluate:([e],t)=>(K(e,t),e.replace(/^\s+/,"")),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns a new string with leading whitespaces removed.",seeAlso:["trim","string.trim-right"],examples:['let { trim-left } = import(string);\ntrim-left(" Albert ")','let { trim-left } = import(string);\ntrim-left(" ")','let { trim-left } = import(string);\ntrim-left("")']}},"trim-right":{evaluate:([e],t)=>(K(e,t),e.replace(/\s+$/,"")),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns a new string with trailing whitespaces removed.",seeAlso:["trim","string.trim-left"],examples:['let { trim-right } = import(string);\ntrim-right(" Albert ")','let { trim-right } = import(string);\ntrim-right(" ")','let { trim-right } = import(string);\ntrim-right("")']}},"split-lines":{evaluate:([e],t)=>(K(e,t),e.split(/\r\n|\n|\r/).filter(e=>""!==e)),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Divides $s into an array of substrings, each representing a line.",seeAlso:["split"],examples:['let { split-lines } = import(string);\nsplit-lines("Albert\nMojir\n")','let { split-lines } = import(string);\nsplit-lines("Albert\n\nMojir")','let { split-lines } = import(string);\nsplit-lines("Albert\nMojir\n\n")','let { split-lines } = import(string);\nsplit-lines("")']}},"pad-left":{evaluate:([e,t,r],n)=>(K(e,n),ee(t,n,{integer:!0}),void 0!==r&&K(r,n),e.padStart(t,r)),arity:{min:2,max:3},docs:{category:"string",returns:{type:"string"},args:{a:{type:"string"},b:{type:"integer"},s:{type:"string"},length:{type:"integer"},padString:{type:"string"}},variants:[{argumentNames:["s","length"]},{argumentNames:["s","length","padString"]}],description:"Pads from the start of $s with `padString` (multiple times, if needed) until the resulting string reaches the given $length.",seeAlso:["string.pad-right"],examples:['let { pad-left } = import(string);\n"Albert" pad-left 20','let { pad-left } = import(string);\npad-left("Albert", 20)','let { pad-left } = import(string);\npad-left("Albert", 20, "-*-")','let { pad-left } = import(string);\npad-left("Albert", 5)','let { pad-left } = import(string);\npad-left("Albert", -1)']}},"pad-right":{evaluate:([e,t,r],n)=>(K(e,n),ee(t,n,{integer:!0}),void 0!==r&&K(r,n),e.padEnd(t,r)),arity:{min:2,max:3},docs:{category:"string",returns:{type:"string"},args:{a:{type:"string"},b:{type:"integer"},s:{type:"string"},length:{type:"integer"},padString:{type:"string"}},variants:[{argumentNames:["s","length"]},{argumentNames:["s","length","padString"]}],description:"Pads from the start of $s with `padString` (multiple times, if needed) until the resulting string reaches the given `length`.",seeAlso:["string.pad-left"],examples:['let { pad-right } = import(string);\n"Albert" pad-right 20','let { pad-right } = import(string);\npad-right("Albert", 20)','let { pad-right } = import(string);\npad-right("Albert", 20, "-*-")','let { pad-right } = import(string);\npad-right("Albert", 5)','let { pad-right } = import(string);\npad-right("Albert", -1)']}},template:{evaluate:([e,...t],r)=>{K(e,r),we(t,r);const n=e.split("||||");if(n.length<=1)return va(n[0],t,r);{const e=t[0];ee(e,r,{integer:!0,nonNegative:!0});const o=[`${e}`,...t.slice(1)];if(2===n.length){return va(n[1===e?0:1],o,r)}return va(n[Math.min(e,n.length-1)],o,r)}},arity:{min:1,max:10},docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"},params:{type:"any",rest:!0}},variants:[{argumentNames:["s","params"]}],description:"Applies placeholders to a string. Support for basic pluralization - see examples. If pluralization is used, first placeholder must be a number.",seeAlso:["str"],examples:['let { template } = import(string);\ntemplate("Hi, $1 and $2", "Carl", "Larry")','let { template } = import(string);\ntemplate("Hi $1, $2, $3, $4, $5, $6, $7, $8 and $9", "A", "B", "C", "D", "E", "F", "G", "H", "I")','let { template } = import(string);\ntemplate("$1 book||||$1 books", 0)','let { template } = import(string);\ntemplate("$1 book||||$1 books", 1)','let { template } = import(string);\ntemplate("$1 book||||$1 books", 2)','let { template } = import(string);\ntemplate("No book||||$1 book||||$1 books", 0)','let { template } = import(string);\ntemplate("No book||||$1 book||||$1 books", 1)','let { template } = import(string);\ntemplate("No book||||$1 book||||$1 books", 10)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 0)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 1)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 2)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 3)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 4)'],hideOperatorForm:!0}},"encode-base64":{evaluate:([e],t)=>(K(e,t),btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16))))),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns a Base64 encoded string from $s.",seeAlso:["string.decode-base64"],examples:['let { encode-base64 } = import(string);\nencode-base64("Albert")']}},"decode-base64":{evaluate:([e],t)=>{K(e,t);try{return decodeURIComponent(Array.prototype.map.call(atob(e),e=>`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}catch(e){throw new r(e,t)}},arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{base64string:{type:"string"}},variants:[{argumentNames:["base64string"]}],description:"Returns a Base64 decoded string from $base64string.",seeAlso:["string.encode-base64"],examples:['let { decode-base64 } = import(string);\ndecode-base64("QWxiZXJ0IPCfkLs=")']}},"encode-uri-component":{evaluate:([e],t)=>(K(e,t),encodeURIComponent(e)),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns an escaped `URI` string.",seeAlso:["string.decode-uri-component"],examples:['let { encode-uri-component } = import(string);\nencode-uri-component("Hi everyone!?")']}},"decode-uri-component":{evaluate:([e],t)=>{K(e,t);try{return decodeURIComponent(e)}catch(e){throw new r(e,t)}},arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns an un-escaped `URI` string.",seeAlso:["string.encode-uri-component"],examples:['let { decode-uri-component } = import(string);\ndecode-uri-component("Hi%20everyone!%3F%20%F0%9F%91%8D")']}},capitalize:{evaluate:([e],t)=>(K(e,t),e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns $s with the first character converted to uppercase and the rest to lowercase.",seeAlso:["lower-case","upper-case"],examples:['let { capitalize } = import(string);\ncapitalize("albert")','let { capitalize } = import(string);\ncapitalize("ALBERT")','let { capitalize } = import(string);\ncapitalize("aLBERT")','let { capitalize } = import(string);\ncapitalize("")']}}},ya=/\$\$/g;function va(e,t,r){for(let n=0;n<9;n+=1){const o=new RegExp(`(\\$\\$|[^$]|^)\\$${n+1}`,"g");if(o.test(e)){const a=H(t[n],r);e=e.replace(o,`$1${a}`)}}return e=e.replace(ya,"$")}const fa={name:"string",functions:da};function ba(e,t){if(O(e)){if("string"==typeof t&&ce(e,t))return pe(e[t])}else if(Q(t,{nonNegative:!0,integer:!0})&&t>=0&&t<e.length)return pe(e[t])}function xa(e,t,r,n){if(W(e,n),Array.isArray(e)||"string"==typeof e){if(ee(t,n,{integer:!0}),ee(t,n,{gte:0}),ee(t,n,{lte:e.length}),"string"==typeof e)return K(r,n,{char:!0}),`${e.slice(0,t)}${r}${e.slice(t+1)}`;const o=[...e];return o[t]=r,o}K(t,n);const o={...e};return o[t]=r,o}function wa(e,t,r,n,o,a,i){if(O(e)){K(t,i);const s={...e};return Ae(a(r,[s[t],...n],o,i),e=>(s[t]=e,s))}{ee(t,i);const s=ue(t);if(ee(s,i,{lte:e.length}),Array.isArray(e))return Ae(Ne(Array.from({length:e.length+(s===e.length?1:0)}),(t,c)=>s===c?a(r,[e[c],...n],o,i):e[c]),e=>e);{const t=e.split("");return Ae(Ne(Array.from({length:t.length+(s===t.length?1:0)}),(e,c)=>s===c?Ae(a(r,[t[c],...n],o,i),e=>J(e,i,{char:!0})):t[c]),e=>e.join(""))}}}function ka(e,t,r){const n=he(e);return{coll:n,innerCollMeta:t.slice(0,t.length-1).reduce((e,t)=>{const n=e.coll;let o;return Array.isArray(n)?(ee(t,r),o=D(n[t],r)):(F(n,r),K(t,r),ce(e.coll,t)||(n[t]={}),o=D(n[t],r)),{coll:o,parent:n}},{coll:n,parent:{}})}}const qa={"get-in":{evaluate:(e,t)=>{let r=pe(e[0]);const n=e[1]??[],o=pe(e[2]);we(n,t);for(const e of n){if(X(e,t),!U(r))return o;{const t=ba(r,e);if(void 0===t)return o;r=t}}return r},arity:{min:2,max:3},docs:{category:"collection",returns:{type:"any"},args:{a:{type:"collection"},b:{type:"array"},"not-found":{type:"any"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","not-found"]}],description:"Returns the value in a nested collection, where $b is an array of keys. Returns $not-found if the key is not present. If $not-found is not set, `null` is returned.",seeAlso:["get","collection.assoc-in","collection.update-in"],examples:['\nlet cu = import(collection);\ncu.get-in(\n [[1, 2, 3], [4, { a: "Kalle" }, 6]],\n [1, 1, "a", 0]\n)','\nlet cu = import(collection);\ncu.get-in(\n [[1, 2, 3], [4, { a: "Kalle" }, 6]],\n [1, 1, "b", 0]\n)','\nlet cu = import(collection);\ncu.get-in(\n [[1, 2, 3], [4, { a: "Kalle" }, 6]],\n [1, 1, "b", 0],\n "Lisa"\n)']}},"assoc-in":{evaluate:([e,t,r],n)=>{if(W(e,n),we(t,n),C(r,n),1===t.length)return X(t[0],n),xa(e,t[0],r,n);const{coll:o,innerCollMeta:a}=ka(e,t,n),i=H(t[t.length-1],n),s=H(t[t.length-2],n);return Array.isArray(a.parent)?(ee(s,n),a.parent[s]=xa(a.coll,i,r,n)):(K(s,n),a.parent[s]=xa(a.coll,i,r,n)),o},arity:ae(3),docs:{category:"collection",returns:{type:"collection"},args:{coll:{type:"collection"},ks:{type:["number","string"],array:!0},value:{type:"any"}},variants:[{argumentNames:["coll","ks","value"]}],description:"\nAssociates a value in the nested collection $coll, where $ks is an array of keys and $value is the new value.\n\nIf any levels do not exist, objects will be created - and the corresponding keys must be of type string.",seeAlso:["assoc","collection.get-in","collection.update-in"],examples:['\nlet cu = import(collection);\ncu.assoc-in(\n {},\n ["a", "b", "c"],\n "Albert"\n)','\nlet cu = import(collection);\ncu.assoc-in(\n [1, 2, [1, 2, 3]],\n [2, 1],\n "Albert"\n)','\nlet cu = import(collection);\ncu.assoc-in(\n [1, 2, { name: "albert" }],\n [2, "name", 0],\n "A"\n)']}},update:{evaluate:([e,t,r,...n],o,a,{executeFunction:i})=>(W(e,o),X(t,o),L(r,o),wa(e,t,r,n,a,i,o)),arity:{min:3},docs:{category:"collection",returns:{type:"collection"},args:{coll:{type:"collection"},key:{type:["string","number"]},fun:{type:"function"},"fun-args":{type:"any",rest:!0}},variants:[{argumentNames:["coll","value","fun"]},{argumentNames:["coll","value","fun","fun-args"]}],description:"\nUpdates a value in the $coll collection, where $key is a key. $fun is a function\nthat will take the old value and any supplied $fun-args and\nreturn the new value.\nIf the key does not exist, `null` is passed as the old value.",seeAlso:["collection.update-in","assoc"],examples:['\nlet cu = import(collection);\nlet x = { a: 1, b: 2 };\ncu.update(x, "a", inc)','\nlet cu = import(collection);\nlet x = { a: 1, b: 2 };\ncu.update(\n x,\n "c",\n val -> null?(val) ? 0 : inc(val)\n)']}},"update-in":{evaluate:([e,t,r,...n],o,a,{executeFunction:i})=>{if(W(e,o),we(t,o),L(r,o),1===t.length)return X(t[0],o),wa(e,t[0],r,n,a,i,o);const{coll:s,innerCollMeta:c}=ka(e,t,o),l=H(t[t.length-1],o),m=H(t[t.length-2],o);return Array.isArray(c.parent)?(ee(m,o),Ae(wa(c.coll,l,r,n,a,i,o),e=>(c.parent[m]=e,s))):(K(m,o),Ae(wa(c.coll,l,r,n,a,i,o),e=>(c.parent[m]=e,s)))},arity:{min:3},docs:{category:"collection",returns:{type:"collection"},args:{coll:{type:"collection"},ks:{type:"array"},fun:{type:"function"},"fun-args":{type:"any",rest:!0}},variants:[{argumentNames:["coll","ks","fun"]},{argumentNames:["coll","ks","fun","fun-args"]}],description:"Updates a value in the $coll collection, where $ks is an array of\nkeys and $fun is a function that will take the old value and\nany supplied $fun-args and return the new value. If any levels do not exist,\nobjects will be created - and the corresponding keys must be of type string.",seeAlso:["collection.update","collection.assoc-in","collection.get-in"],examples:['\nlet cu = import(collection);\ncu.update-in(\n { a: [1, 2, 3] },\n ["a", 1],\n -> null?($) ? 0 : inc($)\n)','\nlet cu = import(collection);\ncu.update-in(\n { a: { foo: "bar"} },\n ["a", "foo"],\n -> null?($) ? "?" : "!"\n)','\nlet cu = import(collection);\ncu.update-in(\n { a: { foo: "bar"} },\n ["a", "baz"],\n -> null?($) ? "?" : "!"\n)','\nlet cu = import(collection);\ncu.update-in(\n { a: [1, 2, 3] },\n ["a", 1],\n *,\n 10,\n 10,\n 10,\n)']}},filteri:{evaluate:([e,t],r,n,{executeFunction:o})=>(W(e,r),L(t,r),Array.isArray(e)?Ie(e,(e,a)=>o(t,[e,a],n,r)):"string"==typeof e?Ae(Ie(e.split(""),(e,a)=>o(t,[e,a],n,r)),e=>e.join("")):Ae(Ie(Object.entries(e),([e,a])=>o(t,[a,e],n,r)),e=>e.reduce((e,[t,r])=>(e[t]=r,e),{}))),arity:ae(2),docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function",description:"The function to call for each element in the collection. The function should take two arguments: the element itself and the index."}},variants:[{argumentNames:["a","b"]}],description:"Creates a new collection with all elements that pass the test implemented by $b. The function is called for each element in the collection, and it should take two arguments: the element itself and the index.",seeAlso:["filter","collection.mapi"],examples:["let cu = import(collection); cu.filteri([1, 2, 3], (x, i) -> i % 2 == 0)","let cu = import(collection); cu.filteri([1, 2, 3], (x, i) -> x % 2 == 0)","let cu = import(collection); cu.filteri([1, 2, 3], (x, i) -> x + i > 3)"]}},mapi:{evaluate:([e,t],r,n,{executeFunction:o})=>{if(W(e,r),L(t,r),Array.isArray(e))return Ne(e,(e,a)=>o(t,[e,a],n,r));if("string"==typeof e)return Ae(Ne(e.split(""),(e,a)=>o(t,[e,a],n,r)),e=>e.join(""));return Te(Object.entries(e),(e,[a,i])=>Ae(o(t,[i,a],n,r),t=>(e[a]=t,e)),{})},arity:ae(2),docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function",description:"The function to call for each element in the collection. The function should take two arguments: the element itself and the index."}},variants:[{argumentNames:["a","b"]}],description:"Creates a new collection populated with the results of calling $b on every element in $a. The function is called for each element in the collection, and it should take two arguments: the element itself and the index.",seeAlso:["map","collection.filteri"],examples:["let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x + i)","let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x * i)","let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x - i)","let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x / i)","let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x % inc(i))"]}},reducei:{evaluate:([e,t,r],n,o,{executeFunction:a})=>(W(e,n),L(t,n),C(r,n),"string"==typeof e?(K(r,n),0===e.length?r:Te(e.split("").map((e,t)=>({elem:e,index:t})),(e,{elem:r,index:i})=>a(t,[e,r,i],o,n),r)):Array.isArray(e)?0===e.length?r:Te(e.map((e,t)=>({elem:e,index:t})),(e,{elem:r,index:i})=>a(t,[e,r,i],o,n),r):0===Object.keys(e).length?r:Te(Object.entries(e),(e,[r,i])=>a(t,[e,i,r],o,n),r)),arity:ae(3),docs:{category:"collection",returns:{type:"any"},args:{coll:{type:"collection"},fun:{type:"function",description:"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:{type:"any",description:"The initial value to use as the accumulator."}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Runs $fun function on each element of the $coll, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.",seeAlso:["reduce","collection.reducei-right","collection.reductionsi"],examples:["let cu = import(collection); cu.reducei([1, 2, 3], (acc, x, i) -> acc + x + i, 0)",'let cu = import(collection); cu.reducei("Albert", (acc, x, i) -> acc ++ x ++ i, "")','let cu = import(collection); cu.reducei({ a: 1, b: 2 }, -> $1 ++ $3, "")']}},"reduce-right":{evaluate:([e,t,r],n,o,{executeFunction:a})=>(W(e,n),L(t,n),C(r,n),"string"==typeof e?0===e.length?r:Te(Array.from(e.split("")).reverse(),(e,r)=>a(t,[e,r],o,n),r):Array.isArray(e)?0===e.length?r:Te(Array.from(e).reverse(),(e,r)=>a(t,[e,r],o,n),r):0===Object.keys(e).length?r:Te(Object.entries(e).reverse(),(e,[,r])=>a(t,[e,r],o,n),r)),arity:ae(3),docs:{category:"collection",returns:{type:"any"},args:{fun:{type:"function"},coll:{type:"collection"},initial:{type:"any"}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Runs $fun function on each element of the $coll (starting from the last item), passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value.",seeAlso:["reduce","collection.reducei-right"],examples:['let cu = import(collection); cu.reduce-right(["A", "B", "C"], str, "")',"let cu = import(collection); cu.reduce-right({ a: 1, b: 2 }, +, 0)"]}},"reducei-right":{evaluate:([e,t,r],n,o,{executeFunction:a})=>(W(e,n),L(t,n),C(r,n),"string"==typeof e?0===e.length?r:Te(Array.from(e.split("")).reverse().map((e,t,r)=>({elem:e,index:r.length-1-t})),(e,{elem:r,index:i})=>a(t,[e,r,i],o,n),r):Array.isArray(e)?0===e.length?r:Te(Array.from(e).reverse().map((e,t,r)=>({elem:e,index:r.length-1-t})),(e,{elem:r,index:i})=>a(t,[e,r,i],o,n),r):0===Object.keys(e).length?r:Te(Object.entries(e).reverse(),(e,[r,i])=>a(t,[e,i,r],o,n),r)),arity:ae(3),docs:{category:"collection",returns:{type:"any"},args:{coll:{type:"collection"},fun:{type:"function",description:"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:{type:"any",description:"The initial value to use as the accumulator."}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Runs $fun function on each element of the $coll (starting from the last item), passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.",seeAlso:["collection.reducei","collection.reduce-right"],examples:["let cu = import(collection); cu.reducei-right([1, 2, 3], (acc, x, i) -> acc + x + i, 0)",'let cu = import(collection); cu.reducei-right("Albert", (acc, x, i) -> acc ++ x ++ i, "")','let cu = import(collection); cu.reducei-right({ a: 1, b: 2 }, -> $1 ++ $3, "")']}},reductions:{evaluate:([e,t,r],n,o,{executeFunction:a})=>{W(e,n),L(t,n),C(r,n),C(r,n);const i="string"==typeof e?(K(r,n),0===e.length?[]:e.split("")):Array.isArray(e)?0===e.length?[]:Array.from(e):0===Object.keys(e).length?[]:Object.entries(e).map(([,e])=>e);if(0===i.length)return[r];const s=[r];return Ae(Te(i,(e,r)=>Ae(a(t,[e,r],o,n),e=>(s.push(e),e)),r),()=>s)},arity:ae(3),docs:{category:"collection",returns:{type:"any",array:!0},args:{fun:{type:"function"},coll:{type:"collection"},initial:{type:"any"}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Returns an array of the intermediate values of the reduction (see `reduce`) of $coll by $fun.",seeAlso:["reduce","collection.reductionsi"],examples:["let cu = import(collection); cu.reductions([1, 2, 3], +, 0)","let cu = import(collection); cu.reductions([1, 2, 3], +, 10)","let cu = import(collection); cu.reductions([], +, 0)","let cu = import(collection); cu.reductions({ a: 1, b: 2 }, +, 0)","\nlet cu = import(collection);\ncu.reductions(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + (even?(value) ? value : 0),\n 0\n)"]}},reductionsi:{evaluate:([e,t,r],n,o,{executeFunction:a})=>{W(e,n),L(t,n),C(r,n),C(r,n);const i=(e,t)=>({elem:e,key:t}),s="string"==typeof e?(K(r,n),0===e.length?[]:e.split("").map((e,t)=>i(e,t))):Array.isArray(e)?0===e.length?[]:e.map((e,t)=>i(e,t)):0===Object.keys(e).length?[]:Object.entries(e).map(([e,t])=>i(t,e));if(0===s.length)return[r];const c=[r];return Ae(Te(s,(e,{elem:r,key:i})=>Ae(a(t,[e,r,i],o,n),e=>(c.push(e),e)),r),()=>c)},arity:ae(3),docs:{category:"collection",returns:{type:"any",array:!0},args:{coll:{type:"collection"},fun:{type:"function",description:"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:{type:"any",description:"The initial value to use as the accumulator."}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Returns an array of the intermediate values of the reduction (see `reduce`) of $coll by $fun. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.",seeAlso:["collection.reductions","collection.reducei"],examples:["let cu = import(collection); cu.reductionsi([1, 2, 3], (acc, x, i) -> acc + x + i, 0)",'let cu = import(collection); cu.reductionsi("Albert", (acc, x, i) -> acc ++ x ++ i, "")','let cu = import(collection); cu.reductionsi({ a: 1, b: 2 }, -> $1 ++ $3, "")']}},"not-empty":{evaluate:([e],t)=>null===e?null:(W(e,t),"string"==typeof e||Array.isArray(e)?e.length>0?e:null:Object.keys(e).length>0?e:null),arity:ae(1),docs:{category:"collection",returns:{type:"boolean"},args:{coll:{type:["collection","null"]}},variants:[{argumentNames:["coll"]}],description:"Returns `null` if $coll is empty or `null`, otherwise $coll.",seeAlso:["empty?","not-empty?"],examples:["let cu = import(collection); cu.not-empty([])","let cu = import(collection); cu.not-empty([1, 2, 3])","let cu = import(collection); cu.not-empty({})","let cu = import(collection); cu.not-empty({ a: 2 })",'let cu = import(collection); cu.not-empty("")','let cu = import(collection); cu.not-empty("Albert")',"let cu = import(collection); cu.not-empty(null)"]}},"every?":{evaluate:([e,t],r,n,{executeFunction:o})=>{W(e,r),L(t,r);return Pe(Array.isArray(e)?e:"string"==typeof e?e.split(""):Object.entries(e),e=>o(t,[e],n,r))},arity:ae(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:"collection"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns `true` if all entries in $a pass the test implemented by $b, otherwise returns `false`.",seeAlso:["collection.any?","collection.not-every?","collection.not-any?","functional.every-pred","grid.cell-every?"],examples:["let cu = import(collection); cu.every?([1, 2, 3], number?)","let cu = import(collection); cu.every?([1, 2, 3], even?)",'\nlet cu = import(collection);\ncu.every?(\n ["Albert", "Mojir", 160, [1, 2]],\n string?,\n)',"\nlet cu = import(collection);\ncu.every?(\n [50, 100, 150, 200],\n -> $ > 10,\n)","let cu = import(collection); cu.every?([], number?)",'let cu = import(collection); cu.every?("", number?)',"let cu = import(collection); cu.every?({}, number?)","\nlet cu = import(collection);\ncu.every?(\n { a: 2, b: 4},\n -> even?(second($))\n)","\nlet cu = import(collection);\ncu.every?(\n { a: 2, b: 3 },\n -> even?(second($))\n)"]}},"any?":{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),W(e,r);return Me(Array.isArray(e)?e:"string"==typeof e?e.split(""):Object.entries(e),e=>o(t,[e],n,r))},arity:ae(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:"collection"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns `true` if any element in $a pass the test implemented by $b, otherwise returns `false`.",seeAlso:["collection.every?","collection.not-any?","collection.not-every?","functional.some-pred","some","grid.some?"],examples:['\nlet cu = import(collection);\ncu.any?(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nlet cu = import(collection);\ncu.any?(\n [50, 100, 150, 200],\n x -> x > 10\n)","let cu = import(collection); cu.any?([], number?)",'let cu = import(collection); cu.any?("", number?)',"let cu = import(collection); cu.any?({}, number?)","\nlet cu = import(collection);\ncu.any?(\n { a: 2, b: 3 },\n -> even?(second($))\n)","\nlet cu = import(collection);\ncu.any?(\n { a: 1, b: 3 },\n -> even?(second($))\n)"]}},"not-any?":{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),W(e,r);return Ae(Me(Array.isArray(e)?e:"string"==typeof e?e.split(""):Object.entries(e),e=>o(t,[e],n,r)),e=>!e)},arity:ae(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:"collection"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns `false` if any element in $a pass the test implemented by $b, otherwise returns `true`.",seeAlso:["collection.any?","collection.every?","collection.not-every?"],examples:['\nlet cu = import(collection);\ncu.not-any?(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nlet cu = import(collection);\ncu.not-any?(\n [50, 100, 150, 200],\n x -> x > 10\n)","let cu = import(collection); cu.not-any?([], number?)",'let cu = import(collection); cu.not-any?("", number?)',"let cu = import(collection); cu.not-any?({}, number?)","\nlet cu = import(collection);\ncu.not-any?(\n { a: 2, b: 3 },\n -> even?(second($))\n)","\nlet cu = import(collection);\ncu.not-any?(\n { a: 1, b: 3 },\n -> even?(second($))\n)"]}},"not-every?":{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),W(e,r);return Ae(Pe(Array.isArray(e)?e:"string"==typeof e?e.split(""):Object.entries(e),e=>o(t,[e],n,r)),e=>!e)},arity:ae(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:"collection"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns `true` if at least one element in $a does not pass the test implemented by $b, otherwise returns `false`.",seeAlso:["collection.every?","collection.any?","collection.not-any?"],examples:['\nlet cu = import(collection);\ncu.not-every?(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nlet cu = import(collection);\ncu.not-every?(\n [50, 100, 150, 200],\n x -> x > 10\n)","let cu = import(collection); cu.not-every?([], number?)",'let cu = import(collection); cu.not-every?("", number?)',"let cu = import(collection); cu.not-every?({}, number?)","\nlet cu = import(collection);\ncu.not-every?(\n { a: 2, b: 4 },\n -> even?(second($))\n)","\nlet cu = import(collection);\ncu.not-every?(\n { a: 2, b: 3 },\n -> even?(second($))\n)"]}}},Aa={name:"collection",functions:qa},Na={position:{evaluate:([e,t],r,n,{executeFunction:o})=>{if(L(t,r),null===e)return null;I(e,r);return Ae(Fe("string"==typeof e?e.split(""):e,e=>o(t,[e],n,r)),e=>-1!==e?e:null)},arity:ae(2),docs:{category:"sequence",returns:{type:["number","null"]},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:["sequence","null"]},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns the index of the first elements that passes the test implemented by $fun. If no element was found, `null` is returned.",seeAlso:["index-of","some","find"],examples:['\nlet su = import(sequence);\nsu.position(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nlet su = import(sequence);\nsu.position(\n [5, 10, 15, 20],\n -> $ > 10\n)","\nlet su = import(sequence);\nsu.position(\n [5, 10, 15, 20],\n -> $ > 100\n)","\nlet su = import(sequence);\nsu.position(\n null,\n -> $ > 100\n)"]}},"last-index-of":{evaluate:([e,t],r)=>{if(C(t,r),null===e)return null;if(I(e,r),"string"==typeof e){K(t,r);const n=e.lastIndexOf(t);return-1!==n?n:null}{const n=e.findLastIndex(e=>me(M(e,r),t),r);return-1!==n?n:null}},arity:ae(2),docs:{category:"sequence",returns:{type:["number","null"]},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:["sequence","null"]},x:{type:"any"}},variants:[{argumentNames:["seq","x"]}],description:"Returns the last index of $x in $seq. If element is not present in $seq `null` is returned.",seeAlso:["index-of"],examples:["let su = import(sequence); su.last-index-of([[1], [2], [1], [2]], [1])",'let su = import(sequence); su.last-index-of(["Albert", "Mojir", 160, [1, 2]], "Mojir")',"let su = import(sequence); su.last-index-of([5, 10, 15, 20, 15], 15)","let su = import(sequence); su.last-index-of([5, 10, 15, 20], 1)","let su = import(sequence); su.last-index-of(null, 1)"]}},splice:{evaluate:(e,t)=>{const[r,n,o,...a]=e;I(r,t),ee(n,t,{integer:!0}),ee(o,t,{integer:!0,nonNegative:!0});const i=n<0?r.length+n:n;return Array.isArray(r)?[...r.slice(0,i),...a,...r.slice(i+o)]:(a.forEach(e=>K(e,t)),`${r.substring(0,i)}${a.join("")}${r.substring(i+o)}`)},arity:{min:3},docs:{category:"sequence",returns:{type:"sequence"},args:{seq:{type:"sequence",rest:!0},start:{type:"integer"},deleteCount:{type:"integer"},items:{type:"any",rest:!0}},variants:[{argumentNames:["seq","start","deleteCount"]},{argumentNames:["seq","start","deleteCount","items"]}],description:"Returns a a spliced array. Removes $deleteCount elements from $seq starting at $start and replaces them with $items. If $start is negative, it is counting from the end of the array.",seeAlso:["slice","sequence.remove-at"],examples:['let su = import(sequence); su.splice([1, 2, 3, 4, 5], 2, 2, "x")','let su = import(sequence); su.splice([1, 2, 3, 4, 5], -2, 1, "x")','let su = import(sequence); su.splice("Albert", 2, 2, "fo")']}},"sort-by":{evaluate:(e,t,r,{executeFunction:n})=>{const[o,a]=e,i=2===e.length;I(o,t),L(a,t);const s=i?null:e[2],c="string"==typeof o,l=c?o.split(""):[...o];return Ae(Ne(l,e=>n(a,[e],r,t)),e=>{if(i){const r=l.map((t,r)=>({elem:t,key:e[r]}));r.sort((e,r)=>(X(e.key,t),X(r.key,t),le(e.key,r.key,t)));const n=r.map(e=>e.elem);return c?n.join(""):n}{L(s,t);const o=l.map((t,r)=>({elem:t,key:e[r]}));o.sort((e,o)=>{const a=n(s,[e.key,o.key],r,t);if(a instanceof Promise)throw new TypeError("Async functions cannot be used as sort-by comparators");return ee(a,t,{finite:!0}),a});const a=o.map(e=>e.elem);return c?a.join(""):a}})},arity:{min:2,max:3},docs:{category:"sequence",returns:{type:"any",rest:!0},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},keyfn:{type:"function"},comparer:{type:"function"}},variants:[{argumentNames:["seq","keyfn"]},{argumentNames:["seq","keyfn","comparer"]}],description:"Returns a sorted sequence of the items in $seq, where the sort order is determined by comparing `(keyfn item)`. If no $comparer is supplied, uses builtin `compare`.",seeAlso:["sort","compare"],examples:['let su = import(sequence); su.sort-by(["Albert", "Mojir", "Nina"], count)','let su = import(sequence); su.sort-by(["Albert", "Mojir", "Nina"], count)','let su = import(sequence); su.sort-by("Albert", lower-case, -> $2 compare $1)']}},unshift:{evaluate:([e,...t],r)=>{if(I(e,r),"string"==typeof e)return qe(t,r),[...t,e].join("");const n=[...e];return n.unshift(...t),n},arity:{min:2},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:"sequence"},values:{type:"any",rest:!0}},variants:[{argumentNames:["seq","values"]}],description:"Returns copy of $seq with $values added to the beginning.",seeAlso:["push","++"],examples:["let su = import(sequence); su.unshift([1, 2, 3], 4)","let su = import(sequence); su.unshift([1, 2, 3], 4)","let su = import(sequence); su.unshift([1, 2, 3], 4, 5, 6)","\nlet su = import(sequence);\nlet l = [1, 2, 3];\nsu.unshift(l, 4);\nl"]}},distinct:{evaluate:([e],t)=>{if(I(e,t),Array.isArray(e)){const r=[];for(const n of e)C(n,t),r.some(e=>me(e,n,t))||r.push(n);return r}return Array.from(new Set(e.split(""))).join("")},arity:ae(1),docs:{category:"sequence",returns:{type:"sequence"},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"Returns a copy of $seq with no duplicates.",seeAlso:["sequence.frequencies"],examples:["let su = import(sequence); su.distinct([[1], [2], [3], [1], [3], [5]])","let su = import(sequence); su.distinct([1, 2, 3, 1, 3, 5])",'let su = import(sequence); su.distinct("Albert Mojir")',"let su = import(sequence); su.distinct([])",'let su = import(sequence); su.distinct("")']}},remove:{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),I(e,r);return Ae(Ie(Array.isArray(e)?e:e.split(""),e=>Ae(o(t,[e],n,r),e=>!e)),t=>"string"==typeof e?t.join(""):t)},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns a new sequence of items in $seq for witch `pred(item)` returns a falsy value.",seeAlso:["filter","sequence.remove-at"],examples:["let su = import(sequence); su.remove([1, 2, 3, 1, 3, 5], odd?)","let su = import(sequence); su.remove([1, 2, 3, 1, 3, 5], even?)",'let su = import(sequence); su.remove("Albert Mojir", -> "aoueiyAOUEIY" contains? $)']}},"remove-at":{evaluate:([e,t],r)=>{ee(t,r,{integer:!0}),I(e,r);const n=t<0?e.length+t:t;return n<0||n>=e.length?e:Array.isArray(e)?e.filter((e,t)=>t!==n):`${e.substring(0,n)}${e.substring(n+1)}`},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence"},n:{type:"number"}},variants:[{argumentNames:["seq","n"]}],description:"Returns a new sequence of all items in $seq except item at position $n. If $n is negative, it is counting from the end of the sequence.",seeAlso:["sequence.remove","sequence.splice"],examples:["let su = import(sequence); su.remove-at([1, 2, 3, 1, 3, 5], 2)",'let su = import(sequence); su.remove-at("Albert", -2)',"let su = import(sequence); su.remove-at([1, 2, 3, 1, 3, 5], 0)","let su = import(sequence); su.remove-at([1, 2, 3, 1, 3, 5], -1)",'let su = import(sequence); su.remove-at("Albert Mojir", 6)']}},"split-at":{evaluate:([e,t],r)=>{ee(t,r,{integer:!0}),I(e,r);const n=t<0?e.length+t:t;return[e.slice(0,n),e.slice(n)]},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence"},n:{type:"number"}},variants:[{argumentNames:["seq","n"]}],description:"Returns a pair of sequence `[take(pos input), drop(pos input)]`.",seeAlso:["sequence.split-with","take","drop"],examples:["let su = import(sequence); su.split-at([1, 2, 3, 4, 5], 2)",'let su = import(sequence); su.split-at("Albert", -2)',"let su = import(sequence); su.split-at([1, 2, 3, 4, 5], -2)",'let su = import(sequence); su.split-at("Albert", 2)']}},"split-with":{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),I(e,r);const a=Array.isArray(e);return Ae(Fe(a?e:e.split(""),e=>Ae(o(t,[e],n,r),e=>!e)),t=>-1===t?[e,a?[]:""]:[e.slice(0,t),e.slice(t)])},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns a pair of sequences `[take-while(input, fun), drop-while(input, fun)]`.",seeAlso:["sequence.split-at","take-while","drop-while"],examples:["let su = import(sequence); su.split-with([1, 2, 3, 4, 5], odd?)","let su = import(sequence); su.split-with([1, 2, 3, 4, 5], -> $ > 3)",'let su = import(sequence); su.split-with("Albert", -> $ <= "o")']}},frequencies:{evaluate:([e],t)=>{I(e,t);return("string"==typeof e?e.split(""):e).reduce((e,r)=>(K(r,t),ce(e,r)?e[r]=e[r]+1:e[r]=1,e),{})},arity:ae(1),docs:{category:"sequence",returns:{type:"object"},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"Returns an object from distinct items in $seq to the number of times they appear. Note that all items in $seq must be valid object keys i.e. strings.",seeAlso:["sequence.group-by","sequence.distinct","vector.count-values"],examples:['let su = import(sequence); su.frequencies(["Albert", "Mojir", "Nina", "Mojir"])','let su = import(sequence); su.frequencies("Pneumonoultramicroscopicsilicovolcanoconiosis")']}},"group-by":{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),I(e,r);return Te(Array.isArray(e)?e:e.split(""),(e,a)=>Ae(o(t,[a],n,r),t=>(K(t,r),ce(e,t)||(e[t]=[]),e[t].push(a),e)),{})},arity:ae(2),docs:{category:"sequence",returns:{type:"object"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns an object of the elements of $seq keyed by the result of $fun on each element. The value at each key will be an array of the corresponding elements.",seeAlso:["sequence.frequencies","sequence.partition-by"],examples:['let su = import(sequence); su.group-by([{ name: "Albert" }, { name: "Albert" }, { name: "Mojir" }], "name")','let su = import(sequence); su.group-by([{name: "Albert"}, {name: "Albert"}, {name: "Mojir"}], "name")','let su = import(sequence); su.group-by("Albert Mojir", -> "aoueiAOUEI" contains? $ ? "vowel" : "other")']}},partition:{evaluate:(e,t)=>{const r=R(e[0],t),n=ue(te(e[1],t)),o=e.length>=3?ue(te(e[2],t)):n,a=4===e.length?null===e[3]?[]:function(e,t){return we(e,t),e}(e[3],t):void 0;return $a(n,o,r,a,t)},arity:{min:2,max:4},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"number"},seq:{type:"sequence"},n:{type:"number"},step:{type:"number"},pad:{type:"array"}},variants:[{argumentNames:["seq","n"]},{argumentNames:["seq","n","step"]},{argumentNames:["seq","n","step","pad"]}],description:"Returns an array of sequences of $n items each, at offsets $step apart. If $step is not supplied, defaults to $n. If a $pad array is supplied, use its elements as necessary to complete last partition upto $n items. In case there are not enough padding elements, return a partition with less than $n items.",seeAlso:["sequence.partition-all","sequence.partition-by"],examples:["let su = import(sequence); su.partition(range(20), 4)","let su = import(sequence); su.partition(range(20), 4)","let su = import(sequence); su.partition(range(22), 4)","let su = import(sequence); su.partition(range(20), 4, 6)","let su = import(sequence); su.partition(range(20), 4, 3)",'let su = import(sequence); su.partition(range(20), 3, 6, ["a"])','let su = import(sequence); su.partition(range(20), 4, 6, ["a"])','let su = import(sequence); su.partition(range(20), 4, 6, ["a", "b", "c", "d"])','let su = import(sequence); su.partition(["a", "b", "c", "d", "e", "f"], 3, 1)',"let su = import(sequence); su.partition([1, 2, 3, 4], 10)","let su = import(sequence); su.partition([1, 2, 3, 4], 10, 10)","let su = import(sequence); su.partition([1, 2, 3, 4], 10, 10, [])","let su = import(sequence); su.partition([1, 2, 3, 4], 10, 10, null)",'let su = import(sequence); su.partition("superfragilistic", 5)','let su = import(sequence); su.partition("superfragilistic", 5, 5, null)',"let su = import(sequence); let foo = [5, 6, 7, 8]; su.partition(foo, 2, 1, foo)"]}},"partition-all":{evaluate:(e,t)=>{const r=R(e[0],t),n=ue(te(e[1],t));return $a(n,3===e.length?ue(te(e[2],t)):n,r,[],t)},arity:{min:2,max:3},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"number"},seq:{type:"sequence"},n:{type:"number"},step:{type:"number"}},variants:[{argumentNames:["seq","n"]},{argumentNames:["seq","n","step"]}],description:"Returns an array of sequences like partition, but may include partitions with fewer than n items at the end.",seeAlso:["sequence.partition","sequence.partition-by"],examples:["let su = import(sequence); su.partition-all([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 4)","let su = import(sequence); su.partition-all([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 4)","let su = import(sequence); su.partition([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 4)","let su = import(sequence); su.partition-all([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 2, 4)"]}},"partition-by":{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),I(e,r);const a="string"==typeof e;return Ae(Te(a?e.split(""):e,(e,a)=>Ae(o(t,[a],n,r),t=>(t!==e.oldValue&&(e.result.push([]),e.oldValue=t),e.result[e.result.length-1].push(a),e)),{result:[],oldValue:void 0}),({result:e})=>a?e.map(e=>e.join("")):e)},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Applies $fun to each value in $seq, splitting it each time $fun returns a new value. Returns an array of sequences.",seeAlso:["sequence.partition","sequence.partition-all","sequence.group-by"],examples:["let su = import(sequence); su.partition-by([1, 2, 3, 4, 5], odd?)","let su = import(sequence); su.partition-by([1, 2, 3, 4, 5], -> $ == 3)","let su = import(sequence); su.partition-by([1, 1, 1, 2, 2, 3, 3], odd?)",'let su = import(sequence); su.partition-by("Leeeeeerrroyyy", identity)']}},"ends-with?":{evaluate:([e,t],r)=>(I(e,r),"string"==typeof e?(K(t,r),e.endsWith(t)):me(M(e.at(-1),r),M(t,r),r)),arity:ae(2),docs:{category:"sequence",returns:{type:"boolean"},args:{a:{type:"sequence"},b:{type:"sequence"},seq:{type:"sequence"},suffix:{type:"sequence"}},variants:[{argumentNames:["seq","suffix"]}],description:"Returns `true` if $seq ends with $suffix, otherwise `false`.",seeAlso:["sequence.starts-with?"],examples:["let su = import(sequence); su.ends-with?([[1], [2], [3], [4], [5]], [5])","let su = import(sequence); su.ends-with?([[1], [2], [3], [4], [5]], 5)","let su = import(sequence); su.ends-with?([1, 2, 3, 4, 5], 5)","let su = import(sequence); su.ends-with?([1, 2, 3, 4, 5], [5])",'let su = import(sequence); su.ends-with?("Albert", "rt")','let su = import(sequence); su.ends-with?("Albert", "RT")']}},"starts-with?":{evaluate:([e,t],r)=>(I(e,r),"string"==typeof e?(K(t,r),e.startsWith(t)):me(M(e[0],r),M(t,r),r)),arity:ae(2),docs:{category:"sequence",returns:{type:"boolean"},args:{a:{type:"sequence"},b:{type:"sequence"},seq:{type:"sequence"},prefix:{type:"sequence"}},variants:[{argumentNames:["seq","prefix"]}],description:"Returns `true` if $seq starts with $prefix, otherwise `false`.",seeAlso:["sequence.ends-with?"],examples:["let su = import(sequence); su.starts-with?([[1], [2], [3], [4], [5]], [1])","let su = import(sequence); su.starts-with?([1, 2, 3, 4, 5], 1)","let su = import(sequence); su.starts-with?([1, 2, 3, 4, 5], [1])",'let su = import(sequence); su.starts-with?("Albert", "Al")','let su = import(sequence); su.starts-with?("Albert", "al")']}},interleave:{evaluate:([...e],t)=>{const r="string"==typeof e[0],n=r?e.map(e=>(K(e,t),e.split(""))):e.map(e=>(we(e,t),e)),o=Math.min(...n.map(e=>e.length)),a=[];for(let e=0;e<o;e+=1)for(const t of n)e<t.length&&a.push(t[e]);return r?a.join(""):a},arity:{min:1},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"sequence"},seqs:{type:"sequence",rest:!0}},variants:[{argumentNames:["seqs"]}],description:"Returns a sequence of the first item from each of the $seqs, then the second item from each of the $seqs, until all items from the shortest seq are exhausted.",seeAlso:["sequence.interpose","zipmap"],examples:["let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6])",'let su = import(sequence); su.interleave("Albert", ".,.,.,")',"let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6])","let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [7, 8, 9])","let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [7, 8])","let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [7])","let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [])","let su = import(sequence); su.interleave([1, 2, 3], [])","let su = import(sequence); su.interleave([])"]}},interpose:{evaluate:([e,t],r)=>{if(I(e,r),"string"==typeof e)return K(t,r),e.split("").join(t);if(0===e.length)return[];const n=[];for(let r=0;r<e.length-1;r+=1)n.push(e[r],t);return n.push(e[e.length-1]),n},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:"sequence"},separator:{type:"any"}},variants:[{argumentNames:["seq","separator"]}],description:"Returns a sequence of the elements of $seq separated by $separator. If $seq is a string, the separator must be a string.",seeAlso:["sequence.interleave","join"],examples:['let su = import(sequence); su.interpose("Albert", "-")','let su = import(sequence); su.interpose([1, 2, 3, 4, 5], "a")','let su = import(sequence); su.interpose(["Albert", "Mojir", "Nina"], ", ")','let su = import(sequence); su.interpose("Albert", ".")']}}};function $a(e,t,r,n,o){ee(t,o,{positive:!0});const a="string"==typeof r,i=[];let s=0;e:for(;s<r.length;){const o=[];for(let a=s;a<s+e;a+=1)if(a>=r.length){const e=a-r.length;if(!n){s+=t;continue e}if(e>=n.length)break;o.push(n[e])}else o.push(r[a]);i.push(o),s+=t}return a?i.map(e=>e.join("")):i}const Ta={name:"sequence",functions:Na};function za(e){return([t],n)=>{const[o,a]=function(e,t){if(Xe(e))return["vector",e];if(ot(e))return["matrix",e];if(!Q(e))throw new r("Invalid parameter type: "+typeof e,t);return["number",e]}(t,n);return"number"===o?e(a):"vector"===o?a.map(t=>e(t)):a.map(t=>t.map(t=>e(t)))}}const Sa={name:"math",functions:{sin:{evaluate:za(e=>Math.sin(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `sin` function computes the sine of an angle (in radians), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the sine of each element while preserving the original structure.",seeAlso:["math.asin","math.sinh","math.cos","math.tan","math.to-rad"],examples:["let { sin } = import(math);\nsin(0)","let { sin } = import(math);\nsin(1)","let { sin } = import(math);\nsin(PI)","let { sin } = import(math);\nsin(-0.5)","let { sin } = import(math);\nsin([1, 2, 3])","let { sin } = import(math);\nsin([[1, 2], [3, 4]])"]}},asin:{evaluate:za(e=>Math.asin(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `asin` function computes the arcsine (inverse sine) of a `number` in radians, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the arcsine of each element while preserving the original structure.",seeAlso:["math.sin","math.asinh","math.acos","math.atan"],examples:["let { asin } = import(math);\nasin(0)","let { asin } = import(math);\nasin(1)","let { asin } = import(math);\nasin(-0.5)","let { asin } = import(math);\nasin([1, 2, 3])","let { asin } = import(math);\nasin([[1, 2], [3, 4]])"]}},sinh:{evaluate:za(e=>Math.sinh(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `sinh` function computes the hyperbolic sine of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the hyperbolic sine of each element while preserving the original structure.",seeAlso:["math.asinh","math.sin","math.cosh","math.tanh"],examples:["let { sinh } = import(math);\nsinh(0)","let { sinh } = import(math);\nsinh(1)","let { sinh } = import(math);\nsinh(-0.5)","let { sinh } = import(math);\nsinh([0.1, 0.2, 0.3])","let { sinh } = import(math);\nsinh([[0.1, 0.2], [0.3, 0.4]])"]}},asinh:{evaluate:za(e=>Math.asinh(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `asinh` function computes the inverse hyperbolic sine of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the inverse hyperbolic sine of each element while preserving the original structure.",seeAlso:["math.sinh","math.asin","math.acosh","math.atanh"],examples:["let { asinh } = import(math);\nasinh(10)","let { asinh } = import(math);\nasinh(90)","let { asinh } = import(math);\nasinh(50)","let { asinh } = import(math);\nasinh([10, 20, 30])","let { asinh } = import(math);\nasinh([[10, 20], [30, 40]])"]}},cos:{evaluate:za(e=>Math.cos(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `cos` function computes the cosine of an angle (in radians), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the cosine of each element while preserving the original structure.",seeAlso:["math.acos","math.cosh","math.sin","math.tan","math.to-rad"],examples:["let { cos } = import(math);\ncos(0)","let { cos } = import(math);\ncos(1)","let { cos } = import(math);\ncos(PI)","let { cos } = import(math);\ncos(-0.5)","let { cos } = import(math);\ncos([1, 2, 3])","let { cos } = import(math);\ncos([[1, 2], [3, 4]])"]}},acos:{evaluate:za(e=>Math.acos(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `acos` function computes the arccosine (inverse cosine) of a `number` in radians, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the arccosine of each element while preserving the original structure.",seeAlso:["math.cos","math.acosh","math.asin","math.atan"],examples:["let { acos } = import(math);\nacos(0)","let { acos } = import(math);\nacos(1)","let { acos } = import(math);\nacos(-0.5)","let { acos } = import(math);\nacos([0.1, 0.2, 0.3])","let { acos } = import(math);\nacos([[0.1, 0.2], [0.3, 0.4]])"]}},cosh:{evaluate:za(e=>Math.cosh(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `cosh` function computes the hyperbolic cosine of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the hyperbolic cosine of each element while preserving the original structure.",seeAlso:["math.acosh","math.cos","math.sinh","math.tanh"],examples:["let { cosh } = import(math);\ncosh(0)","let { cosh } = import(math);\ncosh(1)","let { cosh } = import(math);\ncosh(-0.5)","let { cosh } = import(math);\ncosh([0.1, 0.2, 0.3])","let { cosh } = import(math);\ncosh([[0.1, 0.2], [0.3, 0.4]])"]}},acosh:{evaluate:za(e=>Math.acosh(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `acosh` function computes the inverse hyperbolic cosine of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the inverse hyperbolic cosine of each element while preserving the original structure.",seeAlso:["math.cosh","math.acos","math.asinh","math.atanh"],examples:["let { acosh } = import(math);\nacosh(1)","let { acosh } = import(math);\nacosh(2)","let { acosh } = import(math);\nacosh(100)","let { acosh } = import(math);\nacosh(50)","let { acosh } = import(math);\nacosh([1, 2, 3])","let { acosh } = import(math);\nacosh([[1, 2], [3, 4]])"]}},tan:{evaluate:za(e=>Math.tan(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `tan` function computes the tangent of an angle (in radians), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the tangent of each element while preserving the original structure.",seeAlso:["math.atan","math.tanh","math.sin","math.cos","math.to-rad"],examples:["let { tan } = import(math);\ntan(0)","let { tan } = import(math);\ntan(1)","let { tan } = import(math);\ntan(PI)","let { tan } = import(math);\ntan(-0.5)","let { tan } = import(math);\ntan([1, 2, 3])","let { tan } = import(math);\ntan([[1, 2], [3, 4]])"]}},atan:{evaluate:za(e=>Math.atan(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `atan` function computes the arctangent (inverse tangent) of a `number` in radians, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the arctangent of each element while preserving the original structure.",seeAlso:["math.tan","math.atanh","math.asin","math.acos"],examples:["let { atan } = import(math);\natan(0)","let { atan } = import(math);\natan(1)","let { atan } = import(math);\natan(-0.5)","let { atan } = import(math);\natan([0.1, 0.2, 0.3])","let { atan } = import(math);\natan([[0.1, 0.2], [0.3, 0.4]])"]}},tanh:{evaluate:za(e=>Math.tanh(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `tanh` function computes the hyperbolic tangent of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the hyperbolic tangent of each element while preserving the original structure.",seeAlso:["math.atanh","math.tan","math.sinh","math.cosh"],examples:["let { tanh } = import(math);\ntanh(0)","let { tanh } = import(math);\ntanh(1)","let { tanh } = import(math);\ntanh(-0.5)","let { tanh } = import(math);\ntanh(50)"]}},atanh:{evaluate:za(e=>Math.atanh(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `atanh` function computes the inverse hyperbolic tangent of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the inverse hyperbolic tangent of each element while preserving the original structure.",seeAlso:["math.tanh","math.atan","math.asinh","math.acosh"],examples:["let { atanh } = import(math);\natanh(0)","let { atanh } = import(math);\natanh(0.9)","let { atanh } = import(math);\natanh(-0.5)","let { atanh } = import(math);\natanh([0.1, 0.2, 0.3])","let { atanh } = import(math);\natanh([[0.1, 0.2], [0.3, 0.4]])"]}},ln:{evaluate:za(e=>Math.log(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `ln` function computes the natural logarithm (base `e`) of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the natural logarithm of each element while preserving the original structure.",seeAlso:["math.log2","math.log10","^"],examples:["let { ln } = import(math);\nln(0.01)","let { ln } = import(math);\nln(2.5)","let { ln } = import(math);\nln(E)","let { ln } = import(math);\nln([1, 2, 3])","let { ln } = import(math);\nln([[1, 2], [3, 4]])"]}},log2:{evaluate:za(e=>Math.log2(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `log2` function computes the base `2` logarithm of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the base-2 logarithm of each element while preserving the original structure.",seeAlso:["math.ln","math.log10"],examples:["let { log2 } = import(math);\nlog2(0.01)","let { log2 } = import(math);\nlog2(2 ^ 12)","let { log2 } = import(math);\nlog2(2.5)","let { log2 } = import(math);\nlog2([1, 2, 3])","let { log2 } = import(math);\nlog2([[1, 2], [3, 4]])"]}},log10:{evaluate:za(e=>Math.log10(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `log10` function computes the base `10` logarithm of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the base-10 logarithm of each element while preserving the original structure.",seeAlso:["math.ln","math.log2"],examples:["let { log10 } = import(math);\nlog10(0.01)","let { log10 } = import(math);\nlog10(10 ^ 12)","let { log10 } = import(math);\nlog10(2.5)","let { log10 } = import(math);\nlog10([1, 2, 3])","let { log10 } = import(math);\nlog10([[1, 2], [3, 4]])"]}},"to-rad":{evaluate:za(e=>e*Math.PI/180),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `to-rad` function converts an angle from degrees to radians, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it converts each element while preserving the original structure.",seeAlso:["math.to-deg","math.sin","math.cos","math.tan"],examples:["let { to-rad } = import(math);\nto-rad(0)","let { to-rad } = import(math);\nto-rad(90)","let { to-rad } = import(math);\nto-rad(180)","let { to-rad } = import(math);\nto-rad(360)","let { to-rad } = import(math);\nto-rad([0, 90, 180])","let { to-rad } = import(math);\nto-rad([[0, 90], [180, 360]])"]}},"to-deg":{evaluate:za(e=>180*e/Math.PI),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `to-deg` function converts an angle from radians to degrees, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it converts each element while preserving the original structure.",seeAlso:["math.to-rad"],examples:["let { to-deg } = import(math);\nto-deg(0)","let { to-deg } = import(math);\nto-deg(PI)","let { to-deg } = import(math);\nto-deg(PI / 2)","let { to-deg } = import(math);\nto-deg(3 * PI / 2)","let { to-deg } = import(math);\nto-deg([0, PI, PI / 2])","let { to-deg } = import(math);\nto-deg([[0, PI], [PI / 2, 3 * PI / 2]])"]}}}},Ea={name:"functional",functions:{juxt:{evaluate:(e,t)=>{e.forEach(e=>L(e,t));const n=function(e){return e.reduce((e,t)=>{if(null===e)return null;const r="number"==typeof t||U(t)?ae(1):t.arity,{min:n,max:o}=r,{min:a,max:i}=e,s="number"==typeof n&&"number"==typeof a?Math.max(n,a):"number"==typeof n?n:"number"==typeof a?a:void 0,c="number"==typeof o&&"number"==typeof i?Math.min(o,i):"number"==typeof o?o:"number"==typeof i?i:void 0;return"number"==typeof s&&"number"==typeof c&&s>c?null:{min:s,max:c}},{})}(e);if(null===n)throw new r("All functions must accept the same number of arguments",t);return{[u]:!0,sourceCodeInfo:t,functionType:"Juxt",params:e,arity:n}},arity:{min:1},docs:{category:"functional",returns:{type:"function"},args:{a:{type:"function"},b:{type:"function"},fun:{type:"function"},fns:{type:"function",rest:!0}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","fns"]}],description:"Takes one or many function and returns a function that is the juxtaposition of those functions.\nThe returned function takes a variable number of args,\nand returns a vector containing the result of applying each function to the args (left-to-right).",seeAlso:["comp"],examples:["let { juxt } = import(functional);\njuxt(+, *, min, max)(\n 3,\n 4,\n 6,\n)",'let { juxt } = import(functional);\njuxt("a", "b")(\n {\n a: 1,\n b: 2,\n c: 3,\n d: 4\n }\n)',"let { juxt } = import(functional);\njuxt(+, *, min, max) apply range(1, 11)"]}},complement:{evaluate:([e],t)=>{const r=B(e,t);return{[u]:!0,sourceCodeInfo:t,functionType:"Complement",function:r,arity:re(r)}},arity:ae(1),docs:{category:"functional",returns:{type:"function"},args:{fun:{type:"function"}},variants:[{argumentNames:["fun"]}],description:"Takes a function $fun and returns a new function that takes the same arguments as f, has the same effects, if any, and returns the opposite truth value.",seeAlso:["comp","functional.every-pred","functional.some-pred"],examples:["let { complement } = import(functional);\ncomplement(>)(1, 3)","let { complement } = import(functional);\ncomplement(<)(1, 3)","let { complement } = import(functional);\ncomplement(+)(1, 3)","let { complement } = import(functional);\ncomplement(+)(0, 0)"]}},"every-pred":{evaluate:(e,t)=>({[u]:!0,sourceCodeInfo:t,functionType:"EveryPred",params:e,arity:{min:1,max:1}}),arity:{min:1},docs:{category:"functional",returns:{type:"function"},args:{fun:{type:"function"},fns:{type:"function",rest:!0}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","fns"]}],description:"\nTakes a number of predicates and returns a function that returns `true` if all predicates\nreturn a truthy value against all of its arguments, else it returns `false`.",seeAlso:["functional.some-pred","functional.complement","collection.every?"],examples:['let { every-pred } = import(functional);\nevery-pred(string?, -> count($) > 3)(\n "Albert",\n "Mojir"\n)','let { every-pred } = import(functional);\n(string? every-pred -> count($) > 3)(\n "Albert",\n "M"\n)'],hideOperatorForm:!0}},"some-pred":{evaluate:(e,t)=>({[u]:!0,sourceCodeInfo:t,functionType:"SomePred",params:e,arity:{min:1,max:1}}),arity:{min:1},docs:{category:"functional",returns:{type:"function"},args:{fun:{type:"function"},fns:{type:"function",rest:!0}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","fns"]}],description:"Takes a number of `predicates` and returns a function that returns `true` if at least one of the `predicates` return a truthy `true` value against at least one of its arguments, else it returns `false`.",seeAlso:["functional.every-pred","functional.complement","collection.any?"],examples:['let { some-pred } = import(functional);\nsome-pred(string?, -> count($) > 3)("Albert", "Mojir")','let { some-pred } = import(functional);\nsome-pred(string?, -> count($) > 3)("a", "M")','let { some-pred } = import(functional);\nsome-pred(string?, -> count($) > 3)("a", [1, 2, 3])',"let { some-pred } = import(functional);\nsome-pred(string?, -> count($) > 3)([1, 2, 3], [2])"],hideOperatorForm:!0}},fnull:{evaluate:([e,...t],r)=>{const n=B(e,r);return{[u]:!0,sourceCodeInfo:r,functionType:"Fnull",function:n,params:t,arity:re(n)}},arity:{min:2},docs:{category:"functional",returns:{type:"function"},args:{a:{type:"function"},b:{type:"any"},fun:{type:"function"},arg:{type:"any"},args:{type:"any",rest:!0}},variants:[{argumentNames:["fun","arg"]},{argumentNames:["fun","arg","args"]}],description:"Takes a function $fun, and returns a function that calls $fun, replacing a null argument to the corresponding argument.",seeAlso:["identity","constantly"],examples:["let { fnull } = import(functional);\nfnull(inc, 0)(1)","let { fnull } = import(functional);\nfnull(inc, 0)(null)","let { fnull } = import(functional);\n(inc fnull 0)(null)","let { fnull } = import(functional);\nfnull(+, 1, 2)(null, 0)","let { fnull } = import(functional);\nfnull(+, 1, 2)(0, null)","let { fnull } = import(functional);\nfnull(+, 1, 2)(null, null)","let { fnull } = import(functional);\nfnull(+, 1, 2)(null, null, 3, 4)"]}}}};function ja(e,t){return{a:{type:e},b:{type:t}}}const Ma={name:"bitwise",functions:{"bit-not":{evaluate:([e],t)=>(ee(e,t,{integer:!0}),~e),arity:ae(1),docs:{category:"bitwise",returns:{type:"integer"},args:{a:{type:"integer"}},variants:[{argumentNames:["a"]}],description:"Returns bitwise `not` of $a.",seeAlso:["&","|","xor","bitwise.bit-and-not"],examples:["let { bit-not } = import(bitwise);\nbit-not(0)","let { bit-not } = import(bitwise);\nbit-not(255)"]}},"bit-and-not":{evaluate:([e,...t],r)=>(ee(e,r,{integer:!0}),t.reduce((e,t)=>(ee(t,r,{integer:!0}),e&~t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...ja("integer","integer"),c:{type:"integer",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Returns bitwise `and` with complement.",seeAlso:["&","|","xor","bitwise.bit-not"],examples:["let { bit-and-not } = import(bitwise);\n0b0011 bit-and-not 0b0110","let { bit-and-not } = import(bitwise);\nbit-and-not(0b0011, 0b0110)","let { bit-and-not } = import(bitwise);\nbit-and-not(0b0011, 0b0110, 0b1001)"]}},"bit-flip":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0});return e^1<<t},arity:ae(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ja("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Flips bit number $b.",seeAlso:["bitwise.bit-set","bitwise.bit-clear","bitwise.bit-test"],examples:["let { bit-flip } = import(bitwise);\n0b0011 bit-flip 1","let { bit-flip } = import(bitwise);\nbit-flip(0b0011, 1)","let { bit-flip } = import(bitwise);\nbit-flip(0b1100, 1)"]}},"bit-set":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0});return e|1<<t},arity:ae(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ja("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Sets bit number $b.",seeAlso:["bitwise.bit-flip","bitwise.bit-clear","bitwise.bit-test"],examples:["let { bit-set } = import(bitwise);\n0b0010 bit-set 1","let { bit-set } = import(bitwise);\nbit-set(0b0011, 1)","let { bit-set } = import(bitwise);\nbit-set(0b1100, 1)"]}},"bit-clear":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0});return e&~(1<<t)},arity:ae(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ja("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Clears bit number $b.",seeAlso:["bitwise.bit-flip","bitwise.bit-set","bitwise.bit-test"],examples:["let { bit-clear } = import(bitwise);\n0b0011 bit-clear 1","let { bit-clear } = import(bitwise);\nbit-clear(0b0011, 1)","let { bit-clear } = import(bitwise);\nbit-clear(0b1100, 1)"]}},"bit-test":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0});return!!(e&1<<t)},arity:ae(2),docs:{category:"bitwise",returns:{type:"boolean"},args:{...ja("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Checks if bit number $b is set.",seeAlso:["bitwise.bit-flip","bitwise.bit-set","bitwise.bit-clear"],examples:["let { bit-test } = import(bitwise);\n0b0011 bit-test 1","let { bit-test } = import(bitwise);\nbit-test(0b0011, 1)","let { bit-test } = import(bitwise);\nbit-test(0b1100, 1)"]}}}},Ca={baseUnit:"rad",description:"angle",units:{deg:Math.PI/180,rad:1,grad:Math.PI/200,turn:2*Math.PI}};function Pa(e,t){switch(e){case"c":return t;case"f":return 9*t/5+32;case"k":return t+273.15}}function Ra(e,t){switch(e){case"c":return t;case"f":return 5*(t-32)/9;case"k":return t-273.15}}const Ia=["c","f","k"],Oa={angstrom:"ångströms",um:"micrometers",mm:"millimeters",cm:"centimeters",m:"meters",km:"kilometers",in:"inches",ft:"feet",yd:"yards",mi:"miles",nmi:"nautical miles",mg:"milligrams",g:"grams",kg:"kilograms",t:"metric tons",oz:"ounces",lb:"pounds",st:"stones",ml:"milliliters",cl:"centiliters",dl:"deciliters",l:"liters",tsp:"teaspoons",tbsp:"tablespoons","fl-oz":"fluid ounces",cup:"cups",pt:"pints",qt:"quarts",gal:"gallons",ms:"milliseconds",s:"seconds",min:"minutes",h:"hours",day:"days",week:"weeks",mm2:"square millimeters",cm2:"square centimeters",m2:"square meters",km2:"square kilometers",in2:"square inches",ft2:"square feet",yd2:"square yards",acre:"acres",hectare:"hectares","m/s":"meters per second","km/h":"kilometers per hour",mph:"miles per hour",kn:"knots","ft/s":"feet per second",b:"bytes",kb:"kilobytes",mb:"megabytes",gb:"gigabytes",tb:"terabytes",pb:"petabytes",pa:"pascals",kpa:"kilopascals",bar:"bars",atm:"atmospheres",psi:"pounds per square inch",mmhg:"millimeters of mercury",j:"joules",kj:"kilojoules",cal:"calories",kcal:"kilocalories",wh:"watt-hours",kwh:"kilowatt-hours",btu:"British thermal units",w:"watts",kw:"kilowatts",mw:"megawatts",hp:"horsepower",hz:"hertz",khz:"kilohertz",mhz:"megahertz",ghz:"gigahertz",deg:"degrees",rad:"radians",grad:"gradians",turn:"turns",c:"Celsius",f:"Fahrenheit",k:"Kelvin"};function Fa(e){const t={},r=Object.keys(e.units);for(const n of r)for(const o of r){if(n===o)continue;const a=e.units[n]/e.units[o],i=`${n}->${o}`,s=Oa[n],c=Oa[o],l=[`convert.${o}->${n}`,...r.filter(e=>e!==n&&e!==o).map(e=>`convert.${n}->${e}`)];t[i]={evaluate:([e],t)=>(ee(e,t),e*a),arity:ae(1),docs:{category:"convert",returns:{type:"number"},args:{value:{type:"number",description:`Value in ${s}`}},variants:[{argumentNames:["value"]}],description:`Converts a value from ${s} (\`${n}\`) to ${c} (\`${o}\`).`,seeAlso:l,examples:[`let { ${i} } = import(convert);\n${i}(1)`]}}}return t}const Ua={name:"convert",functions:{...Fa({baseUnit:"m",description:"length",units:{angstrom:1e-10,um:1e-6,mm:.001,cm:.01,m:1,km:1e3,in:.0254,ft:.3048,yd:.9144,mi:1609.344,nmi:1852}}),...Fa({baseUnit:"kg",description:"weight",units:{mg:1e-6,g:.001,kg:1,t:1e3,oz:.028349523125,lb:.45359237,st:6.35029318}}),...Fa({baseUnit:"l",description:"volume",units:{ml:.001,cl:.01,dl:.1,l:1,tsp:.00492892159375,tbsp:.01478676478125,"fl-oz":.0295735295625,cup:.2365882365,pt:.473176473,qt:.946352946,gal:3.785411784}}),...Fa({baseUnit:"s",description:"time",units:{ms:.001,s:1,min:60,h:3600,day:86400,week:604800}}),...Fa({baseUnit:"m2",description:"area",units:{mm2:1e-6,cm2:1e-4,m2:1,km2:1e6,in2:64516e-8,ft2:.09290304,yd2:.83612736,acre:4046.8564224,hectare:1e4}}),...Fa({baseUnit:"m/s",description:"speed",units:{"m/s":1,"km/h":1/3.6,mph:.44704,kn:.514444,"ft/s":.3048}}),...Fa({baseUnit:"b",description:"data",units:{b:1,kb:1e3,mb:1e6,gb:1e9,tb:1e12,pb:1e15}}),...Fa({baseUnit:"pa",description:"pressure",units:{pa:1,kpa:1e3,bar:1e5,atm:101325,psi:6894.757293168,mmhg:133.322387415}}),...Fa({baseUnit:"j",description:"energy",units:{j:1,kj:1e3,cal:4.184,kcal:4184,wh:3600,kwh:36e5,btu:1055.06}}),...Fa({baseUnit:"w",description:"power",units:{w:1,kw:1e3,mw:1e6,hp:745.7}}),...Fa({baseUnit:"hz",description:"frequency",units:{hz:1,khz:1e3,mhz:1e6,ghz:1e9}}),...Fa(Ca),...function(){const e={};for(const t of Ia)for(const r of Ia){if(t===r)continue;const n=`${t}->${r}`,o=Oa[t],a=Oa[r],i=[`convert.${r}->${t}`,...Ia.filter(e=>e!==t&&e!==r).map(e=>`convert.${t}->${e}`)];e[n]={evaluate:([e],n)=>{ee(e,n);const o=Ra(t,e);return Pa(r,o)},arity:ae(1),docs:{category:"convert",returns:{type:"number"},args:{value:{type:"number",description:`Value in ${o}`}},variants:[{argumentNames:["value"]}],description:`Converts a temperature from ${o} (\`${t}\`) to ${a} (\`${r}\`).`,seeAlso:i,examples:[`let { ${n} } = import(convert);\n${n}(100)`]}}}return e}()}},Da={"-type-number":{datatype:!0,title:"number",category:"datatype",description:"A `number`",examples:["42","3.14"]},"-type-string":{datatype:!0,title:"string",category:"datatype",description:"A `string`",examples:['"hello"','""']},"-type-object":{datatype:!0,title:"object",category:"datatype",description:"An `object`, a collection of key-value pairs where keys are `strings`",examples:["{}","{ a: 1, b: 2}"]},"-type-array":{datatype:!0,title:"array",category:"datatype",description:"An `array`",examples:["[]","[1, 2, 3]",'["a", null, true]']},"-type-vector":{datatype:!0,title:"vector",category:"datatype",description:"An `array` of `numbers`",examples:["[]","[1, 2, 3]"]},"-type-matrix":{datatype:!0,title:"matrix",category:"datatype",description:"A `matrix`, a two-dimensional `array` with `numbers` where each row has the same number of columns. A `matrix` is also a `grid`.",examples:["[[]]","[[1, 2], [3, 4]]","[[1, 2], [3, 4], [5, 6]]"]},"-type-grid":{datatype:!0,title:"grid",category:"datatype",description:"A `grid`, a two-dimensional `array` where each row has the same number of columns",examples:["[[]]","[[1, 2], [3, 4]]",'[["a", "b"], [3, 4], [5, 6]]']},"-type-boolean":{datatype:!0,title:"boolean",category:"datatype",description:"A `boolean`",examples:["true","false"]},"-type-function":{datatype:!0,title:"function",category:"datatype",description:"A `function`",examples:["x -> x + 1","(a, b, c) -> (a + b) * c","() -> 42","-> $1 + $2"]},"-type-integer":{datatype:!0,title:"integer",category:"datatype",description:"An `integer`",examples:["42","-42"]},"-type-any":{datatype:!0,title:"any",category:"datatype",description:"`Any` value",examples:["42",'"hello"',"true","null"]},"-type-null":{datatype:!0,title:"null",category:"datatype",description:"The value `null`",examples:["null"]},"-type-collection":{datatype:!0,title:"collection",category:"datatype",description:"A collection, an `object`, an `array` or a `string`",examples:["{ foo: 42 }","[1, 2, 3]",'"hello"']},"-type-sequence":{datatype:!0,title:"sequence",category:"datatype",description:"A sequence, an `array` or a `string`",examples:["[1, 2, 3]",'"hello"']},"-type-regexp":{datatype:!0,title:"regexp",category:"datatype",description:"A regular expression",examples:['regexp("^\\\\s*(.*)$")','#"albert"ig']},"-type-never":{datatype:!0,title:"never",category:"datatype",description:"A value that can never be created",examples:['\n// throw("error") will never return a value\ntry throw("error") catch "never" end']}},Wa={"-short-regexp":{shorthand:!0,title:'#"pattern"',category:"shorthand",description:"Shorthand for `regexp(pattern)`. Only difference is that escaping is not needed.",examples:['#"^\\s*(.*)$"','#"albert"ig'],seeAlso:["regexp","re-match","replace","replace-all"]},"-short-fn":{shorthand:!0,title:"-> expression",category:"shorthand",description:"\nShorthand for `(args, ...) -> expression`.\n`$1, $2, $3, ...` are shorthand for the first, second, third, ... argument.\n\nYou can reference the first argument using either `$1` or `$`.\nHowever, please note that `$1` and `$` are mutually exclusive and cannot be used simultaneously.\nE.g. `-> $ * $1` is not valid.",examples:["-> $1 + $2","(-> $ * $)(9)"]}};function Ga(e){const t={};for(const[r,n]of Object.entries(e)){const e=n.docs;if(!e)throw new Error(`Missing docs for expression "${r}"`);t[r]={title:r,category:e.category,description:e.description,returns:e.returns,args:e.args,variants:e.variants,examples:e.examples,...e.seeAlso?{seeAlso:e.seeAlso}:{},...e.hideOperatorForm?{noOperatorDocumentation:!0}:{}}}return t}function Va(e,t){const r={};for(const[n,o]of Object.entries(t)){const t=o.docs;if(!t)throw new Error(`Missing docs for ${e}.${n}`);const a=`${e}.${n}`;r[a]={title:a,category:t.category,description:t.description,returns:t.returns,args:t.args,variants:t.variants,examples:t.examples,...t.seeAlso?{seeAlso:t.seeAlso}:{},...t.hideOperatorForm?{noOperatorDocumentation:!0}:{}}}return r}const Ba=Ga(Z),La=Ga(se),_a=Ga(We),Ka=Ga(De),Ja=Ga(bt),Ya=Ga(ut),Ha=Ga(kt({})),Xa=Ga(gt),Za=Ga(ht),Qa=Ga(dt),ei=Ga(yt),ti=Ga(Ge),ri=Ga(ft),ni=Ga(qt);const oi=function(){const e={};for(const[t,r]of Object.entries(kr)){const n=qr[r],o=n?.docs;o&&(Or(o)?e[t]={title:t,category:o.category,description:o.description,returns:o.returns,args:o.args,variants:o.variants,examples:o.examples,...o.seeAlso?{seeAlso:o.seeAlso}:{},...o.hideOperatorForm?{noOperatorDocumentation:!0}:{}}:e[t]={title:t,category:o.category,description:o.description,customVariants:o.customVariants,...o.details?{details:o.details}:{},...o.returns?{returns:o.returns}:{},examples:o.examples,...o.seeAlso?{seeAlso:o.seeAlso}:{}})}return e}();function ai(e){return"returns"in e&&"args"in e&&"variants"in e}function ii(e){return"customVariants"in e}function si(e){return"shorthand"in e}function ci(e){return"datatype"in e}const li={...Ba,...La,...Ka,..._a,...ti,...Ya,...Ja,...Ha,...Xa,...Za,...Qa,...ei,...ri,...ni},mi={...Va(Dr.name,Dr.functions),...Va(Br.name,Br.functions),...Va(Yr.name,Yr.functions),...Va(Cn.name,Cn.functions),...Va(_n.name,_n.functions),...Va(to.name,to.functions),...Va(ha.name,ha.functions),...Va(fa.name,fa.functions),...Va(Aa.name,Aa.functions),...Va(Ta.name,Ta.functions),...Va(Sa.name,Sa.functions),...Va(Ea.name,Ea.functions),...Va(Ma.name,Ma.functions),...Va(Ua.name,Ua.functions)};Object.entries(li).forEach(([e,t])=>{if(!$t[e])throw new Error(`Missing normal expression ${e} in normalExpressions`);const r=$t[e].arity;!t.noOperatorDocumentation&&oe(r)&&(t._isOperator=!0,Pr(e)&&(t._prefereOperator=!0))}),Object.entries(oi).forEach(([e,t])=>{if(ai(t)){const r=qr[kr[e]]?.arity;r&&oe(r)&&(t._isOperator=!0)}});const ui=gi({...{...li,...oi},...Wa,...Da}),pi=gi({...ui,...mi});function gi(e){return Object.fromEntries(Object.entries(e).sort(([e,t],[r,n])=>{const o="special-expression"===t.category?"":t.category,a="special-expression"===n.category?"":n.category;return o!==a?o.localeCompare(a):e.localeCompare(r)}))}var hi;Object.values(pi).forEach(e=>{e.title=e.title.replace(/"/g,""")}),hi=li,Object.assign(At,hi);const di=(e,t,r,n)=>{const o=Array.isArray(e)?e:[[s.SpecialExpression,[kr.block,e.body]]],a=new Set;for(const e of o)yi(e,t,r,n)?.forEach(e=>a.add(e));return a};function yi(e,t,n,o){const a=e[0];switch(a){case s.UserDefinedSymbol:{const r=e;return null===t.lookUp(r)?new Set([r[1]]):null}case s.NormalBuiltinSymbol:case s.SpecialBuiltinSymbol:case s.String:case s.Number:case s.ReservedSymbol:case s.Binding:return null;case s.NormalExpression:{const r=e,a=new Set;if(Xt(r)){const[,[e]]=r;if(Kt(e)){null===t.lookUp(e)&&a.add(e[1])}}else{const[,[e]]=r;yi(e,t,n,o)?.forEach(e=>a.add(e))}for(const e of r[1][1])yi(e,t,n,o)?.forEach(e=>a.add(e));return a}case s.SpecialExpression:{const r=e,a=r[1][0];return(0,n.specialExpressions[a].getUndefinedSymbols)(r,t,{getUndefinedSymbols:di,builtin:n,evaluateNode:o})}case s.Spread:return yi(e[1],t,n,o);default:throw new r(`Unhandled node type: ${a}`,e[2])}}const vi=(1+Math.sqrt(5))/2,fi={E:Math.E,"-E":-Math.E,"ε":Math.E,"-ε":-Math.E,PI:Math.PI,"-PI":-Math.PI,"π":Math.PI,"-π":-Math.PI,PHI:vi,"-PHI":-vi,"φ":vi,"-φ":-vi,POSITIVE_INFINITY:Number.POSITIVE_INFINITY,"∞":Number.POSITIVE_INFINITY,NEGATIVE_INFINITY:Number.NEGATIVE_INFINITY,"-∞":Number.NEGATIVE_INFINITY,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,MIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,MAX_VALUE:Number.MAX_VALUE,MIN_VALUE:Number.MIN_VALUE,NaN:Number.NaN},bi={true:!0,false:!1,null:null,do:null,else:null,case:null,each:null,in:null,when:null,while:null,catch:null,function:null,as:null,then:null,end:null,_:null,...fi};const xi={NativeJsFunction:(e,t,n,o)=>{if(o.pure&&!e.nativeFn.pure)throw new r(`Cannot call impure native function '${e.name}' in pure mode`,n);try{const o=e.nativeFn.fn(...t);return o instanceof Promise?o.then(e=>pe(e),e=>{const t="string"==typeof e?e:x(e)&&"string"==typeof e.message?e.message:"<no message>";throw new r(`Native function threw: "${t}"`,n)}):pe(o)}catch(e){const t="string"==typeof e?e:x(e)&&"string"==typeof e.message?e.message:"<no message>";throw new r(`Native function threw: "${t}"`,n)}},UserDefined:(e,n,o,a,{evaluateNode:i})=>{function s(n){if(!function(e,t){const{min:r}=e;return!("number"==typeof r&&t<r)}(e.arity,n.length))throw new r(`Expected ${e.arity} arguments, got ${n.length}.`,o);const c=e.evaluatedfunction,l=c[0],m=l.filter(e=>e[0]!==Ct).length,u=a.create(e.evaluatedfunction[2]),p={self:{value:e}},g=[];let h,d;for(let e=0;e<n.length;e+=1)if(e<m){const t=e;h=Ae(h,()=>{const e=pe(n[t]);return Ae(Ut(l[t],e,e=>i(e,u.create(p))),e=>{Object.entries(e).forEach(([e,t])=>{p[e]={value:t}})})})}else g.push(pe(n[e]));for(let e=n.length;e<m;e++){const t=e;d=Ae(d,()=>{const e=l[t];return Ae(i(e[1][1],a.create(p)),t=>Ae(Ut(e,t,e=>i(e,a.create(p))),e=>{Object.entries(e).forEach(([e,t])=>{p[e]={value:t}})}))})}return Ae(h,()=>Ae(d,()=>{const e=l.find(e=>e[0]===Ct),r=void 0!==e?Ae(Ut(e,g,e=>i(e,a.create(p))),e=>{Object.entries(e).forEach(([e,t])=>{p[e]={value:t}})}):void 0;return Ae(r,()=>{const e=u.create(p),r=Te(c[1],(t,r)=>i(r,e),null);return r instanceof Promise?r.catch(e=>{if(e instanceof t)return s(e.params);throw e}):r})}))}for(;;)try{return s(n)}catch(e){if(e instanceof t){n=e.params;continue}throw e}},Partial:(e,t,n,o,{executeFunction:a})=>{const i=[...e.params];if(t.length!==e.placeholders.length)throw new r(`(partial) expects ${e.placeholders.length} arguments, got ${t.length}.`,n);const s=[...t];for(const t of e.placeholders)i.splice(t,0,s.shift());return a(e.function,i,o,n)},Comp:(e,t,n,o,{executeFunction:a})=>{const{params:i}=e;if(0===i.length){if(1!==t.length)throw new r(`(comp) expects one argument, got ${d(t.length)}.`,n);return M(t[0],n)}let s=t;for(let e=i.length-1;e>=0;e--){const t=i[e];s=Ae(s,e=>Ae(a(B(t,n),e,o,n),e=>[e]))}return Ae(s,e=>M(e[0],n))},Constantly:e=>e.value,Juxt:(e,t,r,n,{executeFunction:o})=>Ne(e.params,e=>o(B(e,r),t,n,r)),Complement:(e,t,r,n,{executeFunction:o})=>Ae(o(e.function,t,n,r),e=>!e),EveryPred:(e,t,r,n,{executeFunction:o})=>{const a=[];for(const i of e.params)for(const e of t)a.push(()=>o(B(i,r),[e],n,r));return Te(a,(e,t)=>!!e&&Ae(t(),e=>!!e),!0)},SomePred:(e,t,r,n,{executeFunction:o})=>{const a=[];for(const i of e.params)for(const e of t)a.push(()=>o(B(i,r),[e],n,r));return Te(a,(e,t)=>!!e||Ae(t(),e=>!!e),!1)},Fnull:(e,t,r,n,{executeFunction:o})=>{const a=t.map((t,r)=>null===t?pe(e.params[r]):t);return o(B(e.function,r),a,n,r)},Builtin:(e,t,n,o,{executeFunction:a})=>{const i=f(zt[e.normalBuiltinSymbolType],n);if(o.pure&&!1===i.pure)throw new r(`Cannot call impure function '${e.name}' in pure mode`,n);return i.evaluate(t,n,o,{executeFunction:a})},SpecialBuiltin:(e,t,n,o,{executeFunction:a})=>{const i=f(qr[e.specialBuiltinSymbolType],n);if(i.evaluateAsNormalExpression)return i.evaluateAsNormalExpression(t,n,o,{executeFunction:a});throw new r(`Special builtin function ${e.specialBuiltinSymbolType} is not supported as normal expression.`,n)},Module:(e,t,n,o,{executeFunction:a})=>{const i=o.getModule(e.moduleName);if(!i)throw new r(`Module '${e.moduleName}' not found.`,n);const s=i.functions[e.functionName];if(!s)throw new r(`Function '${e.functionName}' not found in module '${e.moduleName}'.`,n);if(o.pure&&!1===s.pure)throw new r(`Cannot call impure function '${e.functionName}' in pure mode`,n);return ne(s.arity,t.length,n),s.evaluate(t,n,o,{executeFunction:a})}};function wi(e,t){return Te(e.body,(e,r)=>ki(r,t),null)}function ki(e,t){switch(e[0]){case s.Number:case s.String:return function(e){return e[1]}(e);case s.NormalBuiltinSymbol:case s.SpecialBuiltinSymbol:case s.UserDefinedSymbol:return t.evaluateSymbol(e);case s.ReservedSymbol:return function(e){const t=e[1];if(!["true","false","null"].includes(t))throw new r(`Reserved symbol ${t} cannot be evaluated`,e[2]);return f(bi[t],e[2])}(e);case s.NormalExpression:{const n=function(e,t){const n=e[2];return Ae(function(e,t){const n=[],o=[],a=Se(e,(e,a)=>Zt(e)?Ae(ki(e[1],t),t=>{if(!Array.isArray(t))throw new r(`Spread operator requires an array, got ${d(e)}`,e[2]);n.push(...t)}):e[0]!==s.ReservedSymbol||"_"!==e[1]?Ae(ki(e,t),e=>{n.push(e)}):void o.push(a));return Ae(a,()=>({params:n,placeholders:o}))}(e[1][1],t),({params:o,placeholders:i})=>{if(Xt(e)){const s=e[1][0];if(i.length>0){return Ae(ki(s,t),e=>({[u]:!0,function:B(e,n),functionType:"Partial",params:o,placeholders:i,sourceCodeInfo:n,arity:ae(i.length)}))}if(Yt(s)){const n=s[1],a=Ar.allNormalExpressions[n];if(t.pure&&!1===a.pure)throw new r(`Cannot call impure function '${a.name}' in pure mode`,e[2]);return a.evaluate(o,e[2],t,{executeFunction:qi})}{const r=t.getValue(s[1]);if(void 0!==r)return qi(B(r,n),o,t,n);throw new a(s[1],e[2])}}return Ae(ki(e[1][0],t),e=>{const r=B(e,n);if(i.length>0){return{[u]:!0,function:r,functionType:"Partial",params:o,placeholders:i,sourceCodeInfo:n,arity:ae(i.length)}}return qi(r,o,t,n)})})}(e,t);return Ae(n,t=>{if("number"==typeof t&&Number.isNaN(t))throw new r("Number is NaN",e[2]);return He(t)})}case s.SpecialExpression:return Ae(function(e,t){const r=e[1][0],n=f(Ar.specialExpressions[r],e[2]);return(0,n.evaluate)(e,t,{evaluateNode:ki,builtin:Ar,getUndefinedSymbols:di})}(e,t),e=>He(e));default:throw new r(`${l(e[0])}-node cannot be evaluated`,e[2])}}function qi(e,t,n,o){if(w(e))return xi[e.functionType](e,t,o,n,{evaluateNode:ki,executeFunction:qi});if(Array.isArray(e))return function(e,t,n){if(1!==t.length)throw new r("Array as function requires one non negative integer parameter.",n);const o=t[0];return ee(o,n,{integer:!0,nonNegative:!0}),pe(e[o])}(e,t,o);if(O(e))return function(e,t,n){if(1!==t.length)throw new r("Object as function requires one string parameter.",n);const o=t[0];return K(o,n),pe(e[o])}(e,t,o);if("string"==typeof e)return function(e,t,n){if(1!==t.length)throw new r("String as function requires one Obj parameter.",n);const o=pe(t[0]);if(O(o))return pe(o[e]);if(Q(o,{integer:!0}))return pe(e[o]);throw new r(`string as function expects Obj or integer parameter, got ${d(o)}`,n)}(e,t,o);if(Q(e))return function(e,t,n){if(ee(e,n,{integer:!0}),1!==t.length)throw new r("Number as function requires one Arr parameter.",n);const o=t[0];return I(o,n),pe(o[e])}(e,t,o);throw new r("Unexpected function type",o)}class Ai{contexts;globalContext;values;nativeJsFunctions;modules;valueModules;pure;constructor({contexts:e,values:t,nativeJsFunctions:r,modules:n,valueModules:o,pure:a}){this.globalContext=f(e[0]),this.contexts=e,this.values=t,this.nativeJsFunctions=r,this.modules=n??new Map,this.valueModules=o??new Map,this.pure=a??!1}getModule(e){return this.modules.get(e)}getValueModule(e){return this.valueModules.has(e)?{value:this.valueModules.get(e),found:!0}:{value:void 0,found:!1}}registerValueModule(e,t){this.valueModules.set(e,t)}create(e){const t=this.globalContext,r=new Ai({contexts:[e,...this.contexts],values:this.values,nativeJsFunctions:this.nativeJsFunctions,modules:this.modules,valueModules:this.valueModules,pure:this.pure});return r.globalContext=t,r}new(e){return new Ai({contexts:[{},e],modules:this.modules,valueModules:this.valueModules,pure:this.pure})}addValues(e,t){const n=this.contexts[0];for(const[o,a]of Object.entries(e)){if(n[o])throw new r(`Cannot redefine value "${o}"`,t);const e=Ni(o);if(e)throw new r(`Cannot shadow ${e}`,t);n[o]={value:pe(a)}}}getValue(e){for(const t of this.contexts){const r=t[e];if(r)return r.value}const t=this.nativeJsFunctions?.[e];return t||this.values?.[e]}lookUp(e){const t=e[1];for(const e of this.contexts){const r=e[t];if(r)return r}const r=this.values?.[t];if(void 0!==r)return{value:pe(r)};const n=this.nativeJsFunctions?.[t];return n?{value:n}:null}evaluateSymbol(e){if(Ht(e)){const t=e[1];switch(t){case kr["&&"]:case kr["||"]:case kr.array:case kr.object:case kr["defined?"]:case kr.recur:case kr.throw:case kr["??"]:{const r=f(Ar.specialExpressions[t],e[2]);return{[u]:!0,functionType:"SpecialBuiltin",specialBuiltinSymbolType:t,sourceCodeInfo:e[2],arity:r.arity}}default:throw new r(`Unknown special builtin symbol type: ${t}`,e[2])}}if(Yt(e)){const t=e[1],r=zt[t],n=r.name;return{[u]:!0,functionType:"Builtin",normalBuiltinSymbolType:t,sourceCodeInfo:e[2],arity:r.arity,name:n}}const t=this.lookUp(e);if(x(n=t)&&void 0!==n.value)return t.value;var n;throw new a(e[1],e[2])}}function Ni(e){return $r.includes(e)?`special expression "${e}"`:Nr.includes(e)?`builtin function "${e}"`:"self"===e?`builtin value "${e}"`:null}function $i(e){const t=Ni(e);if(t)throw new r(`Cannot shadow ${t}`,void 0)}function Ti(e={},t,n){const o=e.globalContext??{},a=e.contexts?[o,...e.contexts]:[o];let i,s;if(e.bindings)for(const[t,n]of Object.entries(e.bindings)){if(t.includes("."))throw new r(`Dots are not allowed in binding keys: "${t}"`,void 0);const e="function"==typeof n,o=jt(n);if(e||o){const e=o?n:{fn:n};$i(t),s||(s={}),s[t]={functionType:"NativeJsFunction",nativeFn:e,name:t,[u]:!0,arity:e.arity??{},docString:e.docString??""}}else $i(t),i||(i={}),i[t]=n}const c=new Ai({contexts:a,values:i,modules:t,nativeJsFunctions:s,pure:n});return e.globalModuleScope?c:c.create({})}const zi=["(",")","[","]","{","}","'",'"',"`",",",".",";"," ","\n","\r","\t"],Si=["0","1","2","3","4","5","6","7","8","9",...zi],Ei=new Set(zi),ji=new Set(Si),Mi=/\s/,Ci=[0],Pi=(e,t)=>{if('"'!==e[t])return Ci;let r='"',n=1,o=e[t+n],a=!1;for(;o&&('"'!==o||a);)n+=1,a?(a=!1,r+=o):("\\"===o&&(a=!0),r+=o),o=e[t+n];return o?(r+='"',[n+1,["string",r]]):[n,["Error",r,void 0,`Unclosed string at position ${t}`]]};function Ri(e,t,r,n){return t===r.slice(n,n+t.length)?[t.length,[e,t]]:Ci}const Ii=/\d/,Oi=/[0-7]/,Fi=/[0-9a-f]/i,Ui=/[01]/,Di=/[\s)\]}(,;]/,Wi=(e,t)=>{let r=e[t];if("'"===r){let n=1,o=e[t+n],a=!1;for(;"'"!==o||a;){if(void 0===o)return[n,["Error",r,void 0,`Unclosed quoted symbol at position ${t}`]];n+=1,a?(a=!1,r+=o):("\\"===o&&(a=!0),r+=o),o=e[t+n]}return r+="'",[n+1,["Symbol",r]]}if(!ji.has(r)){const n=t;let o=e[t+=1];for(;o&&!Ei.has(o);)r+=o,o=e[t+=1];return r.endsWith(":")?[t-n-1,["Symbol",r.slice(0,-1)]]:[t-n,["Symbol",r]]}return Ci},Gi=[(e,t)=>{let r=e[t];if(!r||!Mi.test(r))return Ci;let n=r;for(r=e[t+=1];r&&Mi.test(r);)n+=r,r=e[t+=1];return[n.length,["Whitespace",n]]},(e,t)=>{if("/"===e[t]&&"*"===e[t+1]){let r=2,n="/*";for(;("*"!==e[t+r]||"/"!==e[t+r+1])&&t+r+1<e.length;)n+=e[t+r],r+=1;return t+r+1>=e.length?[r,["Error",n,void 0,`Unclosed multi-line comment at position ${t}`]]:(n+="*/",r+=2,[r,["MultiLineComment",n]])}return Ci},(e,t)=>{if("/"===e[t]&&"/"===e[t+1]){let r=2,n="//";for(;"\n"!==e[t+r]&&t+r<e.length;)n+=e[t+r],r+=1;return[r,["SingleLineComment",n]]}return Ci},(e,t)=>{const r=Wi(e,t);if(0===r[0]||!r[1])return Ci;let n=r[1][1];n=n.startsWith("'")?n.slice(1,n.length-1):n;return void 0===bi[n]?Ci:[r[0],["ReservedSymbol",n]]},(e,t)=>Ri("LParen","(",e,t),(e,t)=>Ri("RParen",")",e,t),(e,t)=>Ri("LBracket","[",e,t),(e,t)=>Ri("RBracket","]",e,t),(e,t)=>Ri("LBrace","{",e,t),(e,t)=>Ri("RBrace","}",e,t),(e,t)=>{if('"'!==e[t]||'"'!==e[t+1]||'"'!==e[t+2])return Ci;let r='"""',n=3,o=e[t+n],a=e.slice(t+n,t+n+3),i=!1;for(;o&&('"""'!==a||i);)n+=1,i?(i=!1,r+=o):("\\"===o&&(i=!0),r+=o),o=e[t+n],a=e.slice(t+n,t+n+3);return o?(r+='"""',[n+3,["DocString",r]]):[n,["Error",r,void 0,`Unclosed doc string at position ${t}`]]},Pi,(e,t)=>{if("#"!==e[t])return Ci;const[r,n]=Pi(e,t+1);if(!n)return Ci;if("Error"===n[0]){return[r+1,["Error",`#${n[1]}`,void 0,`Unclosed regexp at position ${t}`]]}t+=r+1;let o=r+1,a="";for(;"g"===e[t]||"i"===e[t];)if(a+=e[t],o+=1,t+=1,a.includes(e[t]))return[o,["Error",`#${n[1]}${a}`,void 0,`Duplicated regexp option "${e[t]}"`]];return[o,["RegexpShorthand",`#${n[1]}${a}`]]},(e,t)=>{if("0"!==e[t])return Ci;const r=e[t+1],n="b"===r||"B"===r?"binary":"o"===r||"O"===r?"octal":"x"===r||"X"===r?"hex":null;if(null===n)return Ci;let o;for(o=t+2;o<e.length;o+=1){const t=e[o];if("binary"===n&&!Ui.test(t))break;if("octal"===n&&!Oi.test(t))break;if("hex"===n&&!Fi.test(t))break}const a=o-t;if(a<=2)return Ci;const i=e[o];return i&&!Di.test(i)?Ci:[a,["BasePrefixedNumber",e.substring(t,o)]]},(e,t)=>{let r;const n="-"===e[t],o="+"===e[t],a=n||o?t+1:t;let i=!1,s=!1;for(r=a;r<e.length;r+=1){const n=e[r];if("_"===n){if(!Ii.test(e[r-1])||!Ii.test(e[r+1]))return r===a?Ci:[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]]}else if("."===n){if(r===a)return Ci;if(i||s)return[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]];i=!0}else if("e"===n||"E"===n){if(r===a)return Ci;if(s)return[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]];if("."===e[r-1]||"+"===e[r-1]||"-"===e[r-1])return[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]];"+"!==e[r+1]&&"-"!==e[r+1]||(r+=1),s=!0}else if(!Ii.test(n))break}if((n||o)&&r===a)return Ci;const c=r-t;if(0===c)return Ci;const l=e[r];return l&&":"!==l&&!Di.test(l)?[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]]:[c,["Number",e.substring(t,r)]]},(e,t)=>{const r=e.slice(t,t+3);if(t+2<e.length&&Pr(r))return[3,["Operator",r]];const n=e.slice(t,t+2);if(t+1<e.length&&Pr(n))return[2,["Operator",n]];const o=e[t]??"";return Pr(o)?[1,["Operator",o]]:Ci},Wi];function Vi(e,t,r){const n=e.substring(0,t+1).split(/\r\n|\r|\n/),o=n[n.length-1],a=function(e,t){return e.split(/\r\n|\r|\n/)[t]}(e,n.length-1);return{code:a,position:{line:n.length,column:o.length},filePath:r}}function Bi(e,t){const r=t;if(0===t){const[n,o]=((e,t)=>{if("#"===e[t]&&"!"===e[t+1]){let r=2,n="#!";for(;"\n"!==e[t+r]&&t+r<e.length;)n+=e[t+r],r+=1;return[r,["SingleLineComment",n]]}return Ci})(e,t);if(t+=n,n>0)return[t-r,o]}for(const n of Gi){const[o,a]=n(e,t);if(t+=o,0!==o)return[t-r,a]}return[1,["Error",e[r],void 0,"Unrecognized character"]]}function Li(e,t){return"Symbol"===e?.[0]&&(!t||e[1]===t)}function _i(e,t){return function(e,t){Li(e,t)||gs("Symbol",void 0,e)}(e,t),e}function Ki(e,t){return"ReservedSymbol"===e?.[0]&&(!t||e[1]===t)}function Ji(e,t){Ki(e,t)||gs("ReservedSymbol",t,e)}function Yi(e,t){return Ji(e,t),e}function Hi(e,t){return"Operator"===e?.[0]&&(!t||e[1]===t)}function Xi(e,t){Hi(e,t)||gs("Operator",t,e)}function Zi(e){return"Number"===e?.[0]}function Qi(e){return"BasePrefixedNumber"===e?.[0]}function es(e){return"LParen"===e?.[0]}function ts(e){es(e)||gs("LParen",void 0,e)}function rs(e){return"RParen"===e?.[0]}function ns(e){rs(e)||gs("RParen",void 0,e)}function os(e){return"LBracket"===e?.[0]}function as(e){return function(e){os(e)||gs("LBracket",void 0,e)}(e),e}function is(e){return"RBracket"===e?.[0]}function ss(e){is(e)||gs("RBracket",void 0,e)}function cs(e){return"LBrace"===e?.[0]}function ls(e){return function(e){cs(e)||gs("LBrace",void 0,e)}(e),e}function ms(e){return"RBrace"===e?.[0]}function us(e){return"string"===e?.[0]}function ps(e){return"Operator"===e?.[0]&&Mr(e[1])}function gs(e,t,n){const o=n?`${n[0]} '${n[1]}'`:"end of input";throw new r(`Unexpected token: ${o}, expected ${e}${t?` '${t}'`:""}`,n?.[2])}function hs(e,{removeWhiteSpace:t}){const r=e.tokens.filter(e=>!(function(e){return"SingleLineComment"===e?.[0]}(e)||function(e){return"MultiLineComment"===e?.[0]}(e)||function(e){return"Shebang"===e?.[0]}(e)||t&&function(e){return"Whitespace"===e?.[0]}(e)));return{...e,tokens:r}}const ds=new Set([...Nr,...$r,...Object.keys(bi)]);class ys{originalProgram;originalPosition;prefixProgram="";suffixProgram="";searchString="";suggestions=[];suggestionIndex=null;constructor(e,t,r,n){this.originalProgram=e,this.originalPosition=t;const o=this.originalProgram.slice(0,this.originalPosition),a=r.tokenize(o).tokens.at(-1);a&&"Error"!==a[0]&&(this.searchString=a[1],this.prefixProgram=this.originalProgram.slice(0,this.originalPosition-this.searchString.length),this.suffixProgram=this.originalProgram.slice(this.prefixProgram.length+this.searchString.length),this.originalProgram.slice(this.prefixProgram.length+this.searchString.length),this.suggestions=this.generateSuggestions(n))}getNextSuggestion(){return this.getAutoCompleteSuggestionResult(this.getNextSuggestionSymbol())}getPreviousSuggestion(){return this.getAutoCompleteSuggestionResult(this.getPreviousSuggestionSymbol())}getAutoCompleteSuggestionResult(e){return null===e?null:{program:this.prefixProgram+e+this.suffixProgram,position:this.prefixProgram.length+e.length}}getNextSuggestionSymbol(){return 0===this.suggestions.length?null:(null===this.suggestionIndex?this.suggestionIndex=0:(this.suggestionIndex+=1,this.suggestionIndex>=this.suggestions.length&&(this.suggestionIndex=0)),this.suggestions[this.suggestionIndex])}getPreviousSuggestionSymbol(){return 0===this.suggestions.length?null:(null===this.suggestionIndex?this.suggestionIndex=this.suggestions.length-1:(this.suggestionIndex-=1,this.suggestionIndex<0&&(this.suggestionIndex=this.suggestions.length-1)),this.suggestions[this.suggestionIndex])}getSuggestions(){return[...this.suggestions]}getSearchString(){return this.searchString}generateSuggestions(e){const t=new Set(["0_defn","0_lambda"]),r=this.generateWithPredicate(e,e=>!t.has(e)&&e.startsWith(this.searchString));r.forEach(e=>t.add(e));const n=this.generateWithPredicate(e,e=>!t.has(e)&&e.toLowerCase().startsWith(this.searchString.toLowerCase()));n.forEach(e=>t.add(e));const o=this.generateWithPredicate(e,e=>!t.has(e)&&e.includes(this.searchString));o.forEach(e=>t.add(e));const a=this.generateWithPredicate(e,e=>!t.has(e)&&e.includes(this.searchString.toLowerCase()));return a.forEach(e=>t.add(e)),[...r,...n,...o,...a]}generateWithPredicate(e,t){const r=new Set;return ds.forEach(e=>{t(e)&&r.add(e)}),Object.keys(e.globalContext??{}).filter(t).forEach(e=>r.add(e)),e.contexts?.forEach(e=>{Object.keys(e).filter(t).forEach(e=>r.add(e))}),Object.keys(e.bindings??{}).filter(t).forEach(e=>r.add(e)),[...r].sort((e,t)=>e.localeCompare(t))}}function vs(e){return"object"==typeof e&&null!==e&&"string"==typeof e.program&&Array.isArray(e.fileModules)}function fs(e,t){return t&&(e[2]=t),e}function bs(e,t){return void 0!==kr[e]&&"fn"!==e&&"defn"!==e?fs([s.SpecialBuiltinSymbol,kr[e]],t):void 0!==Tt[e]?fs([s.NormalBuiltinSymbol,Tt[e]],t):fs([s.UserDefinedSymbol,e],t)}function xs(e){return e.substring(1,e.length-1).replace(/(\\{2})|(\\')|\\(.)/g,(e,t,r,n)=>t?"\\":r?"'":`\\${n}`)}const ws=Object.entries(Tt).reduce((e,[t,r])=>(e[r]=t,e),[]),ks=Object.entries(kr).reduce((e,[t,r])=>(e[r]=t,e),[]);function qs(e){return Kt(e)?e[1]:Yt(e)?ws[e[1]]:ks[e[1]]}function As(e,t,r){const n=fs([s.NormalExpression,[e,t]],r);return Yt(e)&&ne(zt[e[1]].arity,n[1][1].length,r),n}function Ns(e){if(e.isAtEnd())return!0;const t=e.tryPeek();return Hi(t)?[";",",",":"].includes(t[1]):!!Ki(t)&&["else","when","while","case","catch","let","then","end","do"].includes(t[1])}function $s(e,t,n,o,a){const i=e[1];switch(i){case"^":case"*":case"/":case"%":case"+":case"-":case"<<":case">>":case">>>":case"++":case"<":case"<=":case"≤":case">":case">=":case"≥":case"==":case"!=":case"&":case"xor":case"|":case"|>":return As(t,[n,o],a);case"&&":case"||":case"??":return fs([s.SpecialExpression,[kr[i],[n,o]]],a);default:throw new r(`Unknown binary operator: ${i}`,a)}}class Ts{tokens;position;storedPosition=0;parseExpression;constructor(e){this.tokens=e.tokens,this.position=0}advance(){this.position+=1}tryPeek(){return this.tokens[this.position]}peek(){const e=this.tokens[this.position];if(!e){const e=this.tokens.at(-1),t=e?e[2]:void 0;throw new r("Unexpected end of input",t)}return e}isAtEnd(){return this.position>=this.tokens.length}peekSourceCodeInfo(){const e=this.tryPeek();return e?e[2]:this.tokens.at(-1)?.[2]}storePosition(){return this.storedPosition=this.position}restorePosition(){this.position=this.storedPosition}peekAhead(e){return this.tokens[this.position+e]}getPosition(){return this.position}getTokenAt(e){return this.tokens[e]}}function zs(e,t){switch(e){case"^":return 12;case"*":case"/":case"%":return 11;case"+":case"-":return 10;case"<<":case">>":case">>>":return 9;case"++":return 8;case"<":case"<=":case"≤":case">":case">=":case"≥":return 7;case"==":case"!=":return 6;case"&":case"xor":case"|":return 5;case"&&":case"||":case"??":return 4;case"|>":return 2;default:throw new r(`Unknown binary operator: ${e}`,t)}}function Ss(e,t){const n=[];for(;!e.isAtEnd()&&!Es(e,t);)Hi(e.tryPeek(),";")?e.advance():n.push(e.parseExpression());if(function(e,t){if(!Es(e,t))throw new r(`Expected ${t.map(e=>e[1]).join(" or ")}`,e.peekSourceCodeInfo())}(e,t),0===n.length)throw new r("Expected expression",e.peekSourceCodeInfo());return 1===n.length?n[0]:fs([s.SpecialExpression,[kr.block,n]],e.peekSourceCodeInfo())}function Es(e,t){for(const r of t)if(Ki(e.tryPeek(),r))return!0;return!1}function js(e,t){e.advance();const r=t[1].substring(1,t[1].length-1).replace(/(\\{2})|(\\")|(\\n)|(\\t)|(\\r)|(\\b)|(\\f)|\\(.)/g,(e,t,r,n,o,a,i,s,c)=>t?"\\":n?"\n":o?"\t":a?"\r":i?"\b":s?"\f":r?'"':c);return fs([s.String,r],t[2])}function Ms(e,t=!1){const n=Yi(e.tryPeek(),"do");e.advance();let o="";t&&function(e){return"DocString"===e?.[0]}(e.tryPeek())&&(o=function(e){const t=e.peek(),r=t[2]?["string",t[1].slice(2,-2),t[2]]:["string",t[1].slice(2,-2)],n=js(e,r);return xe(n[1])}(e),e.isAtEnd()||Ki(e.tryPeek(),"end")||(Xi(e.tryPeek(),";"),e.advance()));const a=[];for(;!e.isAtEnd()&&!Ki(e.tryPeek(),"end");)if(a.push(e.parseExpression()),Hi(e.tryPeek(),";"))e.advance();else if(!Ki(e.tryPeek(),"end"))throw new r("Expected end",e.peekSourceCodeInfo());return Ji(e.tryPeek(),"end"),e.advance(),[fs([s.SpecialExpression,[kr.block,a]],n[2]),o]}function Cs(e){const t=e.peek();if(e.advance(),!Li(t))throw new r(`Expected symbol token, got ${t[0]}`,t[2]);return"'"===t[1][0]?bs(xs(t[1]),t[2]):bs(t[1],t[2])}function Ps(e){const t=e.peek();e.advance();const r=t[1],n="-"===r[0],o=(n?r.substring(1):r).replace(/_/g,"");return fs([s.Number,n?-Number(o):Number(o)],t[2])}function Rs(e,{requireDefaultValue:t,noRest:n,allowLiteralPatterns:o}={}){const a=e.tryPeek();if(o&&Ki(a,"_"))return e.advance(),fs([Ot,[]],a[2]);if(o&&Os(a)){if(Zi(a)||Qi(a)){const t=Ps(e);return fs([It,[t]],a[2])}if(us(a)){const t=js(e,a);return fs([It,[t]],a[2])}if(Ki(a,"true")){e.advance();const t=fs([s.ReservedSymbol,"true"],a[2]);return fs([It,[t]],a[2])}if(Ki(a,"false")){e.advance();const t=fs([s.ReservedSymbol,"false"],a[2]);return fs([It,[t]],a[2])}if(Ki(a,"null")){e.advance();const t=fs([s.ReservedSymbol,"null"],a[2]);return fs([It,[t]],a[2])}}if(Li(a)){const n=Cs(e);if(!Kt(n))throw new r("Expected user defined symbol",a[2]);const o=Is(e);if(t&&!o)throw new r("Expected assignment",e.peekSourceCodeInfo());return fs([Mt,[n,o]],a[2])}if(Hi(a,"...")){if(n)throw new r("Rest element not allowed",a[2]);e.advance();const t=Jt(Cs(e));if(Hi(e.tryPeek(),"="))throw new r("Rest argument can not have default value",e.peekSourceCodeInfo());return fs([Ct,[t[1],void 0]],a[2])}if(os(a)){e.advance();const n=[];let i=e.peek(),s=!1;for(;!is(i);){if(s)throw new r("Rest argument must be last",i[2]);if(Hi(i,",")){n.push(null),e.advance(),i=e.peek();continue}const t=Rs(e,{allowLiteralPatterns:o});t[0]===Ct&&(s=!0),n.push(t),i=e.peek(),is(i)||(Xi(i,","),e.advance()),i=e.peek()}e.advance();const c=Is(e);if(t&&!c)throw new r("Expected assignment",e.peekSourceCodeInfo());return fs([Rt,[n,c]],a[2])}if(cs(a)){e.advance();const n={};let i=e.peek(),s=!1;for(;!ms(i);){if(s)throw new r("Rest argument must be last",i[2]);Hi(i,"...")&&(s=!0,e.advance());const t=Cs(e),c=qs(t);if(i=e.peek(),Ki(i,"as")){if(s)throw new r("Rest argument can not have alias",i[2]);e.advance();const t=Jt(Cs(e));if(n[t[1]])throw new r(`Duplicate binding name: ${t}`,i[2]);n[c]=fs([Mt,[t,Is(e)]],a[2])}else if(ms(i)||Hi(i,",")||Hi(i,"=")){const o=Jt(t,t[2]);if(n[o[1]])throw new r(`Duplicate binding name: ${o}`,i[2]);if(s&&Hi(e.tryPeek(),"="))throw new r("Rest argument can not have default value",e.peekSourceCodeInfo());n[o[1]]=fs(s?[Ct,[o[1],Is(e)]]:[Mt,[o,Is(e)]],a[2])}else if(Hi(i,":")){if(e.advance(),i=e.peek(),o){if(!cs(i)&&!os(i)&&!Os(i))throw new r("Expected literal, object or array pattern",i[2])}else if(!cs(i)&&!os(i))throw new r("Expected object or array",i[2]);n[c]=Rs(e,{allowLiteralPatterns:o})}ms(e.peek())||(Xi(e.peek(),","),e.advance()),i=e.peek()}e.advance(),i=e.peek();const c=Is(e);if(t&&!c)throw new r("Expected assignment",i[2]);return fs([Pt,[n,c]],a[2])}throw new r("Expected symbol",e.peekSourceCodeInfo())}function Is(e){if(Hi(e.tryPeek(),"="))return e.advance(),e.parseExpression()}function Os(e){return Zi(e)||Qi(e)||us(e)||Ki(e,"true")||Ki(e,"false")||Ki(e,"null")}function Fs(e,t){e.advance();const r=Rs(e,{requireDefaultValue:!0,noRest:!0}),n=r[1][1];r[1][1]=void 0;const o=fs([s.Binding,[r,n]],t[2]);return fs([s.SpecialExpression,[kr.let,o]],t[2])}function Us(e){const t=function(e){const t=_i(e.tryPeek()),r=Jt(Cs(e));Ji(e.tryPeek(),"in"),e.advance();const n=e.parseExpression();return fs([s.Binding,[fs([Mt,[r,void 0]],t[2]),n]],t[2])}(e),n=[];let o=e.peek();Ds(o,["let","when","while"]);const a=[];if("let"===o[1])for(n.push("&let");Li(o,"let");){const t=Fs(e,o),n=a.flatMap(e=>Object.keys(Wt(e[1][0])));if(Object.keys(Wt(t[1][1][1][0])).some(e=>n.includes(e)))throw new r("Duplicate binding",t[1][1][2]);a.push(t[1][1]),o=e.peek(),Ds(o,["let","when","while"]),o=e.peek()}let i,c;for(;Ki(o,"when")||Ki(o,"while");){e.advance(),"when"===o[1]?(n.push("&when"),i=e.parseExpression()):(n.push("&while"),c=e.parseExpression()),o=e.peek();Ds(o,n.includes("&when")&&n.includes("&while")?[]:n.includes("&when")?["while"]:["when"]),o=e.peek()}return Ds(o,[]),[t,a,i,c]}function Ds(e,t){if(!function(e,t){if(Hi(e,",")||rs(e))return!0;for(const r of t){if("let"===r&&Li(e,"let"))return!0;if(["when","while"].includes(r)&&Ki(e,r))return!0}return!1}(e,t)){const n=`${[...t,","].map(e=>`"${e}"`).join(", ")} or ")"`;throw new r(`Expected symbol ${n}`,e[2])}}function Ws(e){const t=Yi(e.tryPeek());e.advance();const r=t[1];return function(e){return e in fi}(r)?fs([s.Number,fi[r]],t[2]):fs([s.ReservedSymbol,t[1]],t[2])}const Gs=/^\$([1-9]\d?)?$/;function Vs(e){const t=e.peek();if(es(t)&&Li(e.peekAhead(1))&&Hi(e.peekAhead(2),"->"))return null;try{const n=function(e){const t=e.peek();if(Li(t))return[fs([Mt,[Cs(e),void 0]],t[2])];ts(t),e.advance();let n=!1,o=!1;const a=[];for(;!e.isAtEnd()&&!rs(e.peek())&&!Li(e.peek(),"let");){if(n)throw new r("Rest argument must be last",e.peekSourceCodeInfo());const t=Rs(e);if(void 0!==t[1][1]&&(o=!0),t[0]===Ct&&(n=!0),o&&!t[1][1])throw new r("Default arguments must be last",e.peekSourceCodeInfo());if(a.push(t),!Hi(e.peek(),",")&&!rs(e.peek())&&!Li(e.peek(),"let"))throw new r("Expected comma or closing parenthesis",e.peekSourceCodeInfo());Hi(e.peek(),",")&&e.advance()}if(!rs(e.peek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());return e.advance(),a}(e);if(!Hi(e.peek(),"->"))return null;let o;e.advance();let a="";if(Ki(e.peek(),"do")){const t=Ms(e,!0);a=t[1],o=t[0][1][1]}else o=[e.parseExpression()];return fs([s.SpecialExpression,[kr["0_lambda"],[n,o],a]],t[2])}catch{return null}}function Bs(e,t){e.advance();const n=[];for(;!e.isAtEnd()&&!rs(e.tryPeek());){Hi(e.tryPeek(),"...")?(e.advance(),n.push(fs([s.Spread,e.parseExpression()],e.peekSourceCodeInfo()))):n.push(e.parseExpression());const t=e.tryPeek();if(!Hi(t,",")&&!rs(t))throw new r("Expected comma or closing parenthesis",e.tryPeek()?.[2]);Hi(t,",")&&e.advance()}if(!rs(e.tryPeek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());if(e.advance(),!Ht(t))return Yt(t)||Kt(t)?As(t,n,t[2]):fs([s.NormalExpression,[t,n]],t[2]);{const e=t[1];if(e===kr.import){if(1!==n.length)throw new r(`import expects exactly 1 argument, got ${n.length}`,t[2]);const o=n[0];if(!Kt(o))throw new r("import expects a module name (symbol), got a non-symbol argument",o[2]??t[2]);const a=o[1];return fs([s.SpecialExpression,[e,a]],t[2])}const o=e;switch(ne(Ar.specialExpressions[o].arity,n.length,t[2]),o){case kr["||"]:case kr["&&"]:case kr.recur:case kr.array:case kr.object:case kr["??"]:return fs([s.SpecialExpression,[o,n]],t[2]);case kr["defined?"]:{const[e]=n;return fs([s.SpecialExpression,[o,e]],t[2])}case kr.throw:{const[e]=n;return fs([s.SpecialExpression,[o,e]],t[2])}case kr["0_lambda"]:throw new r(`${o} is not allowed`,t[2]);default:throw new r(`Unknown special expression: ${o}`,t[2])}}}function Ls(e){const t=ls(e.tryPeek());e.advance();const n=[];for(;!e.isAtEnd()&&!ms(e.tryPeek());){if(Hi(e.tryPeek(),"..."))e.advance(),n.push(fs([s.Spread,e.parseExpression()],e.peekSourceCodeInfo()));else{const t=e.tryPeek();if(us(t)){const r=js(e,t);n.push(fs([s.String,r[1]],t[2]))}else if(Li(t)){const r=t[1].startsWith("'")?xs(t[1]):t[1];n.push(fs([s.String,r],t[2])),e.advance()}else{if(!os(t))throw new r("Expected key to be a symbol or a string",e.peekSourceCodeInfo());e.advance(),n.push(e.parseExpression()),ss(e.tryPeek()),e.advance()}Xi(e.tryPeek(),":"),e.advance(),n.push(e.parseExpression())}const t=e.tryPeek();if(!Hi(t,",")&&!ms(t))throw new r("Expected comma or closing brace",e.peekSourceCodeInfo());Hi(t,",")&&e.advance()}var o;return ms(o=e.tryPeek())||gs("RBrace",void 0,o),e.advance(),fs([s.SpecialExpression,[kr.object,n]],t[2])}function _s(e){let t=function(e){const t=e.peek();if(es(t)){e.storePosition();const t=Vs(e);if(t)return t;e.restorePosition(),e.advance();const n=e.parseExpression();if(!rs(e.peek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());return e.advance(),n}if(Hi(t)){const n=t[1];if(Mr(n))return e.advance(),fs(void 0!==kr[n]?[s.SpecialBuiltinSymbol,kr[n]]:[s.NormalBuiltinSymbol,Tt[n]],t[2]);if("->"===n)return function(e){const t=e.peek();e.advance();const n=e.getPosition();let o,a="";if(Ki(e.peek(),"do")){const t=Ms(e,!0);a=t[1],o=t[0][1][1]}else o=[e.parseExpression()];const i=e.getPosition()-1;let c=0,l="NOT_SET";for(let o=n;o<=i;o+=1){const n=e.getTokenAt(o);if(Li(n)){const e=Gs.exec(n[1]);if(e){const n=e[1]??"1";if("1"===n){if(!e[1]&&"WITH_1"===l||e[1]&&"NAKED"===l)throw new r("Please make up your mind, either use $ or $1",t[2]);l=e[1]?"WITH_1":"NAKED"}if(c=Math.max(c,Number(n)),c>20)throw new r("Can't specify more than 20 arguments",t[2])}}}const m=[];for(let e=1;e<=c;e+=1)1===e&&"NAKED"===l?m.push(fs([Mt,[[s.UserDefinedSymbol,"$"],void 0]],t[2])):m.push(fs([Mt,[[s.UserDefinedSymbol,`$${e}`],void 0]],t[2]));return fs([s.SpecialExpression,[kr["0_lambda"],[m,o],a]],t[2])}(e);throw new r(`Illegal operator: ${n}`,t[2])}if(cs(t))return Ls(e);if(os(t))return function(e){const t=as(e.tryPeek());e.advance();const n=[];for(;!e.isAtEnd()&&!is(e.tryPeek());){Hi(e.tryPeek(),"...")?(e.advance(),n.push(fs([s.Spread,e.parseExpression()],e.peekSourceCodeInfo()))):n.push(e.parseExpression());const t=e.tryPeek();if(!Hi(t,",")&&!is(t))throw new r("Expected comma or closing parenthesis",e.peekSourceCodeInfo());Hi(t,",")&&e.advance()}return ss(e.tryPeek()),e.advance(),fs([s.SpecialExpression,[kr.array,n]],t[2])}(e);const n=t[0];switch(n){case"Number":case"BasePrefixedNumber":return Ps(e);case"string":return js(e,t);case"Symbol":{e.storePosition();const t=Vs(e);return t||(e.restorePosition(),Cs(e))}case"ReservedSymbol":return Ws(e);case"RegexpShorthand":return function(e){const t=e.peek();e.advance();const r=t[1].lastIndexOf('"'),n=t[1].substring(2,r),o=t[1].substring(r+1),a=fs([s.String,n],t[2]),i=fs([s.String,o],t[2]);return fs([s.NormalExpression,[fs([s.NormalBuiltinSymbol,Tt.regexp],t[2]),[a,i]]],t[2])}(e);default:throw new r(`Unknown token type: ${n}`,t[2])}}(e),n=e.tryPeek();for(;Hi(n,".")||os(n)||es(n);)if("."===n[1]){e.advance();const o=e.tryPeek();if(!Li(o))throw new r("Expected symbol",e.peekSourceCodeInfo());t=Ks(t,fs([s.String,o[1]],o[2]),n[2]),e.advance(),n=e.tryPeek()}else if(os(n)){e.advance();const o=e.parseExpression();if(!is(e.tryPeek()))throw new r("Expected closing bracket",e.peekSourceCodeInfo());t=Ks(t,o,n[2]),e.advance(),n=e.tryPeek()}else es(n)&&(t=Bs(e,t),n=e.tryPeek());return t}function Ks(e,t,r){return fs([s.NormalExpression,[[s.NormalBuiltinSymbol,Tt.get],[e,t]]],r)}function Js(e,t=0){const n=e.tryPeek();let o;if(Li(n))switch(n[1]){case"let":return Fs(e,n);case"if":case"unless":o=function(e,t){const r="unless"===t[1];e.advance();const n=e.parseExpression();Ji(e.tryPeek(),"then"),e.advance();const o=Ss(e,["else","end"]);let a;return Ki(e.tryPeek(),"else")&&(e.advance(),a=Ss(e,["end"])),e.advance(),fs(r?[s.SpecialExpression,[kr.unless,[n,o,a]]]:[s.SpecialExpression,[kr.if,[n,o,a]]],t[2])}(e,n);break;case"cond":o=function(e,t){e.advance();const r=[];for(;!e.isAtEnd()&&!Ki(e.tryPeek(),"end");){Ji(e.tryPeek(),"case"),e.advance();const t=e.parseExpression();Ji(e.tryPeek(),"then"),e.advance();const n=Ss(e,["case","end"]);if(r.push([t,n]),Ki(e.tryPeek(),"end"))break}return Ji(e.tryPeek()),e.advance(),fs([s.SpecialExpression,[kr.cond,r]],t[2])}(e,n);break;case"match":o=function(e,t){e.advance();const r=e.parseExpression(),n=[];for(;!e.isAtEnd()&&!Ki(e.tryPeek(),"end");){Ji(e.tryPeek(),"case"),e.advance();const t=Rs(e,{allowLiteralPatterns:!0});let r;Ki(e.tryPeek(),"when")&&(e.advance(),r=e.parseExpression()),Ji(e.tryPeek(),"then"),e.advance();const o=Ss(e,["case","end"]);if(n.push([t,o,r]),Ki(e.tryPeek(),"end"))break}return Ji(e.tryPeek(),"end"),e.advance(),fs([s.SpecialExpression,[kr.match,r,n]],t[2])}(e,n);break;case"for":case"doseq":o=function(e,t){const n="doseq"===t[1];e.advance(),ts(e.tryPeek()),e.advance();const o=[];for(;!e.isAtEnd()&&!rs(e.tryPeek());){const t=Us(e),n=o.flatMap(e=>Object.keys(Wt(e[0][1][0]))),a=Wt(t[0][1][0]);if(Object.keys(a).some(e=>n.includes(e)))throw new r("Duplicate binding",t[0][2]);o.push(t),Hi(e.tryPeek(),",")&&e.advance()}ns(e.tryPeek()),e.advance(),Xi(e.tryPeek(),"->"),e.advance();const a=e.parseExpression();return fs(n?[s.SpecialExpression,[kr.doseq,o,a]]:[s.SpecialExpression,[kr.for,o,a]],t[2])}(e,n);break;case"loop":o=function(e,t){e.advance(),ts(e.tryPeek()),e.advance();const n=[];let o=e.tryPeek();for(;!e.isAtEnd()&&!rs(o);){const t=Rs(e,{requireDefaultValue:!0,noRest:!0}),r=t[1][1];t[1][1]=void 0,n.push(fs([s.Binding,[t,r]],t[2])),Hi(e.tryPeek(),",")&&e.advance(),o=e.tryPeek()}if(0===n.length)throw new r("Expected binding",e.peekSourceCodeInfo());ns(o),e.advance(),Xi(e.tryPeek(),"->"),e.advance();const a=e.parseExpression();return fs([s.SpecialExpression,[kr.loop,n,a]],t[2])}(e,n);break;case"try":o=function(e,t){e.advance();const r=Ss(e,["catch"]);let n;e.advance(),es(e.tryPeek())&&(e.advance(),n=Cs(e),ns(e.tryPeek()),e.advance());const o=Ss(e,["end"]);return e.advance(),fs([s.SpecialExpression,[kr.try,r,n,o]],t[2])}(e,n)}else Ki(n,"do")&&(o=Ms(e)[0]);o||=_s(e);let a=e.tryPeek();for(;!Ns(e);){if(ps(a)){const r=a[1],n=zs(r,a[2]);if(n<=t&&(12!==n||12!==t))break;const i=fs(kr[r]?[s.SpecialBuiltinSymbol,kr[r]]:[s.NormalBuiltinSymbol,Tt[r]],a[2]);e.advance();o=$s(a,i,o,Js(e,n),a[2])}else if(Li(a)){if(!Er(a[1]))break;const n=3;if(n<=t)break;const i=Cs(e),s=Js(e,n);if(Ht(i))throw new r("Special expressions are not allowed in binary functional operators",i[2]);o=As(i,[o,s],a[2])}else{if("?"!==a?.[1])break;{if(1<=t)break;e.advance();const n=Js(e);if(!Hi(e.tryPeek(),":"))throw new r("Expected :",e.peekSourceCodeInfo());e.advance();const a=Js(e);o=fs([s.SpecialExpression,[kr.if,[o,n,a]]],o[2])}}a=e.tryPeek()}return o}function Ys(e){e.tokens.forEach(e=>{if("Error"===e[0])throw new r(e[3],e[2])});const t=[],n=function(e){const t=new Ts(e);return t.parseExpression=(e=0)=>Js(t,e),t}(e);for(;!n.isAtEnd();)if(t.push(Js(n,0)),Hi(n.tryPeek(),";"))n.advance();else if(!n.isAtEnd())throw new r("Expected ;",n.peekSourceCodeInfo());return t}class Hs{cache={};firstEntry=void 0;lastEntry=void 0;_size=0;maxSize;constructor(e){if(this.maxSize=null===e?null:ue(e),"number"==typeof this.maxSize&&this.maxSize<1)throw new Error(`1 is the minimum maxSize, got ${d(e)}`)}getContent(){return Object.entries(this.cache).reduce((e,[t,r])=>(e[t]=r.value,e),{})}get size(){return this._size}get(e){return this.cache[e]?.value}clear(){this.cache={},this.firstEntry=void 0,this.lastEntry=void 0,this._size=0}has(e){return!!this.cache[e]}set(e,t){if(this.has(e))throw new Error(`AstCache - key already present: ${e}`);const r={value:t,nextEntry:void 0,key:e};for(this.cache[e]=r,this._size+=1,this.lastEntry&&(this.lastEntry.nextEntry=r),this.lastEntry=r,this.firstEntry||(this.firstEntry=this.lastEntry);null!==this.maxSize&&this.size>this.maxSize;)this.dropFirstEntry()}dropFirstEntry(){const e=this.firstEntry;delete this.cache[e.key],this._size-=1,this.firstEntry=e.nextEntry}}class Xs{astCache;astCacheSize;debug;modules;constructor(e={}){if(this.debug=e.debug??!1,this.astCacheSize=e.astCacheSize??null,this.astCacheSize){this.astCache=new Hs(this.astCacheSize);const t=e.initialCache??{};for(const e of Object.keys(t))this.astCache.set(e,t[e])}else this.astCache=null;const t=e.modules??[];this.modules=new Map(t.map(e=>[e.name,e]))}getRuntimeInfo(){return{astCacheSize:this.astCacheSize,astCache:this.astCache,debug:this.debug}}async={run:async(e,t={})=>{if(vs(e))return this.runBundle(e,t);const r=this.generateAst(e,t);return this.evaluate(r,t)},apply:async(e,t,r={})=>this.apply(e,t,r)};run(e,t={}){if(vs(e))return this.runBundle(e,t);const r=this.generateAst(e,t),n=this.evaluate(r,t);if(n instanceof Promise)throw new TypeError("Unexpected async result in synchronous run(). Use lits.async.run() for async operations.");return n}runBundle(e,t={}){const r=Ti(t,this.modules,t.pure),n=r.pure;r.pure=!0;for(const[n,o]of e.fileModules){const e=wi(this.generateAst(o,t),r.create({}));if(e instanceof Promise)throw new TypeError("Unexpected async result in synchronous runBundle(). Use lits.async.run() for async operations.");r.registerValueModule(n,e)}r.pure=n;const o=wi(this.generateAst(e.program,t),r);if(o instanceof Promise)throw new TypeError("Unexpected async result in synchronous runBundle(). Use lits.async.run() for async operations.");return o}getUndefinedSymbols(e,t={}){const r="string"==typeof e?this.generateAst(e,t):e,n=Ti(t,this.modules);return di(r,n,Ar,ki)}tokenize(e,t={}){const r=function(e,t,r){let n=0;const o={tokens:[],filePath:r,hasDebugData:t};for(;n<e.length;){const a=t?Vi(e,n,r):void 0,i=Bi(e,n),[s,c]=i;n+=s,c&&(a&&(c[2]=a),o.tokens.push(c))}return o}(e,this.debug,t.filePath);return t.minify?hs(r,{removeWhiteSpace:!1}):r}parse(e){const t={body:[],hasDebugData:(e=hs(e,{removeWhiteSpace:!0})).hasDebugData};return t.body=Ys(e),t}evaluate(e,t){return wi(e,Ti(t,this.modules,t.pure))}transformSymbols(e,t){return function(e,t){return{...e,tokens:e.tokens.map(e=>Li(e)?[e[0],t(e[1])]:e)}}(e,t)}untokenize(e){return function(e){return e.tokens.reduce((e,t)=>`${e}${t[1]}`,"")}(e)}apply(e,t,r={}){const n="FN_2eb7b316_471c_5bfa_90cb_d3dfd9164a59",o=this.generateApplyFunctionCall(n,t),a=this.generateAst(o,r),i=t.reduce((e,t,r)=>(e[`${n}_${r}`]=t,e),{[n]:e});return r.bindings={...r.bindings,...i},this.evaluate(a,r)}generateApplyFunctionCall(e,t){const r=t.map((t,r)=>`${e}_${r}`).join(", ");return`${e}(${r})`}generateAst(e,t){if(this.astCache){const t=this.astCache.get(e);if(t)return t}const r=this.tokenize(e,{filePath:t.filePath}),n=this.parse(r);return this.astCache?.set(e,n),n}getAutoCompleter(e,t,r={}){return new ys(e,t,this,r)}}const Zs=[Dr,Br,Yr,Cn,_n,to,ha,Sa,Ea,fa,Aa,Ta,Ma,Ua];function Qs(e){return[`number-theory.${e}-seq`,`number-theory.${e}-nth`,`number-theory.${e}-take-while`,`number-theory.${e}?`]}function ec(e){const t=e.replace(/^/,"");return[`vector.${e}`,`vector.moving-${t}`,`vector.centered-moving-${t}`,`vector.running-${t}`]}function tc(e){return[`vector.moving-${e}`,`vector.centered-moving-${e}`,`vector.running-${e}`]}const rc={collection:["filter","map","reduce","count","get","contains?","assoc","++"],collectionUtils:["collection.filteri","collection.mapi","collection.reducei","collection.reduce-right","collection.reducei-right","collection.reductions","collection.reductionsi","collection.get-in","collection.assoc-in","collection.update","collection.update-in","collection.not-empty","collection.every?","collection.not-every?","collection.any?","collection.not-any?"],array:["range","repeat","flatten","mapcat","moving-fn","running-fn"],sequence:["nth","push","pop","index-of","some","reverse","first","second","last","rest","next","sort","slice","take","take-last","drop","drop-last","take-while","drop-while"],sequenceUtils:["sequence.position","sequence.last-index-of","sequence.unshift","sequence.splice","sequence.sort-by","sequence.distinct","sequence.remove","sequence.remove-at","sequence.split-at","sequence.split-with","sequence.frequencies","sequence.group-by","sequence.partition","sequence.partition-all","sequence.partition-by","sequence.starts-with?","sequence.ends-with?","sequence.interleave","sequence.interpose"],math:["+","-","*","/","mod","%","quot","inc","dec","sqrt","cbrt","^","round","trunc","floor","ceil","min","max","abs","sign"],mathUtils:["math.ln","math.log2","math.log10","math.sin","math.cos","math.tan","math.asin","math.acos","math.atan","math.sinh","math.cosh","math.tanh","math.asinh","math.acosh","math.atanh","math.to-rad","math.to-deg"],functional:["|>","apply","identity","comp","constantly"],functionalUtils:["functional.juxt","functional.complement","functional.every-pred","functional.some-pred","functional.fnull"],meta:["doc","arity"],misc:["!=","==","<",">","<=",">=","not","write!","iso-date->epoch","epoch->iso-date","boolean","compare","identical?","json-parse","json-stringify"],object:["dissoc","keys","vals","entries","find","merge","merge-with","zipmap","select-keys"],predicate:["boolean?","null?","number?","string?","function?","integer?","array?","object?","collection?","sequence?","regexp?","zero?","pos?","neg?","even?","odd?","finite?","negative-infinity?","positive-infinity?","false?","true?","empty?","not-empty?","vector?","grid?","matrix?"],regularExpression:["regexp","re-match","replace","replace-all"],string:["str","number","lower-case","upper-case","trim","split","join","blank?"],stringUtils:["string.string-repeat","string.from-char-code","string.to-char-code","string.trim-left","string.trim-right","string.pad-left","string.pad-right","string.split-lines","string.template","string.encode-base64","string.decode-base64","string.encode-uri-component","string.decode-uri-component","string.capitalize"],bitwise:["<<",">>",">>>","&","|","xor"],bitwiseUtils:["bitwise.bit-not","bitwise.bit-and-not","bitwise.bit-flip","bitwise.bit-clear","bitwise.bit-set","bitwise.bit-test"],assertion:["assert"],assertionUtils:["assertion.assert=","assertion.assert!=","assertion.assert-gt","assertion.assert-lt","assertion.assert-gte","assertion.assert-lte","assertion.assert-true","assertion.assert-false","assertion.assert-truthy","assertion.assert-falsy","assertion.assert-null","assertion.assert-throws","assertion.assert-throws-error","assertion.assert-not-throws","assertion.assert-array","assertion.assert-boolean","assertion.assert-collection","assertion.assert-function","assertion.assert-grid","assertion.assert-integer","assertion.assert-matrix","assertion.assert-number","assertion.assert-object","assertion.assert-regexp","assertion.assert-sequence","assertion.assert-string","assertion.assert-vector"],grid:["grid.cell-every?","grid.some?","grid.every-row?","grid.some-row?","grid.every-col?","grid.some-col?","grid.row","grid.col","grid.shape","grid.fill","grid.generate","grid.reshape","grid.transpose","grid.flip-h","grid.flip-v","grid.rotate","grid.crop","grid.slice-rows","grid.slice-cols","grid.splice-rows","grid.splice-cols","grid.concat-rows","grid.concat-cols","grid.cell-map","grid.cell-mapi","grid.cell-reduce","grid.cell-reducei","grid.push-rows","grid.unshift-rows","grid.pop-row","grid.shift-row","grid.push-cols","grid.unshift-cols","grid.pop-col","grid.shift-col","grid.from-array"],matrix:["matrix.mul","matrix.det","matrix.inv","matrix.adj","matrix.cofactor","matrix.minor","matrix.trace","matrix.symmetric?","matrix.triangular?","matrix.upper-triangular?","matrix.lower-triangular?","matrix.diagonal?","matrix.square?","matrix.orthogonal-matrix?","matrix.identity?","matrix.invertible?","matrix.hilbert","matrix.vandermonde","matrix.band","matrix.banded?","matrix.rank","matrix.frobenius-norm","matrix.one-norm","matrix.inf-norm","matrix.max-norm"],vector:["sum","mean","median","prod"],vectorUtils:["vector.monotonic?","vector.strictly-monotonic?","vector.increasing?","vector.decreasing?","vector.strictly-increasing?","vector.strictly-decreasing?","vector.mode","vector.min-index","vector.max-index","vector.sort-indices","vector.count-values","vector.linspace","vector.cumsum","vector.cumprod","vector.quartiles","vector.percentile","vector.quantile","vector.histogram","vector.ecdf","vector.outliers?","vector.outliers","vector.bincount","vector.winsorize","vector.mse","vector.mae","vector.rmse","vector.smape",...tc("mean"),...tc("median"),...ec("variance"),...ec("sample-variance"),...tc("sum"),...tc("prod"),...ec("stdev"),...ec("sample-stdev"),...ec("iqr"),...ec("span"),...ec("geometric-mean"),...ec("harmonic-mean"),...ec("skewness"),...ec("sample-skewness"),...ec("kurtosis"),...ec("sample-kurtosis"),...ec("excess-kurtosis"),...ec("sample-excess-kurtosis"),...ec("rms"),...ec("mad"),...ec("medad"),...ec("gini-coefficient"),...ec("entropy"),...ec("skewness")],linAlg:["linear-algebra.reflect","linear-algebra.refract","linear-algebra.lerp","linear-algebra.rotate2d","linear-algebra.rotate3d","linear-algebra.dot","linear-algebra.cross","linear-algebra.normalize-minmax","linear-algebra.normalize-zscore","linear-algebra.normalize-robust","linear-algebra.normalize-l1","linear-algebra.normalize-l2","linear-algebra.normalize-log","linear-algebra.angle","linear-algebra.projection","linear-algebra.orthogonal?","linear-algebra.parallel?","linear-algebra.collinear?","linear-algebra.cosine-similarity","linear-algebra.euclidean-distance","linear-algebra.euclidean-norm","linear-algebra.manhattan-distance","linear-algebra.manhattan-norm","linear-algebra.hamming-distance","linear-algebra.hamming-norm","linear-algebra.chebyshev-distance","linear-algebra.chebyshev-norm","linear-algebra.minkowski-distance","linear-algebra.minkowski-norm","linear-algebra.cov","linear-algebra.corr","linear-algebra.spearman-corr","linear-algebra.pearson-corr","linear-algebra.kendall-tau","linear-algebra.autocorrelation","linear-algebra.cross-correlation","linear-algebra.rref","linear-algebra.solve","linear-algebra.to-polar","linear-algebra.from-polar"],numberTheory:[...Qs("abundant"),...Qs("arithmetic"),...Qs("bell"),...Qs("catalan"),...Qs("composite"),...Qs("deficient"),...Qs("factorial"),...Qs("fibonacci"),...Qs("geometric"),...Qs("golomb"),...Qs("happy"),...Qs("look-and-say"),...Qs("lucas"),...Qs("lucky"),...Qs("mersenne"),...Qs("padovan"),...Qs("partition"),...Qs("pell"),...Qs("perfect"),...Qs("perfect-cube"),...Qs("perfect-power"),...Qs("perfect-square"),...Qs("polygonal"),...Qs("prime"),...Qs("recaman"),...Qs("sylvester"),...Qs("thue-morse"),...Qs("tribonacci"),"number-theory.collatz-seq","number-theory.juggler-seq","number-theory.bernoulli-seq","number-theory.bernoulli-take-while","number-theory.bernoulli-nth","number-theory.combinations","number-theory.count-combinations","number-theory.derangements","number-theory.count-derangements","number-theory.divisors","number-theory.count-divisors","number-theory.proper-divisors","number-theory.count-proper-divisors","number-theory.prime-factors","number-theory.count-prime-factors","number-theory.distinct-prime-factors","number-theory.count-distinct-prime-factors","number-theory.factorial","number-theory.partitions","number-theory.count-partitions","number-theory.permutations","number-theory.count-permutations","number-theory.power-set","number-theory.count-power-set","number-theory.coprime?","number-theory.divisible-by?","number-theory.gcd","number-theory.lcm","number-theory.multinomial","number-theory.amicable?","number-theory.euler-totient","number-theory.mobius","number-theory.mertens","number-theory.sigma","number-theory.carmichael-lambda","number-theory.cartesian-product","number-theory.perfect-power","number-theory.mod-exp","number-theory.mod-inv","number-theory.extended-gcd","number-theory.chinese-remainder","number-theory.stirling-first","number-theory.stirling-second"],random:["random.random!","random.random-int!","random.random-int-inclusive!","random.random-float!","random.random-boolean!","random.random-item!","random.random-sample!","random.random-sample-unique!","random.shuffle!","random.random-normal!","random.random-exponential!","random.random-binomial!","random.random-poisson!","random.random-gamma!","random.random-pareto!","random.uuid!","random.random-char!","random.random-string!","random.random-id!","random.random-color!"],convert:["convert.angstrom->um","convert.angstrom->mm","convert.angstrom->cm","convert.angstrom->m","convert.angstrom->km","convert.angstrom->in","convert.angstrom->ft","convert.angstrom->yd","convert.angstrom->mi","convert.angstrom->nmi","convert.um->angstrom","convert.um->mm","convert.um->cm","convert.um->m","convert.um->km","convert.um->in","convert.um->ft","convert.um->yd","convert.um->mi","convert.um->nmi","convert.mm->angstrom","convert.mm->um","convert.mm->cm","convert.mm->m","convert.mm->km","convert.mm->in","convert.mm->ft","convert.mm->yd","convert.mm->mi","convert.mm->nmi","convert.cm->angstrom","convert.cm->um","convert.cm->mm","convert.cm->m","convert.cm->km","convert.cm->in","convert.cm->ft","convert.cm->yd","convert.cm->mi","convert.cm->nmi","convert.m->angstrom","convert.m->um","convert.m->mm","convert.m->cm","convert.m->km","convert.m->in","convert.m->ft","convert.m->yd","convert.m->mi","convert.m->nmi","convert.km->angstrom","convert.km->um","convert.km->mm","convert.km->cm","convert.km->m","convert.km->in","convert.km->ft","convert.km->yd","convert.km->mi","convert.km->nmi","convert.in->angstrom","convert.in->um","convert.in->mm","convert.in->cm","convert.in->m","convert.in->km","convert.in->ft","convert.in->yd","convert.in->mi","convert.in->nmi","convert.ft->angstrom","convert.ft->um","convert.ft->mm","convert.ft->cm","convert.ft->m","convert.ft->km","convert.ft->in","convert.ft->yd","convert.ft->mi","convert.ft->nmi","convert.yd->angstrom","convert.yd->um","convert.yd->mm","convert.yd->cm","convert.yd->m","convert.yd->km","convert.yd->in","convert.yd->ft","convert.yd->mi","convert.yd->nmi","convert.mi->angstrom","convert.mi->um","convert.mi->mm","convert.mi->cm","convert.mi->m","convert.mi->km","convert.mi->in","convert.mi->ft","convert.mi->yd","convert.mi->nmi","convert.nmi->angstrom","convert.nmi->um","convert.nmi->mm","convert.nmi->cm","convert.nmi->m","convert.nmi->km","convert.nmi->in","convert.nmi->ft","convert.nmi->yd","convert.nmi->mi","convert.mg->g","convert.mg->kg","convert.mg->t","convert.mg->oz","convert.mg->lb","convert.mg->st","convert.g->mg","convert.g->kg","convert.g->t","convert.g->oz","convert.g->lb","convert.g->st","convert.kg->mg","convert.kg->g","convert.kg->t","convert.kg->oz","convert.kg->lb","convert.kg->st","convert.t->mg","convert.t->g","convert.t->kg","convert.t->oz","convert.t->lb","convert.t->st","convert.oz->mg","convert.oz->g","convert.oz->kg","convert.oz->t","convert.oz->lb","convert.oz->st","convert.lb->mg","convert.lb->g","convert.lb->kg","convert.lb->t","convert.lb->oz","convert.lb->st","convert.st->mg","convert.st->g","convert.st->kg","convert.st->t","convert.st->oz","convert.st->lb","convert.ml->cl","convert.ml->dl","convert.ml->l","convert.ml->tsp","convert.ml->tbsp","convert.ml->fl-oz","convert.ml->cup","convert.ml->pt","convert.ml->qt","convert.ml->gal","convert.cl->ml","convert.cl->dl","convert.cl->l","convert.cl->tsp","convert.cl->tbsp","convert.cl->fl-oz","convert.cl->cup","convert.cl->pt","convert.cl->qt","convert.cl->gal","convert.dl->ml","convert.dl->cl","convert.dl->l","convert.dl->tsp","convert.dl->tbsp","convert.dl->fl-oz","convert.dl->cup","convert.dl->pt","convert.dl->qt","convert.dl->gal","convert.l->ml","convert.l->cl","convert.l->dl","convert.l->tsp","convert.l->tbsp","convert.l->fl-oz","convert.l->cup","convert.l->pt","convert.l->qt","convert.l->gal","convert.tsp->ml","convert.tsp->cl","convert.tsp->dl","convert.tsp->l","convert.tsp->tbsp","convert.tsp->fl-oz","convert.tsp->cup","convert.tsp->pt","convert.tsp->qt","convert.tsp->gal","convert.tbsp->ml","convert.tbsp->cl","convert.tbsp->dl","convert.tbsp->l","convert.tbsp->tsp","convert.tbsp->fl-oz","convert.tbsp->cup","convert.tbsp->pt","convert.tbsp->qt","convert.tbsp->gal","convert.fl-oz->ml","convert.fl-oz->cl","convert.fl-oz->dl","convert.fl-oz->l","convert.fl-oz->tsp","convert.fl-oz->tbsp","convert.fl-oz->cup","convert.fl-oz->pt","convert.fl-oz->qt","convert.fl-oz->gal","convert.cup->ml","convert.cup->cl","convert.cup->dl","convert.cup->l","convert.cup->tsp","convert.cup->tbsp","convert.cup->fl-oz","convert.cup->pt","convert.cup->qt","convert.cup->gal","convert.pt->ml","convert.pt->cl","convert.pt->dl","convert.pt->l","convert.pt->tsp","convert.pt->tbsp","convert.pt->fl-oz","convert.pt->cup","convert.pt->qt","convert.pt->gal","convert.qt->ml","convert.qt->cl","convert.qt->dl","convert.qt->l","convert.qt->tsp","convert.qt->tbsp","convert.qt->fl-oz","convert.qt->cup","convert.qt->pt","convert.qt->gal","convert.gal->ml","convert.gal->cl","convert.gal->dl","convert.gal->l","convert.gal->tsp","convert.gal->tbsp","convert.gal->fl-oz","convert.gal->cup","convert.gal->pt","convert.gal->qt","convert.ms->s","convert.ms->min","convert.ms->h","convert.ms->day","convert.ms->week","convert.s->ms","convert.s->min","convert.s->h","convert.s->day","convert.s->week","convert.min->ms","convert.min->s","convert.min->h","convert.min->day","convert.min->week","convert.h->ms","convert.h->s","convert.h->min","convert.h->day","convert.h->week","convert.day->ms","convert.day->s","convert.day->min","convert.day->h","convert.day->week","convert.week->ms","convert.week->s","convert.week->min","convert.week->h","convert.week->day","convert.mm2->cm2","convert.mm2->m2","convert.mm2->km2","convert.mm2->in2","convert.mm2->ft2","convert.mm2->yd2","convert.mm2->acre","convert.mm2->hectare","convert.cm2->mm2","convert.cm2->m2","convert.cm2->km2","convert.cm2->in2","convert.cm2->ft2","convert.cm2->yd2","convert.cm2->acre","convert.cm2->hectare","convert.m2->mm2","convert.m2->cm2","convert.m2->km2","convert.m2->in2","convert.m2->ft2","convert.m2->yd2","convert.m2->acre","convert.m2->hectare","convert.km2->mm2","convert.km2->cm2","convert.km2->m2","convert.km2->in2","convert.km2->ft2","convert.km2->yd2","convert.km2->acre","convert.km2->hectare","convert.in2->mm2","convert.in2->cm2","convert.in2->m2","convert.in2->km2","convert.in2->ft2","convert.in2->yd2","convert.in2->acre","convert.in2->hectare","convert.ft2->mm2","convert.ft2->cm2","convert.ft2->m2","convert.ft2->km2","convert.ft2->in2","convert.ft2->yd2","convert.ft2->acre","convert.ft2->hectare","convert.yd2->mm2","convert.yd2->cm2","convert.yd2->m2","convert.yd2->km2","convert.yd2->in2","convert.yd2->ft2","convert.yd2->acre","convert.yd2->hectare","convert.acre->mm2","convert.acre->cm2","convert.acre->m2","convert.acre->km2","convert.acre->in2","convert.acre->ft2","convert.acre->yd2","convert.acre->hectare","convert.hectare->mm2","convert.hectare->cm2","convert.hectare->m2","convert.hectare->km2","convert.hectare->in2","convert.hectare->ft2","convert.hectare->yd2","convert.hectare->acre","convert.m/s->km/h","convert.m/s->mph","convert.m/s->kn","convert.m/s->ft/s","convert.km/h->m/s","convert.km/h->mph","convert.km/h->kn","convert.km/h->ft/s","convert.mph->m/s","convert.mph->km/h","convert.mph->kn","convert.mph->ft/s","convert.kn->m/s","convert.kn->km/h","convert.kn->mph","convert.kn->ft/s","convert.ft/s->m/s","convert.ft/s->km/h","convert.ft/s->mph","convert.ft/s->kn","convert.b->kb","convert.b->mb","convert.b->gb","convert.b->tb","convert.b->pb","convert.kb->b","convert.kb->mb","convert.kb->gb","convert.kb->tb","convert.kb->pb","convert.mb->b","convert.mb->kb","convert.mb->gb","convert.mb->tb","convert.mb->pb","convert.gb->b","convert.gb->kb","convert.gb->mb","convert.gb->tb","convert.gb->pb","convert.tb->b","convert.tb->kb","convert.tb->mb","convert.tb->gb","convert.tb->pb","convert.pb->b","convert.pb->kb","convert.pb->mb","convert.pb->gb","convert.pb->tb","convert.pa->kpa","convert.pa->bar","convert.pa->atm","convert.pa->psi","convert.pa->mmhg","convert.kpa->pa","convert.kpa->bar","convert.kpa->atm","convert.kpa->psi","convert.kpa->mmhg","convert.bar->pa","convert.bar->kpa","convert.bar->atm","convert.bar->psi","convert.bar->mmhg","convert.atm->pa","convert.atm->kpa","convert.atm->bar","convert.atm->psi","convert.atm->mmhg","convert.psi->pa","convert.psi->kpa","convert.psi->bar","convert.psi->atm","convert.psi->mmhg","convert.mmhg->pa","convert.mmhg->kpa","convert.mmhg->bar","convert.mmhg->atm","convert.mmhg->psi","convert.j->kj","convert.j->cal","convert.j->kcal","convert.j->wh","convert.j->kwh","convert.j->btu","convert.kj->j","convert.kj->cal","convert.kj->kcal","convert.kj->wh","convert.kj->kwh","convert.kj->btu","convert.cal->j","convert.cal->kj","convert.cal->kcal","convert.cal->wh","convert.cal->kwh","convert.cal->btu","convert.kcal->j","convert.kcal->kj","convert.kcal->cal","convert.kcal->wh","convert.kcal->kwh","convert.kcal->btu","convert.wh->j","convert.wh->kj","convert.wh->cal","convert.wh->kcal","convert.wh->kwh","convert.wh->btu","convert.kwh->j","convert.kwh->kj","convert.kwh->cal","convert.kwh->kcal","convert.kwh->wh","convert.kwh->btu","convert.btu->j","convert.btu->kj","convert.btu->cal","convert.btu->kcal","convert.btu->wh","convert.btu->kwh","convert.w->kw","convert.w->mw","convert.w->hp","convert.kw->w","convert.kw->mw","convert.kw->hp","convert.mw->w","convert.mw->kw","convert.mw->hp","convert.hp->w","convert.hp->kw","convert.hp->mw","convert.hz->khz","convert.hz->mhz","convert.hz->ghz","convert.khz->hz","convert.khz->mhz","convert.khz->ghz","convert.mhz->hz","convert.mhz->khz","convert.mhz->ghz","convert.ghz->hz","convert.ghz->khz","convert.ghz->mhz","convert.deg->rad","convert.deg->grad","convert.deg->turn","convert.rad->deg","convert.rad->grad","convert.rad->turn","convert.grad->deg","convert.grad->rad","convert.grad->turn","convert.turn->deg","convert.turn->rad","convert.turn->grad","convert.c->f","convert.c->k","convert.f->c","convert.f->k","convert.k->c","convert.k->f"],shorthand:["-short-regexp","-short-fn"],datatype:["-type-number","-type-string","-type-object","-type-array","-type-vector","-type-matrix","-type-grid","-type-boolean","-type-function","-type-integer","-type-any","-type-null","-type-collection","-type-sequence","-type-regexp","-type-never"]},nc=[...[...[...rc.collection,...rc.array,...rc.sequence,...rc.math,...rc.functional,...rc.meta,...rc.misc,...rc.object,...rc.predicate,...rc.regularExpression,...rc.string,...rc.bitwise,...rc.vector,...rc.assertion],...[...rc.matrix,...rc.vectorUtils,...rc.linAlg,...rc.grid,...rc.numberTheory,...rc.random,...rc.mathUtils,...rc.functionalUtils,...rc.assertionUtils,...rc.stringUtils,...rc.collectionUtils,...rc.sequenceUtils,...rc.bitwiseUtils,...rc.convert]],...rc.shorthand,...rc.datatype];function oc(e){return nc.includes(e)}export{Xs as Lits,Zs as allBuiltinModules,ui as apiReference,k as asLitsFunction,z as asNativeJsFunction,N as asUserDefinedFunction,q as assertLitsFunction,Dr as assertModule,S as assertNativeJsFunction,$ as assertUserDefinedFunction,Ma as bitwiseUtilsModule,Ea as functionalUtilsModule,Br as gridModule,oc as isApiName,E as isBuiltinFunction,ii as isCustomReference,Ir as isDataType,ci as isDatatypeReference,ai as isFunctionReference,rt as isGrid,vs as isLitsBundle,i as isLitsError,w as isLitsFunction,ot as isMatrix,T as isNativeJsFunction,si as isShorthandReference,A as isUserDefinedFunction,Xe as isVector,_n as linearAlgebraModule,Sa as mathUtilsModule,to as matrixModule,Nr as normalExpressionKeys,ha as numberTheoryModule,Yr as randomModule,$r as specialExpressionKeys,Cn as vectorModule};
|
|
1
|
+
function e(e){if(!e.position||!e.code)return"";const t=e.position.column-1,r=e.code.length-t-1;return`${" ".repeat(Math.max(t,0))}^${" ".repeat(Math.max(r,0))}`}class t extends Error{params;constructor(e){super(`recur, params: ${e}`),Object.setPrototypeOf(this,t.prototype),this.name="RecurSignal",this.params=e}}class r extends Error{sourceCodeInfo;shortMessage;constructor(t,n){const o=t instanceof Error?t.message:`${t}`;super(function(t,r){if(!r)return t;const n=`${r.position.line}:${r.position.column}`;return`${t}${r.filePath?`\n${r.filePath}:${n}`:`\nLocation ${n}`}\n${r.code}\n${e(r)}`}(o,n)),this.shortMessage=o,this.sourceCodeInfo=n,Object.setPrototypeOf(this,r.prototype),this.name="LitsError"}getCodeMarker(){return this.sourceCodeInfo&&e(this.sourceCodeInfo)}}class n extends r{userMessage;constructor(e,t){super(e,t),this.userMessage=e,Object.setPrototypeOf(this,n.prototype),this.name="UserDefinedError"}}class o extends r{constructor(e,t){super(e,t),Object.setPrototypeOf(this,o.prototype),this.name="AssertionError"}}class a extends r{symbol;constructor(e,t){super(`Undefined symbol '${e}'.`,t),this.symbol=e,Object.setPrototypeOf(this,a.prototype),this.name="UndefinedSymbolError"}}function i(e){return e instanceof r}const s={Number:1,String:2,NormalExpression:3,SpecialExpression:4,UserDefinedSymbol:5,NormalBuiltinSymbol:6,SpecialBuiltinSymbol:7,ReservedSymbol:8,Binding:9,Spread:10},c=new Set(Object.values(s));function l(e){return Object.keys(s).find(t=>s[t]===e)}const m=new Set(["UserDefined","Partial","Comp","Constantly","Juxt","Complement","EveryPred","SomePred","Fnull","Builtin","SpecialBuiltin","NativeJsFunction","Module"]);const u="^^fn^^",p="^^re^^";function g(e){return null!==e&&"object"==typeof e&&(u in e&&"functionType"in e&&function(e){return"string"==typeof e&&m.has(e)}(e.functionType))}function h(e){return!(!Array.isArray(e)||e.length<2)&&function(e){return"number"==typeof e&&c.has(e)}(e[0])}function d(e){return g(e)?`<function ${e.name||"λ"}>`:h(e)?`${l(e[0])}-node`:null===e?"null":"object"==typeof e&&e instanceof RegExp?`${e}`:"object"==typeof e&&e instanceof Error?e.toString():JSON.stringify(e)}function y(e,t){return e?.sourceCodeInfo??t}function v(e,t,n){return new r(`Expected ${e}, got ${d(t)}.`,y(t,n))}function f(e,t){return b(e,t),e}function b(e,t){if(!function(e){return void 0!==e}(e))throw new r("Unexpected undefined",y(e,t))}function x(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function w(e){return null!==e&&"object"==typeof e&&!!e[u]}function k(e,t){return q(e,t),e}function q(e,t){if(!w(e))throw v("LitsFunction",e,t)}function A(e){return w(e)&&"UserDefined"===e.functionType}function N(e,t){return $(e,t),e}function $(e,t){if(!A(e))throw v("NativeJsFunction",e,t)}function T(e){return w(e)&&"NativeJsFunction"===e.functionType}function z(e,t){return S(e,t),e}function S(e,t){if(!T(e))throw v("NativeJsFunction",e,t)}function E(e){return x(e)&&"Builtin"===e.functionType}function j(e){return void 0!==e}function M(e,t){return C(e,t),e}function C(e,t){if(!j(e))throw v("not undefined",e,t)}function P(e){return Array.isArray(e)||"string"==typeof e}function R(e,t){return I(e,t),e}function I(e,t){if(!P(e))throw v("string or array",e,t)}function O(e){return!(null===e||"object"!=typeof e||Array.isArray(e)||e instanceof RegExp||w(e)||G(e))}function F(e,t){if(!O(e))throw v("object",e,t)}function U(e){return P(e)||O(e)}function D(e,t){return W(e,t),e}function W(e,t){if(!U(e))throw v("string, array or object",e,t)}function G(e){return null!==e&&"object"==typeof e&&!!e[p]}function V(e,t){if(!function(e){return G(e)||"string"==typeof e}(e))throw v("string or RegularExpression",e,t)}function B(e,t){return L(e,t),e}function L(e,t){if(!function(e){return"number"==typeof e||!!U(e)||!!w(e)}(e))throw v("FunctionLike",e,t)}function _(e,t={}){return"string"==typeof e&&((!t.nonEmpty||0!==e.length)&&(!t.char||1===e.length))}function K(e,t,r={}){if(!_(e,r))throw v(""+(r.nonEmpty?"non empty string":r.char?"character":"string"),e,t)}function J(e,t,r={}){return K(e,t,r),e}function Y(e){return"string"==typeof e||"number"==typeof e}function H(e,t){return X(e,t),e}function X(e,t){if(!Y(e))throw v("string or number",e,t)}const Z={assert:{evaluate:(e,t)=>{const r=e[0],n=2===e.length?e[1]:`${r}`;if(K(n,t),!r)throw new o(n,t);return M(r,t)},arity:{min:1,max:2},docs:{category:"assertion",description:"If $value is falsy it throws `AssertionError` with $message. If no $message is provided, message is set to $value.",returns:{type:"any"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['try assert(0, "Expected a positive value") catch (e) e.message end'],seeAlso:["assertion.assert-truthy","assertion.assert-true"],hideOperatorForm:!0}}};function Q(e,t={}){return"number"==typeof e&&(!Number.isNaN(e)&&(!(t.integer&&!Number.isInteger(e))&&(!(t.finite&&!Number.isFinite(e))&&((!t.zero||0===e)&&((!t.nonZero||0!==e)&&(!(t.positive&&e<=0)&&(!(t.negative&&e>=0)&&(!(t.nonPositive&&e>0)&&(!(t.nonNegative&&e<0)&&(!("number"==typeof t.gt&&e<=t.gt)&&(!("number"==typeof t.gte&&e<t.gte)&&(!("number"==typeof t.lt&&e>=t.lt)&&!("number"==typeof t.lte&&e>t.lte)))))))))))))}function ee(e,t,n={}){if(!Q(e,n))throw new r(`Expected ${function(e){if(e.zero)return"zero";const t=function(e){return e.positive?"positive":e.negative?"negative":e.nonNegative?"non negative":e.nonPositive?"non positive":e.nonZero?"non zero":""}(e),r=e.integer?"integer":"number",n=e.finite?"finite":"",o=function(e){return"number"!=typeof e.gt&&"number"!=typeof e.gte||"number"!=typeof e.lt&&"number"!=typeof e.lte?"number"==typeof e.gt||"number"==typeof e.gte?"number"==typeof e.gt?`n > ${e.gt}`:`n >= ${e.gte}`:"number"==typeof e.lt||"number"==typeof e.lte?"number"==typeof e.lt?`n < ${e.lt}`:`n <= ${e.lte}`:"":`${"number"==typeof e.gt?`${e.gt} < n `:`${e.gte} <= n `}${"number"==typeof e.lt?`< ${e.lt}`:`<= ${e.lte}`}`}(e);return[t,n,r,o].filter(e=>!!e).join(" ")}(n)}, got ${d(e)}.`,y(e,t))}function te(e,t,r={}){return ee(e,t,r),e}function re(e){return"number"==typeof e||U(e)?ae(1):e.arity}function ne(e,t,n){const{min:o,max:a}=e;if("number"==typeof o&&t<o)throw new r(`Wrong number of arguments, expected at least ${o}, got ${d(t)}.`,n);if("number"==typeof a&&t>a)throw new r(`Wrong number of arguments, expected at most ${a}, got ${d(t)}.`,n)}function oe(e){return!("number"==typeof e.max&&e.max<2)&&!("number"==typeof e.min&&e.min>2)}function ae(e){return{min:e,max:e}}function ie(e,t){return{a:{type:e},b:{type:t}}}const se={"<<":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0}),e<<t),arity:ae(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ie("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Shifts $a arithmetically left by $b bit positions.",seeAlso:[">>",">>>"],examples:["1 << 10","<<(1, 10)","<<(-4, 2)"]}},">>":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0}),e>>t),arity:ae(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ie("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Shifts $a arithmetically right by $b bit positions.",seeAlso:["<<",">>>"],examples:["2048 >> 10",">>(2048, 10)",">>>(-16, 2)",">>(4, 10)"]}},">>>":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0}),e>>>t),arity:ae(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ie("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Shifts $a arithmetically right by $b bit positions without sign extension.",seeAlso:["<<",">>"],examples:["-16 >>> 2",">>>(2048, 10)",">>>(-16, 2)",">>>(4, 10)",">>>(-1, 10)"]}},"&":{evaluate:([e,...t],r)=>(ee(e,r,{integer:!0}),t.reduce((e,t)=>(ee(t,r,{integer:!0}),e&t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...ie("integer","integer"),c:{type:"integer",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Returns bitwise `and` of all arguments.",seeAlso:["|","xor","bitwise.bit-not","bitwise.bit-and-not"],examples:["0b0011 & 0b0110","&(0b0011, 0b0110)","&(0b0011, 0b0110, 0b1001)"]}},"|":{evaluate:([e,...t],r)=>(ee(e,r,{integer:!0}),t.reduce((e,t)=>(ee(t,r,{integer:!0}),e|t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...ie("integer","integer"),c:{type:"integer",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Returns bitwise `or` of all arguments.",seeAlso:["&","xor","bitwise.bit-not","bitwise.bit-and-not"],examples:["0b0011 | 0b0110","|(0b0011, 0b0110)","|(0b1000, 0b0100, 0b0010)"]}},xor:{evaluate:([e,...t],r)=>(ee(e,r,{integer:!0}),t.reduce((e,t)=>(ee(t,r,{integer:!0}),e^t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...ie("integer","integer"),c:{type:"integer",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Returns bitwise `xor` of all arguments.",seeAlso:["&","|","bitwise.bit-not","bitwise.bit-and-not"],examples:["0b0011 xor 0b0110","xor(0b0011, 0b0110)","xor(0b11110000, 0b00111100, 0b10101010)"]}}};function ce(e,t){return!!U(e)&&("string"==typeof e||Array.isArray(e)?!!Q(t,{integer:!0})&&(t>=0&&t<e.length):!!Object.getOwnPropertyDescriptor(e,t))}function le(e,t,n){if(X(e,n),X(t,n),"string"==typeof e&&"string"==typeof t)return e<t?-1:e>t?1:0;if("number"==typeof e&&"number"==typeof t)return Math.sign(e-t);throw new r(`Cannot compare values of different types: ${typeof e} and ${typeof t}`,n)}function me(e,t,r){if(e===t)return!0;if("number"==typeof e&&"number"==typeof t)return fe(e,t);if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!me(M(e[n],r),M(t[n],r),r))return!1;return!0}if(G(e)&&G(t))return e.s===t.s&&e.f===t.f;if(x(e)&&x(t)){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const a=J(n[o],r);if(!me(e[a],t[a],r))return!1}return!0}return!1}function ue(e){return Math.max(0,Math.ceil(e))}function pe(e){return e??null}function ge(e){return O(e)?Object.entries(e).reduce((e,t)=>{const[r,n]=t;return e[r]=ge(n),e},{}):Array.isArray(e)?e.map(e=>ge(e)):e}function he(e){return ge(e)}function de(...e){const t=new Set;for(const r of e)r.forEach(e=>t.add(e));return t}function ye(e,t){t.forEach(t=>e.add(t))}const ve=1e-10;function fe(e,t,r=ve){if(e===t)return!0;const n=Math.abs(e-t);if(0===e||0===t||n<r)return n<r;return n/(Math.abs(e)+Math.abs(t))<r}function be(e){return Math.abs(e)<ve}function xe(e,t=0){const r=e.split("\n");for(;r[0]?.match(/^\s*$/);)r.shift();for(;r[r.length-1]?.match(/^\s*$/);)r.pop();const n=r.reduce((e,t)=>{if(t.match(/^\s*$/))return e;const r=t.match(/^\s*/)[0].length;return Math.min(e,r)},1/0);return r.map(e=>" ".repeat(t)+e.slice(n)).join("\n").trimEnd()}function we(e,t){if(!Array.isArray(e))throw v("array",e,t)}function ke(e,t){if(!function(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e)}(e))throw v("array of strings",e,t)}function qe(e,t){if(!function(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e&&1===e.length)}(e))throw v("array of strings",e,t)}function Ae(e,t){return e instanceof Promise?e.then(t):t(e)}function Ne(e,t){const r=[];for(let n=0;n<e.length;n++){const o=t(e[n],n);if(o instanceof Promise)return $e(o,r,e,t,n);r.push(o)}return r}async function $e(e,t,r,n,o){t.push(await e);for(let e=o+1;e<r.length;e++)t.push(await n(r[e],e));return t}function Te(e,t,r){let n=r;for(let r=0;r<e.length;r++){const o=t(n,e[r],r);if(o instanceof Promise)return ze(o,e,t,r);n=o}return n}async function ze(e,t,r,n){let o=await e;for(let e=n+1;e<t.length;e++)o=await r(o,t[e],e);return o}function Se(e,t){for(let r=0;r<e.length;r++){const n=t(e[r],r);if(n instanceof Promise)return Ee(n,e,t,r)}}async function Ee(e,t,r,n){await e;for(let e=n+1;e<t.length;e++)await r(t[e],e)}function je(e,t){try{const r=e();return r instanceof Promise?r.catch(t):r}catch(e){return t(e)}}function Me(e,t){for(let r=0;r<e.length;r++){const n=t(e[r],r);if(n instanceof Promise)return Ce(n,e,t,r);if(n)return!0}return!1}async function Ce(e,t,r,n){if(await e)return!0;for(let e=n+1;e<t.length;e++)if(await r(t[e],e))return!0;return!1}function Pe(e,t){for(let r=0;r<e.length;r++){const n=t(e[r],r);if(n instanceof Promise)return Re(n,e,t,r);if(!n)return!1}return!0}async function Re(e,t,r,n){if(!await e)return!1;for(let e=n+1;e<t.length;e++)if(!await r(t[e],e))return!1;return!0}function Ie(e,t){const r=[];for(let n=0;n<e.length;n++){const o=t(e[n],n);if(o instanceof Promise)return Oe(o,r,e,t,n);o&&r.push(e[n])}return r}async function Oe(e,t,r,n,o){await e&&t.push(r[o]);for(let e=o+1;e<r.length;e++)await n(r[e],e)&&t.push(r[e]);return t}function Fe(e,t){for(let r=0;r<e.length;r++){const n=t(e[r],r);if(n instanceof Promise)return Ue(n,e,t,r);if(n)return r}return-1}async function Ue(e,t,r,n){if(await e)return n;for(let e=n+1;e<t.length;e++)if(await r(t[e],e))return e;return-1}const De={filter:{evaluate:([e,t],r,n,{executeFunction:o})=>{if(W(e,r),L(t,r),Array.isArray(e))return Te(e,(e,a)=>Ae(o(t,[a],n,r),t=>(t&&e.push(a),e)),[]);if(_(e)){return Ae(Te(e.split(""),(e,a)=>Ae(o(t,[a],n,r),t=>(t&&e.push(a),e)),[]),e=>e.join(""))}return Te(Object.entries(e),(e,[a,i])=>Ae(o(t,[i],n,r),t=>(t&&(e[a]=i),e)),{})},arity:ae(2),docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function"},coll:{type:"collection"},fun:{type:"function"}},variants:[{argumentNames:["coll","fun"]}],description:"Creates a new collection with all elements that pass the test implemented by $fun.",seeAlso:["collection.filteri","map","sequence.remove"],examples:['\nfilter(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nfilter(\n [5, 10, 15, 20],\n -> $ > 10\n)","\nfilter(\n { a: 1, b: 2 },\n odd?\n)"]}},map:{evaluate:(e,t,n,{executeFunction:o})=>{const a=B(e.at(-1),t);if(O(e[0]))return function({colls:e,contextStack:t,executeFunction:n,fn:o,sourceCodeInfo:a}){F(e[0],a);const i=Object.keys(e[0]),s={};return e.forEach(e=>{F(e,a);const t=Object.keys(e);if(t.length!==i.length)throw new r(`All objects must have the same keys. Expected: ${i.join(", ")}. Found: ${t.join(", ")}`,a);if(!t.every(e=>i.includes(e)))throw new r(`All objects must have the same keys. Expected: ${i.join(", ")}. Found: ${t.join(", ")}`,a);Object.entries(e).forEach(([e,t])=>{s[e]||(s[e]=[]),s[e].push(t)})}),Te(i,(e,r)=>Ae(n(o,s[r],t,a),t=>(e[r]=t,e)),{})}({colls:e.slice(0,-1),fn:a,sourceCodeInfo:t,contextStack:n,executeFunction:o});const i=e.slice(0,-1);I(i[0],t);const s="string"==typeof i[0];let c=i[0].length;i.slice(1).forEach(e=>{s?K(e,t):we(e,t),c=Math.min(c,e.length)});const l=[];for(let e=0;e<c;e++)l.push(i.map(t=>t[e]));const m=Ne(l,e=>o(a,e,n,t));return s?Ae(m,e=>(e.forEach(e=>K(e,t)),e.join(""))):m},arity:{min:2},docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function"},colls:{type:"collection",rest:!0,description:"At least one."},fun:{type:"function"}},variants:[{argumentNames:["colls","fun"]}],description:"Creates a new collection populated with the results of calling $fun on every element in $colls.",seeAlso:["collection.mapi","filter","reduce","mapcat","grid.cell-map","grid.cell-mapi"],examples:["[1, 2, 3] map -","[1, 2, 3] map -> -($)",'map(["Albert", "Mojir", 42], str)',"map([1, 2, 3], inc)","map([1, 2, 3], [1, 10, 100], *)","map({ a: 1, b: 2 }, inc)","map({ a: 1, b: 2 }, { a: 10, b: 20 }, +)"]}},reduce:{evaluate:([e,t,r],n,o,{executeFunction:a})=>(W(e,n),L(t,n),C(r,n),"string"==typeof e?(K(r,n),0===e.length?r:Te(e.split(""),(e,r)=>a(t,[e,r],o,n),r)):Array.isArray(e)?0===e.length?r:Te(e,(e,r)=>a(t,[e,r],o,n),r):0===Object.keys(e).length?r:Te(Object.entries(e),(e,[,r])=>a(t,[e,r],o,n),r)),arity:ae(3),docs:{category:"collection",returns:{type:"any"},args:{fun:{type:"function"},coll:{type:"collection"},initial:{type:"any"}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Runs $fun function on each element of the $coll, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value.",seeAlso:["collection.reduce-right","collection.reducei","collection.reductions","map","grid.cell-reduce","grid.cell-reducei"],examples:["reduce([1, 2, 3], +, 0)","reduce([], +, 0)","reduce({ a: 1, b: 2 }, +, 0)","\nreduce(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + (even?(value) ? value : 0),\n 0)"]}},get:{evaluate:(e,t)=>{const[r,n]=e,o=pe(e[2]);if(X(n,t),null===r)return o;W(r,t);const a=function(e,t){if(O(e)){if("string"==typeof t&&ce(e,t))return pe(e[t])}else if(Q(t,{nonNegative:!0,integer:!0})&&t>=0&&t<e.length)return pe(e[t])}(r,n);return void 0===a?o:a},arity:{min:2,max:3},docs:{category:"collection",returns:{type:"any"},args:{a:{type:"collection"},b:{type:["string","integer"]},"not-found":{type:"any",description:"Default value to return if $b is not found."}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","not-found"]}],description:"Returns value in $a mapped at $b.",seeAlso:["collection.get-in","contains?","find","nth"],examples:["[1, 2, 3] get 1",'{ a: 1 } get "a"','"Albert" get "3"',"\nget(\n [1, 2, 3],\n 1, // Optional comma after last argument\n)","\nget(\n [],\n 1\n)",'\nget(\n [],\n 1,\n "default"\n)','\nget(\n { a: 1 },\n "a"\n)','\nget(\n { a: 1 },\n "b"\n)','\nget(\n { a: 1 },\n "b",\n "default"\n)','\nget(\n null,\n "a"\n)','\nget(\n null,\n "b",\n "default"\n)']}},count:{evaluate:([e],t)=>null===e?0:"string"==typeof e?e.length:(W(e,t),Array.isArray(e)?e.length:Object.keys(e).length),arity:ae(1),docs:{category:"collection",returns:{type:"number"},args:{coll:{type:["collection","null"]}},variants:[{argumentNames:["coll"]}],description:"Returns number of elements in $coll.",seeAlso:["empty?"],examples:["count([1, 2, 3])","count([])","count({ a: 1 })",'count("")','count("Albert")',"count(null)"]}},"contains?":{evaluate:([e,t],r)=>null!==e&&(W(e,r),_(e)?(K(t,r),e.includes(t)):P(e)?(C(t,r),!!e.find(e=>me(M(e),t,r))):(K(t,r),t in e)),arity:ae(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:["collection","null"]},b:{type:["string","integer"]}},variants:[{argumentNames:["a","b"]}],description:"Returns `true` if $a contains $b, otherwise returns `false`. For strings, it checks if substring is included.",seeAlso:["get","find","index-of"],examples:["[1, 2, 3] contains? 1","null contains? 1",'{ a: 1, b: 2 } contains? "a"',"\ncontains?(\n [],\n 1\n)","\ncontains?(\n [1],\n 1\n)","\ncontains?(\n [1, 2, 3],\n 1\n)",'\ncontains?(\n {},\n "a"\n)','\ncontains?(\n { a: 1, b: 2 },\n "a"\n)']}},assoc:{evaluate:([e,t,r],n)=>(W(e,n),X(t,n),C(r,n),function(e,t,r,n){if(W(e,n),X(t,n),Array.isArray(e)||"string"==typeof e){if(ee(t,n,{integer:!0}),ee(t,n,{gte:0}),ee(t,n,{lte:e.length}),"string"==typeof e)return K(r,n,{char:!0}),`${e.slice(0,t)}${r}${e.slice(t+1)}`;const o=[...e];return o[t]=r,o}K(t,n);const o={...e};return o[t]=r,o}(e,t,r,n)),arity:ae(3),docs:{category:"collection",returns:{type:"collection"},args:{coll:{type:"collection"},key:{type:["string","number"]},value:{type:"any"},kvs:{type:"any",description:"Key-value pairs to associate.",rest:!0}},variants:[{argumentNames:["coll","key","value"]},{argumentNames:["coll","key","value","kvs"]}],description:"\nAdd or replace the value of element $key to $value in $coll. Repeated for all key-value pairs in $kvs.\nIf $coll is an 'array', $key must be `number` satisfying `0 <=` $key `<= length`.",seeAlso:["collection.assoc-in","dissoc","merge","collection.update"],examples:['\nassoc(\n [1, 2, 3],\n 1,\n "Two"\n)','\nassoc(\n [1, 2, 3],\n 3,\n "Four"\n)','\nassoc(\n { a: 1, b: 2 },\n "a",\n "One")','\nassoc(\n { a: 1, b: 2 },\n "c",\n "Three")','\nassoc(\n "Albert",\n 6,\n "a")']}},"++":{evaluate:(e,t)=>(Q(e[0])||W(e[0],t),Array.isArray(e[0])?e.reduce((e,r)=>(we(r,t),e.concat(r)),[]):Y(e[0])?e.reduce((e,r)=>(X(r,t),`${e}${r}`),""):e.reduce((e,r)=>(F(r,t),Object.assign(e,r)),{})),arity:{min:1},docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"collection"},colls:{type:"collection",rest:!0}},variants:[{argumentNames:["a"]},{argumentNames:["a","colls"]}],description:"Concatenates collections into one collection.",seeAlso:["mapcat","str","join","push","sequence.unshift"],examples:['"Albert" ++ " " ++ "Mojir"','"Albert" ++ "Mojir"','++("Albert", "-", "Mojir")','++("Albert")','++("A", "l", "b", "e", "r", "t")',"++([1, 2], [3, 4])","++([], [3, 4])","++([1, 2], [])","++([1, 2], [3, 4], [5, 6])","++([])","++({ a: 1, b: 2 }, { b: 1, c: 2 })","++({}, { a: 1 })"]}}},We={range:{evaluate:(e,t)=>{const[r,n,o]=e;let a,i,s;ee(r,t,{finite:!0}),1===e.length?(a=0,i=r,s=i>=0?1:-1):2===e.length?(ee(n,t,{finite:!0}),a=r,i=n,s=i>=a?1:-1):(ee(n,t,{finite:!0}),ee(o,t,{finite:!0}),a=r,i=n,s=o,ee(s,t,i>a?{positive:!0}:i<a?{negative:!0}:{nonZero:!0}));const c=[];for(let e=a;s<0?e>i:e<i;e+=s)c.push(e);return c},arity:{min:1,max:3},docs:{category:"array",returns:{type:"number",array:!0},args:{a:{type:"number"},b:{type:"number"},step:{type:"number"}},variants:[{argumentNames:["b"]},{argumentNames:["a","b"]},{argumentNames:["a","b","step"]}],description:"$range creates an array with a range of numbers from $a to $b (exclusive), by $step.\n\n$a defaults to 0.\n$step defaults to 1.",seeAlso:["repeat","vector.linspace"],examples:["range(4)","range(1, 4)","1 range 10","range(0.4, 4.9)","\nrange(\n 0.25, // start value\n 1, // end value (exclusive)\n 0.25, // step value\n)"]}},repeat:{evaluate:([e,t],r)=>{ee(t,r,{integer:!0,nonNegative:!0});const n=[];for(let r=0;r<t;r+=1)n.push(e);return n},arity:ae(2),docs:{category:"array",returns:{type:"any",array:!0},args:{a:{type:"any"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],description:"Returns an array with $a repeated $b times.",seeAlso:["range","string.string-repeat"],examples:["repeat(10, 3)","repeat(10, 0)",'"Albert" repeat 5']}},flatten:{evaluate:([e,t],r)=>{we(e,r);const n=void 0===t||t===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:te(t,r,{integer:!0,nonNegative:!0});return e.flat(n)},arity:{min:1,max:2},docs:{category:"array",returns:{type:"any",array:!0},args:{x:{type:["array","any"],description:"If $x is not an array, `[ ]` is returned."}},variants:[{argumentNames:["x"]}],description:"Takes a nested array $x and flattens it.",seeAlso:["mapcat"],examples:["flatten([1, 2, [3, 4], 5])",'\nlet foo = "bar";\nflatten([\n 1,\n " 2 A ",\n [foo, [4, ["ABC"]]],\n 6,\n])'],hideOperatorForm:!0}},mapcat:{evaluate:([e,t],r,n,{executeFunction:o})=>(we(e,r),L(t,r),Ae(Ne(e,e=>o(t,[e],n,r)),e=>e.flat(1))),arity:ae(2),docs:{category:"array",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function"},colls:{type:"collection",array:!0},fun:{type:"function"}},variants:[{argumentNames:["colls","fun"]}],description:"Returns the result of applying concat to the result of applying map to $fun and $colls.",seeAlso:["flatten","map","++"],examples:["[[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]] mapcat reverse","mapcat([[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]], reverse)","[[3, 2, 1, 0,], [6, 5, 4,], [9, 8, 7]] mapcat reverse","\nlet foo = (n) -> do\n [n - 1, n, n + 1]\nend;\n[1, 2, 3] mapcat foo","\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ filter odd?\n)"]}},"moving-fn":{evaluate:([e,t,r],n,o,{executeFunction:a})=>{we(e,n),ee(t,n,{integer:!0,lte:e.length}),L(r,n);const i=[];for(let r=0;r<=e.length-t;r++)i.push(e.slice(r,r+t));return Ne(i,e=>a(r,[e],o,n))},arity:ae(3),docs:{category:"array",returns:{type:"array"},args:{arr:{type:"array"},windowSize:{type:"number",description:"The size of the moving window."},fn:{type:"function"}},variants:[{argumentNames:["arr","windowSize","fn"]}],description:"Returns the result of applying $fn to each moving window of size $windowSize in $arr.",seeAlso:["running-fn","vector.moving-mean"],examples:["moving-fn([1, 2, 3], 2, sum)","moving-fn([1, 2, 3], 1, sum)","moving-fn([1, 2, 3], 3, sum)"]}},"running-fn":{evaluate:([e,t],r,n,{executeFunction:o})=>{we(e,r),L(t,r);const a=[];for(let t=0;t<e.length;t+=1)a.push(e.slice(0,t+1));return Ne(a,e=>o(t,[e],n,r))},arity:ae(2),docs:{category:"array",returns:{type:"array"},args:{a:{type:"array"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns the result of applying $b to each element of $a.",seeAlso:["moving-fn","vector.running-mean"],examples:["running-fn([1, 2, 3], sum)","running-fn([1, 2, 3], max)","running-fn([1, 2, 3], min)"]}}},Ge={nth:{evaluate:(e,t)=>{const[r,n]=e,o=pe(e[2]);if(ee(n,t,{integer:!0}),null===r)return o;if(I(r,t),n>=0&&n<r.length){return pe(r[n])}return o},arity:{min:2,max:3},docs:{category:"sequence",returns:{type:"any"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:["sequence","null"]},n:{type:"integer"},"not-found":{type:"any"}},variants:[{argumentNames:["seq","n"]},{argumentNames:["seq","n","not-found"]}],description:"Accesses element $n of $seq. Accessing out-of-bounds indices returns $not-found, if present, else `null`.",seeAlso:["first","second","last","get","slice"],examples:["[1, 2, 3] nth 1",'"A string" nth 3',"nth([1, 2, 3], 1)","nth([1, 2, 3], 3)","nth([1, 2, 3], -1)","nth([1, 2, 3], 3, 99)",'nth("A string", 1)','nth("A string", 3)','nth("A string", -3)','nth("A string", 30, "X")',"nth(null, 1)",'nth(null, 1, "Default value")']}},first:{evaluate:([e],t)=>{if(null===e)return null;I(e,t);return pe(e[0])},arity:ae(1),docs:{category:"sequence",returns:{type:"any"},args:{seq:{type:["sequence","null"]}},variants:[{argumentNames:["seq"]}],description:"Returns the first element of $seq. If $seq is empty or `null`, `null` is returned.",seeAlso:["second","last","nth","rest","next"],examples:['first(["Albert", "Mojir", 160, [1, 2]])',"first([])","first(null)"]}},last:{evaluate:([e],t)=>{if(null===e)return null;I(e,t);return pe(e.at(-1))},arity:ae(1),docs:{category:"sequence",returns:{type:"any"},args:{seq:{type:["sequence","null"]}},variants:[{argumentNames:["seq"]}],description:"Returns the last element of $seq. If $seq is empty, `null` is returned.",seeAlso:["first","second","nth","pop"],examples:['last(["Albert", "Mojir", 160, [1, 2]])',"last([1, 2])","last([1])","last([])","last(null)"]}},pop:{evaluate:([e],t)=>(I(e,t),"string"==typeof e?e.substring(0,e.length-1):e.slice(0,e.length-1)),arity:ae(1),docs:{category:"sequence",returns:{type:["sequence","null"],rest:!0},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"Returns a copy of $seq with last element removed. If $seq is empty `null` is returned.",seeAlso:["push","last"],examples:["pop([1, 2, 3])","pop([])"]}},"index-of":{evaluate:([e,t],r)=>{if(C(t,r),null===e)return null;if(I(e,r),"string"==typeof e){K(t,r);const n=e.indexOf(t);return-1!==n?n:null}{const n=e.findIndex(e=>me(M(e,r),t),r);return-1!==n?n:null}},arity:ae(2),docs:{category:"sequence",returns:{type:["number","null"]},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:["sequence","null"]},x:{type:"any"}},variants:[{argumentNames:["seq","x"]}],description:"Returns the index of $x in $seq. If element is not present in $seq `null` is returned.",seeAlso:["sequence.last-index-of","sequence.position","contains?"],examples:["[[1], [2], [1], [2]] index-of [1]",'index-of(["Albert", "Mojir", 160, [1, 2]], "Mojir")',"index-of([5, 10, 15, 20], 15)","index-of([5, 10, 15, 20], 1)","index-of(null, 1)"]}},push:{evaluate:([e,...t],r)=>(I(e,r),"string"==typeof e?(qe(t,r),[e,...t].join("")):[...e,...t]),arity:{min:2},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:"sequence"},values:{type:"any",rest:!0,description:"At least one."}},variants:[{argumentNames:["seq","values"]}],description:"Returns copy of $seq with $values added to the end of it.",seeAlso:["sequence.unshift","pop","++"],examples:["[1, 2, 3] push 4",'"Albert" push "!"',"push([1, 2, 3], 4)","push([1, 2, 3], 4, 5, 6)","\nlet l = [1, 2, 3];\npush(l, 4);\nl"]}},rest:{evaluate:([e],t)=>(I(e,t),Array.isArray(e)?e.length<=1?[]:e.slice(1):e.substring(1)),arity:ae(1),docs:{category:"sequence",returns:{type:["sequence","null"]},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"If $seq is an array, returns a new array with all but the first element from $seq.\nIf $seq has less than two elements, an empty array is returned.\nFor string $seq returns all but the first characters in $seq.",seeAlso:["next","first"],examples:['rest(["Albert", "Mojir", 160, [1, 2]])','rest(["Albert"])',"rest([])",'rest("Albert")','rest("A",)','rest("")']}},next:{evaluate:([e],t)=>(I(e,t),Array.isArray(e)?e.length<=1?null:e.slice(1):e.length<=1?null:e.substring(1)),arity:ae(1),docs:{category:"sequence",returns:{type:["sequence","null"]},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"If $seq is an array, returns a new array with all but the first element from $seq. If $seq has less than two elements, `null` is returned. For string $seq returns all but the first characters in $seq. If length of string $seq is less than two, `null` is returned.",seeAlso:["rest","first"],examples:['next(["Albert", "Mojir", 160, [1, 2]])','next(["Albert"])',"next([])",'next("Albert")','next("A",)','next("")']}},reverse:{evaluate:([e],t)=>null===e?null:(I(e,t),Array.isArray(e)?[...e].reverse():e.split("").reverse().join("")),arity:ae(1),docs:{category:"sequence",returns:{type:["sequence","null"]},args:{seq:{type:["sequence","null"]}},variants:[{argumentNames:["seq"]}],description:"If $seq is an array, creates a new array with the elements from $seq in reversed order. If $seq is a string, returns new reversed string.",seeAlso:["sort"],examples:['reverse(["Albert", "Mojir", 160, [1, 2]])',"reverse([])",'reverse("Albert")',"reverse(null)"]}},second:{evaluate:([e],t)=>null===e?null:(I(e,t),pe(e[1])),arity:ae(1),docs:{category:"sequence",returns:{type:"any"},args:{seq:{type:["sequence","null"]}},variants:[{argumentNames:["seq"]}],description:"Returns the second element of $seq. If $seq has less than two elements or is `null`, `null` is returned.",seeAlso:["first","last","nth"],examples:['second(["Albert", "Mojir", 160, [1, 2]])',"second([1])","second([])","second(null)"]}},slice:{evaluate:(e,t)=>{const[r,n,o]=e;return I(r,t),ee(n,t,{integer:!0}),2===e.length?(Array.isArray(r),r.slice(n)):(ee(o,t,{integer:!0}),Array.isArray(r),r.slice(n,o))},arity:{min:2,max:3},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence",rest:!0},start:{type:"integer",description:"Defaults to `0`."},stop:{type:"integer",description:"Defaults lenght of sequence + 1."}},variants:[{argumentNames:["seq"]},{argumentNames:["seq","start"]},{argumentNames:["seq","start","stop"]}],description:"Returns a copy of a portion of $seq from index $start (inclusive) to $stop (exclusive).",seeAlso:["take","drop","sequence.splice","nth"],examples:["[1, 2, 3, 4, 5] slice 2","slice([1, 2, 3, 4, 5], 2, 4)","slice([1, 2, 3, 4, 5], 2)"]}},some:{evaluate:([e,t],r,n,{executeFunction:o})=>{if(L(t,r),null===e)return null;if(I(e,r),0===e.length)return null;return Te("string"==typeof e?e.split(""):e,(e,a)=>null!==e?e:Ae(o(t,[a],n,r),e=>e?pe(a):null),null)},arity:ae(2),docs:{category:"sequence",returns:{type:"any"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:["sequence","null"]},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns the first element that passes the test implemented by $fun. I no element was found, `null` is returned.",seeAlso:["sequence.position","collection.any?","find"],examples:['\nsome(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nsome(\n [5, 10, 15, 20],\n -> $ > 10\n)","\nsome(\n [1, 2, 3, 4],\n -> $ > 10\n)","\nsome(\n [],\n -> $ > 10\n)","\nsome(\n null,\n -> $ > 10\n)"]}},sort:{evaluate:(e,t,r,{executeFunction:n})=>{const[o]=e,a=1===e.length,i=a?null:e[1];if(I(o,t),"string"==typeof o){const e=o.split("");return a?e.sort((e,r)=>le(e,r,t)):(L(i,t),e.sort((e,o)=>{const a=n(i,[e,o],r,t);if(a instanceof Promise)throw new TypeError("Async functions cannot be used as sort comparators");return ee(a,t,{finite:!0}),a})),e.join("")}const s=[...o];return a?s.sort((e,r)=>(X(e,t),X(r,t),le(e,r,t))):s.sort((e,o)=>{L(i,t);const a=n(i,[e,o],r,t);if(a instanceof Promise)throw new TypeError("Async functions cannot be used as sort comparators");return ee(a,t,{finite:!0}),a}),s},arity:{min:1,max:2},docs:{category:"sequence",returns:{type:"any",rest:!0},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq"]},{argumentNames:["seq","fun"]}],description:"Returns a new sequence with the elements from $seq sorted according to $fun. If no $fun is supplied, builtin `compare` will be used.",seeAlso:["sequence.sort-by","compare","reverse","vector.sort-indices"],examples:["[3, 1, 2] sort (a, b) -> b - a","sort([3, 1, 2])","\nsort(\n [3, 1, 2],\n (a, b) -> cond case a < b then -1 case a > b then 1 case true then -1 end\n)","\nsort(\n [3, 1, 2],\n (a, b) -> cond case a > b then -1 case a < b then 1 case true then -1 end\n)"]}},take:{evaluate:([e,t],r)=>{ee(t,r),I(e,r);const n=Math.max(Math.ceil(t),0);return e.slice(0,n)},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},n:{type:"integer"},seq:{type:"sequence"}},variants:[{argumentNames:["seq","n"]}],description:"Constructs a new array/string with the $n first elements from $seq.",seeAlso:["take-last","take-while","drop","slice","sequence.split-at"],examples:["take([1, 2, 3, 4, 5], 3)","[1, 2, 3, 4, 5] take 3","take([1, 2, 3, 4, 5], 0)",'take("Albert", 2)','take("Albert", 50)']}},"take-last":{evaluate:([e,t],r)=>{I(e,r),ee(t,r);const n=Math.max(Math.ceil(t),0),o=e.length-n;return e.slice(o)},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},n:{type:"integer"},seq:{type:"sequence"}},variants:[{argumentNames:["seq","n"]}],description:"Constructs a new array with the $n last elements from $seq.",seeAlso:["take","drop-last"],examples:["take-last([1, 2, 3, 4, 5], 3)","[1, 2, 3, 4, 5] take-last 3","take-last([1, 2, 3, 4, 5], 0)"]}},drop:{evaluate:([e,t],r)=>{ee(t,r);const n=Math.max(Math.ceil(t),0);return I(e,r),e.slice(n)},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence"},n:{type:"integer"}},variants:[{argumentNames:["seq","n"]}],description:"Constructs a new array/string with the $n first elements dropped from $seq.",seeAlso:["drop-last","drop-while","take","slice","sequence.split-at"],examples:["drop([1, 2, 3, 4, 5], 3)","[1, 2, 3, 4, 5] drop 0",'drop("Albert", 2)','drop("Albert", 50)']}},"drop-last":{evaluate:([e,t],r)=>{I(e,r),ee(t,r);const n=Math.max(Math.ceil(t),0),o=e.length-n;return e.slice(0,o)},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence"},n:{type:"integer"}},variants:[{argumentNames:["seq","n"]}],description:"Constructs a new array with the $n last elements dropped from $seq.",seeAlso:["drop","take-last"],examples:["drop-last([1, 2, 3, 4, 5], 3)","[1, 2, 3, 4, 5] drop-last 3","drop-last([1, 2, 3, 4, 5], 0)"]}},"take-while":{evaluate:([e,t],r,n,{executeFunction:o})=>{I(e,r),L(t,r);const a="string"==typeof e?e.split(""):Array.from(e);return Ae(Fe(a,e=>Ae(o(t,[e],n,r),e=>!e)),t=>{const r=-1===t?a:a.slice(0,t);return"string"==typeof e?r.join(""):r})},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns the members of $seq in order, stopping before the first one for which `predicate` returns a falsy value.",seeAlso:["take","drop-while","sequence.split-with"],examples:["take-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)","take-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)"]}},"drop-while":{evaluate:([e,t],r,n,{executeFunction:o})=>{I(e,r),L(t,r);const a=Array.isArray(e)?e:e.split("");return Ae(Fe(a,e=>Ae(o(t,[e],n,r),e=>!e)),t=>-1===t?"string"==typeof e?"":[]:"string"==typeof e?a.slice(t).join(""):e.slice(t))},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns the members of $seq in order, skipping the fist elements for witch the `predicate` returns a truethy value.",seeAlso:["drop","take-while","sequence.split-with"],examples:["drop-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)","drop-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)"]}}},Ve=new WeakSet,Be=new WeakSet,Le=new WeakSet,_e=new WeakSet,Ke=new WeakSet,Je=new WeakSet,Ye=new WeakSet;function He(e){return Array.isArray(e)?(Ve.has(e)||(Xe(e),ot(e)||rt(e)),e):e}function Xe(e){return!!Array.isArray(e)&&(!!Be.has(e)||!Le.has(e)&&(e.every(e=>Q(e))?(Ve.add(e),Be.add(e),!0):(Le.add(e),!1)))}function Ze(e,t){if(!Xe(e))throw new r(`Expected a vector, but got ${e}`,t)}function Qe(e,t){if(!function(e){return!!Xe(e)&&2===e.length}(e))throw new r(`Expected a 2d vector, but got ${e}`,t)}function et(e,t){if(!function(e){return!!Xe(e)&&3===e.length}(e))throw new r(`Expected a 3d vector, but got ${e}`,t)}function tt(e,t){if(Ze(e,t),0===e.length)throw new r(`Expected a non empty vector, but got ${e}`,t)}function rt(e){if(!Array.isArray(e))return!1;if(Je.has(e))return!0;if(Ye.has(e))return!1;if(0===e.length)return Ye.add(e),!1;if(!Array.isArray(e[0]))return Ye.add(e),!1;const t=e[0].length;for(const r of e.slice(1)){if(!Array.isArray(r))return Ye.add(e),!1;if(r.length!==t)return Ye.add(e),!1}return Ve.add(e),Je.add(e),!0}function nt(e,t){if(!rt(e))throw new r(`Expected a grid, but got ${e}`,t)}function ot(e){if(!Array.isArray(e))return!1;if(_e.has(e))return!0;if(Ke.has(e))return!1;if(0===e.length)return Ke.add(e),!1;if(!Array.isArray(e[0])||0===e[0].length)return Ke.add(e),!1;const t=e[0].length;for(const r of e)if(!Array.isArray(r)||r.length!==t||r.some(e=>!Q(e)))return Ke.add(e),!1;return Ve.add(e),Je.add(e),_e.add(e),!0}function at(e,t){if(!ot(e))throw new r(`Expected a matrix, but got ${e}`,t)}function it(e,t){if(!ot(e))throw new r(`Expected a matrix, but got ${e}`,t);if(e.length!==e[0].length)throw new r(`Expected square matrix, but got ${e.length} and ${e[0].length}`,t)}function st(e,t){let n=!1,o=!1;for(const a of e)if(Xe(a))n=!0;else if(ot(a))o=!0;else if(!Q(a))throw new r("Invalid parameter type: "+typeof a,t);if(o){if(n)throw new r("Cannot mix vector and matrix types",t);let o=null,a=null;for(const n of e)if(ot(n))if(null===o)o=n.length,a=n[0].length;else if(n.length!==o||n[0].length!==a)throw new r("Matrix dimensions do not match",t);return["matrix",e.map(e=>ot(e)?e:Array.from({length:o},()=>Array.from({length:a},()=>e)))]}if(n){let n=null;for(const o of e)if(Xe(o))if(null===n)n=o.length;else if(o.length!==n)throw new r("Vector lengths do not match",t);return["vector",e.map(e=>Xe(e)?e:Array.from({length:n},()=>e))]}return["number",e]}function ct(e){return(t,r)=>{const[n,o]=st(t,r);return"number"===n?e(o[0]):"vector"===n?o[0].map(t=>e(t)):o[0].map(t=>t.map(t=>e(t)))}}function lt(e){return(t,r)=>{const[n,o]=st(t,r);return"number"===n?e(o[0],o[1]):"vector"===n?o[0].map((t,r)=>e(t,o[1][r])):o[0].map((t,r)=>t.map((t,n)=>e(t,o[1][r][n])))}}function mt(e,t){return(r,n)=>{if(0===r.length)return e;const[o,a]=st(r,n);if("number"===o)return a.reduce((e,r)=>t(e,r),e);if("vector"===o){const[e,...r]=a;return r.reduce((e,r)=>e.map((e,n)=>t(e,r[n])),e)}{const[e,...r]=a;return r.reduce((e,r)=>e.map((e,n)=>e.map((e,o)=>t(e,r[n][o]))),e)}}}const ut={inc:{evaluate:ct(e=>e+1),arity:ae(1),docs:{category:"math",returns:{type:"number"},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `inc` function increments its argument by 1, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it increases each element by 1 while preserving the original structure.",seeAlso:["dec","+"],examples:["inc(0)","inc(1)","inc(100.1)","inc([1, 2, 3])","inc([[1, 2], [3, 4]])"]}},dec:{evaluate:ct(e=>e-1),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `dec` function decrements its argument by 1, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it decreases each element by 1 while preserving the original structure.",seeAlso:["inc","-"],examples:["dec(0)","dec(1)","dec(100.1)","dec([1, 2, 3])","dec([[1, 2], [3, 4]])"]}},"+":{evaluate:mt(0,(e,t)=>e+t),arity:{},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]},xs:{type:["number","vector","matrix"],rest:!0}},variants:[{argumentNames:["xs"]}],description:"The `+` function performs addition of numbers and element-wise addition of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it adds the scalar to each element of the collection.",seeAlso:["-","*","/","inc"],examples:["1 + 2","1 + 20 + 30","+(1, 2, 3, 4)","+()","+(1)","[1, 2, 3] + 2","[1, 2, 3] + [4, 5, 6]","[[1, 2, 3], [4, 5, 6]] + [[7, 8, 9], [10, 11, 12]]","[[1, 2, 3], [4, 5, 6]] + 2"]}},"*":{evaluate:mt(1,(e,t)=>e*t),arity:{},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]},xs:{type:["number","vector","matrix"],rest:!0}},variants:[{argumentNames:["xs"]}],description:"The `*` function performs multiplication of `numbers` and element-wise multiplication of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it multiplies each element of the collection by the scalar.",seeAlso:["/","+","-","^"],examples:["6 * 7","-1 * 4","*(4, 7)","*(1, 2, 3, 4, 5)","*()","*(8)","[1, 2, 3] * 2","[1, 2, 3] * [4, 5, 6]","[[1, 2, 3], [4, 5, 6]] * [[7, 8, 9], [10, 11, 12]]","[[1, 2, 3], [4, 5, 6]] * 2"]}},"/":{evaluate:(e,t)=>{if(0===e.length)return 1;const[r,n]=st(e,t);if("number"===r){const[e,...t]=n;return 0===t.length?1/e:t.reduce((e,t)=>e/t,e)}if("vector"===r){const e=n[0];return n.slice(1).reduce((e,t)=>e.map((e,r)=>e/t[r]),e)}{const e=n[0];return n.slice(1).reduce((e,t)=>e.map((e,r)=>e.map((e,n)=>e/t[r][n])),e)}},arity:{},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]},xs:{type:["number","vector","matrix"],rest:!0}},variants:[{argumentNames:["xs"]}],description:"The `/` function performs division of `numbers` and element-wise division of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it divides each element of the collection by the scalar.",seeAlso:["*","+","-","quot","mod","%"],examples:["12 / 100","-1 / 4","/(7, 4)","/(1, 2, 4, 8)","/()","/(8)","[1, 2, 3] / 2","[1, 2, 3] / [4, 5, 6]","[[1, 2, 3], [4, 5, 6]] / [[7, 8, 9], [10, 11, 12]]","[[1, 2, 3], [4, 5, 6]] / 2"]}},"-":{evaluate:(e,t)=>{if(0===e.length)return 0;const[r,n]=st(e,t);if("number"===r){const[e,...t]=n;return 0===t.length?-e:t.reduce((e,t)=>e-t,e)}if("vector"===r){const e=n[0];return n.slice(1).reduce((e,t)=>e.map((e,r)=>e-t[r]),e)}{const e=n[0];return n.slice(1).reduce((e,t)=>e.map((e,r)=>e.map((e,n)=>e-t[r][n])),e)}},arity:{},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]},xs:{type:["number","vector","matrix"],rest:!0}},variants:[{argumentNames:["xs"]}],description:"Computes difference between first value and sum of the rest. When called with only one argument, it does negation.",seeAlso:["+","*","/","dec","abs"],examples:["50 - 8","1 - 1 - 1","-()","-(4, 2)","-(4, 3, 2, 1,)","[1, 2, 3] - 2","[1, 2, 3] - [4, 5, 6]","[[1, 2, 3], [4, 5, 6]] - [[7, 8, 9], [10, 11, 12]]","[[1, 2, 3], [4, 5, 6]] - 2"]}},quot:{evaluate:lt((e,t)=>Math.trunc(e/t)),arity:ae(2),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]}},variants:[{argumentNames:["a","b"]}],description:"The `quot` function performs integer division truncated toward zero, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies integer division between each element of the collection and the scalar.",seeAlso:["mod","%","/","trunc"],examples:["quot(5, 3)","quot(5.2, 3.1)","quot(-5, 3)","5 quot -3","-5 quot -3","quot(5, 0)","quot(0, 5)","[1, 2, 3] quot 2","2 quot [1, 2, 3]","quot([1, 2, 3], [4, 5, 6])","[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]","quot([[1, 2, 3], [4, 5, 6]], 2)","[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]"]}},mod:{evaluate:lt((e,t)=>e-t*Math.floor(e/t)),arity:ae(2),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]}},variants:[{argumentNames:["a","b"]}],description:"The `mod` function computes the modulo of division with the same sign as the divisor, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the modulo operation between each element of the collection and the scalar.",seeAlso:["%","quot","/"],examples:["mod(5, 3)","mod(5.2, 3.1)","mod(-5, 3)","5 mod -3","-5 mod -3","[1, 2, 3] mod 2","2 mod [1, 2, 3]","mod([1, 2, 3], [4, 5, 6])","[[1, 2, 3], [4, 5, 6]] mod [[7, 8, 9], [10, 11, 12]]","mod([[1, 2, 3], [4, 5, 6]], 2)"]}},"%":{evaluate:lt((e,t)=>e%t),arity:ae(2),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]}},variants:[{argumentNames:["a","b"]}],description:"The `%` function computes the remainder of division with the same sign as the dividend, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the remainder operation between each element of the collection and the scalar.",seeAlso:["mod","quot","/"],examples:["5 % 3","5.2 % 3.1","-5 % 3","%(5, -3)","%(-5, -3)","[1, 2, 3] % 2","2 % [1, 2, 3]","%([1, 2, 3], [4, 5, 6])","[[1, 2, 3], [4, 5, 6]] % [[7, 8, 9], [10, 11, 12]]","%([[1, 2, 3], [4, 5, 6]], 2)"]}},sqrt:{evaluate:ct(e=>Math.sqrt(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `sqrt` function calculates the square root of `numbers` and computes element-wise square roots of `vectors` and `matrices`. When applied to collections, it returns the square root of each element while preserving the original structure.",seeAlso:["cbrt","^"],examples:["sqrt(0)","sqrt(9)","sqrt(2)","sqrt(0)","sqrt(9)","sqrt(2)","sqrt([1, 4, 9])","sqrt([[1, 4], [9, 16]])"]}},cbrt:{evaluate:ct(e=>Math.cbrt(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `cbrt` function calculates the cube root of `numbers` and computes element-wise cube roots of `vectors` and `matrices`. When applied to collections, it returns the cube root of each element while preserving the original structure.",seeAlso:["sqrt","^"],examples:["cbrt(0)","cbrt(27)","cbrt(2)","cbrt(1)","cbrt(0)","cbrt(27)","cbrt(2)","cbrt(1)","cbrt([1, 8, 27])","cbrt([[1, 8], [27, 64]])"]}},"^":{evaluate:lt((e,t)=>e**t),arity:ae(2),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]}},variants:[{argumentNames:["a","b"]}],description:"The ^ function computes exponentiation, raising the first argument to the power of the second, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the power operation between each element of the collection and the scalar.",seeAlso:["sqrt","cbrt","*","math.ln"],examples:["2 ^ 3","2 ^ 0","2 ^ -3","^(-2, 3)","^(-2, -3)","[1, 2, 3] ^ 2","2 ^ [1, 2, 3]","^([1, 2, 3], [4, 5, 6])","[[1, 2, 3], [4, 5, 6]] ^ [[7, 8, 9], [10, 11, 12]]","^([[1, 2, 3], [4, 5, 6]], 2)"]}},round:{evaluate:([e,t],r)=>{const[n,o]=st([e],r);if("number"===n){if(void 0===t||0===t)return Math.round(o[0]);{ee(t,r,{integer:!0,positive:!0});const e=10**t;return Math.round(o[0]*e)/e}}if("vector"===n){const e=o[0];if(void 0===t||0===t)return e.map(e=>Math.round(e));{ee(t,r,{integer:!0,positive:!0});const n=10**t;return e.map(e=>Math.round(e*n)/n)}}{const e=o[0];if(void 0===t||0===t)return e.map(e=>e.map(e=>Math.round(e)));{ee(t,r,{integer:!0,positive:!0});const n=10**t;return e.map(e=>e.map(e=>Math.round(e*n)/n))}}},arity:{min:1,max:2},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:"integer"}},variants:[{argumentNames:["a"]},{argumentNames:["a","b"]}],description:"The `round` function rounds a `number` to the nearest `integer` or to a specified number of `decimal` places, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it rounds each element while preserving the original structure.",seeAlso:["floor","ceil","trunc"],examples:["round(2)","round(2.49)","round(2.5)","round(-2.49)","round(-2.5)","round(-2.501)","round(1.23456789, 4)","1.123456789 round 2","round([1.23456789, 2.3456789], 1)","[1.23456789, 2.3456789] round 4","[[1.23456789, 2.3456789], [3.456789, 4.56789]] round 4","round([[1.23456789, 2.3456789], [3.456789, 4.56789]], 2)"]}},trunc:{evaluate:ct(e=>Math.trunc(e)),arity:ae(1),docs:{category:"math",returns:{type:["integer","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `trunc` function truncates `numbers` toward zero (removing decimal portions without rounding), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it truncates each element while preserving the original structure.",seeAlso:["round","floor","ceil","quot"],examples:["trunc(2)","trunc(2.49)","trunc(2.5)","trunc(-2.49)","trunc(-2.5)","trunc(-2.501)","trunc([1.23456789, 2.3456789])","trunc([[1.23456789, 2.3456789], [3.456789, 4.56789]])"]}},floor:{evaluate:ct(e=>Math.floor(e)),arity:ae(1),docs:{category:"math",returns:{type:["integer","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `floor` function returns the largest `integer` less than or equal to a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the floor of each element while preserving the original structure.",seeAlso:["ceil","round","trunc"],examples:["floor(2)","floor(2.49)","floor(2.5)","floor(-2.49)","floor(-2.5)","floor(-2.501)","floor([1.23456789, 2.3456789])","floor([[1.23456789, 2.3456789], [3.456789, 4.56789]])"]}},ceil:{evaluate:ct(e=>Math.ceil(e)),arity:ae(1),docs:{category:"math",returns:{type:["integer","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `ceil` function returns the smallest `integer` greater than or equal to a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the ceiling of each element while preserving the original structure.",seeAlso:["floor","round","trunc"],examples:["ceil(2)","ceil(2.49)","ceil(2.5)","ceil(-2.49)","ceil(-2.5)","ceil(-2.501)","ceil([1.23456789, 2.3456789])","ceil([[1.23456789, 2.3456789], [3.456789, 4.56789]])"]}},min:{evaluate:(e,t)=>{if(1===e.length&&Xe(e[0])){const r=e[0];return tt(r,t),r.reduce((e,t)=>Math.min(e,t),1/0)}const[r,...n]=e;return ee(r,t),n.reduce((e,r)=>(ee(r,t),Math.min(e,r)),r)},arity:{min:1},docs:{category:"math",returns:{type:"number"},args:{a:{type:"number"},b:{type:"number"},xs:{type:"number",rest:!0},vector:{type:"vector"}},variants:[{argumentNames:["xs"]},{argumentNames:["vector"]}],description:"Returns the smallest value. Accepts either multiple numbers or a single vector of numbers.",seeAlso:["max","vector.span","vector.min-index"],examples:["2 min 3","min(2, 0, 1)","min(2, -1, 1)","min([2, 0, -1])","12 min 14"]}},max:{evaluate:(e,t)=>{if(1===e.length&&Xe(e[0])){const r=e[0];return tt(r,t),r.reduce((e,t)=>Math.max(e,t),-1/0)}const[r,...n]=e;return ee(r,t),n.reduce((e,r)=>(ee(r,t),Math.max(e,r)),r)},arity:{min:1},docs:{category:"math",returns:{type:"number"},args:{a:{type:"number"},b:{type:"number"},xs:{type:"number",rest:!0},vector:{type:"vector"}},variants:[{argumentNames:["xs"]},{argumentNames:["vector"]}],description:"Returns the largest value. Accepts either multiple numbers or a single vector of numbers.",seeAlso:["min","vector.span","vector.max-index"],examples:["2 max 3","max(2, 0, 1)","max(2, -1, 1)","max([2, 0, -1])","4 max 2"]}},abs:{evaluate:ct(e=>Math.abs(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The abs function returns the absolute value (magnitude) of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the absolute value of each element while preserving the original structure.",seeAlso:["sign","-"],examples:["abs(-2.3)","abs(0)","abs(2.5)","abs([1, -2, 3])","abs([[1, -2], [3, -4]])"]}},sign:{evaluate:ct(e=>Math.sign(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `sign` function returns the `sign` of a `number` (-1 for negative, 0 for zero, 1 for positive), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the sign of each element while preserving the original structure.",seeAlso:["abs"],examples:["sign(-2.3)","sign(-0)","sign(0)","sign(12312)","sign([1, -2, 3])","sign([[1, -2], [3, -4]])"]}}};function pt([e,...t],r){const n=M(e,r);for(const e of t)if(!me(n,M(e,r),r))return!1;return!0}const gt={"==":{evaluate:(e,t)=>pt(e,t),arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:"any"},b:{type:"any"},x:{type:"any"},ys:{type:"any",rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if all `values` are structaul equal to each other, otherwise result is `false`.",seeAlso:["!=","identical?"],examples:["1 == 1","[1, 2] == [1, 2]","\n{\n a: 1,\n b: 2,\n} == {\n b: 2,\n a: 1,\n}","==(1, 1)","==(1.01, 1)",'==("1", 1)','==("2", "2", "2", "2")',"==(2, 2, 1, 2)","==([1, 2], [1, 2])","==({ a: 1, b: 2 }, { b: 2, a: 1 })"]}},"!=":{evaluate:(e,t)=>!pt(e,t),arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:"any"},b:{type:"any"},x:{type:"any"},ys:{type:"any",rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if all `values` are not equal to each other, otherwise result is `false`. `(!= a b c)` is same as `(not (== a b c))`.",seeAlso:["==","identical?"],examples:["1 != 2","3 != 3","!=(3)","!=(3, 3, 2)",'!=("3", "2", "1", "0",)',"!=(0, -0)"]}},"identical?":{evaluate:e=>function([e,...t]){for(const r of t)if(r!==e)return!1;return!0}(e),arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:"any"},b:{type:"any"}},variants:[{argumentNames:["a","b"]}],description:"Returns true if $a and $b are referential equal.",seeAlso:["==","!="],examples:["identical?({ a: 10, b: 20 }, { b: 20, a: 10 })","identical?([1, true, null], [1, true, null])","identical?(0.3, 0.1 + 0.2)"]}},">":{evaluate:([e,...t],r)=>{let n=H(e);for(const e of t){if(le(n,H(e),r)<=0)return!1;n=H(e)}return!0},arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:["number","string"]},b:{type:["number","string"]},x:{type:["number","string"]},ys:{type:["number","string"],rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if $x and $ys are in decreasing order, `false` otherwise.",seeAlso:["<",">=","<=","compare"],examples:[">(1, 0)",">(1.01, 1)",">(1, 1)",">(4, 3, 2, 1)",">(3, 2, 2, 1)"]}},"<":{evaluate:([e,...t],r)=>{let n=H(e);for(const e of t){if(le(n,H(e),r)>=0)return!1;n=H(e)}return!0},arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:["number","string"]},b:{type:["number","string"]},x:{type:["number","string"]},ys:{type:["number","string"],rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if $x and $ys are in increasing order, `false` otherwise.",seeAlso:[">",">=","<=","compare"],examples:["<(0, 1)","<(1, 1.01)","<(1, 1)","<(1, 2, 2, 3)",'<("a", "b")']}},">=":{evaluate:([e,...t],r)=>{let n=H(e);for(const e of t){if(le(n,H(e),r)<0)return!1;n=H(e)}return!0},arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:["number","string"]},b:{type:["number","string"]},x:{type:["number","string"]},ys:{type:["number","string"],rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if $x and $ys are in non increasing order, `false` otherwise.",seeAlso:[">","<","<=","compare"],examples:["1 >= 1","0 >= 1",">=(1, 0)",">=(1.01, 1)",">=(1, 1)",">=(4, 3, 2, 1)",">=(3, 2, 2, 1)"]}},"<=":{evaluate:([e,...t],r)=>{let n=H(e);for(const e of t){if(le(n,H(e),r)>0)return!1;n=H(e)}return!0},arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:["number","string"]},b:{type:["number","string"]},x:{type:["number","string"]},ys:{type:["number","string"],rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if $x and $ys are in non decreasing order, `false` otherwise.",seeAlso:[">","<",">=","compare"],examples:["1 <= 1","<=(0, 1)","<=(1, 1.01)","<=(1, 1)","<=(1, 2, 3, 4)","<=(1, 2, 2, 3)"]}},not:{evaluate:([e])=>!e,arity:ae(1),docs:{category:"misc",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Computes logical negation. Note that any other $x than `false`, `0`, `null` and `''` is truthy.",seeAlso:["boolean"],examples:["not(3)","not(true)",'not("A string")',"not(0)","not(false)","not(null)",'not("")']}},"epoch->iso-date":{evaluate:([e],t)=>(ee(e,t),new Date(e).toISOString()),arity:ae(1),docs:{category:"misc",returns:{type:"string"},args:{ms:{type:"number"}},variants:[{argumentNames:["ms"]}],description:"Returns IOS date time string from `ms` (milliseconds elapsed since the UNIX epoch).",seeAlso:["iso-date->epoch"],examples:["epoch->iso-date(1649756230899)","epoch->iso-date(0)"]}},"iso-date->epoch":{evaluate:([e],t)=>{K(e,t);const r=new Date(e).valueOf();return ee(r,t,{finite:!0}),r},arity:ae(1),docs:{category:"misc",returns:{type:"number"},args:{iso:{type:"string"}},variants:[{argumentNames:["iso"]}],description:"Returns milliseconds elapsed since the UNIX epoch to `iso`.",seeAlso:["epoch->iso-date"],examples:['iso-date->epoch("2022-04-12T09:37:10.899Z")','iso-date->epoch("1980-01-01")']}},"write!":{evaluate:(e,t)=>(console.log(...e),e.length>0?M(e[e.length-1],t):null),pure:!1,arity:{},docs:{category:"misc",returns:{type:"any"},args:{values:{type:"any",rest:!0}},variants:[{argumentNames:["values"]}],description:"It logs the $values and then returns the last argument. If called with no arguments `null` is returned.",examples:['write!("A string")','write!(100, "items")','write!(object("a", 10))','write!(["a", "b", "c"])','write!(#"^start")',"write!(null, true, false)"],hideOperatorForm:!0}},boolean:{evaluate:([e])=>!!e,arity:ae(1),docs:{category:"misc",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Coerces $x to boolean.",seeAlso:["not","boolean?","true?","false?"],examples:["boolean(0)","boolean(1)","boolean(null)",'boolean("Albert")']}},compare:{evaluate:([e,t],r)=>(X(e,r),X(t,r),le(e,t,r)),arity:ae(2),docs:{category:"misc",returns:{type:"number"},args:{a:{type:["number","string"]},b:{type:["number","string"]}},variants:[{argumentNames:["a","b"]}],description:"Compares two values. Returns `-1` if $a < $b, `1` if $a > $b and `0` if $a and $b have the same sort order.",seeAlso:["<",">","<=",">=","sort","sequence.sort-by"],examples:["compare(0, 1)","compare(0, 0)","compare(1, 0)",'compare("Albert", "Mojir")']}},"json-parse":{evaluate:([e],t)=>(K(e,t),JSON.parse(e)),arity:ae(1),docs:{category:"misc",returns:{type:"any"},args:{x:{type:"string"}},variants:[{argumentNames:["x"]}],description:"Returns `JSON.parse(`$x`)`.",seeAlso:["json-stringify"],examples:['json-parse("[1, 2, 3]")']}},"json-stringify":{evaluate:([e,t],r)=>(C(e,r),void 0===t?JSON.stringify(e):(ee(t,r),JSON.stringify(e,null,t))),arity:{min:1,max:2},docs:{category:"misc",returns:{type:"string"},args:{x:{type:"any"},indent:{type:"integer",description:"Number of spaces to use for indentation."}},variants:[{argumentNames:["x"]},{argumentNames:["x","indent"]}],description:"Returns `JSON.stringify(`$x`)`. If second argument is provided, returns `JSON.stringify(`$x`, null, `$indent`)`.",seeAlso:["json-parse"],examples:["json-stringify([1, 2, 3])","json-stringify({ a: { b: 10 }}, 2)"],hideOperatorForm:!0}}},ht={keys:{evaluate:([e],t)=>(F(e,t),Object.keys(e)),arity:ae(1),docs:{category:"object",returns:{type:"any",array:!0},args:{obj:{type:"object"}},variants:[{argumentNames:["obj"]}],description:"Returns array of all keys in $obj.",seeAlso:["vals","entries","zipmap","select-keys"],examples:["keys({})",'keys({ x: 10, y: true, z: "A string" })','keys(object("x", 10, "y", true, "z", "A string"))']}},vals:{evaluate:([e],t)=>(F(e,t),Object.values(e)),arity:ae(1),docs:{category:"object",returns:{type:"any",array:!0},args:{obj:{type:"object"}},variants:[{argumentNames:["obj"]}],description:"Returns array of all values in $obj.",seeAlso:["keys","entries","zipmap"],examples:["vals({})",'vals({ x: 10, y: true, z: "A string" })','vals(object("x", 10, "y", true, "z", "A string"))']}},entries:{evaluate:([e],t)=>(F(e,t),Object.entries(e)),arity:ae(1),docs:{category:"object",returns:{type:"array"},args:{obj:{type:"object"}},variants:[{argumentNames:["obj"]}],description:"Returns nested array of all key - value pairs in $obj.",seeAlso:["keys","vals","zipmap","find"],examples:["entries({})",'entries({ x: 10, y: true, z: "A string" })','entries(object("x", 10, "y", true, "z", "A string"))']}},find:{evaluate:([e,t],r)=>(F(e,r),K(t,r),ce(e,t)?[t,e[t]]:null),arity:ae(2),docs:{category:"object",returns:{type:["array","null"]},args:{a:{type:"object"},b:{type:"string"},obj:{type:"object"},key:{type:"string"}},variants:[{argumentNames:["obj","key"]}],description:"Returns entry (key-value pair) for $key, or `null` if $key not present in $obj.",seeAlso:["get","contains?","entries","sequence.position","some"],examples:['{ a: 1, "b": 2 } find "a"','find(object("a", 1, "b", 2), "b")','find(object("a", 1, "b", 2), "c")']}},dissoc:{evaluate:([e,t],r)=>{F(e,r),K(t,r);const n={...e};return delete n[t],n},arity:ae(2),docs:{category:"object",returns:{type:"object"},args:{a:{type:"object"},b:{type:"string"},obj:{type:"object"},key:{type:"string"}},variants:[{argumentNames:["obj","key"]}],description:"Return shallow copy of $obj with $key deleted.",seeAlso:["assoc","select-keys"],examples:['{ x: 10, y: 20 } dissoc "y"','dissoc({ x: 10, y: 20 }, "x")','dissoc({ x: 10 }, "y")','\nlet o = { a: 5 };\ndissoc(o, "a");\no']}},merge:{evaluate:(e,t)=>{if(0===e.length)return null;const[r,...n]=e;return F(r,t),n.reduce((e,r)=>(F(r,t),{...e,...r}),{...r})},arity:{min:0},docs:{category:"object",returns:{type:"object"},args:{a:{type:"object"},b:{type:"object"},objs:{type:"object",rest:!0}},variants:[{argumentNames:["objs"]}],description:"Returns a new object created by merging together all arguments.\n\nIf two keys appears in more than one object the value from the last object is used.\nIf no arguments are provided `null` is returned.",seeAlso:["merge-with","assoc"],examples:["{ x: 10 } merge { y: 20 }",'merge(object("x", 10), object("y", 20))','merge(object("x", 10), object("x", 15, "y", 20))']}},"merge-with":{evaluate:(e,t,r,{executeFunction:n})=>{const o=e[0],a=e.at(-1),i=e.slice(1,-1);return F(o,t),L(a,t),Te(i,(e,o)=>{F(o,t);return Ae(Te(Object.entries(o),(e,o)=>{const i=J(o[0],t),s=pe(o[1]);return ce(e,i)?Ae(n(a,[e[i],s],r,t),t=>(e[i]=t,e)):(e[i]=s,e)},e),e=>e)},{...o})},arity:{min:2},docs:{category:"object",returns:{type:"object"},args:{objs:{type:"object",rest:!0},fun:{type:"function"}},variants:[{argumentNames:["objs","fun"]}],description:"\nReturns a new object created by merging together all arguments.\nIf two keys appears in more than one object $fun is used to calculate the new value.\n\nIf no arguments are provided `null` is returned.",seeAlso:["merge"],examples:['merge-with(object("x", 10), object("y", 20), +)','merge-with(object("x", 10), object("x", 15, "y", 20), +)',"merge-with({ x: 10 }, { x: 20 }, { x: 30 }, { x: 40 }, -)"],hideOperatorForm:!0}},zipmap:{evaluate:([e,t],r)=>{ke(e,r),we(t,r);const n=Math.min(e.length,t.length),o={};for(let a=0;a<n;a+=1){o[J(e[a],r)]=pe(t[a])}return o},arity:ae(2),docs:{category:"object",returns:{type:"object"},args:{a:{type:"array"},b:{type:"array"}},variants:[{argumentNames:["a","b"]}],description:"Returns a new object created by mapping $a to $b.",seeAlso:["entries","keys","vals","sequence.interleave"],examples:['["a", "b", "c"] zipmap [1, 2, 3]','zipmap(["a", "b", "c"], [10, null, [1, 2, 3]])','zipmap(["a", "b", "c"], [1])',"zipmap([], [10, null, [1, 2, 3]])"]}},"select-keys":{evaluate:([e,t],r)=>(ke(t,r),F(e,r),t.reduce((t,r)=>(ce(e,r)&&(t[r]=pe(e[r])),t),{})),arity:ae(2),docs:{category:"object",returns:{type:"object"},args:{a:{type:"object"},b:{type:"array"}},variants:[{argumentNames:["a","b"]}],description:"Returns an object containing only those entries in $a whose key is in $b.",seeAlso:["dissoc","keys"],examples:['{ a: 1, b: 2, c: 3 } select-keys ["a", "b"]','select-keys({ a: 1, b: 2, c: 3 }, ["a", "b"])','select-keys({ a: 1 }, ["a", "b"])']}}},dt={"function?":{evaluate:([e])=>w(e),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a function, otherwise `false`.",seeAlso:["string?","number?","boolean?","null?","array?","object?","regexp?"],examples:["function?(+)","function?(/)","function?((x, y) -> x + y)","function?(false)",'function?("false")',"function?([1, 2, 3])"]}},"string?":{evaluate:([e])=>"string"==typeof e,arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a string, otherwise `false`.",seeAlso:["blank?","number?","boolean?","null?","array?","object?","regexp?","function?","collection?","sequence?"],examples:['string?("")','string?("A string")','string?(true ? "A string" : false)',"string?(false)","string?([1, 2, 3])","string?(100)"]}},"number?":{evaluate:([e])=>"number"==typeof e,arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a number, otherwise `false`.",seeAlso:["integer?","zero?","pos?","neg?","finite?","number","string?","boolean?","null?","function?"],examples:["number?(0)","number?(2)","number?(-0.12)","number?(false)","number?([1, 2, 3])",'number?("A string")']}},"integer?":{evaluate:([e])=>"number"==typeof e&&Q(e,{integer:!0}),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is an integer, otherwise `false`.",seeAlso:["number?","number","even?","odd?"],examples:["integer?(0)","integer?(-12)","integer?(42)","integer?(10.1)","integer?((x, y) -> x + y)","integer?(false)",'integer?("false")',"integer?([1, 2, 3])"]}},"boolean?":{evaluate:([e])=>"boolean"==typeof e,arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a `boolean`, otherwise `false`.",seeAlso:["true?","false?","boolean","string?","number?","null?","function?"],examples:["boolean?(true)","boolean?(false)","boolean?([1, 2, 3])","boolean?(0)",'boolean?("A string")']}},"null?":{evaluate:([e])=>null==e,arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is `null`, otherwise `false`.",seeAlso:["empty?","not-empty?","string?","number?","boolean?","function?"],examples:["null?(null)","null?(false)","null?([1, 2, 3])","null?(0)",'null?("A string")']}},"zero?":{evaluate:([e],t)=>(ee(e,t,{finite:!0}),Math.abs(e)<ve),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is `0`, otherwise `false`.",seeAlso:["pos?","neg?","even?","number?"],examples:["zero?(0)","zero?(-0.0)","zero?(1)","zero?(0.1)"]}},"pos?":{evaluate:([e],t)=>(ee(e,t,{finite:!0}),e>0),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is greater than `0`, otherwise `false`.",seeAlso:["neg?","zero?","number?"],examples:["pos?(0)","pos?(-0.0)","pos?(1)","pos?(-0.1)"]}},"neg?":{evaluate:([e],t)=>(ee(e,t,{finite:!0}),e<0),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is less than `0`, otherwise `false`.",seeAlso:["pos?","zero?","number?"],examples:["neg?(0)","neg?(-0.0)","neg?(1)","neg?(-0.1)"]}},"even?":{evaluate:([e],t)=>(ee(e,t,{finite:!0}),e%2==0),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is even, otherwise `false`.",seeAlso:["odd?","integer?","zero?"],examples:["even?(0)","even?(-0.0)","even?(-1)","even?(2.1)"]}},"odd?":{evaluate:([e],t)=>(ee(e,t,{finite:!0}),Q(e,{integer:!0})&&e%2!=0),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is odd, otherwise `false`.",seeAlso:["even?","integer?"],examples:["odd?(1.0)","odd?(1.001)","odd?(-1)","odd?(2.1)"]}},"array?":{evaluate:([e])=>Array.isArray(e),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is an array, otherwise `false`.",seeAlso:["sequence?","collection?","object?","string?","vector?","matrix?","grid?","function?"],examples:["array?([])","array?([1, 2, 3])",'array?(object("a", 10))',"array?(42)","array?(10.1)","array?((x, y) -> x + y)"]}},"collection?":{evaluate:([e])=>U(e),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a collection i.e. an array, an object or a string, otherwise `false`.",seeAlso:["sequence?","array?","object?","string?"],examples:["collection?([])","collection?([1, 2, 3])",'collection?(object("a", 10))','collection?("Albert")',"collection?(42)","collection?(10.1)","collection?((x, y) -> x + y)"]}},"sequence?":{evaluate:([e])=>P(e),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a sequence i.e. an array or a string, otherwise `false`.",seeAlso:["collection?","array?","string?"],examples:["sequence?([])","sequence?([1, 2, 3])",'sequence?(object("a", 10))','sequence?("Albert")',"sequence?(42)","sequence?(10.1)","sequence?((x, y) -> x + y)"]}},"object?":{evaluate:([e])=>O(e),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is an object, otherwise `false`.",seeAlso:["collection?","array?","string?","function?"],examples:['object?(object("a", 10))',"object?(42)","object?(10.1)","object?((x, y) -> x + y)",'object?(#"^start")','object?("false")',"object?([1, 2, 3])"]}},"regexp?":{evaluate:([e])=>G(e),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a regexp, otherwise `false`.",seeAlso:["regexp","re-match","string?","function?"],examples:['regexp?(regexp("^start"))','regexp?(#"^start")',"regexp?(-12)","regexp?({})","regexp?(10.1)","regexp?((x, y) -> x + y)","regexp?(false)",'regexp?("false")',"regexp?([1, 2, 3])"]}},"finite?":{evaluate:([e],t)=>(ee(e,t),Number.isFinite(e)),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is finite, otherwise `false`.",seeAlso:["positive-infinity?","negative-infinity?","number?"],examples:["finite?(1.0)","finite?(1 / 0)","finite?(-1 / 0)"]}},"positive-infinity?":{evaluate:([e],t)=>(ee(e,t),e===Number.POSITIVE_INFINITY),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x equals positive infinity, otherwise `false`.",seeAlso:["negative-infinity?","finite?"],examples:["positive-infinity?(1.0)","positive-infinity?(1 / 0)","positive-infinity?(-1 / 0)"]}},"negative-infinity?":{evaluate:([e],t)=>(ee(e,t),e===Number.NEGATIVE_INFINITY),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x equals negative infinity, otherwise `false`.",seeAlso:["positive-infinity?","finite?"],examples:["negative-infinity?(1.0)","negative-infinity?(1 / 0)","negative-infinity?(-1 / 0)"]}},"true?":{evaluate:([e])=>!0===e,arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is `true`, otherwise `false`.",seeAlso:["false?","boolean?","boolean"],examples:["true?(false)","true?(true)","true?(1)","true?(0)"]}},"false?":{evaluate:([e])=>!1===e,arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is `true`, otherwise `false`.",seeAlso:["true?","boolean?","boolean"],examples:["false?(false)","false?(true)","false?(1)","false?(0)"]}},"empty?":{evaluate:([e],t)=>null===e||(W(e,t),"string"==typeof e||Array.isArray(e)?0===e.length:0===Object.keys(e).length),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:["collection","string","null"]}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is empty or `null`, otherwise `false`.",seeAlso:["not-empty?","collection.not-empty","null?","blank?","count"],examples:["empty?([])","empty?([1, 2, 3])","empty?({})","empty?({ a: 2 })",'empty?("")','empty?("Albert")',"empty?(null)"]}},"not-empty?":{evaluate:([e],t)=>null!==e&&(W(e,t),"string"==typeof e||Array.isArray(e)?e.length>0:Object.keys(e).length>0),arity:ae(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:["collection","string","null"]}},variants:[{argumentNames:["x"]}],description:"Returns `false` if $x is empty or `null`, otherwise `true`.",seeAlso:["empty?","collection.not-empty","null?"],examples:["not-empty?([])","not-empty?([1, 2, 3])","not-empty?({})","not-empty?({ a: 2 })",'not-empty?("")','not-empty?("Albert")',"not-empty?(null)"]}},"vector?":{evaluate:([e])=>Xe(e),arity:ae(1),docs:{category:"predicate",description:"Checks if a value is a `vector`. A `vector` is an array of `numbers`.",seeAlso:["matrix?","grid?","array?"],returns:{type:"boolean"},args:{value:{type:"any",description:"The value to check."}},variants:[{argumentNames:["value"]}],examples:["vector?(1)","vector?([1, 2, 3])",'vector?([1, 2, "3"])']}},"matrix?":{evaluate:([e])=>ot(e),arity:ae(1),docs:{category:"predicate",description:"Checks if a value is a `matrix`. A `matrix` is an array of arrays of `numbers`.",seeAlso:["vector?","grid?","array?"],returns:{type:"boolean"},args:{value:{type:"any",description:"The value to check."}},variants:[{argumentNames:["value"]}],examples:["matrix?(1)","matrix?([1, 2, 3])","matrix?([[1, 2], [3, 4]])",'matrix?([[1, 2], [3, "4"]])',"matrix?([[1, 2], [3]])"]}},"grid?":{evaluate:([e])=>rt(e),arity:ae(1),docs:{category:"predicate",description:"Checks if a `value` is a `grid`. A `grid` is an `array` of `arrays` where all inner `arrays` have the same length.",seeAlso:["vector?","matrix?","array?"],returns:{type:"boolean"},args:{value:{type:"any",description:"The value to check."}},variants:[{argumentNames:["value"]}],examples:['grid?("1")','grid?(["1", 2, 3])','grid?([["1", 2], [3, 4]])','grid?([["1", 2], [3, "4"]])','grid?([["1", 2], [3]])']}}},yt={regexp:{evaluate:([e,t],n)=>{K(e,n);const o=e||"(?:)",a="string"==typeof t?t:"";try{new RegExp(o,a)}catch(e){throw new r(`Invalid regular expression: ${o} ${a}`,n)}return{[p]:!0,sourceCodeInfo:n,s:o,f:a}},arity:{min:1,max:2},docs:{category:"regular-expression",returns:{type:"regexp"},args:{pattern:{type:"string"},flags:{type:"string",description:"Optional flags for the regular expression. Possible values are the same as Javascript RegExp takes."}},variants:[{argumentNames:["pattern"]},{argumentNames:["pattern","flags"]}],description:"Creates a RegExp from $pattern and $flags.",examples:['regexp("^\\s*(.*)$")','#"^\\s*(.*)$"','regexp("albert", "ig")','#"albert"ig'],seeAlso:["-short-regexp","re-match","replace","replace-all","regexp?"],hideOperatorForm:!0}},"re-match":{evaluate:([e,t],r)=>{if(function(e,t){if(!G(e))throw v("RegularExpression",e,t)}(t,r),!_(e))return null;const n=new RegExp(t.s,t.f).exec(e);return n?[...n]:null},arity:ae(2),docs:{category:"regular-expression",returns:{type:"any",array:!0},args:{a:{type:"regexp"},b:{type:"string"}},variants:[{argumentNames:["a","b"]}],description:"Matches $b against regular expression $a.\nIf $b is a string and matches the regular expression, a `re-match`-array is returned, otherwise `null` is returned.",seeAlso:["regexp","replace","replace-all","-short-regexp","regexp?"],examples:['re-match(" A string", regexp("^\\\\s*(.*)$"))','re-match(" A string", #"^\\s*(.*)$")','re-match("My name is Albert", #"albert"i)','re-match("My name is Ben", #"albert"i)','re-match(null, #"albert"i)','re-match(1, #"albert"i)','re-match({}, #"albert"i)']}},replace:{evaluate:([e,t,r],n)=>{K(e,n),V(t,n),K(r,n);const o=G(t)?new RegExp(t.s,`${t.f}`):t;return e.replace(o,r)},arity:ae(3),docs:{category:"regular-expression",returns:{type:"any",array:!0},args:{a:{type:"string"},b:{type:["regexp","string"]},x:{type:"string"}},variants:[{argumentNames:["a","b","x"]}],description:"Returns a new string with first match of regular expression $b replaced by $x.",seeAlso:["replace-all","regexp","re-match","-short-regexp"],examples:['replace("Duck duck", "u", "i")','replace("Duck duck", #"u", "i")','replace("abcABC", regexp("a", "i"), "-")','replace("abcABC", regexp("a", "gi"), "-")','replace("abcABC", #"a"i, "-")','replace("abcABC", #"a"gi, "-")']}},"replace-all":{evaluate:([e,t,r],n)=>{K(e,n),V(t,n),K(r,n);const o=G(t)?new RegExp(t.s,`${t.f.includes("g")?t.f:`${t.f}g`}`):t;return e.replaceAll(o,r)},arity:ae(3),docs:{category:"regular-expression",returns:{type:"any",array:!0},args:{a:{type:"string"},b:{type:["regexp","string"]},x:{type:"string"}},variants:[{argumentNames:["a","b","x"]}],description:"Returns a new string with all matches of regular expression $b replaced by $x.",seeAlso:["replace","regexp","re-match","-short-regexp"],examples:['replace-all("Duck duck", "u", "i")','replace-all("Duck duck", regexp("u"), "i")','replace-all("abcABC", regexp("a", "i"), "-")','replace-all("abcABC", regexp("a", "gi"), "-")','replace-all("abcABC", #"a"i, "-")','replace-all("abcABC", #"a"gi, "-")']}}},vt=/^\s*$/,ft={str:{evaluate:e=>e.reduce((e,t)=>e+(null==t?"":O(t)||Array.isArray(t)?JSON.stringify(t):`${t}`),""),arity:{},docs:{category:"string",returns:{type:"string"},args:{values:{type:"any",rest:!0}},variants:[{argumentNames:["values"]}],description:"Concatenats $values into one string. If `value` equals `null` empty string is returned.",seeAlso:["++","join","string.template","string.string-repeat","number"],examples:['str("A string", ", and another string", " ...and more")','str("Just one string")',"str()",'str(0, false, true, null, #"^kalle", [1, 2, 3], {a: "a"})'],hideOperatorForm:!0}},number:{evaluate:([e],t)=>{K(e,t);const n=Number(e);if(Number.isNaN(n))throw new r(`Could not convert '${e}' to a number.`,t);return n},arity:ae(1),docs:{category:"string",returns:{type:"number"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Parses $s to a number.",seeAlso:["str","number?","integer?"],examples:['number("10")','number("010")','number("-1.01")']}},"lower-case":{evaluate:([e],t)=>(K(e,t),e.toLowerCase()),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns $s converted to lower case.",seeAlso:["upper-case","string.capitalize"],examples:['lower-case("Albert")','lower-case("")']}},"upper-case":{evaluate:([e],t)=>(K(e,t),e.toUpperCase()),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns $s converted to upper case.",seeAlso:["lower-case","string.capitalize"],examples:['upper-case("Albert")','upper-case("")']}},trim:{evaluate:([e],t)=>(K(e,t),e.trim()),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns a new string with leading and trailing whitespaces removed.",seeAlso:["string.trim-left","string.trim-right","blank?"],examples:['trim(" Albert ")','trim(" ")','trim("")']}},join:{evaluate:([e,t],r)=>(we(e,r),e.forEach(e=>X(e,r)),K(t,r),e.join(t)),arity:ae(2),docs:{category:"string",returns:{type:"string"},args:{a:{type:"array"},b:{type:"string"},arr:{type:"array"},delimiter:{type:"string"}},variants:[{argumentNames:["arr","delimiter"]}],description:"Returns a new string by concatenating all of the elements in $arr, separated by $delimiter.",seeAlso:["split","str","++","sequence.interpose"],examples:['map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str) join ", "','([0, 1, 2, 3, 4, 5, 6, 7, 8, 9] map str) join ", "','join(["Albert", 10], ", ")','join(["Albert", "Mojir"], " ")','join(map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str), ", ")']}},split:{evaluate:([e,t,r],n)=>{K(e,n),V(t,n),void 0!==r&&ee(r,n,{integer:!0,nonNegative:!0});const o="string"==typeof t?t:new RegExp(t.s,t.f);return e.split(o,r)},arity:{min:2,max:3},docs:{category:"string",returns:{type:"string"},args:{a:{type:"string"},b:{type:"string"},s:{type:"string"},delimiter:{type:"string"},limit:{type:"integer"}},variants:[{argumentNames:["s","delimiter"]},{argumentNames:["s","delimiter","limit"]}],description:"Divides $s into an array of substrings. The division is done by searching for `delimiter`. If `limit` as provided, at most `limit` number of substrings are returned.",seeAlso:["join","string.split-lines"],examples:['"Albert Mojir" split " "','split("Albert Mojir", " ")','split("abcdefghijklmnopqrstuvw", #"[aoueiy]")','split("0123456789", "")','split("0123456789", "", 5) map number']}},"blank?":{evaluate:([e],t)=>null===e||(K(e,t),vt.test(e)),arity:ae(1),docs:{category:"string",returns:{type:"boolean"},args:{s:{type:["string","null"]}},variants:[{argumentNames:["s"]}],description:"Returns true if $s is null or only contains whitespace characters.",seeAlso:["trim","empty?","string?"],examples:['blank?("")',"blank?(null)",'blank?("\n")','blank?(" ")','blank?(".")']}}},bt={"|>":{evaluate:([e,t],r,n,{executeFunction:o})=>(L(t,r),o(t,[e],n,r)),arity:ae(2),docs:{category:"functional",returns:{type:"any"},args:{a:{type:"any"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Takes a value $a and a function $b, and returns the result of applying $b to $a.",seeAlso:["apply","comp"],examples:["\n1 |> inc |> inc","range(10)\n |> map(_, -> $ ^ 2) // [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]\n |> filter(_, odd?) // [1, 9, 25, 49, 81]\n |> reduce(_, +, 0) // 165\n |> sqrt // 12.84523257866513\n |> round(_, 2)"]}},apply:{evaluate:([e,...t],r,n,{executeFunction:o})=>{L(e,r);const a=t[t.length-1];we(a,r);return o(e,[...t.slice(0,-1),...a],n,r)},arity:{min:2},docs:{category:"functional",returns:{type:"any"},args:{a:{type:"function"},b:{type:"array"},fun:{type:"function"},args:{type:"array"}},variants:[{argumentNames:["fun","args"]}],description:"Call supplied function $fun with specified arguments $args.",seeAlso:["|>"],examples:["\napply(+, [1, 2, 3])","\napply(\n (x, y) -> sqrt(x ^ 2 + y ^ 2),\n [3, 4]\n)","\n(x, y) -> sqrt(x ^ 2 + y ^ 2) apply [3, 4]"]}},identity:{evaluate:([e])=>pe(e),arity:ae(1),docs:{category:"functional",returns:{type:"any"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns $x.",seeAlso:["constantly","functional.fnull"],examples:["identity(1)",'identity("Albert")',"identity({ a: 1 })","identity(null)"]}},comp:{evaluate:(e,t)=>(e.forEach(e=>L(e,t)),{[u]:!0,sourceCodeInfo:t,functionType:"Comp",params:e,arity:e.length>0?re(e.at(-1)):{min:1,max:1}}),arity:{},docs:{category:"functional",returns:{type:"function"},args:{a:{type:"function"},b:{type:"function"},fns:{type:"function",rest:!0}},variants:[{argumentNames:["fns"]}],description:"Takes a variable number of functions and returns a function that is the composition of those.\n\n The returned function takes a variable number of arguments,\n applies the rightmost function to the args,\n the next function (right-to-left) to the result, etc.",seeAlso:["|>","functional.juxt","functional.complement"],examples:["\nlet negative-quotient = comp(-, /);\nnegative-quotient(9, 3)",'\nlet x = { bar: { foo: 42 } };\ncomp("foo", "bar")(x)']}},constantly:{evaluate:([e],t)=>({[u]:!0,sourceCodeInfo:t,functionType:"Constantly",value:pe(e),arity:{}}),arity:ae(1),docs:{category:"functional",returns:{type:"function"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns a function that takes any number of arguments and always returns $x.",seeAlso:["identity","functional.fnull"],examples:["\nlet always-true = constantly(true);\nalways-true(9, 3)"]}}};function xt(e){return xe(`\n ${e.title}\n\n ${e.description.replace(/`(.+?)`/g,"$1").replace(/\$(\w+)/g,"$1").replace(/\*\*\*(.+)\*\*\*/g,"$1").replace(/\*\*(.+)\*\*/g,"$1")}\n\n Signature:\n ${function({title:e,variants:t,args:r,returns:n,_isOperator:o}){const a=t.map(t=>`${` ${e}(${t.argumentNames.map(e=>{let t="";return r[e].rest&&(t+="..."),t+=e,t}).join(", ")})`} -> ${wt(n)}`),i=o?["","Operator:",` a ${e} b -> ${wt(n)}`]:[];return[...a,...i]}(e).join("\n ")}\n\n Arguments:\n ${function(e){return Object.entries(e.args).map(([e,t])=>`${e}: ${wt(t)}`)}(e).join("\n ")}\n\n Examples:\n${e.examples.map(e=>xe(e,4)).join("\n\n")}`)}function wt(e){const t=e.type,r=(Array.isArray(t)?t:[t]).join(" | ");return e.array||e.rest?`Array<${r}>`:r}function kt(e){return{doc:{evaluate:([t],r)=>{if(b(e),L(t,r),!w(t))return"";if("Builtin"===t.functionType){const r=e[t.name];return r?xt(r):""}return"UserDefined"===t.functionType||"NativeJsFunction"===t.functionType?t.docString:""},arity:ae(1),docs:{category:"meta",returns:{type:"string"},args:{fun:{type:"function"}},variants:[{argumentNames:["fun"]}],description:"Returns documentation string of the $fun.",seeAlso:["arity"],examples:["doc(+)",'\nlet add = (x, y) -> do\n """\n Adds two numbers.\n Args:\n x: First number.\n y: Second number.\n Returns:\n Sum of x and y.\n """;\n x + y;\nend;\n\ndoc(add)']}},arity:{evaluate:([e],t)=>(L(e,t),w(e)?e.arity:ae(1)),arity:ae(1),docs:{category:"meta",returns:{type:"object"},args:{fun:{type:"function"}},variants:[{argumentNames:["fun"]}],description:"Returns arity of the $fun. The arity is an object with the properties: `min` and `max`. If the function has fixed arity, `min` and `max` are equal to the number of required parameters. If no restrictions apply, empty object is returned.",seeAlso:["doc"],examples:["arity(+)","arity(defined?)","\nlet add = (x, y = 0) -> do\n x + y;\nend;\n\narity(add)","\nlet foo = (k, ...x) -> do\n k + x;\nend;\n arity(foo)"]}}}}const qt={sum:{evaluate:([e],t)=>(Ze(e,t),e.reduce((e,t)=>e+t,0)),arity:ae(1),docs:{category:"vector",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to sum."}},variants:[{argumentNames:["vector"]}],description:"Returns the **sum** of all elements in the `vector`. Returns `0` for an empty vector.",seeAlso:["prod","mean","median","vector.moving-sum","vector.centered-moving-sum","vector.running-sum","vector.cumsum"],examples:["sum([1, 2, 3, 4, 5])","sum([1, -2, 3])","sum([])"]}},prod:{evaluate:([e],t)=>(Ze(e,t),e.reduce((e,t)=>e*t,1)),arity:ae(1),docs:{category:"vector",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to multiply."}},variants:[{argumentNames:["vector"]}],description:"Returns the **product** of all elements in the `vector`. Returns `1` for an empty vector.",seeAlso:["sum","mean","median","vector.moving-prod","vector.centered-moving-prod","vector.running-prod","vector.cumprod"],examples:["prod([1, 2, 3, 4, 5])","prod([1, -2, 3])","prod([])"]}},mean:{evaluate:([e],t)=>(tt(e,t),e.reduce((e,t)=>e+t,0)/e.length),arity:ae(1),docs:{category:"vector",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to calculate the mean of."}},variants:[{argumentNames:["vector"]}],description:"Returns the arithmetic **mean** of all elements in the `vector`. Throws for an empty vector.",seeAlso:["median","sum","prod","vector.moving-mean","vector.centered-moving-mean","vector.running-mean","vector.geometric-mean","vector.harmonic-mean","vector.rms","vector.mode"],examples:["mean([1, 2, 3, 4, 5])","mean([1, -2, 3])"]}},median:{evaluate:([e],t)=>(tt(e,t),function(e){const t=[...e].sort((e,t)=>e-t),r=Math.floor(t.length/2);return t.length%2==0?(t[r-1]+t[r])/2:t[r]}(e)),arity:ae(1),docs:{category:"vector",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to calculate the median of."}},variants:[{argumentNames:["vector"]}],description:"Returns the **median** of all elements in the `vector`. For even-length vectors, returns the average of the two middle values. Throws for an empty vector.",seeAlso:["mean","sum","prod","vector.moving-median","vector.centered-moving-median","vector.running-median","vector.mode","vector.quartiles","vector.percentile","vector.iqr","vector.medad"],examples:["median([1, 2, 3, 4, 5])","median([1, 2, 3, 4])","median([3, 1, 4, 1, 5])"]}}},At={};const Nt={...Z,...se,...De,...We,...Ge,...ut,...kt(At),...gt,...ht,...dt,...yt,...ft,...bt,...qt};Object.entries(Nt).forEach(([e,t])=>{t.name=e});const $t={...Nt},Tt={},zt=[];Object.entries($t).forEach(([e,t],r)=>{Tt[e]=r,zt.push(t)});const St={arity:{},docs:{category:"special-expression",returns:{type:"any"},args:{a:{type:"any"},b:{type:"any"},c:{type:"any",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"\nComputes logical `and`. Evaluation of expressions starts from left.\nAs soon as an `expression` evaluates to a falsy value, the result is returned.\n\nIf all expressions evaluate to truthy values, the value of the last expression is returned.",examples:["true && 1","&&(1, 1)",'&&(3 > 2, "string")','&&(3 < 2, "string")',"&&(true, true, true, true)","&&(true, true, 0, true)"]},evaluate:(e,t,{evaluateNode:r})=>Te(e[1][1],(e,n)=>e?r(n,t):e,!0),evaluateAsNormalExpression:(e,t)=>{let r=!0;for(const n of e)if(r=M(n,t),!r)break;return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},Et={arity:{},docs:{category:"special-expression",customVariants:["cond cond-branch cond-branch ... end"],details:[["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."]],description:"Used for branching. `cond-branches` are tested sequentially from the top. If no branch is tested truthy, `null` is returned.",examples:['\ncond\n case false then write!("FALSE")\n case true then write!("TRUE")\nend','\ncond\n case false then write!("FALSE")\n case null then write!("null")\nend ?? write!("TRUE")','\ncond\n case false then write!("FALSE")\n case null then write!("null")\nend ?? write!("TRUE")']},evaluate:(e,t,{evaluateNode:r})=>{const n=e[1][1];return function e(o){if(o>=n.length)return null;const[a,i]=n[o];return Ae(r(a,t),n=>n?r(i,t):e(o+1))}(0)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1].flat(),t,n,o)},jt=11,Mt=12,Ct=13,Pt=14,Rt=15,It=16;function Ot(e,t){if(e[0]===Ct)Object.values(e[1][0]).forEach(e=>{e[1][1]&&t(e[1][1]),Ot(e,t)});else if(e[0]===Pt)for(let r=0;r<e[1][0].length;r+=1){const n=e[1][0][r]??null;null!==n&&(n[1][1]&&t(n[1][1]),Ot(n,t))}}function Ft(e,t,r){const n=e[2],o={};return Ae(Ut(e,t,r,n,o),()=>o)}function Ut(e,t,n,o,a){if(e[0]===Ct){!function(e,t){if(!x(e))throw new r(`Expected UnknownRecord, got ${d(e)}.`,y(e,t))}(t,o);const i=new Set;let s;return Ae(Se(Object.entries(e[1][0]),([e,r])=>{if(r[0]===Mt)return void(s=r);i.add(e);const c=t[e];return Ae(void 0!==c?c:r[1][1]?n(r[1][1]):null,e=>{const t=e??null;return C(t,o),Ut(r,t,n,o,a)})}),()=>{if(s){const e=Object.entries(t).filter(([e])=>!i.has(e)).reduce((e,[t,r])=>(e[t]=M(r),e),{});a[s[1][0]]=e}})}if(e[0]===Pt){let r=null;we(t,o);const i=[];for(let t=0;t<e[1][0].length;t+=1){const n=e[1][0][t]??null;if(null!==n){if(n[0]===Mt){r=t;break}i.push({element:n,index:t})}}return Ae(Se(i,({element:e,index:r})=>{const i=t[r];return Ae(void 0!==i?i:e[1][1]?n(e[1][1]):null,t=>{const r=t??null;return C(r,o),Ut(e,r,n,o,a)})}),()=>{if(null!==r){const n=t.slice(r),o=e[1][0][r];a[o[1][0]]=n}})}e[0]===Mt?a[e[1][0]]=M(t):a[e[1][0][1]]=M(t)}function Dt(e){const t={};return Wt(e,t),t}function Wt(e,t){if(null!==e)if(e[0]===Pt)for(const r of e[1][0])Wt(r,t);else if(e[0]===Ct)for(const r of Object.values(e[1][0]))Wt(r,t);else if(e[0]===Mt){if(t[e[1][0]])throw new r(`Duplicate binding name: ${e[1][0]}`,e[2]);t[e[1][0]]=!0}else if(e[0]===jt){if(t[e[1][0][1]])throw new r(`Duplicate binding name: ${e[1][0]}`,e[2]);t[e[1][0][1]]=!0}}function Gt(e,t,r){const n={};return Ae(Vt(e,t,r,n),e=>e?n:null)}function Vt(e,t,r,n){if(e[0]===It)return!0;if(e[0]===Rt){const n=e[1][0];return Ae(r(n),e=>me(t,e))}if(e[0]===jt){const o=e[1][0],a=e[1][1];if(null==t){if(a)return Ae(r(a),e=>(n[o[1]]=M(e),!0));n[o[1]]=t??null}else n[o[1]]=M(t);return!0}if(e[0]===Ct){if(!x(t))return!1;const o=new Set;let a;const i=Object.entries(e[1][0]);let s=!0;for(const[e,c]of i)s=Ae(s,i=>{if(!i)return!1;if(c[0]===Mt)return a=c,!0;o.add(e);const s=t[e];if(void 0===s&&c[0]===Rt)return Ae(r(c[1][0]),e=>me(void 0,e));return Ae(void 0!==s?s:c[1]&&c[1][1]?r(c[1][1]):null,e=>Vt(c,e??null,r,n))});return Ae(s,e=>{if(!e)return!1;if(a){const e=Object.entries(t).filter(([e])=>!o.has(e)).reduce((e,[t,r])=>(e[t]=M(r),e),{});n[a[1][0]]=e}return!0})}{const o=e;if(!Array.isArray(t))return!1;const a=o[1][0];let i=null;for(let e=0;e<a.length;e+=1){const t=a[e];if(null!==t&&t[0]===Mt){i=e;break}}if(null===i&&t.length!==a.length)return!1;if(null!==i&&t.length<i)return!1;let s=!0;for(let e=0;e<a.length;e+=1){const o=a[e];if(null===o)continue;if(o[0]===Mt){n[o[1][0]]=t.slice(e);break}const i=o;s=Ae(s,o=>!!o&&Vt(i,M(t[e]),r,n))}return s}}const Bt={arity:{},docs:{category:"special-expression",customVariants:["match value match-branch match-branch ... end"],details:[["value","any","The value to match against patterns."],["match-branch","case pattern [when guard] then body","A branch of the match expression."],["pattern","pattern","A pattern to match: literal, variable, array destructuring, object destructuring, or wildcard (_)."],["guard","expression","An optional guard expression that must be truthy for the match to succeed."],["body","expressions","The expressions to evaluate if the pattern matches."]],description:"Pattern matching expression. Matches `value` against each `pattern` sequentially. If a pattern matches (and the optional `when` guard is truthy), the corresponding `body` is evaluated and its result returned. Bound variables from the pattern are available in the guard and body. If no pattern matches, `null` is returned.",examples:['\nmatch 1\n case 1 then "One"\n case 2 then "Two"\nend','\nmatch [1, 2, 3]\n case [x] then "one element"\n case [x, y] then "two elements"\n case [x, ...xs] then "first: " ++ str(x) ++ " rest: " ++ str(xs)\nend','\nmatch { type: "click", x: 10, y: 20 }\n case { type: "click", x, y } then "Click at " ++ str(x) ++ ", " ++ str(y)\n case { type: "keydown", key } then "Key: " ++ key\n case _ then "unknown event"\nend','\nmatch { role: "admin", name: "Alice" }\n case { role: "admin", name } then "Admin: " ++ name\n case { role, name } when role == "user" then "User: " ++ name\n case _ then "Unknown role"\nend']},evaluate:(e,t,{evaluateNode:r})=>{const[,n,o]=e[1];return Ae(r(n,t),e=>function n(a){if(a>=o.length)return null;const[i,s,c]=o[a];return Ae(Gt(i,e,e=>r(e,t)),e=>{if(null===e)return n(a+1);const o={};for(const[t,r]of Object.entries(e))o[t]={value:r};const i=t.create(o);return c?Ae(r(c,i),e=>e?r(s,i):n(a+1)):r(s,i)})}(0))},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>{const a=new Set;r([e[1][1]],t,n,o).forEach(e=>a.add(e));for(const[i,s,c]of e[1][2]){const e={};Object.assign(e,Dt(i));const l=t.create(e);c&&r([c],l,n,o).forEach(e=>a.add(e)),r([s],l,n,o).forEach(e=>a.add(e))}return a}};function Lt(e){const t=e[0];return s.UserDefinedSymbol===t||s.NormalBuiltinSymbol===t||s.SpecialBuiltinSymbol===t}function _t(e){return s.UserDefinedSymbol===e[0]}function Kt(e,t){return function(e,t){if(!_t(e))throw v("UserDefinedSymbolNode",e,t)}(e,t),e}function Jt(e){return s.NormalBuiltinSymbol===e[0]}function Yt(e){return s.SpecialBuiltinSymbol===e[0]}function Ht(e){return!!function(e){return e[0]===s.NormalExpression}(e)&&Lt(e[1][0])}function Xt(e){return e[0]===s.Spread}const Zt={category:"special-expression",returns:{type:"boolean"},args:{symbol:{type:"any"}},variants:[{argumentNames:["symbol"]}],description:"Returns `true` if `symbol` is defined, `false` otherwise.\n\nBuilt-in symbols are always considered defined. For user-defined symbols, checks if the symbol exists in the current scope.",examples:["let x = 42; defined?(x)","defined?(x)","defined?(+)"]},Qt={arity:ae(1),docs:Zt,evaluate:(e,t)=>{const r=e[1][1];if(function(e,t){if(!Lt(e))throw v("SymbolNode",e,t)}(r),!_t(r))return!0;return null!==t.lookUp(r)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r([e[1][1]],t,n,o)},er={arity:{},docs:{category:"special-expression",customVariants:["do body end"],details:[["body","expressions","The expressions to evaluate."]],description:"Evaluates `body`. Resulting value is the value of the last expression.",examples:["\ndo\n let a = 1 + 2 + 3 + 4;\n let b = -> $ * ( $ + 1 );\n b(a)\nend"]},evaluate:(e,t,{evaluateNode:r})=>{const n=t.create({});return Te(e[1][1],(e,t)=>r(t,n),null)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t.create({}),n,o)},tr={arity:{},evaluate:(e,t,{builtin:r,getUndefinedSymbols:n,evaluateNode:o})=>{const a=e[1][1],i=e[1][2],s=function(e,t,r,n,o){const a={},i=e[0].reduce((e,t)=>(Object.keys(Dt(t)).forEach(t=>{e[t]={value:null}}),e),{}),s=n(e[1],t.new(i),r,o);s.forEach(e=>{const r=t.getValue(e);j(r)&&(a[e]={value:r})});const c=[e[0],e[1],a];return c}(a,t,r,n,o),c=s[0].filter(e=>e[0]!==Mt&&void 0===e[1][1]).length,l={min:c>0?c:void 0,max:s[0].some(e=>e[0]===Mt)?void 0:s[0].length};return{[u]:!0,sourceCodeInfo:e[2],functionType:"UserDefined",name:void 0,evaluatedfunction:s,arity:l,docString:i}},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>function(e,t,r,n,o){const a=new Set,i={self:{value:null}};e[0].forEach(e=>{Object.assign(i,Dt(e)),Ot(e,e=>{ye(a,r([e],t,n,o))})});const s=t.create(i),c=r(e[1],s,n,o);return ye(a,c),a}(e[1][1],t,r,n,o)};const rr={arity:{min:2,max:3},docs:{category:"special-expression",customVariants:["if test then true-expr else false-expr","if test then true-expr"],details:[["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."]],description:"Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is truthy. If $test is falsy `false-expr` is executed, if no `false-expr` exists, `null` is returned.",examples:['\nif true then\n write!("TRUE")\nelse\n write!("FALSE")\nend','if false then write!("TRUE") else write!("FALSE") end','if true then write!("TRUE") end','if false then write!("TRUE") end']},evaluate:(e,t,{evaluateNode:r})=>{const[n,o,a]=e[1][1];return Ae(r(n,t),e=>e?r(o,t):a?r(a,t):null)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1].filter(e=>!!e),t,n,o)},nr={arity:{},docs:{category:"special-expression",customVariants:["unless test then true-expr else false-expr end","unless test true-expr end"],details:[["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."]],description:"Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is falsy. If $test is truthy `false-expr` is executed, if no `false-expr` exists, `null` is returned.",examples:['\nunless true then\n write!("TRUE")\nelse\n write!("FALSE")\nend','unless false then write!("TRUE") else write!("FALSE") end','unless true then write!("TRUE") end','unless false then write!("TRUE") end']},evaluate:(e,t,{evaluateNode:r})=>{const[n,o,a]=e[1][1];return Ae(r(n,t),e=>e?a?r(a,t):null:r(o,t))},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1].filter(e=>!!e),t,n,o)},or={category:"special-expression",customVariants:["let s = value;"],details:[["s","symbol","The name of the variable to bind."],["value","any","The value to bind to the variable."]],description:"\n Binds local variables s to `value`. `value` can be any expression. The scope of the variables is the body of the let expression.",examples:['\nlet a = 1 + 2 + 3 + 4;\nlet b = -> $ * ( $ + 1 );\nwrite!("a", a, "b", b)']},ar={arity:ae(0),docs:or,evaluate:(e,t,{evaluateNode:r})=>{const n=e[1][1],o=n[1][0],a=n[1][1];return Ae(r(a,t),e=>Ae(Ft(o,e,e=>r(e,t)),r=>(t.addValues(r,o[2]),e)))},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>{const a=e[1][1],i=a[1][0],s=a[1][1],c=r([s],t,n,o);return Ot(i,e=>{ye(c,r([e],t,n,o))}),t.addValues(Dt(i),i[2]),c}},ir={arity:{},docs:{category:"special-expression",customVariants:["loop (bindings) -> body"],details:[["bindings","binding pairs","Comma-separated bindings with initial values, e.g. `n = 10, acc = 0`."],["body","expression","The expression to evaluate repeatedly. Use `recur` to loop back with new values."]],description:"Creates a loop with initial bindings. Use `recur` inside the body to jump back to the loop head with new binding values.\n\nIf `recur` is not called, the loop terminates and returns the value of the body expression.",examples:["loop (n = 10, acc = 0) -> do\n if n == 0 then\n acc\n else\n recur(n - 1, acc + n)\n end\nend","loop (n = 5, acc = 1) -> do\n if n <= 1 then\n acc\n else\n recur(n - 1, acc * n)\n end\nend"]},evaluate:(e,n,{evaluateNode:o})=>{const a=e[1][1],i=Te(a,(e,t)=>Ae(o(t[1][1],n.create(e)),r=>Ae(Ft(t[1][0],r,e=>o(e,n)),t=>(Object.entries(t).forEach(([t,r])=>{e[t]={value:r}}),e))),{});return Ae(i,i=>{const s=n.create(i),c=e[1][2];function l(t){if(t.length!==a.length)throw new r(`recur expected ${a.length} parameters, got ${d(t.length)}`,e[2]);return Ae(Se(a,(e,r)=>Ae(Ft(e[1][0],M(t[r]),e=>o(e,n)),e=>{for(const[t,r]of Object.entries(e))i[t].value=r})),()=>m())}function m(){return je(()=>o(c,s),e=>{if(e instanceof t)return l(e.params);throw e})}for(;;)try{const e=o(c,s);return e instanceof Promise?e.catch(e=>{if(e instanceof t)return l(e.params);throw e}):e}catch(s){if(s instanceof t){const t=s.params;if(t.length!==a.length)throw new r(`recur expected ${a.length} parameters, got ${d(t.length)}`,e[2]);for(let e=0;e<a.length;e+=1){const r=Ft(a[e][1][0],M(t[e]),e=>o(e,n));if(r instanceof Promise)return r.then(r=>{for(const[e,t]of Object.entries(r))i[e].value=t;return Ae(Se(a.slice(e+1),(r,a)=>Ae(Ft(r[1][0],M(t[e+1+a]),e=>o(e,n)),e=>{for(const[t,r]of Object.entries(e))i[t].value=r})),()=>m())});for(const[e,t]of Object.entries(r))i[e].value=t}continue}throw s}})},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>{const a=e[1][1],i=a.reduce((e,t)=>{const r=Dt(t[1][0]);return Object.keys(r).forEach(t=>{e[t]={value:!0}}),e},{});return de(r(a.map(e=>e[1][1]),t,n,o),r([e[1][2]],t.create(i),n,o))}};function sr(e,t,r,n){const o=t[2],[,a,i]=t[1],s=[],c=a.map(()=>0);return function t(){const l={},m=r.create(l);return Ae(function e(t){if(t>=a.length)return"continue";const[r,i,s,u]=a[t],[p,g]=r[1];return Ae(n(g,m),r=>{const a=D(r,o),g=P(a)?a:Object.entries(a);if(0===g.length)return"abort";const h=f(c[t],o);if(h>=g.length)return 0===t?"abort":(c[t]=0,c[t-1]=f(c[t-1],o)+1,"skip");const d=M(g[h],o);return Ae(Ft(p,d,e=>n(e,m)),r=>(Object.entries(r).forEach(([e,t])=>{l[e]={value:t}}),Ae(i.length>0?function(e,t,r,n){let o;for(const a of e)o=Ae(o,()=>{const[e,o]=a[1];return Ae(n(o,r),o=>Ae(Ft(e,o,e=>n(e,r)),e=>{Object.entries(e).forEach(([e,r])=>{t[e]={value:r}})}))});return o}(i,l,m,n):void 0,()=>s?Ae(n(s,m),r=>r?u?Ae(n(u,m),r=>r?e(t+1):(c[t]=Number.POSITIVE_INFINITY,"skip")):e(t+1):(c[t]=f(c[t],o)+1,"skip")):u?Ae(n(u,m),r=>r?e(t+1):(c[t]=Number.POSITIVE_INFINITY,"skip")):e(t+1))))})}(0),r=>"abort"===r?e?s:null:"skip"===r?t():Ae(n(i,m),r=>(e&&s.push(r),c.length>0&&(c[c.length-1]+=1),t())))}()}function cr(e,t,r,n,o){const a=new Set,i={},[,s,c]=e[1];return s.forEach(e=>{const[s,c,l,m]=e,[u,p]=s[1];r([p],t.create(i),n,o).forEach(e=>a.add(e)),Object.assign(i,Dt(u)),c&&c.forEach(e=>{const[s,c]=e[1];r([c],t.create(i),n,o).forEach(e=>a.add(e)),Object.assign(i,Dt(s))}),l&&r([l],t.create(i),n,o).forEach(e=>a.add(e)),m&&r([m],t.create(i),n,o).forEach(e=>a.add(e))}),r([c],t.create(i),n,o).forEach(e=>a.add(e)),a}const lr={category:"special-expression",customVariants:["for (...binding) -> body"],details:[["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."]],returns:{type:"any",array:!0},description:"Iterates over `bindings`, evaluates `body` for each `binding` and returns an `array` of results.",examples:["\nfor (i in [1, 2, 3]) -> i * 2\n ","\nfor (\n i in range(10) let ii = i ^ 2 while ii < 40 when ii % 3 == 0,\n j in range(10) when j % 2 == 1\n) -> ii + j\n "]},mr={arity:ae(1),docs:lr,evaluate:(e,t,r)=>sr(!0,e,t,r.evaluateNode),getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>cr(e,t,r,n,o)},ur={category:"special-expression",customVariants:["doseq (...binding) -> body"],details:[["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."]],returns:{type:"null"},description:"Iterates over `bindings`, evaluates `body` for each `binding` and returns `null`. This is useful for side effects.",examples:["\ndoseq (i in [1, 2, 3]) -> write!(i * 2)\n "]},pr={arity:ae(1),docs:ur,evaluate:(e,t,r)=>Ae(sr(!1,e,t,r.evaluateNode),()=>null),getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>cr(e,t,r,n,o)},gr={arity:{},docs:{category:"special-expression",returns:{type:"boolean"},args:{a:{type:"any"},b:{type:"any"},c:{type:"any",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"\n Computes logical `or`. Evaluation of expressions evaluation starts from left.\n As soon as a `expression` evaluates to a truthy value, the result is returned.\n\n If all expressions evaluate to falsy values, the value of the last expression is returned.",examples:["false || 1","||(1, 1)",'||(3 > 2, "string")','||(3 < 2, "string")',"||(false, false, false, true)","||(1, 2, 3, 4)"]},evaluate:(e,t,{evaluateNode:r})=>Te(e[1][1],(e,n)=>e||r(n,t),!1),evaluateAsNormalExpression:(e,t)=>{let r=!1;for(const n of e)if(r=M(n,t),r)break;return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},hr={arity:{min:1},docs:{category:"special-expression",returns:{type:"any"},args:{a:{type:"any"},b:{type:"any"},c:{type:"any",rest:!0}},variants:[{argumentNames:["a"]},{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Nullish coalescing operator. Returns the first non-`null` value.\n\nEvaluation is short-circuited — as soon as a non-`null` value is found, the remaining expressions are not evaluated.\n\nIf all values are `null`, returns `null`.\n\nAlso works with undefined symbols — if a symbol is undefined, it is treated as `null`.",examples:["1 ?? 2","null ?? 2","??(null)",'??(null, "default")','??(1, "default")','false ?? "default"',"??(null, null, 3)"]},evaluate:(e,t,{evaluateNode:r})=>{const n=Symbol("qq-sentinel");return Ae(Te(e[1][1],(e,o)=>e!==n?e:_t(o)&&null===t.lookUp(o)?n:Ae(r(o,t),e=>null!==e?e:n),n),e=>e===n?null:e)},evaluateAsNormalExpression:(e,t)=>{for(const r of e){const e=M(r,t);if(null!==e)return e}return null},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},dr={arity:{},docs:{category:"special-expression",customVariants:["recur(...recur-args)"],description:"Recursevly calls enclosing function or loop with its evaluated `recur-args`.",examples:["\nlet foo = (n) -> do\n write!(n);\n if not(zero?(n)) then\n recur(n - 1)\n end\nend;\nfoo(3)","\n(n -> do\n write!(n);\n if not(zero?(n)) then\n recur(n - 1)\n end\nend)(3)","\nloop (n = 3) -> do\n write!(n);\n if not(zero?(n)) then\n recur(n - 1)\n end\nend"]},evaluate:(e,r,{evaluateNode:n})=>Ae(Ne(e[1][1],e=>n(e,r)),e=>{throw new t(e)}),evaluateAsNormalExpression:e=>{throw new t(e)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},yr={arity:ae(1),docs:{category:"special-expression",returns:{type:"never"},args:{expr:{type:"any"}},variants:[{argumentNames:["expr"]}],description:"Throws `UserDefinedError` with message set to $expr evaluated. $expr must evaluate to a string.",examples:['try throw("You shall not pass!") catch(error) "Error: " ++ error.message end','try throw(slice("You shall not pass!", 0, 3)) catch(error) "Error: " ++ error.message end']},evaluate:(e,t,{evaluateNode:r})=>Ae(r(e[1][1],t),t=>{const r=J(t,e[2],{nonEmpty:!0});throw new n(r,e[2])}),evaluateAsNormalExpression:(e,t)=>{const r=J(e[0],t,{nonEmpty:!0});throw new n(r,void 0)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r([e[1][1]],t,n,o)},vr={arity:{},docs:{category:"special-expression",customVariants:["try { try-body } catch { catch-body }","try { try-body } catch(error) { catch-body }"],details:[["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."]],description:"Executes `try-body`. If that throws, the `catch-body` gets executed. See examples for details.",examples:['\ntry\n 2 / 4\ncatch\n "Oops!"\nend','\ntry\n foo()\ncatch(error)\n "Error: " ++ error.message\nend',"\ntry\n foo()\ncatch\n 42\nend"]},evaluate:(e,t,{evaluateNode:r})=>{const[,n,o,a]=e[1];return je(()=>r(n,t),e=>{const n=o?{[o[1]]:{value:e}}:{};return r(a,t.create(n))})},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>{const[,a,i,s]=e[1],c=r([a],t,n,o),l=i?{[i[1]]:{value:!0}}:{};return de(c,r([s],t.create(l),n,o))}},fr={arity:{},docs:{category:"special-expression",returns:{type:"any",array:!0},args:{values:{type:"any",rest:!0}},variants:[{argumentNames:["values"]}],description:"Makes new array from $values.",examples:["array(1, 2, 3)","array(array(null, false, true))","[]","[1, 2, 3]","[1, 2, ...[3, 4, 5], 6]","[[null, false, true]]","[1, 2, 3][1]"],hideOperatorForm:!0},evaluate:(e,t,{evaluateNode:n})=>{const o=[];return Ae(Se(e[1][1],e=>Xt(e)?Ae(n(e[1],t),t=>{if(!Array.isArray(t))throw new r("Spread value is not an array",e[2]);o.push(...t)}):Ae(n(e,t),e=>{o.push(e)})),()=>o)},evaluateAsNormalExpression:(e,t)=>{const r=[];for(const n of e)r.push(M(n,t));return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},br={arity:{},docs:{category:"special-expression",returns:{type:"object"},args:{kvps:{type:"any",rest:!0,description:"key - value pairs, where key is a string"}},variants:[{argumentNames:["kvps"]}],description:"Constructs a new object. Object members are created from the $kvps key-value pairs. Requires an even number of arguments.",examples:["object()",'\nlet default = {\n type: "Person",\n name: "John Doe",\n age: 42\n};\n\n{\n ...default,\n name: "Lisa"\n}','object("x", 10, "y", true, "z", "A string")',"{}","{ a: 1, b: 2 }"],hideOperatorForm:!0},evaluate:(e,t,{evaluateNode:n})=>{const o={},a=e[1][1];return function e(i){if(i>=a.length)return o;const s=a[i];if(Xt(s))return Ae(n(s[1],t),t=>{if(!x(t))throw new r("Spread value is not an object",s[2]);return Object.assign(o,t),e(i+1)});{const c=a[i+1];if(void 0===c)throw new r("Missing value for key",s[2]);return Ae(n(s,t),r=>Ae(n(c,t),t=>(K(r,s[2]),o[r]=t,e(i+2))))}}(0)},evaluateAsNormalExpression:(e,t)=>{const r={};for(let n=0;n<e.length;n+=2){const o=e[n],a=e[n+1];K(o,t),r[o]=a??null}return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},xr={arity:ae(1),docs:{category:"special-expression",description:"Imports all functions from a module as an object. Use destructuring to pick specific functions.",customVariants:["import(module-name)"],returns:{type:"object"},examples:["let v = import(vector); v.stdev([1, 2, 3, 4])","let { linspace } = import(vector); linspace(0, 10, 5)","let g = import(grid); g.row([[1, 2], [3, 4]], 0)"]},evaluate:(e,t)=>{const n=e[1][1],o=e[2],a=t.getValueModule(n);if(a.found)return a.value;const i=t.getModule(n);if(!i)throw new r(`Unknown module: '${n}'`,o);const s={};for(const[e,t]of Object.entries(i.functions))s[e]={[u]:!0,sourceCodeInfo:o,functionType:"Module",moduleName:n,functionName:e,arity:t.arity};return s},getUndefinedSymbols:()=>new Set},wr={"??":0,"&&":1,"||":2,array:3,cond:4,"defined?":5,block:6,doseq:7,"0_lambda":8,for:9,if:10,let:11,loop:12,object:13,recur:14,match:15,throw:16,try:17,unless:18,import:19},kr=[hr,St,gr,fr,Et,Qt,er,pr,tr,mr,rr,ar,ir,br,dr,Bt,yr,vr,nr,xr],qr={normalExpressions:$t,specialExpressions:kr,allNormalExpressions:zt},Ar=Object.keys($t),Nr=Object.keys(wr),$r=["^","*","/","%","+","-","<<",">>",">>>","++","<","<=","≤",">",">=","≥","==","!=","!=","&","xor","|","&&","||","??","|>"],Tr=[...$r,"?",":","->","...",".",",","=",":",";"],zr=new Set(["comment","cond","defined?","block","doseq","if","let","loop","recur","throw","try","unless","while"]);function Sr(e){return!zr.has(e)}const Er=new Set($r);function jr(e){return Er.has(e)}const Mr=new Set(Tr);function Cr(e){return Mr.has(e)}const Pr=["number","string","object","array","vector","matrix","grid","boolean","function","integer","any","null","collection","sequence","regexp","never"];function Rr(e){return Pr.includes(e)}function Ir(e){return"args"in e&&"variants"in e}const Or={"assert!=":{category:"assertion",description:"If $a is the same as $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert!= } = import(assertion);\ntry assert!=(0, 0, "Expected different values") catch (e) e.message end',"let { assert!= } = import(assertion);\ntry assert!=(0, 0) catch (e) e.message end","let { assert!= } = import(assertion);\ntry 0 assert!= 0 catch (e) e.message end","let { assert!= } = import(assertion);\ntry assert!=(0, 1) catch (e) e.message end"],seeAlso:["assertion.assert="],hideOperatorForm:!0},"assert=":{category:"assertion",description:"If $a is not structural equal to $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert= } = import(assertion);\ntry assert=({ "a": 1 }, { "a": 2 }, "Expected equal values") catch (e) e.message end','let { assert= } = import(assertion);\ntry assert=({ "a": 1 }, { "a": 2 }) catch (e) e.message end','let { assert= } = import(assertion);\ntry assert=({ "a": 1 }, { "a": 1 }) catch (e) e.message end'],seeAlso:["assertion.assert!="],hideOperatorForm:!0},"assert-gt":{category:"assertion",description:"If $a is not greater than $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert-gt } = import(assertion);\ntry assert-gt(0, 1, "Expected greater value") catch (e) e.message end',"let { assert-gt } = import(assertion);\ntry assert-gt(0, 0) catch (e) e.message end","let { assert-gt } = import(assertion);\ntry assert-gt(1, 0) catch (e) e.message end"],seeAlso:["assertion.assert-lt","assertion.assert-gte","assertion.assert-lte"],hideOperatorForm:!0},"assert-lt":{category:"assertion",description:"If $a is not less than $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert-lt } = import(assertion);\ntry assert-lt(1, 0, "Expected smaller value value") catch (e) e.message end',"let { assert-lt } = import(assertion);\ntry assert-lt(1, 1) catch (e) e.message end","let { assert-lt } = import(assertion);\ntry assert-lt(0, 1) catch (e) e.message end"],seeAlso:["assertion.assert-gt","assertion.assert-lte","assertion.assert-gte"],hideOperatorForm:!0},"assert-gte":{category:"assertion",description:"If $a is less than $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert-gte } = import(assertion);\ntry assert-gte(0, 1, "Expected greater value") catch (e) e.message end',"let { assert-gte } = import(assertion);\ntry assert-gte(0, 1) catch (e) e.message end","let { assert-gte } = import(assertion);\ntry assert-gte(1, 1) catch (e) e.message end"],seeAlso:["assertion.assert-lte","assertion.assert-gt","assertion.assert-lt"],hideOperatorForm:!0},"assert-lte":{category:"assertion",description:"If $a is grater than $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert-lte } = import(assertion);\ntry assert-lte(1, 0, "Expected smaller value value") catch (e) e.message end',"let { assert-lte } = import(assertion);\ntry assert-lte(1, 0) catch (e) e.message end","let { assert-lte } = import(assertion);\ntry assert-lte(1, 1) catch (e) e.message end"],seeAlso:["assertion.assert-gte","assertion.assert-lt","assertion.assert-gt"],hideOperatorForm:!0},"assert-true":{category:"assertion",description:"If $value is not `true` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-true } = import(assertion);\ntry assert-true(false, "Expected true") catch (e) e.message end',"let { assert-true } = import(assertion);\ntry assert-true(false) catch (e) e.message end","let { assert-true } = import(assertion);\ntry assert-true(true) catch (e) e.message end"],seeAlso:["assertion.assert-false","assertion.assert-truthy","assertion.assert-falsy","assert","assertion.assert-boolean"],hideOperatorForm:!0},"assert-false":{category:"assertion",description:"If $value is not `false` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-false } = import(assertion);\ntry assert-false(true, "Expected false") catch (e) e.message end',"let { assert-false } = import(assertion);\ntry assert-false(true) catch (e) e.message end","let { assert-false } = import(assertion);\ntry assert-false(false) catch (e) e.message end"],seeAlso:["assertion.assert-true","assertion.assert-falsy","assertion.assert-truthy","assertion.assert-boolean"],hideOperatorForm:!0},"assert-truthy":{category:"assertion",description:"If $value is not `truthy` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-truthy } = import(assertion);\ntry assert-truthy(false, "Expected truthy") catch (e) e.message end',"let { assert-truthy } = import(assertion);\ntry assert-truthy(false) catch (e) e.message end","let { assert-truthy } = import(assertion);\ntry assert-truthy(0) catch (e) e.message end","let { assert-truthy } = import(assertion);\ntry assert-truthy(null) catch (e) e.message end",'let { assert-truthy } = import(assertion);\ntry assert-truthy("") catch (e) e.message end',"let { assert-truthy } = import(assertion);\ntry assert-truthy(true) catch (e) e.message end","let { assert-truthy } = import(assertion);\ntry assert-truthy(1) catch (e) e.message end",'let { assert-truthy } = import(assertion);\ntry assert-truthy("x") catch (e) e.message end',"let { assert-truthy } = import(assertion);\ntry assert-truthy([]) catch (e) e.message end","let { assert-truthy } = import(assertion);\ntry assert-truthy(nd) catch (e) e.message end"],seeAlso:["assertion.assert-falsy","assertion.assert-true","assertion.assert-false","assert","assertion.assert-null"],hideOperatorForm:!0},"assert-falsy":{category:"assertion",description:"If $value is not `falsy` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-falsy } = import(assertion);\ntry assert-falsy(true, "Expected falsy") catch (e) e.message end','let { assert-falsy } = import(assertion);\ntry assert-falsy("x") catch (e) e.message end',"let { assert-falsy } = import(assertion);\ntry assert-falsy([]) catch (e) e.message end","let { assert-falsy } = import(assertion);\ntry assert-falsy(nd) catch (e) e.message end","let { assert-falsy } = import(assertion);\ntry assert-falsy(1) catch (e) e.message end","let { assert-falsy } = import(assertion);\ntry assert-falsy(false) catch (e) e.message end","let { assert-falsy } = import(assertion);\ntry assert-falsy(0) catch (e) e.message end","let { assert-falsy } = import(assertion);\ntry assert-falsy(null) catch (e) e.message end",'let { assert-falsy } = import(assertion);\ntry assert-falsy("") catch (e) e.message end'],seeAlso:["assertion.assert-truthy","assertion.assert-false","assertion.assert-true","assertion.assert-null"],hideOperatorForm:!0},"assert-null":{category:"assertion",description:"If $value is not `null` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-null } = import(assertion);\ntry assert-null(null) catch (e) e.message end",'let { assert-null } = import(assertion);\ntry assert-null(true, "Expected null") catch (e) e.message end','let { assert-null } = import(assertion);\ntry assert-null("x") catch (e) e.message end',"let { assert-null } = import(assertion);\ntry assert-null([]) catch (e) e.message end","let { assert-null } = import(assertion);\ntry assert-null(nd) catch (e) e.message end","let { assert-null } = import(assertion);\ntry assert-null(1) catch (e) e.message end","let { assert-null } = import(assertion);\ntry assert-null(false) catch (e) e.message end","let { assert-null } = import(assertion);\ntry assert-null(0) catch (e) e.message end",'let { assert-null } = import(assertion);\ntry assert-null("") catch (e) e.message end'],seeAlso:["assertion.assert-truthy","assertion.assert-falsy"],hideOperatorForm:!0},"assert-throws":{category:"assertion",description:"If $fun does not throw, it throws `AssertionError`.",returns:{type:"null"},args:{fun:{type:"function"},message:{type:"string"}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","message"]}],examples:['let { assert-throws } = import(assertion);\nassert-throws(-> throw("Error"))','let { assert-throws } = import(assertion);\ntry assert-throws(-> identity("Error")) catch (e) e.message end'],seeAlso:["assertion.assert-throws-error","assertion.assert-not-throws"],hideOperatorForm:!0},"assert-throws-error":{category:"assertion",description:"If $fun does not throw $error-message, it throws `AssertionError`.",returns:{type:"null"},args:{fun:{type:"function"},"error-message":{type:"string"},message:{type:"string"}},variants:[{argumentNames:["value","error-message"]},{argumentNames:["value","error-message","message"]}],examples:['let { assert-throws-error } = import(assertion);\ntry assert-throws-error(-> throw("Error"), "Error") catch (e) e.message end','let { assert-throws-error } = import(assertion);\ntry assert-throws-error(-> identity("Error"), "Error") catch (e) e.message end'],seeAlso:["assertion.assert-throws","assertion.assert-not-throws"],hideOperatorForm:!0},"assert-not-throws":{category:"assertion",description:"If $fun throws, it throws `AssertionError`.",returns:{type:"null"},args:{fun:{type:"function"},message:{type:"string"}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","message"]}],examples:['let { assert-not-throws } = import(assertion);\ntry assert-not-throws(-> identity("Error")) catch (e) e.message end','let { assert-not-throws } = import(assertion);\ntry assert-not-throws(-> throw("Error")) catch (e) e.message end'],seeAlso:["assertion.assert-throws","assertion.assert-throws-error"],hideOperatorForm:!0},"assert-array":{category:"assertion",description:"If $value is not an `array` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-array } = import(assertion);\ntry assert-array([1, 2, 3]) catch (e) e.message end",'let { assert-array } = import(assertion);\ntry assert-array("string") catch (e) e.message end','let { assert-array } = import(assertion);\ntry assert-array(42, "Expected an array") catch (e) e.message end'],seeAlso:["assertion.assert-object","assertion.assert-collection","assertion.assert-sequence"],hideOperatorForm:!0},"assert-boolean":{category:"assertion",description:"If $value is not a `boolean` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-boolean } = import(assertion);\ntry assert-boolean(true) catch (e) e.message end","let { assert-boolean } = import(assertion);\ntry assert-boolean(false) catch (e) e.message end",'let { assert-boolean } = import(assertion);\ntry assert-boolean(1, "Expected a boolean") catch (e) e.message end'],seeAlso:["assertion.assert-true","assertion.assert-false","assertion.assert-number","assertion.assert-string"],hideOperatorForm:!0},"assert-collection":{category:"assertion",description:"If $value is not a `collection` (array, object, or string) it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-collection } = import(assertion);\ntry assert-collection([1, 2]) catch (e) e.message end","let { assert-collection } = import(assertion);\ntry assert-collection({ a: 1 }) catch (e) e.message end",'let { assert-collection } = import(assertion);\ntry assert-collection("hello") catch (e) e.message end','let { assert-collection } = import(assertion);\ntry assert-collection(42, "Expected a collection") catch (e) e.message end'],seeAlso:["assertion.assert-sequence","assertion.assert-array","assertion.assert-object"],hideOperatorForm:!0},"assert-function":{category:"assertion",description:"If $value is not a `function` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-function } = import(assertion);\ntry assert-function(-> $ + 1) catch (e) e.message end",'let { assert-function } = import(assertion);\ntry assert-function(42, "Expected a function") catch (e) e.message end'],seeAlso:["assertion.assert-number","assertion.assert-string"],hideOperatorForm:!0},"assert-grid":{category:"assertion",description:"If $value is not a `grid` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-grid } = import(assertion);\ntry assert-grid([[1, 2], [3, 4]]) catch (e) e.message end",'let { assert-grid } = import(assertion);\ntry assert-grid([1, 2], "Expected a grid") catch (e) e.message end'],seeAlso:["assertion.assert-matrix","assertion.assert-vector"],hideOperatorForm:!0},"assert-integer":{category:"assertion",description:"If $value is not an `integer` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-integer } = import(assertion);\ntry assert-integer(42) catch (e) e.message end",'let { assert-integer } = import(assertion);\ntry assert-integer(3.14, "Expected an integer") catch (e) e.message end'],seeAlso:["assertion.assert-number"],hideOperatorForm:!0},"assert-matrix":{category:"assertion",description:"If $value is not a `matrix` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-matrix } = import(assertion);\ntry assert-matrix([[1, 2], [3, 4]]) catch (e) e.message end",'let { assert-matrix } = import(assertion);\ntry assert-matrix([1, 2], "Expected a matrix") catch (e) e.message end'],seeAlso:["assertion.assert-vector","assertion.assert-grid"],hideOperatorForm:!0},"assert-number":{category:"assertion",description:"If $value is not a `number` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-number } = import(assertion);\ntry assert-number(42) catch (e) e.message end",'let { assert-number } = import(assertion);\ntry assert-number("hello", "Expected a number") catch (e) e.message end'],seeAlso:["assertion.assert-integer","assertion.assert-boolean","assertion.assert-string","assertion.assert-function"],hideOperatorForm:!0},"assert-object":{category:"assertion",description:"If $value is not an `object` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-object } = import(assertion);\ntry assert-object({ a: 1 }) catch (e) e.message end",'let { assert-object } = import(assertion);\ntry assert-object([1, 2], "Expected an object") catch (e) e.message end'],seeAlso:["assertion.assert-array","assertion.assert-collection"],hideOperatorForm:!0},"assert-regexp":{category:"assertion",description:"If $value is not a `regexp` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-regexp } = import(assertion);\ntry assert-regexp(#"^start") catch (e) e.message end','let { assert-regexp } = import(assertion);\ntry assert-regexp("hello", "Expected a regexp") catch (e) e.message end'],seeAlso:["assertion.assert-string"],hideOperatorForm:!0},"assert-sequence":{category:"assertion",description:"If $value is not a `sequence` (array or string) it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-sequence } = import(assertion);\ntry assert-sequence([1, 2]) catch (e) e.message end",'let { assert-sequence } = import(assertion);\ntry assert-sequence("hello") catch (e) e.message end','let { assert-sequence } = import(assertion);\ntry assert-sequence({ a: 1 }, "Expected a sequence") catch (e) e.message end'],seeAlso:["assertion.assert-collection","assertion.assert-array"],hideOperatorForm:!0},"assert-string":{category:"assertion",description:"If $value is not a `string` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-string } = import(assertion);\ntry assert-string("hello") catch (e) e.message end','let { assert-string } = import(assertion);\ntry assert-string(42, "Expected a string") catch (e) e.message end'],seeAlso:["assertion.assert-number","assertion.assert-boolean","assertion.assert-regexp","assertion.assert-function"],hideOperatorForm:!0},"assert-vector":{category:"assertion",description:"If $value is not a `vector` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-vector } = import(assertion);\ntry assert-vector([1, 2, 3]) catch (e) e.message end",'let { assert-vector } = import(assertion);\ntry assert-vector(["a", "b"], "Expected a vector") catch (e) e.message end'],seeAlso:["assertion.assert-matrix","assertion.assert-grid"],hideOperatorForm:!0}},Fr={"assert=":{evaluate:([e,t,r],n)=>{if(void 0!==r&&(K(r,n),r=` ${r}`),r??="",!me(M(e,n),M(t,n),n))throw new o(`Expected ${JSON.stringify(e,null,2)} to deep equal ${JSON.stringify(t,null,2)}.${r}`,n);return null},arity:{min:2,max:3}},"assert!=":{evaluate:([e,t,r],n)=>{if(void 0!==r&&(K(r,n),r=` ${r}`),r??="",me(M(e,n),M(t,n),n))throw new o(`Expected ${JSON.stringify(e)} not to deep equal ${JSON.stringify(t)}.${r}`,n);return null},arity:{min:2,max:3}},"assert-gt":{evaluate:([e,t,r],n)=>{if(X(e,n),X(t,n),void 0!==r&&(K(r,n),r=` ${r}`),r??="",le(e,t,n)<=0)throw new o(`Expected ${e} to be grater than ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-gte":{evaluate:([e,t,r],n)=>{if(X(e,n),X(t,n),void 0!==r&&(K(r,n),r=` ${r}`),r??="",le(e,t,n)<0)throw new o(`Expected ${e} to be grater than or equal to ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-lt":{evaluate:([e,t,r],n)=>{if(X(e,n),X(t,n),void 0!==r&&(K(r,n),r=` ${r}`),r??="",le(e,t,n)>=0)throw new o(`Expected ${e} to be less than ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-lte":{evaluate:([e,t,r],n)=>{if(X(e,n),X(t,n),void 0!==r&&(K(r,n),r=` ${r}`),r??="",le(e,t,n)>0)throw new o(`Expected ${e} to be less than or equal to ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-true":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!0!==e)throw new o(`Expected ${e} to be true.${t}`,r);return null},arity:{min:1,max:2}},"assert-false":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!1!==e)throw new o(`Expected ${e} to be false.${t}`,r);return null},arity:{min:1,max:2}},"assert-truthy":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!e)throw new o(`Expected ${e} to be truthy.${t}`,r);return null},arity:{min:1,max:2}},"assert-falsy":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",e)throw new o(`Expected ${e} to be falsy.${t}`,r);return null},arity:{min:1,max:2}},"assert-null":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",null!==e)throw new o(`Expected ${e} to be null.${t}`,r);return null},arity:{min:1,max:2}},"assert-throws":{evaluate:([e,t],r,n,{executeFunction:a})=>(void 0!==t&&(K(t,r),t=` ${t}`),t??="",L(e,r),je(()=>Ae(a(e,[],n,r),()=>{throw new o(`Expected function to throw.${t}`,r)}),()=>null)),arity:{min:1,max:2}},"assert-throws-error":{evaluate:([e,t,r],n,a,{executeFunction:i})=>(void 0!==r&&(K(r,n),r=` ${r}`),r??="",K(t,n),L(e,n),je(()=>Ae(i(e,[],a,n),()=>{throw new o(`Expected function to throw "${t}".${r}`,n)}),e=>{const a=e.shortMessage;if(a!==t)throw new o(`Expected function to throw "${t}", but thrown "${a}".${r}`,n);return null})),arity:{min:2,max:3}},"assert-not-throws":{evaluate:([e,t],r,n,{executeFunction:a})=>(void 0!==t&&(K(t,r),t=` ${t}`),t??="",L(e,r),je(()=>Ae(a(e,[],n,r),()=>null),()=>{throw new o(`Expected function not to throw.${t}`,r)})),arity:{min:1,max:2}},"assert-array":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!Array.isArray(e))throw new o(`Expected ${JSON.stringify(e)} to be an array.${t}`,r);return null},arity:{min:1,max:2}},"assert-boolean":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="","boolean"!=typeof e)throw new o(`Expected ${JSON.stringify(e)} to be a boolean.${t}`,r);return null},arity:{min:1,max:2}},"assert-collection":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!U(e))throw new o(`Expected ${JSON.stringify(e)} to be a collection.${t}`,r);return null},arity:{min:1,max:2}},"assert-function":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!w(e))throw new o(`Expected ${JSON.stringify(e)} to be a function.${t}`,r);return null},arity:{min:1,max:2}},"assert-grid":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!rt(e))throw new o(`Expected ${JSON.stringify(e)} to be a grid.${t}`,r);return null},arity:{min:1,max:2}},"assert-integer":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="","number"!=typeof e||!Q(e,{integer:!0}))throw new o(`Expected ${JSON.stringify(e)} to be an integer.${t}`,r);return null},arity:{min:1,max:2}},"assert-matrix":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!ot(e))throw new o(`Expected ${JSON.stringify(e)} to be a matrix.${t}`,r);return null},arity:{min:1,max:2}},"assert-number":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="","number"!=typeof e)throw new o(`Expected ${JSON.stringify(e)} to be a number.${t}`,r);return null},arity:{min:1,max:2}},"assert-object":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!O(e))throw new o(`Expected ${JSON.stringify(e)} to be an object.${t}`,r);return null},arity:{min:1,max:2}},"assert-regexp":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!G(e))throw new o(`Expected ${JSON.stringify(e)} to be a regexp.${t}`,r);return null},arity:{min:1,max:2}},"assert-sequence":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!P(e))throw new o(`Expected ${JSON.stringify(e)} to be a sequence.${t}`,r);return null},arity:{min:1,max:2}},"assert-string":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="","string"!=typeof e)throw new o(`Expected ${JSON.stringify(e)} to be a string.${t}`,r);return null},arity:{min:1,max:2}},"assert-vector":{evaluate:([e,t],r)=>{if(void 0!==t&&(K(t,r),t=` ${t}`),t??="",!Xe(e))throw new o(`Expected ${JSON.stringify(e)} to be a vector.${t}`,r);return null},arity:{min:1,max:2}}};for(const[e,t]of Object.entries(Or))Fr[e]&&(Fr[e].docs=t);const Ur={name:"assertion",functions:Fr},Dr={"cell-every?":{category:"grid",description:"Checks if all elements in a grid satisfy a predicate. Returns true only if the predicate returns true for every element in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { cell-every? } = import(grid);\ncell-every?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], string?)','let { cell-every? } = import(grid);\ncell-every?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], string?)',"let { cell-every? } = import(grid);\ncell-every?([\n [1, 2],\n [3, 4],\n], string?)"],seeAlso:["collection.every?","grid.some?","grid.every-row?","grid.every-col?"]},"some?":{category:"grid",description:"Checks if any element in a grid satisfies a predicate. Returns true if the predicate returns true for at least one element in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { some? } = import(grid);\nsome?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], string?)','let { some? } = import(grid);\nsome?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], string?)',"let { some? } = import(grid);\nsome?([\n [1, 2],\n [3, 4],\n], string?)"],seeAlso:["collection.any?","grid.cell-every?","grid.some-row?","grid.some-col?"]},"every-row?":{category:"grid",description:"Checks if all rows in a grid satisfy a predicate. Returns true only if the predicate returns true for every row in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { every-row? } = import(grid);\nevery-row?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> string?($[0]))','let { every-row? } = import(grid);\nevery-row?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> string?($[0]))',"let { every-row? } = import(grid);\nevery-row?([\n [1, 2],\n [3, 4],\n], -> string?($[0]))"],seeAlso:["grid.some-row?","grid.every-col?","grid.cell-every?"]},"some-row?":{category:"grid",description:"Checks if any row in a grid satisfies a predicate. Returns true if the predicate returns true for at least one row in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { some-row? } = import(grid);\nsome-row?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $ contains? "Albert")','let { some-row? } = import(grid);\nsome-row?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> $ contains? "Albert")','let { some-row? } = import(grid);\nsome-row?([\n [1, 2],\n [3, 4],\n], -> $ contains? "Albert")'],seeAlso:["grid.every-row?","grid.some-col?","grid.some?"]},"every-col?":{category:"grid",description:"Checks if all columns in a grid satisfy a predicate. Returns true only if the predicate returns true for every column in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { every-col? } = import(grid);\nevery-col?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> string?($[0]))','let { every-col? } = import(grid);\nevery-col?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> string?($[0]))',"let { every-col? } = import(grid);\nevery-col?([\n [1, 2],\n [3, 4],\n], -> string?($[0]))"],seeAlso:["grid.some-col?","grid.every-row?","grid.cell-every?"]},"some-col?":{category:"grid",description:"Checks if any column in a grid satisfies a predicate. Returns true if the predicate returns true for at least one column in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { some-col? } = import(grid);\nsome-col?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $ contains? "Albert")','let { some-col? } = import(grid);\nsome-col?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> $ contains? "Albert")','let { some-col? } = import(grid);\nsome-col?([\n [1, 2],\n [3, 4],\n], -> $ contains? "Albert")'],seeAlso:["grid.every-col?","grid.some-row?","grid.some?"]},row:{category:"grid",description:"Returns the row at index $a in the grid $b.",returns:{type:"any"},args:{a:{type:"grid"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:['let { row } = import(grid);\nrow([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 0)','let { row } = import(grid);\nrow([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)','let { row } = import(grid);\nrow([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 2)'],seeAlso:["grid.col","grid.shape"]},col:{category:"grid",description:"Returns the column at index $a in the grid $b.",returns:{type:"any"},args:{a:{type:"grid"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:['let { col } = import(grid);\ncol([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 0)','let { col } = import(grid);\ncol([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)','let { col } = import(grid);\ncol([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 2)'],seeAlso:["grid.row","grid.shape"]},shape:{category:"grid",description:"Returns the shape of the grid `g` as a `vector` of two numbers, where the first number is the number of rows and the second number is the number of columns.",returns:{type:"vector"},args:{g:{type:"grid",description:"The grid to get the shape of."}},variants:[{argumentNames:["g"]}],examples:['let { shape } = import(grid);\nshape([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { shape } = import(grid);\nshape([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { shape } = import(grid);\nshape([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.row","grid.col","grid.reshape"]},fill:{category:"grid",description:"Creates a grid of the specified size, filled with the specified value.",returns:{type:"grid"},args:{rows:{type:"integer",description:"The number of rows in the grid."},cols:{type:"integer",description:"The number of columns in the grid."},value:{type:"any",description:"The value to fill the grid with."}},variants:[{argumentNames:["rows","cols","value"]}],examples:["let { fill } = import(grid);\nfill(2, 3, 0)",'let { fill } = import(grid);\nfill(2, 3, "x")'],seeAlso:["grid.generate","grid.from-array"]},generate:{category:"grid",description:"Generates a grid of the specified size, where each element is generated by the provided function.",returns:{type:"grid"},args:{rows:{type:"number",description:"The number of rows in the grid."},cols:{type:"number",description:"The number of columns in the grid."},fn:{type:"function",description:"The function to generate the grid. It takes two arguments: the row index and the column index."}},variants:[{argumentNames:["rows","cols","fn"]}],examples:["let { generate } = import(grid);\ngenerate(3, 3, (i, j) -> i + j)"],seeAlso:["grid.fill","grid.from-array"]},reshape:{category:"grid",description:"Reshapes the grid `a` into a new grid with the specified number of rows `b`. The number of columns is automatically calculated based on the total number of elements in the grid.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:['let { reshape } = import(grid);\nreshape([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], 2)'],seeAlso:["grid.shape","grid.from-array"]},transpose:{category:"grid",description:"Transposes the grid `g`, swapping its rows and columns.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to transpose."}},variants:[{argumentNames:["g"]}],examples:['let { transpose } = import(grid);\ntranspose([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { transpose } = import(grid);\ntranspose([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { transpose } = import(grid);\ntranspose([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.flip-h","grid.flip-v","grid.rotate"]},"flip-h":{category:"grid",description:"Flips the grid `g` horizontally.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to flip horizontally."}},variants:[{argumentNames:["g"]}],examples:['let { flip-h } = import(grid);\nflip-h([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { flip-h } = import(grid);\nflip-h([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { flip-h } = import(grid);\nflip-h([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.flip-v","grid.transpose","grid.rotate"]},"flip-v":{category:"grid",description:"Flips the grid `g` vertically.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to flip vertically."}},variants:[{argumentNames:["g"]}],examples:['let { flip-v } = import(grid);\nflip-v([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { flip-v } = import(grid);\nflip-v([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { flip-v } = import(grid);\nflip-v([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.flip-h","grid.transpose","grid.rotate"]},rotate:{category:"grid",description:"Rotates the grid `g` by the specified angle. The angle is given in terms of 90-degree rotations. Positive values rotate the grid clockwise, while negative values rotate it counterclockwise.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 1)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 2)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 3)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 4)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], -1)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], -2)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], -3)"],seeAlso:["grid.transpose","grid.flip-h","grid.flip-v"]},crop:{category:"grid",description:"Crops the grid `g` from the starting index `begin` to the optional ending index `stop`. The crop is inclusive of the starting index and exclusive of the ending index.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to slice."},begin:{type:"vector",description:"The starting index of the slice as a vector of two numbers: `[row, col]`."},stop:{type:"vector",description:"Optional ending index of the slice as a vector of two numbers: `[row, col]`."}},variants:[{argumentNames:["g","begin"]},{argumentNames:["g","begin","stop"]}],examples:['let { crop } = import(grid);\ncrop([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [1, 1], [2, 2])','let { crop } = import(grid);\ncrop([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [1, 1])'],hideOperatorForm:!0,seeAlso:["grid.slice-rows","grid.slice-cols"]},"slice-rows":{category:"grid",description:"Slices rows of the grid `g` from the starting index `begin` to the optional ending index `stop`. The slice is inclusive of the starting index and exclusive of the ending index.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to slice."},begin:{type:"number",description:"The starting index of the slice."},stop:{type:"number",description:"Optional ending index of the slice."}},variants:[{argumentNames:["g","begin"]},{argumentNames:["g","begin","stop"]}],examples:['let { slice-rows } = import(grid);\nslice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { slice-rows } = import(grid);\nslice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)'],hideOperatorForm:!0,seeAlso:["grid.crop","grid.slice-cols","grid.splice-rows"]},"slice-cols":{category:"grid",description:"Slices columns of the grid `g` from the starting index `begin` to the optional ending index `stop`. The slice is inclusive of the starting index and exclusive of the ending index.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to slice."},begin:{type:"number",description:"The starting index of the slice."},stop:{type:"number",description:"Optional ending index of the slice."}},variants:[{argumentNames:["g","begin"]},{argumentNames:["g","begin","stop"]}],examples:['let { slice-cols } = import(grid);\nslice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { slice-cols } = import(grid);\nslice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)'],hideOperatorForm:!0,seeAlso:["grid.crop","grid.slice-rows","grid.splice-cols"]},"splice-rows":{category:"grid",description:"Splices rows of the grid `g` starting from the index `begin`. Deletes `deleteCount` rows and inserts the specified `items` at that position.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to splice."},begin:{type:"number",description:"The starting index of the splice."},deleteCount:{type:"number",description:"The number of rows to delete."},items:{type:"array",rest:!0,description:"The rows to insert."}},variants:[{argumentNames:["g","begin","deleteCount"]},{argumentNames:["g","begin","deleteCount","items"]}],examples:['let { splice-rows } = import(grid);\nsplice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { splice-rows } = import(grid);\nsplice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 1, ["Nazanin", "mother", 40])'],hideOperatorForm:!0,seeAlso:["grid.splice-cols","grid.slice-rows"]},"splice-cols":{category:"grid",description:"Splices columns of the grid `g` starting from the index `begin`. Deletes `deleteCount` columns and inserts the specified `items` at that position.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to splice."},begin:{type:"number",description:"The starting index of the splice."},deleteCount:{type:"number",description:"The number of columns to delete."},items:{type:"array",rest:!0,description:"The columns to insert."}},variants:[{argumentNames:["g","begin","deleteCount"]},{argumentNames:["g","begin","deleteCount","items"]}],examples:['let { splice-cols } = import(grid);\nsplice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { splice-cols } = import(grid);\nsplice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 1, ["f", "m", "s"])'],hideOperatorForm:!0,seeAlso:["grid.splice-rows","grid.slice-cols"]},"concat-rows":{category:"grid",description:"Concatenates two grids `a` and `b` by rows. The number of columns in both grids must be the same.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"grid"}},variants:[{argumentNames:["a","b"]}],examples:['let { concat-rows } = import(grid);\nconcat-rows([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], [\n [1, 2],\n [3, 4],\n])'],seeAlso:["grid.concat-cols","grid.push-rows"]},"concat-cols":{category:"grid",description:"Concatenates two grids `a` and `b` by columns. The number of rows in both grids must be the same.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"grid"}},variants:[{argumentNames:["a","b"]}],examples:['let { concat-cols } = import(grid);\nconcat-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])'],seeAlso:["grid.concat-rows","grid.push-cols"]},"cell-map":{category:"grid",description:"Maps a function `a` over each element of the grid `b`, returning a new grid with the results.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { cell-map } = import(grid);\ncell-map([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], str)'],seeAlso:["map","grid.cell-mapi","grid.cell-reduce"]},"cell-mapi":{category:"grid",description:"Maps a function `a` over each element of the grid `b`, passing the row and column index as additional arguments to the function.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { cell-mapi } = import(grid);\ncell-mapi([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $1 ++ "(" ++ $2 ++ ", " ++ $3 ++ ")")'],seeAlso:["grid.cell-map","grid.cell-reducei","map"]},"cell-reduce":{category:"grid",description:"Reduces the grid `a` using the function `b`, returning a single value.",returns:{type:"any"},args:{g:{type:"grid",description:"The grid to reduce."},fn:{type:"function",description:"The function to reduce the grid. It takes two arguments: the accumulator and the current element."},"initial-value":{type:"any",description:"The initial value for the accumulator."}},variants:[{argumentNames:["g","fn","initial-value"]}],examples:['// Using "as" alias because "reduce" shadows a builtin function\nlet { cell-reduce } = import(grid);\ncell-reduce([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ++, "")'],seeAlso:["reduce","grid.cell-reducei","grid.cell-map"]},"cell-reducei":{category:"grid",description:"Reduces the grid `a` using the function `b`, passing the row and column indices as additional arguments to the function.",returns:{type:"any"},args:{g:{type:"grid",description:"The grid to reduce."},fn:{type:"function",description:"The function to reduce the grid. It takes four arguments: the accumulator, the current element, the row index, and the column index."},"initial-value":{type:"any",description:"The initial value for the accumulator."}},variants:[{argumentNames:["g","fn","initial-value"]}],examples:['// Using "as" alias because "reducei" shadows a builtin function\nlet { cell-reducei } = import(grid);\ncell-reducei([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ++, "")'],seeAlso:["grid.cell-reduce","grid.cell-mapi","reduce"]},"push-rows":{category:"grid",description:"Pushes the specified rows into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to push rows into."},rows:{type:"array",rest:!0,description:"The rows to push into the grid."}},variants:[{argumentNames:["g","rows"]}],examples:['let { push-rows } = import(grid);\npush-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["Nazanin", "mother", 40])'],hideOperatorForm:!0,seeAlso:["grid.unshift-rows","grid.pop-row","grid.shift-row","grid.concat-rows"]},"unshift-rows":{category:"grid",description:"Unshifts the specified rows into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to unshift rows into."},rows:{type:"array",rest:!0,description:"The rows to unshift into the grid."}},variants:[{argumentNames:["g","rows"]}],examples:['let { unshift-rows } = import(grid);\nunshift-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["Nazanin", "mother", 40])'],hideOperatorForm:!0,seeAlso:["grid.push-rows","grid.shift-row","grid.pop-row"]},"pop-row":{category:"grid",description:"Pops the last row from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to pop a row from."}},variants:[{argumentNames:["g"]}],examples:['let { pop-row } = import(grid);\npop-row([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.shift-row","grid.push-rows","grid.unshift-rows"]},"shift-row":{category:"grid",description:"Shifts the first row from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to shift a row from."}},variants:[{argumentNames:["g"]}],examples:['let { shift-row } = import(grid);\nshift-row([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.pop-row","grid.push-rows","grid.unshift-rows"]},"push-cols":{category:"grid",description:"Pushes the specified columns into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to push columns into."},cols:{type:"array",rest:!0,description:"The columns to push into the grid."}},variants:[{argumentNames:["g","cols"]}],examples:['let { push-cols } = import(grid);\npush-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["f", "m", "s"])'],hideOperatorForm:!0,seeAlso:["grid.unshift-cols","grid.pop-col","grid.shift-col","grid.concat-cols"]},"unshift-cols":{category:"grid",description:"Unshifts the specified columns into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to unshift columns into."},cols:{type:"array",rest:!0,description:"The columns to unshift into the grid."}},variants:[{argumentNames:["g","cols"]}],examples:['let { unshift-cols } = import(grid);\nunshift-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["f", "m", "s"])'],hideOperatorForm:!0,seeAlso:["grid.push-cols","grid.shift-col","grid.pop-col"]},"pop-col":{category:"grid",description:"Pops the last column from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to pop a column from."}},variants:[{argumentNames:["g"]}],examples:['let { pop-col } = import(grid);\npop-col([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.shift-col","grid.push-cols","grid.unshift-cols"]},"shift-col":{category:"grid",description:"Shifts the first column from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to shift a column from."}},variants:[{argumentNames:["g"]}],examples:['let { shift-col } = import(grid);\nshift-col([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.pop-col","grid.push-cols","grid.unshift-cols"]},"from-array":{category:"grid",description:"Creates a grid from a flat array with specified dimensions. The array is reshaped into the specified number of rows, and the number of columns is automatically calculated based on the total number of elements in the array.",returns:{type:"grid"},args:{a:{type:"array"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:["let { from-array } = import(grid);\nfrom-array([1, 2, 3, 4], 2)","let { from-array } = import(grid);\nfrom-array([1, 2, 3, 4], 4)"],seeAlso:["grid.fill","grid.generate","grid.reshape"]}};function Wr(e){const t=[];for(let r=0;r<e[0].length;r+=1){const n=[];for(let t=0;t<e.length;t+=1)n.push(e[t][r]);t.push(n)}return t}const Gr={"cell-every?":{evaluate:([e,t],r,n,{executeFunction:o})=>{nt(e,r),L(t,r);const a=[];for(const t of e)for(const e of t)a.push(e);return Pe(a,e=>o(t,[e],n,r))},arity:ae(2)},"some?":{evaluate:([e,t],r,n,{executeFunction:o})=>{nt(e,r),L(t,r);const a=[];for(const t of e)for(const e of t)a.push(e);return Me(a,e=>o(t,[e],n,r))},arity:ae(2)},"every-row?":{evaluate:([e,t],r,n,{executeFunction:o})=>(nt(e,r),L(t,r),Pe(Array.from(e),e=>o(t,[e],n,r))),arity:ae(2)},"some-row?":{evaluate:([e,t],r,n,{executeFunction:o})=>(nt(e,r),L(t,r),Me(Array.from(e),e=>o(t,[e],n,r))),arity:ae(2)},"every-col?":{evaluate:([e,t],r,n,{executeFunction:o})=>{nt(e,r),L(t,r);const a=Wr(e);return Pe(Array.from(a),e=>o(t,[e],n,r))},arity:ae(2)},"some-col?":{evaluate:([e,t],r,n,{executeFunction:o})=>{nt(e,r),L(t,r);const a=Wr(e);return Me(Array.from(a),e=>o(t,[e],n,r))},arity:ae(2)},row:{evaluate:([e,t],r)=>(nt(e,r),ee(t,r,{integer:!0,nonNegative:!0,lt:e.length}),e[t]),arity:ae(2)},col:{evaluate:([e,t],r)=>(nt(e,r),ee(t,r,{integer:!0,nonNegative:!0,lt:e[0].length}),e.map(e=>e[t])),arity:ae(2)},shape:{evaluate:([e],t)=>(nt(e,t),[e.length,e[0].length]),arity:ae(1)},fill:{evaluate:([e,t,r],n)=>{ee(e,n,{integer:!0,positive:!0}),ee(t,n,{integer:!0,positive:!0}),C(r,n);const o=[];for(let n=0;n<e;n+=1){const e=[];for(let n=0;n<t;n+=1)e.push(r);o.push(e)}return o},arity:ae(3)},generate:{evaluate:([e,t,r],n,o,{executeFunction:a})=>(ee(e,n,{integer:!0,positive:!0}),ee(t,n,{integer:!0,positive:!0}),L(r,n),Ne(Array.from({length:e}),(e,i)=>Ne(Array.from({length:t}),(e,t)=>Ae(a(r,[i,t],o,n),e=>(C(e,n),e))))),arity:ae(3)},reshape:{evaluate:([e,t],n)=>{nt(e,n),ee(t,n,{integer:!0,positive:!0});const o=e.flat();if(o.length%t!==0)throw new r(`The number of elements in the grid must be divisible by rows, but got ${o.length} and ${t}`,n);const a=o.length/t,i=[];for(let e=0;e<t;e+=1){const t=[];for(let r=0;r<a;r+=1)t.push(o[e*a+r]);i.push(t)}return i},arity:ae(2)},transpose:{evaluate:([e],t)=>(nt(e,t),Wr(e)),arity:ae(1)},"flip-h":{evaluate:([e],t)=>(nt(e,t),e.map(e=>e.reverse())),arity:ae(1)},"flip-v":{evaluate:([e],t)=>(nt(e,t),e.reverse()),arity:ae(1)},rotate:{evaluate:([e,t],r)=>{if(nt(e,r),ee(t,r,{integer:!0}),0===(t=(t%4+4)%4)||0===e.length)return e.map(e=>[...e]);const n=e.length,o=e[0].length;let a;switch(t){case 1:a=Array(o).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<o;r++)a[r][n-1-t]=e[t][r];break;case 2:a=Array(n).fill(null).map(()=>Array(o).fill(null));for(let t=0;t<n;t++)for(let r=0;r<o;r++)a[n-1-t][o-1-r]=e[t][r];break;case 3:a=Array(o).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<o;r++)a[o-1-r][t]=e[t][r]}return a},arity:ae(2)},crop:{evaluate:([e,t,n],o)=>{if(nt(e,o),Ze(t,o),2!==t.length)throw new r(`The start vector must have 2 elements, but got ${t.length}`,o);const[a,i]=t;if(ee(a,o,{integer:!0,nonNegative:!0,lt:e.length}),ee(i,o,{integer:!0,nonNegative:!0,lt:e[0].length}),n??=[e.length,e[0].length],Ze(n,o),2!==n.length)throw new r(`The end vector must have 2 elements, but got ${n.length}`,o);const[s,c]=n;ee(s,o,{gt:a,lte:e.length}),ee(c,o,{gt:i,lte:e[0].length});const l=[];for(let t=a;t<s;t+=1){const r=[];for(let n=i;n<c;n+=1)r.push(e[t][n]);l.push(r)}return l},arity:{min:2,max:3}},"slice-rows":{evaluate:([e,t,r],n)=>(nt(e,n),void 0===r?(ee(t,n,{integer:!0,lte:e.length,gte:-e.length}),t<0?e.slice(e.length+t):e.slice(t)):(ee(t,n,{integer:!0,nonNegative:!0,lte:e.length}),ee(r,n,{integer:!0}),ee(r=r<0?e.length+r:r,n,{gt:t,lte:e.length}),e.slice(t,r))),arity:{min:2,max:3}},"slice-cols":{evaluate:([e,t,r],n)=>{nt(e,n);const o=Wr(e);return void 0===r?(ee(t,n,{integer:!0,lte:o.length,gte:-o.length}),Wr(t<0?o.slice(o.length+t):o.slice(t))):(ee(t,n,{integer:!0,nonNegative:!0,lte:o.length}),ee(r,n,{integer:!0}),ee(r=r<0?o.length+r:r,n,{gt:t,lte:o.length}),Wr(o.slice(t,r)))},arity:{min:2,max:3}},"splice-rows":{evaluate:([e,t,n,...o],a)=>{nt(e,a),ee(t,a,{integer:!0,nonNegative:!0,lte:e.length}),ee(n,a,{integer:!0,nonNegative:!0}),0!==o.length&&(nt(o,a),o.every(t=>{if(we(t,a),e[0].length!==t.length)throw new r(`All rows must have the same length as the number of columns in grid, but got ${t.length}`,a);return!0}));const i=[];for(let r=0;r<t;r+=1)i.push(e[r]);o.length>0&&i.push(...o);for(let r=t+n;r<e.length;r+=1)i.push(e[r]);return i},arity:{min:3}},"splice-cols":{evaluate:([e,t,n,...o],a)=>{nt(e,a);const i=Wr(e);ee(t,a,{integer:!0,nonNegative:!0,lte:i.length}),ee(n,a,{integer:!0,nonNegative:!0}),0!==o.length&&(nt(o,a),o.every(e=>{if(we(e,a),i[0].length!==e.length)throw new r(`All rows must have the same length as the number of rows in grid, but got ${e.length}`,a);return!0}));const s=[];for(let e=0;e<t;e+=1)s.push(i[e]);s.push(...o);for(let e=t+n;e<i.length;e+=1)s.push(i[e]);return Wr(s)},arity:{min:3}},"concat-rows":{evaluate:(e,t)=>{we(e,t),e.every(e=>nt(e,t));const n=e[0][0].length;e.slice(1).every(e=>{if(e[0].length!==n)throw new r(`All grids must have the same number of columns, but got ${n} and ${e[0].length}`,t);return!0});const o=[];return e.forEach(e=>{e.forEach(e=>{o.push(e)})}),o},arity:{min:1}},"concat-cols":{evaluate:(e,t)=>{we(e,t),e.every(e=>nt(e,t));const n=e[0].length;e.slice(1).every(e=>{if(e.length!==n)throw new r(`All grids must have the same number of rows, but got ${n} and ${e.length}`,t);return!0});const o=[];for(let t=0;t<n;t+=1){const r=[];e.forEach(e=>{r.push(...e[t])}),o.push(r)}return o},arity:{min:1}},"cell-map":{evaluate:(e,t,n,{executeFunction:o})=>{const a=B(e.at(-1),t),i=e.slice(0,-1);nt(i[0],t);const s=i[0].length,c=i[0][0].length;return i.slice(1).forEach(e=>{if(nt(e,t),e.length!==s)throw new r(`All grids must have the same number of rows, but got ${s} and ${e.length}`,t);if(e[0].length!==c)throw new r(`All grids must have the same number of columns, but got ${c} and ${e[0].length}`,t)}),Ne(Array.from({length:s}),(e,r)=>Ne(Array.from({length:c}),(e,s)=>{const c=i.map(e=>e[r][s]);return Ae(o(a,c,n,t),e=>M(e))}))},arity:{min:2}},"cell-mapi":{evaluate:([e,t],r,n,{executeFunction:o})=>{nt(e,r),L(t,r);const a=e.length,i=e[0].length;return Ne(Array.from({length:a}),(a,s)=>Ne(Array.from({length:i}),(a,i)=>Ae(o(t,[e[s][i],s,i],n,r),e=>M(e))))},arity:ae(2)},"cell-reduce":{evaluate:([e,t,r],n,o,{executeFunction:a})=>{nt(e,n),L(t,n);const i=[];for(const t of e)for(const e of t)i.push(e);return Te(i,(e,r)=>a(t,[e,r],o,n),M(r))},arity:ae(3)},"cell-reducei":{evaluate:([e,t,r],n,o,{executeFunction:a})=>{nt(e,n),L(t,n);const i=[];for(let t=0;t<e.length;t+=1)for(let r=0;r<e[t].length;r+=1)i.push({cell:e[t][r],i:t,j:r});return Te(i,(e,{cell:r,i:i,j:s})=>a(t,[e,r,i,s],o,n),M(r))},arity:ae(3)},"push-rows":{evaluate:([e,...t],n)=>{if(nt(e,n),nt(t,n),e[0].length!==t[0].length)throw new r(`All rows must have the same length as the number of columns in grid, but got ${e[0].length} and ${t[0].length}`,n);return[...e,...t]},arity:{min:2}},"unshift-rows":{evaluate:([e,...t],n)=>{if(nt(e,n),nt(t,n),e[0].length!==t[0].length)throw new r(`All rows must have the same length as the number of columns in grid, but got ${e[0].length} and ${t[0].length}`,n);return[...t,...e]},arity:{min:2}},"pop-row":{evaluate:([e],t)=>(nt(e,t),1===e.length?null:e.slice(0,-1)),arity:ae(1)},"shift-row":{evaluate:([e],t)=>(nt(e,t),1===e.length?null:e.slice(1)),arity:ae(1)},"push-cols":{evaluate:([e,...t],n)=>{if(nt(e,n),nt(t,n),e.length!==t[0].length)throw new r(`All columns must have the same length as the number of rows in grid, but got ${t.length}`,n);const o=[];for(let r=0;r<e.length;r+=1){const n=[];n.push(...e[r]),t.forEach(e=>{n.push(e[r])}),o.push(n)}return o},arity:{min:2}},"unshift-cols":{evaluate:([e,...t],n)=>{if(nt(e,n),nt(t,n),e.length!==t[0].length)throw new r(`All columns must have the same length as the number of rows in grid, but got ${t.length}`,n);const o=[];for(let r=0;r<e.length;r+=1){const n=[];t.forEach(e=>{n.push(e[r])}),n.push(...e[r]),o.push(n)}return o},arity:{min:2}},"pop-col":{evaluate:([e],t)=>(nt(e,t),1===e[0].length?null:e.map(e=>e.slice(0,-1))),arity:ae(1)},"shift-col":{evaluate:([e],t)=>(nt(e,t),1===e[0].length?null:e.map(e=>e.slice(1))),arity:ae(1)},"from-array":{evaluate:([e,t],n)=>{if(we(e,n),ee(t,n,{integer:!0,positive:!0}),e.length%t!==0)throw new r(`The number of elements in the array must be divisible by rows, but got ${e.length} and ${t}`,n);return function(e,t){const r=[],n=e.length/t;for(let o=0;o<t;o++){const t=o*n,a=t+n;r.push(e.slice(t,a))}return r}(e,t)},arity:ae(2)}};for(const[e,t]of Object.entries(Dr))Gr[e]&&(Gr[e].docs=t);const Vr={name:"grid",functions:Gr},Br={"random!":{category:"random",description:"Returns a random number between 0 and 1.",returns:{type:"number"},args:{},variants:[{argumentNames:[]}],examples:["let { random! } = import(random);\nrandom!()"],seeAlso:["random.random-float!","random.random-int!","random.random-boolean!"]},"random-int!":{category:"random",description:"Returns a random integer between min and max (exclusive).",returns:{type:"integer"},args:{a:{type:"integer",description:"The minimum value."},b:{type:"integer",description:"The maximum value (exclusive)."}},variants:[{argumentNames:["a","b"]}],examples:["let { random-int! } = import(random);\nrandom-int!(0, 10)","let { random-int! } = import(random);\nrandom-int!(1, 100)"],seeAlso:["random.random-int-inclusive!","random.random-float!","random.random!"]},"random-int-inclusive!":{category:"random",description:"Returns a random integer between min and max (inclusive).",returns:{type:"integer"},args:{a:{type:"integer",description:"The minimum value."},b:{type:"integer",description:"The maximum value (inclusive)."}},variants:[{argumentNames:["a","b"]}],examples:["let { random-int-inclusive! } = import(random);\nrandom-int-inclusive!(0, 10)"],seeAlso:["random.random-int!","random.random-float!"]},"random-float!":{category:"random",description:"Returns a random float between min and max.",returns:{type:"number"},args:{a:{type:"number",description:"The minimum value."},b:{type:"number",description:"The maximum value."}},variants:[{argumentNames:["a","b"]}],examples:["let { random-float! } = import(random);\nrandom-float!(0, 10)","let { random-float! } = import(random);\nrandom-float!(1, 100)"],seeAlso:["random.random!","random.random-int!","random.random-int-inclusive!"]},"random-boolean!":{category:"random",description:"Returns a random boolean.",returns:{type:"boolean"},args:{prob:{type:"number",description:"The probability of returning true (between 0 and 1)."}},variants:[{argumentNames:["prob"]}],examples:["let { random-boolean! } = import(random);\nrandom-boolean!()","let { random-boolean! } = import(random);\nrandom-boolean!(0.99)"],seeAlso:["random.random!"]},"random-item!":{category:"random",description:"Returns a random item from the array.",returns:{type:"any"},args:{a:{type:"array",description:"The array to sample from."}},variants:[{argumentNames:["a"]}],examples:["let { random-item! } = import(random);\nrandom-item!([1, 2, 3, 4, 5])",'let { random-item! } = import(random);\nrandom-item!(["apple", "banana", "cherry"])'],seeAlso:["random.random-sample!","random.random-sample-unique!","random.random-char!"]},"random-sample-unique!":{category:"random",description:"Returns a random sample of n unique items from the array.",returns:{type:"array"},args:{a:{type:"array",description:"The array to sample from."},b:{type:"integer",description:"The number of items to sample."}},variants:[{argumentNames:["a","b"]}],examples:["let { random-sample-unique! } = import(random);\nrandom-sample-unique!([1, 2, 3, 4, 5], 3)",'let { random-sample-unique! } = import(random);\nrandom-sample-unique!(["apple", "banana", "cherry"], 2)'],seeAlso:["random.random-sample!","random.random-item!","random.shuffle!"]},"random-sample!":{category:"random",description:"Returns a random sample of n items from the array.",returns:{type:"array"},args:{a:{type:"array",description:"The array to sample from."},b:{type:"integer",description:"The number of items to sample."}},variants:[{argumentNames:["a","b"]}],examples:["let { random-sample! } = import(random);\nrandom-sample!([1, 2, 3, 4, 5], 3)",'let { random-sample! } = import(random);\nrandom-sample!(["apple", "banana", "cherry"], 10)'],seeAlso:["random.random-sample-unique!","random.random-item!","random.shuffle!"]},"shuffle!":{category:"random",description:"Returns a shuffled version of the array.",returns:{type:"array"},args:{a:{type:"array",description:"The array to shuffle."}},variants:[{argumentNames:["a"]}],examples:["let { shuffle! } = import(random);\nshuffle!([1, 2, 3, 4, 5])",'let { shuffle! } = import(random);\nshuffle!(["apple", "banana", "cherry"])'],seeAlso:["random.random-sample!","random.random-sample-unique!"]},"random-normal!":{category:"random",description:"Returns a random number from a normal distribution with the given mean and standard deviation.",returns:{type:"number"},args:{mean:{type:"number",description:"The mean of the normal distribution."},stdDev:{type:"number",description:"The standard deviation of the normal distribution."}},variants:[{argumentNames:["mean","stdDev"]}],examples:["let { random-normal! } = import(random);\nrandom-normal!(0, 1)","let { random-normal! } = import(random);\nrandom-normal!(5, 2)"],seeAlso:["random.random-exponential!","random.random-binomial!","random.random-poisson!"],hideOperatorForm:!0},"random-exponential!":{category:"random",description:"Returns a random number from an exponential distribution with the given rate parameter.",returns:{type:"number"},args:{lambda:{type:"number",description:"The rate parameter of the exponential distribution."}},variants:[{argumentNames:["lambda"]}],examples:["let { random-exponential! } = import(random);\nrandom-exponential!(1)","let { random-exponential! } = import(random);\nrandom-exponential!(0.5)"],seeAlso:["random.random-normal!","random.random-poisson!","random.random-gamma!","random.random-pareto!"]},"random-binomial!":{category:"random",description:"Returns a random number from a binomial distribution with the given number of trials and probability of success.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number of trials."},p:{type:"number",description:"The probability of success on each trial."}},variants:[{argumentNames:["n","p"]}],examples:["let { random-binomial! } = import(random);\nrandom-binomial!(10, 0.5)","let { random-binomial! } = import(random);\nrandom-binomial!(20, 0.3)"],seeAlso:["random.random-normal!","random.random-poisson!"],hideOperatorForm:!0},"random-poisson!":{category:"random",description:"Returns a random number from a Poisson distribution with the given rate parameter.",returns:{type:"integer"},args:{lambda:{type:"number",description:"The rate parameter of the Poisson distribution."}},variants:[{argumentNames:["lambda"]}],examples:["let { random-poisson! } = import(random);\nrandom-poisson!(1)","let { random-poisson! } = import(random);\nrandom-poisson!(5)"],seeAlso:["random.random-binomial!","random.random-normal!","random.random-exponential!"]},"random-gamma!":{category:"random",description:"Returns a random number from a gamma distribution with the given shape and scale parameters.",returns:{type:"number"},args:{shape:{type:"number",description:"The shape parameter of the gamma distribution."},scale:{type:"number",description:"The scale parameter of the gamma distribution."}},variants:[{argumentNames:["shape","scale"]}],examples:["let { random-gamma! } = import(random);\nrandom-gamma!(2, 2)","let { random-gamma! } = import(random);\nrandom-gamma!(5, 1)"],seeAlso:["random.random-exponential!","random.random-pareto!"],hideOperatorForm:!0},"random-pareto!":{category:"random",description:"Returns a random number from a Pareto distribution with the given shape parameter.",returns:{type:"number"},args:{alpha:{type:"number",description:"The shape parameter of the Pareto distribution."}},variants:[{argumentNames:["alpha"]}],examples:["let { random-pareto! } = import(random);\nrandom-pareto!(1)","let { random-pareto! } = import(random);\nrandom-pareto!(2)"],seeAlso:["random.random-gamma!","random.random-exponential!"]},"uuid!":{category:"random",description:"Returns a random UUID v4 (Universally Unique Identifier).",returns:{type:"string"},args:{},variants:[{argumentNames:[]}],examples:["let { uuid! } = import(random);\nuuid!()"],seeAlso:["random.random-id!","random.random-string!"]},"random-char!":{category:"random",description:"Returns a random character from the given string.",returns:{type:"string"},args:{charSet:{type:"string",description:"The string to sample from."}},variants:[{argumentNames:["charSet"]}],examples:['let { random-char! } = import(random);\nrandom-char!("abcde")','let { random-char! } = import(random);\nrandom-char!("ABCDEFGHIJKLMNOPQRSTUVWXYZ")'],seeAlso:["random.random-string!","random.random-item!"]},"random-string!":{category:"random",description:"Returns a random string of the given length from the given string.",returns:{type:"string"},args:{length:{type:"integer",description:"The length of the random string."},charSet:{type:"string",description:"The string to sample from."}},variants:[{argumentNames:["length","charSet"]}],examples:['let { random-string! } = import(random);\nrandom-string!(10, "abcde")','let { random-string! } = import(random);\nrandom-string!(5, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")'],seeAlso:["random.random-char!","random.random-id!","random.uuid!"],hideOperatorForm:!0},"random-id!":{category:"random",description:"Returns a random ID of the given length.",returns:{type:"string"},args:{length:{type:"integer",description:"The length of the random ID."}},variants:[{argumentNames:["length"]}],examples:["let { random-id! } = import(random);\nrandom-id!(10)","let { random-id! } = import(random);\nrandom-id!(5)"],seeAlso:["random.random-string!","random.uuid!"]},"random-color!":{category:"random",description:"Returns a random color in hex format.",returns:{type:"string"},args:{},variants:[{argumentNames:[]}],examples:["let { random-color! } = import(random);\nrandom-color!()"]}},Lr={"random!":{evaluate:()=>Math.random(),pure:!1,arity:ae(0)},"random-int!":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0,gt:e}),Math.floor(Math.random()*(t-e))+e),pure:!1,arity:ae(2)},"random-int-inclusive!":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0,gte:e}),Math.floor(Math.random()*(t-e+1))+e),pure:!1,arity:ae(2)},"random-float!":{evaluate:([e,t],r)=>(ee(e,r),ee(t,r,{gt:e}),Math.random()*(t-e)+e),pure:!1,arity:ae(2)},"random-boolean!":{evaluate:([e],t)=>{const r=e??.5;return ee(r,t,{gte:0,lte:1}),Math.random()<r},pure:!1,arity:{min:0,max:1}},"random-item!":{evaluate:([e],t)=>{we(e,t);return M(e[Math.floor(Math.random()*e.length)])},pure:!1,arity:ae(1)},"random-sample!":{evaluate:([e,t],n)=>{if(we(e,n),ee(t,n,{integer:!0,nonNegative:!0}),0===e.length)throw new r("Cannot sample from an empty array.",n);const o=[];for(let r=0;r<t;r++){const t=Math.floor(Math.random()*e.length);o.push(e[t])}return o},pure:!1,arity:ae(2)},"random-sample-unique!":{evaluate:([e,t],n)=>{if(we(e,n),ee(t,n,{integer:!0,nonNegative:!0,lte:e.length}),0===e.length)throw new r("Cannot sample from an empty array.",n);const o=[],a=[...e];for(let e=0;e<t;e++){const e=Math.floor(Math.random()*a.length);o.push(a[e]),a.splice(e,1)}return o},pure:!1,arity:ae(2)},"shuffle!":{evaluate:([e],t)=>{we(e,t);const r=[...e];for(let e=r.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1));[r[e],r[t]]=[r[t],r[e]]}return r},pure:!1,arity:ae(1)},"random-normal!":{evaluate:([e,t],r)=>{ee(e,r),ee(t,r,{gt:0});const n=Math.random(),o=Math.random();return Math.sqrt(-2*Math.log(n))*Math.cos(2*Math.PI*o)*t+e},pure:!1,arity:ae(2)},"random-exponential!":{evaluate:([e],t)=>{ee(e,t,{gt:0});const r=Math.random();return-Math.log(r)/e},pure:!1,arity:ae(1)},"random-binomial!":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0,nonNegative:!0}),ee(t,r,{gte:0,lte:1});let n=0;for(let r=0;r<e;r++)Math.random()<t&&n++;return n},pure:!1,arity:ae(2)},"random-poisson!":{evaluate:([e],t)=>{ee(e,t,{gt:0});const r=Math.exp(-e);let n=0,o=1;do{n++,o*=Math.random()}while(o>r);return n-1},pure:!1,arity:ae(1)},"random-gamma!":{evaluate:([e,t],r)=>(ee(e,r,{gt:0}),ee(t,r,{gt:0}),_r(e,t)),pure:!1,arity:ae(2)},"random-pareto!":{evaluate:([e],t)=>{ee(e,t,{gt:0});return(1/Math.random())**(1/e)},pure:!1,arity:ae(1)},"uuid!":{evaluate:()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),pure:!1,arity:ae(0)},"random-char!":{evaluate:([e],t)=>{if(K(e,t),0===e.length)throw new r("Character set cannot be empty.",t);return e[Math.floor(Math.random()*e.length)]},pure:!1,arity:ae(1)},"random-string!":{evaluate:([e,t],n)=>{if(ee(e,n,{integer:!0,positive:!0}),K(t,n),0===t.length)throw new r("Character set cannot be empty.",n);let o="";for(let r=0;r<e;r++){o+=t[Math.floor(Math.random()*t.length)]}return o},pure:!1,arity:ae(2)},"random-id!":{evaluate:([e],t)=>{ee(e,t,{integer:!0,positive:!0});const r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let n="";for(let t=0;t<e;t++){n+=r[Math.floor(62*Math.random())]}return n},pure:!1,arity:ae(1)},"random-color!":{evaluate:()=>`#${Math.floor(16777216*Math.random()).toString(16).padStart(6,"0")}`,pure:!1,arity:ae(0)}};function _r(e,t=1){if(e<1){return _r(e+1-1/3,t)*Math.random()**(1/e)}const r=e-1/3,n=1/Math.sqrt(9*r);let o,a,i;for(;;){do{o=Kr(),a=1+n*o}while(a<=0);if(a*=a*a,i=Math.random(),i<1-.0331*o*o*o*o)return t*r*a;if(Math.log(i)<.5*o*o+r*(1-a+Math.log(a)))return t*r*a}}function Kr(){let e=0,t=0;for(;0===e;)e=Math.random();for(;0===t;)t=Math.random();return Math.sqrt(-2*Math.log(e))*Math.cos(2*Math.PI*t)}for(const[e,t]of Object.entries(Br))Lr[e]&&(Lr[e].docs=t);const Jr={name:"random",functions:Lr},Yr={"moving-mean":{category:"vector",description:"Returns the **moving mean** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving mean** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-mean } = import(vector);\nmoving-mean([1, 2, 3, 4, 5], 3)","let { moving-mean } = import(vector);\nmoving-mean([1, 2, 3, 4, 5], 5)"],seeAlso:["moving-fn","mean","vector.centered-moving-mean","vector.running-mean"]},"centered-moving-mean":{category:"vector",description:"Returns the **centered moving mean** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving mean** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-mean } = import(vector);\ncentered-moving-mean([1, 2, 3, 4, 5], 3)","let { centered-moving-mean } = import(vector);\ncentered-moving-mean([1, 2, 3, 4, 5], 3, 0, 10)","let { centered-moving-mean } = import(vector);\ncentered-moving-mean([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["mean","vector.moving-mean","vector.running-mean"]},"running-mean":{category:"vector",description:"Returns the **running mean** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-mean } = import(vector);\nrunning-mean([1, 2, 3, 4, 5])"],seeAlso:["running-fn","mean","vector.moving-mean","vector.centered-moving-mean"]},"geometric-mean":{category:"vector",description:"Returns the **geometric mean** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **geometric mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { geometric-mean } = import(vector);\ngeometric-mean([1, 2, 3])","let { geometric-mean } = import(vector);\ngeometric-mean([1, 2, 9])"],seeAlso:["vector.moving-geometric-mean","vector.centered-moving-geometric-mean","vector.running-geometric-mean","mean","vector.harmonic-mean"]},"moving-geometric-mean":{category:"vector",description:"Returns the **moving geometric mean** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving geometric mean** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-geometric-mean } = import(vector);\nmoving-geometric-mean([1, 2, 3, 4, 5], 3)","let { moving-geometric-mean } = import(vector);\nmoving-geometric-mean([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.geometric-mean","vector.centered-moving-geometric-mean","vector.running-geometric-mean"]},"centered-moving-geometric-mean":{category:"vector",description:"Returns the **centered moving geometric mean** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving geometric mean** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-geometric-mean } = import(vector);\ncentered-moving-geometric-mean([1, 2, 3, 4, 5], 3)","let { centered-moving-geometric-mean } = import(vector);\ncentered-moving-geometric-mean([1, 2, 3, 4, 5], 3, 0, 10)","let { centered-moving-geometric-mean } = import(vector);\ncentered-moving-geometric-mean([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["vector.geometric-mean","vector.moving-geometric-mean","vector.running-geometric-mean"]},"running-geometric-mean":{category:"vector",description:"Returns the **running geometric mean** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running geometric mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-geometric-mean } = import(vector);\nrunning-geometric-mean([1, 2, 3, 4, 5])"],seeAlso:["vector.geometric-mean","vector.moving-geometric-mean","vector.centered-moving-geometric-mean"]},"harmonic-mean":{category:"vector",description:"Returns the **harmonic mean** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **harmonic mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { harmonic-mean } = import(vector);\nharmonic-mean([1, 2, 3])","let { harmonic-mean } = import(vector);\nharmonic-mean([1, 2, 9])"],seeAlso:["vector.moving-harmonic-mean","vector.centered-moving-harmonic-mean","vector.running-harmonic-mean","mean","vector.geometric-mean"]},"moving-harmonic-mean":{category:"vector",description:"Returns the **moving harmonic mean** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving harmonic mean** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-harmonic-mean } = import(vector);\nmoving-harmonic-mean([1, 2, 3, 4, 5], 3)","let { moving-harmonic-mean } = import(vector);\nmoving-harmonic-mean([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.harmonic-mean","vector.centered-moving-harmonic-mean","vector.running-harmonic-mean"]},"centered-moving-harmonic-mean":{category:"vector",description:"Returns the **centered moving harmonic mean** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving harmonic mean** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-harmonic-mean } = import(vector);\ncentered-moving-harmonic-mean([1, 2, 3, 4, 5], 3)","let { centered-moving-harmonic-mean } = import(vector);\ncentered-moving-harmonic-mean([1, 2, 3, 4, 5], 3, 0, 10)","let { centered-moving-harmonic-mean } = import(vector);\ncentered-moving-harmonic-mean([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["vector.harmonic-mean","vector.moving-harmonic-mean","vector.running-harmonic-mean"]},"running-harmonic-mean":{category:"vector",description:"Returns the **running harmonic mean** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running harmonic mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-harmonic-mean } = import(vector);\nrunning-harmonic-mean([1, 2, 3, 4, 5])"],seeAlso:["vector.harmonic-mean","vector.moving-harmonic-mean","vector.centered-moving-harmonic-mean"]},"moving-median":{category:"vector",description:"Returns the **moving median** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving median** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-median } = import(vector);\nmoving-median([1, 2, 3, 4, 5], 3)","let { moving-median } = import(vector);\nmoving-median([1, 2, 3, 4, 5], 5)"],seeAlso:["median","vector.centered-moving-median","vector.running-median"]},"centered-moving-median":{category:"vector",description:"Returns the **centered moving median** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving median** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-median } = import(vector);\ncentered-moving-median([1, 2, 3, 4, 5], 3)","let { centered-moving-median } = import(vector);\ncentered-moving-median([1, 2, 3, 4, 5], 3, 0, 10)","let { centered-moving-median } = import(vector);\ncentered-moving-median([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["median","vector.moving-median","vector.running-median"]},"running-median":{category:"vector",description:"Returns the **running median** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running median** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-median } = import(vector);\nrunning-median([1, 2, 3, 4, 5])"],seeAlso:["median","vector.moving-median","vector.centered-moving-median"]},variance:{category:"vector",description:"Returns the **variance** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **variance** of."}},variants:[{argumentNames:["vector"]}],examples:["let { variance } = import(vector);\nvariance([1, 2, 3])","let { variance } = import(vector);\nvariance([1, 2, -3])"],seeAlso:["linear-algebra.cov","vector.moving-variance","vector.centered-moving-variance","vector.running-variance","vector.stdev","vector.sample-variance","vector.mad"]},"moving-variance":{category:"vector",description:"Returns the **moving variance** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving variance** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-variance } = import(vector);\nmoving-variance([1, 2, 3, 4, 5], 3)","let { moving-variance } = import(vector);\nmoving-variance([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.variance","vector.centered-moving-variance","vector.running-variance"]},"centered-moving-variance":{category:"vector",description:"Returns the **centered moving variance** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving variance** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-variance } = import(vector);\ncentered-moving-variance([1, 2, 3, 4, 5], 3)","let { centered-moving-variance } = import(vector);\ncentered-moving-variance([1, 2, 3, 4, 5], 3, 1)","let { centered-moving-variance } = import(vector);\ncentered-moving-variance([1, 2, 3, 4, 5], 3, 1, 5)","let { centered-moving-variance } = import(vector);\ncentered-moving-variance([1, 2, 3, 4, 5], 3, 0, 6)"],seeAlso:["vector.variance","vector.moving-variance","vector.running-variance"]},"running-variance":{category:"vector",description:"Returns the **running variance** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running variance** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-variance } = import(vector);\nrunning-variance([1, 2, 3, 4, 5])"],seeAlso:["vector.variance","vector.moving-variance","vector.centered-moving-variance"]},"sample-variance":{category:"vector",description:"Returns the sample variance of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the sample variance of."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-variance } = import(vector);\nsample-variance([1, 2, 3])","let { sample-variance } = import(vector);\nsample-variance([1, 2, -3])","let { sample-variance } = import(vector);\nsample-variance([1, 2, 3, 4])","let { sample-variance } = import(vector);\nsample-variance([1, 2, -3, 4])","let { sample-variance } = import(vector);\nsample-variance([1, 2, 3, 40, 50])"],seeAlso:["vector.moving-sample-variance","vector.centered-moving-sample-variance","vector.running-sample-variance","vector.variance","vector.sample-stdev"]},"moving-sample-variance":{category:"vector",description:"Returns the **moving sample variance** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample variance** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-variance } = import(vector);\nmoving-sample-variance([1, 2, 3, 4, 5], 3)","let { moving-sample-variance } = import(vector);\nmoving-sample-variance([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.sample-variance","vector.centered-moving-sample-variance","vector.running-sample-variance"]},"centered-moving-sample-variance":{category:"vector",description:"Returns the **centered moving sample variance** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample variance** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-variance } = import(vector);\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3)","let { centered-moving-sample-variance } = import(vector);\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3, 1)","let { centered-moving-sample-variance } = import(vector);\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3, 1, 5)","let { centered-moving-sample-variance } = import(vector);\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3, 0, 6)"],seeAlso:["vector.sample-variance","vector.moving-sample-variance","vector.running-sample-variance"]},"running-sample-variance":{category:"vector",description:"Returns the **running sample variance** of the `vector`.",returns:{type:"array"},args:{vector:{type:"vector",description:"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."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-variance } = import(vector);\nrunning-sample-variance([1, 2, 3, 4, 5])"],seeAlso:["vector.sample-variance","vector.moving-sample-variance","vector.centered-moving-sample-variance"]},stdev:{category:"vector",description:"Returns the standard deviation of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the standard deviation of."}},variants:[{argumentNames:["vector"]}],examples:["let { stdev } = import(vector);\nstdev([1, 2, 3])","let { stdev } = import(vector);\nstdev([1, 2, -3])","let { stdev } = import(vector);\nstdev([1, 2, 3, 4])","let { stdev } = import(vector);\nstdev([1, 2, -3, 4])","let { stdev } = import(vector);\nstdev([1, 2, 3, 40, 50])"],seeAlso:["vector.moving-stdev","vector.centered-moving-stdev","vector.running-stdev","vector.variance","vector.sample-stdev","vector.rms","vector.mad"]},"moving-stdev":{category:"vector",description:"Returns the **moving standard deviation** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving standard deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-stdev } = import(vector);\nmoving-stdev([1, 2, 3, 4, 5], 3)","let { moving-stdev } = import(vector);\nmoving-stdev([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.stdev","vector.centered-moving-stdev","vector.running-stdev"]},"centered-moving-stdev":{category:"vector",description:"Returns the **centered moving standard deviation** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving standard deviation** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-stdev } = import(vector);\ncentered-moving-stdev([1, 2, 3, 4, 5], 3)","let { centered-moving-stdev } = import(vector);\ncentered-moving-stdev([1, 2, 3, 4, 5], 3, 1)","let { centered-moving-stdev } = import(vector);\ncentered-moving-stdev([1, 2, 3, 4, 5], 3, 1, 5)","let { centered-moving-stdev } = import(vector);\ncentered-moving-stdev([1, 2, 3, 4, 5], 3, 0, 6)"],seeAlso:["vector.stdev","vector.moving-stdev","vector.running-stdev"]},"running-stdev":{category:"vector",description:"Returns the **running standard deviation** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running standard deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-stdev } = import(vector);\nrunning-stdev([1, 2, 3, 4, 5])"],seeAlso:["vector.stdev","vector.moving-stdev","vector.centered-moving-stdev"]},"sample-stdev":{category:"vector",description:"Returns the sample standard deviation of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the sample standard deviation of."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-stdev } = import(vector);\nsample-stdev([1, 2, 3])","let { sample-stdev } = import(vector);\nsample-stdev([1, 2, -3])","let { sample-stdev } = import(vector);\nsample-stdev([1, 2, 3, 4])","let { sample-stdev } = import(vector);\nsample-stdev([1, 2, -3, 4])","let { sample-stdev } = import(vector);\nsample-stdev([1, 2, 3, 40, 50])"],seeAlso:["vector.moving-sample-stdev","vector.centered-moving-sample-stdev","vector.running-sample-stdev","vector.stdev","vector.sample-variance"]},"moving-sample-stdev":{category:"vector",description:"Returns the **moving sample standard deviation** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample standard deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-stdev } = import(vector);\nmoving-sample-stdev([1, 2, 3, 4, 5], 3)","let { moving-sample-stdev } = import(vector);\nmoving-sample-stdev([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.sample-stdev","vector.centered-moving-sample-stdev","vector.running-sample-stdev"]},"centered-moving-sample-stdev":{category:"vector",description:"Returns the **centered moving sample standard deviation** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample standard deviation** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-stdev } = import(vector);\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3)","let { centered-moving-sample-stdev } = import(vector);\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3, 1)","let { centered-moving-sample-stdev } = import(vector);\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3, 1, 5)","let { centered-moving-sample-stdev } = import(vector);\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3, 0, 6)"],seeAlso:["vector.sample-stdev","vector.moving-sample-stdev","vector.running-sample-stdev"]},"running-sample-stdev":{category:"vector",description:"Returns the **running sample standard deviation** of the `vector`.",returns:{type:"array"},args:{vector:{type:"vector",description:"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."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-stdev } = import(vector);\nrunning-sample-stdev([1, 2, 3, 4, 5])"],seeAlso:["vector.sample-stdev","vector.moving-sample-stdev","vector.centered-moving-sample-stdev"]},iqr:{category:"vector",description:"Calculates the **interquartile range** of a `vector`. Returns the difference between the third and first quartiles.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **interquartile range** of. Minimum length is 4."}},variants:[{argumentNames:["vector"]}],examples:["let { iqr } = import(vector);\niqr([1, 2, 3, 4])","let { iqr } = import(vector);\niqr([5, 4, 3, 2, 1, 2, 3, 4, 5])","let { iqr } = import(vector);\niqr(range(1, 1000))","let { iqr } = import(vector);\niqr(map(range(1000), -> 1e6 / ($ + 1) ^ 2))","let { iqr } = import(vector);\nlet { ln } = import(math);\niqr(map(range(1000), -> ln($ + 1)))"],seeAlso:["vector.moving-iqr","vector.centered-moving-iqr","vector.running-iqr","vector.quartiles","median","vector.mad","vector.medad","vector.outliers?","vector.outliers"]},"moving-iqr":{category:"vector",description:"Calculates the **moving interquartile range** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving interquartile range** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-iqr } = import(vector);\nmoving-iqr([1, 2, 4, 7, 11, 16], 4)","let { moving-iqr } = import(vector);\nmoving-iqr([1, 2, 4, 7, 11, 16], 5)","let { moving-iqr } = import(vector);\nmoving-iqr([1, 2, 4, 7, 11, 16], 6)"],seeAlso:["vector.iqr","vector.centered-moving-iqr","vector.running-iqr"]},"centered-moving-iqr":{category:"vector",description:"Calculates the **centered moving interquartile range** of a `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving interquartile range** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-iqr } = import(vector);\ncentered-moving-iqr([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-iqr } = import(vector);\ncentered-moving-iqr([1, 2, 4, 7, 11, 16], 4, 0, 0)"],seeAlso:["vector.iqr","vector.moving-iqr","vector.running-iqr"]},"running-iqr":{category:"vector",description:"Calculates the **running interquartile range** of a `vector`. First three element in result is `null` since **running interquartile range** is not defined for less than four elements.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running interquartile range** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-iqr } = import(vector);\nrunning-iqr([1, 2, 3, 4, 5, 6])","let { running-iqr } = import(vector);\nrunning-iqr([-1, -2, -3, 1, 2, 3])"],seeAlso:["vector.iqr","vector.moving-iqr","vector.centered-moving-iqr"]},"moving-sum":{category:"vector",description:"Returns the **moving sum** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sum** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sum } = import(vector);\nmoving-sum([1, 2, 3, 4, 5], 3)","let { moving-sum } = import(vector);\nmoving-sum([1, 2, 3, 4, 5], 5)"],seeAlso:["sum","vector.centered-moving-sum","vector.running-sum"]},"centered-moving-sum":{category:"vector",description:"Returns the **centered moving sum** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sum** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sum } = import(vector);\ncentered-moving-sum([1, 2, 3, 4, 5], 3)","let { centered-moving-sum } = import(vector);\ncentered-moving-sum([1, 2, 3, 4, 5], 3, 0, 0)","let { centered-moving-sum } = import(vector);\ncentered-moving-sum([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["sum","vector.moving-sum","vector.running-sum"]},"running-sum":{category:"vector",description:"Returns the **running sum** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sum** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sum } = import(vector);\nrunning-sum([1, 2, 3])","let { running-sum } = import(vector);\nrunning-sum([1, -2, -3])"],seeAlso:["sum","vector.moving-sum","vector.centered-moving-sum","vector.cumsum"]},"moving-prod":{category:"vector",description:"Returns the **moving product** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving product** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-prod } = import(vector);\nmoving-prod([1, 2, 3, 4, 5], 3)","let { moving-prod } = import(vector);\nmoving-prod([1, 2, 3, 4, 5], 5)"],seeAlso:["prod","vector.centered-moving-prod","vector.running-prod"]},"centered-moving-prod":{category:"vector",description:"Returns the **centered moving product** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving product** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-prod } = import(vector);\ncentered-moving-prod([1, 2, 3, 4, 5], 3)","let { centered-moving-prod } = import(vector);\ncentered-moving-prod([1, 2, 3, 4, 5], 3, 0, 0)"],seeAlso:["prod","vector.moving-prod","vector.running-prod"]},"running-prod":{category:"vector",description:"Returns the **running product** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running product** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-prod } = import(vector);\nrunning-prod([1, 2, 3, 4, 5])","let { running-prod } = import(vector);\nrunning-prod([1, -2, -3])"],seeAlso:["prod","vector.moving-prod","vector.centered-moving-prod","vector.cumprod"]},span:{category:"vector",description:"Returns the difference between the maximum and minimum values in a vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to calculate the span of."}},variants:[{argumentNames:["vector"]}],examples:["let { span } = import(vector);\nspan([1, 2, 3])","let { span } = import(vector);\nspan([1, 1, 2, 3, 3])","let { span } = import(vector);\nspan([1, 2, -3])"],seeAlso:["vector.moving-span","vector.centered-moving-span","vector.running-span","min","max"]},"moving-span":{category:"vector",description:"Calculates the **moving span** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving span** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-span } = import(vector);\nmoving-span([1, 2, 4, 7, 11, 16], 4)","let { moving-span } = import(vector);\nmoving-span([1, 2, 4, 7, 11, 16], 5)","let { moving-span } = import(vector);\nmoving-span([1, 2, 4, 7, 11, 16], 6)"],seeAlso:["vector.span","vector.centered-moving-span","vector.running-span"]},"centered-moving-span":{category:"vector",description:"Calculates the **centered moving span** of a `vector` with a given window size. The result is padded with `leftPadding` on the left and right.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving span** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"The value to pad the result with on the left."},rightPadding:{type:"number",description:"The value to pad the result with on the right."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-span } = import(vector);\ncentered-moving-span([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-span } = import(vector);\ncentered-moving-span([1, 2, 4, 7, 11, 16], 3, 0, 100)"],seeAlso:["vector.span","vector.moving-span","vector.running-span"]},"running-span":{category:"vector",description:"Calculates the **running span** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running span** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-span } = import(vector);\nrunning-span([1, 2, 4])"],seeAlso:["vector.span","vector.moving-span","vector.centered-moving-span"]},skewness:{category:"vector",description:"Calculates the **skewness** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **skewness** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { skewness } = import(vector);\nskewness([1, 2, 3, 6, 20])","let { skewness } = import(vector);\nskewness([1, 2, 2, 3])"],seeAlso:["vector.moving-skewness","vector.centered-moving-skewness","vector.running-skewness","vector.kurtosis","vector.sample-skewness","vector.excess-kurtosis"]},"moving-skewness":{category:"vector",description:"Calculates the **moving skewness** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving skewness** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-skewness } = import(vector);\nmoving-skewness([1, 2, 4, 7, 11, 16], 4)","let { moving-skewness } = import(vector);\nmoving-skewness([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.skewness","vector.centered-moving-skewness","vector.running-skewness"]},"centered-moving-skewness":{category:"vector",description:"Calculates the **centered moving skewness** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving skewness** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-skewness } = import(vector);\ncentered-moving-skewness([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-skewness } = import(vector);\ncentered-moving-skewness([1, 2, 4, 7, 11, 16], 4, 0, 0)"],seeAlso:["vector.skewness","vector.moving-skewness","vector.running-skewness"]},"running-skewness":{category:"vector",description:"Calculates the **running skewness** of a `vector` with a given window size. First two element in result is `null` since **running skewness** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running skewness** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-skewness } = import(vector);\nrunning-skewness([1, 2, 4, 7, 11])"],seeAlso:["vector.skewness","vector.moving-skewness","vector.centered-moving-skewness"]},"sample-skewness":{category:"vector",description:"Calculates the **sample skewness** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **sample skewness** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-skewness } = import(vector);\nsample-skewness([1, 2, 3, 6, 20])","let { sample-skewness } = import(vector);\nsample-skewness([1, 2, 2, 3])"],seeAlso:["vector.moving-sample-skewness","vector.centered-moving-sample-skewness","vector.running-sample-skewness","vector.skewness","vector.sample-kurtosis"]},"moving-sample-skewness":{category:"vector",description:"Calculates the **moving sample skewness** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample skewness** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-skewness } = import(vector);\nmoving-sample-skewness([1, 2, 4, 7, 11, 16], 4)","let { moving-sample-skewness } = import(vector);\nmoving-sample-skewness([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.sample-skewness","vector.centered-moving-sample-skewness","vector.running-sample-skewness"]},"centered-moving-sample-skewness":{category:"vector",description:"Calculates the **centered moving sample skewness** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample skewness** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-skewness } = import(vector);\ncentered-moving-sample-skewness([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-sample-skewness } = import(vector);\ncentered-moving-sample-skewness([1, 2, 4, 7, 11, 16], 3, 0, 100)"],seeAlso:["vector.sample-skewness","vector.moving-sample-skewness","vector.running-sample-skewness"]},"running-sample-skewness":{category:"vector",description:"Calculates the **running sample skewness** of a `vector` with a given window size. First two element in result is `null` since **running sample skewness** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sample skewness** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-skewness } = import(vector);\nrunning-sample-skewness([1, 2, 4, 7, 11])"],seeAlso:["vector.sample-skewness","vector.moving-sample-skewness","vector.centered-moving-sample-skewness"]},"excess-kurtosis":{category:"vector",description:"Calculates the **excess kurtosis** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **excess kurtosis** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { excess-kurtosis } = import(vector);\nexcess-kurtosis([1, 2, 3, 6, 20])","let { excess-kurtosis } = import(vector);\nexcess-kurtosis([1, 2, 2, 3])"],seeAlso:["vector.moving-excess-kurtosis","vector.centered-moving-excess-kurtosis","vector.running-excess-kurtosis","vector.kurtosis","vector.sample-excess-kurtosis","vector.skewness"]},"moving-excess-kurtosis":{category:"vector",description:"Calculates the **moving excess kurtosis** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving excess kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-excess-kurtosis } = import(vector);\nmoving-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { moving-excess-kurtosis } = import(vector);\nmoving-excess-kurtosis([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.excess-kurtosis","vector.centered-moving-excess-kurtosis","vector.running-excess-kurtosis"]},"centered-moving-excess-kurtosis":{category:"vector",description:"Calculates the **centered moving excess kurtosis** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving excess kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-excess-kurtosis } = import(vector);\ncentered-moving-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-excess-kurtosis } = import(vector);\ncentered-moving-excess-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 0)"],seeAlso:["vector.excess-kurtosis","vector.moving-excess-kurtosis","vector.running-excess-kurtosis"]},"running-excess-kurtosis":{category:"vector",description:"Calculates the **running excess kurtosis** of a `vector` with a given window size. First two element in result is `null` since **running excess kurtosis** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running excess kurtosis** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-excess-kurtosis } = import(vector);\nrunning-excess-kurtosis([1, 2, 4, 7, 11])"],seeAlso:["vector.excess-kurtosis","vector.moving-excess-kurtosis","vector.centered-moving-excess-kurtosis"]},kurtosis:{category:"vector",description:"Calculates the **kurtosis** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **kurtosis** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { kurtosis } = import(vector);\nkurtosis([1, 2, 3, 6, 20])","let { kurtosis } = import(vector);\nkurtosis([1, 2, 2, 3])"],seeAlso:["vector.moving-kurtosis","vector.centered-moving-kurtosis","vector.running-kurtosis","vector.excess-kurtosis","vector.sample-kurtosis","vector.skewness"]},"moving-kurtosis":{category:"vector",description:"Calculates the **moving kurtosis** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-kurtosis } = import(vector);\nmoving-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { moving-kurtosis } = import(vector);\nmoving-kurtosis([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.kurtosis","vector.centered-moving-kurtosis","vector.running-kurtosis"]},"centered-moving-kurtosis":{category:"vector",description:"Calculates the **centered moving kurtosis** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-kurtosis } = import(vector);\ncentered-moving-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-kurtosis } = import(vector);\ncentered-moving-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 0)"],seeAlso:["vector.kurtosis","vector.moving-kurtosis","vector.running-kurtosis"]},"running-kurtosis":{category:"vector",description:"Calculates the **running kurtosis** of a `vector` with a given window size. First two element in result is `null` since **running kurtosis** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running kurtosis** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-kurtosis } = import(vector);\nrunning-kurtosis([1, 2, 4, 7, 11])"],seeAlso:["vector.kurtosis","vector.moving-kurtosis","vector.centered-moving-kurtosis"]},"sample-excess-kurtosis":{category:"vector",description:"Calculates the **sample excess kurtosis** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **sample excess kurtosis** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-excess-kurtosis } = import(vector);\nsample-excess-kurtosis([1, 2, 3, 6, 20])","let { sample-excess-kurtosis } = import(vector);\nsample-excess-kurtosis([1, 2, 2, 3])"],seeAlso:["vector.moving-sample-excess-kurtosis","vector.centered-moving-sample-excess-kurtosis","vector.running-sample-excess-kurtosis","vector.sample-kurtosis","vector.excess-kurtosis"]},"moving-sample-excess-kurtosis":{category:"vector",description:"Calculates the **moving sample excess kurtosis** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample excess kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-excess-kurtosis } = import(vector);\nmoving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { moving-sample-excess-kurtosis } = import(vector);\nmoving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.sample-excess-kurtosis","vector.centered-moving-sample-excess-kurtosis","vector.running-sample-excess-kurtosis"]},"centered-moving-sample-excess-kurtosis":{category:"vector",description:"Calculates the **centered moving sample excess kurtosis** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample excess kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-excess-kurtosis } = import(vector);\ncentered-moving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-sample-excess-kurtosis } = import(vector);\ncentered-moving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 100)"],seeAlso:["vector.sample-excess-kurtosis","vector.moving-sample-excess-kurtosis","vector.running-sample-excess-kurtosis"]},"running-sample-excess-kurtosis":{category:"vector",description:"Calculates the **running sample excess kurtosis** of a `vector` with a given window size. First two element in result is `null` since **running sample excess kurtosis** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sample excess kurtosis** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-excess-kurtosis } = import(vector);\nrunning-sample-excess-kurtosis([1, 2, 4, 7, 11])"],seeAlso:["vector.sample-excess-kurtosis","vector.moving-sample-excess-kurtosis","vector.centered-moving-sample-excess-kurtosis"]},"sample-kurtosis":{category:"vector",description:"Calculates the **sample kurtosis** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **sample kurtosis** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-kurtosis } = import(vector);\nsample-kurtosis([1, 2, 3, 6, 20])","let { sample-kurtosis } = import(vector);\nsample-kurtosis([1, 2, 2, 3])"],seeAlso:["vector.moving-sample-kurtosis","vector.centered-moving-sample-kurtosis","vector.running-sample-kurtosis","vector.sample-excess-kurtosis","vector.kurtosis","vector.sample-skewness"]},"moving-sample-kurtosis":{category:"vector",description:"Calculates the **moving sample kurtosis** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-kurtosis } = import(vector);\nmoving-sample-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { moving-sample-kurtosis } = import(vector);\nmoving-sample-kurtosis([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.sample-kurtosis","vector.centered-moving-sample-kurtosis","vector.running-sample-kurtosis"]},"centered-moving-sample-kurtosis":{category:"vector",description:"Calculates the **centered moving sample kurtosis** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-kurtosis } = import(vector);\ncentered-moving-sample-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-sample-kurtosis } = import(vector);\ncentered-moving-sample-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 100)"],seeAlso:["vector.sample-kurtosis","vector.moving-sample-kurtosis","vector.running-sample-kurtosis"]},"running-sample-kurtosis":{category:"vector",description:"Calculates the **running sample kurtosis** of a `vector` with a given window size. First two element in result is `null` since **running sample kurtosis** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sample kurtosis** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-kurtosis } = import(vector);\nrunning-sample-kurtosis([1, 2, 4, 7, 11])"],seeAlso:["vector.sample-kurtosis","vector.moving-sample-kurtosis","vector.centered-moving-sample-kurtosis"]},rms:{category:"vector",description:"Calculates the **root mean square** of a `vector`. Returns the square root of the average of the squares of the elements.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **root mean square** of. Minimum length is 1."}},variants:[{argumentNames:["vector"]}],examples:["let { rms } = import(vector);\nrms([1, 2, 3, 4])","let { rms } = import(vector);\nrms([5, 4, 3, 2, 1])","let { rms } = import(vector);\nrms(range(1, 1000))","let { rms } = import(vector);\nrms(map(range(1000), -> 1e6 / ($ + 1) ^ 2))","let { rms } = import(vector);\nlet { ln } = import(math);\nrms(map(range(1000), -> ln($ + 1)))"],seeAlso:["vector.moving-rms","vector.centered-moving-rms","vector.running-rms","mean","vector.stdev"]},"moving-rms":{category:"vector",description:"Calculates the **moving root mean square** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving root mean square** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-rms } = import(vector);\nmoving-rms([1, 2, 4, 7, 11, 16], 4)","let { moving-rms } = import(vector);\nmoving-rms([1, 2, 4, 7, 11, 16], 5)","let { moving-rms } = import(vector);\nmoving-rms([1, 2, 4, 7, 11, 16], 6)"],seeAlso:["vector.rms","vector.centered-moving-rms","vector.running-rms"]},"centered-moving-rms":{category:"vector",description:"Calculates the **centered moving root mean square** of a `vector` with a given window size and padding value.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving root mean square** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-rms } = import(vector);\ncentered-moving-rms([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-rms } = import(vector);\ncentered-moving-rms([1, 2, 4, 7, 11, 16], 5, 0)","let { centered-moving-rms } = import(vector);\ncentered-moving-rms([1, 2, 4, 7, 11, 16], 6, 0, 0)"],seeAlso:["vector.rms","vector.moving-rms","vector.running-rms"]},"running-rms":{category:"vector",description:"Calculates the **running root mean square** of a `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running root mean square** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-rms } = import(vector);\nrunning-rms([1, 2, 3, 4, 5, 6])","let { running-rms } = import(vector);\nrunning-rms([1, -3, 2])","let { running-rms } = import(vector);\nrunning-rms([-1, -2, -3])","let { running-rms } = import(vector);\nrunning-rms([0])"],seeAlso:["vector.rms","vector.moving-rms","vector.centered-moving-rms"]},mad:{category:"vector",description:"Returns the **mean absolute deviation** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **mean absolute deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { mad } = import(vector);\nmad([1, 2, 3])","let { mad } = import(vector);\nmad([1, 2, -3])"],seeAlso:["vector.moving-mad","vector.centered-moving-mad","vector.running-mad","vector.medad","vector.stdev","vector.variance","vector.iqr"]},"moving-mad":{category:"vector",description:"Returns the **moving mean absolute deviation** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving mean absolute deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-mad } = import(vector);\nmoving-mad([1, 2, 3, 4, 5], 3)","let { moving-mad } = import(vector);\nmoving-mad([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.mad","vector.centered-moving-mad","vector.running-mad"]},"centered-moving-mad":{category:"vector",description:"Returns the **centered moving mean absolute deviation** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving mean absolute deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-mad } = import(vector);\ncentered-moving-mad([1, 2, 3, 4, 5], 3)","let { centered-moving-mad } = import(vector);\ncentered-moving-mad([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.mad","vector.moving-mad","vector.running-mad"]},"running-mad":{category:"vector",description:"Returns the **running mean absolute deviation** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running mean absolute deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-mad } = import(vector);\nrunning-mad([1, 2, 3])","let { running-mad } = import(vector);\nrunning-mad([1, 2, -3])"],seeAlso:["vector.mad","vector.moving-mad","vector.centered-moving-mad"]},medad:{category:"vector",description:"Returns the **median absolute deviation** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **median absolute deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { medad } = import(vector);\nmedad([1, 2, 3])","let { medad } = import(vector);\nmedad([1, 2, -3])"],seeAlso:["vector.moving-medad","vector.centered-moving-medad","vector.running-medad","vector.mad","median","vector.iqr"]},"moving-medad":{category:"vector",description:"Returns the **moving median absolute deviation** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving median absolute deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-medad } = import(vector);\nmoving-medad([1, 2, 3, 4, 5], 3)","let { moving-medad } = import(vector);\nmoving-medad([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.medad","vector.centered-moving-medad","vector.running-medad"]},"centered-moving-medad":{category:"vector",description:"Returns the **centered moving median absolute deviation** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving median absolute deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-medad } = import(vector);\ncentered-moving-medad([1, 2, 3, 4, 5], 3)","let { centered-moving-medad } = import(vector);\ncentered-moving-medad([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.medad","vector.moving-medad","vector.running-medad"]},"running-medad":{category:"vector",description:"Returns the **running median absolute deviation** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running median absolute deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-medad } = import(vector);\nrunning-medad([1, 2, 3])","let { running-medad } = import(vector);\nrunning-medad([1, 2, -3])"],seeAlso:["vector.medad","vector.moving-medad","vector.centered-moving-medad"]},"gini-coefficient":{category:"vector",description:"Returns the **gini coefficient** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **gini coefficient** of."}},variants:[{argumentNames:["vector"]}],examples:["let { gini-coefficient } = import(vector);\ngini-coefficient([1, 2, 3])","let { gini-coefficient } = import(vector);\ngini-coefficient([1, 1, 3])"],seeAlso:["vector.moving-gini-coefficient","vector.centered-moving-gini-coefficient","vector.running-gini-coefficient","vector.entropy"]},"moving-gini-coefficient":{category:"vector",description:"Returns the **moving gini coefficient** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving gini coefficient** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-gini-coefficient } = import(vector);\nmoving-gini-coefficient([1, 2, 3], 2)","let { moving-gini-coefficient } = import(vector);\nmoving-gini-coefficient([1, 1, 3], 2)"],seeAlso:["vector.gini-coefficient","vector.centered-moving-gini-coefficient","vector.running-gini-coefficient"]},"centered-moving-gini-coefficient":{category:"vector",description:"Returns the **centered moving gini coefficient** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving gini coefficient** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-gini-coefficient } = import(vector);\ncentered-moving-gini-coefficient([1, 2, 3], 2)","let { centered-moving-gini-coefficient } = import(vector);\ncentered-moving-gini-coefficient([1, 1, 3], 2)"],seeAlso:["vector.gini-coefficient","vector.moving-gini-coefficient","vector.running-gini-coefficient"]},"running-gini-coefficient":{category:"vector",description:"Returns the **running gini coefficient** of the `vector`.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running gini coefficient** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-gini-coefficient } = import(vector);\nrunning-gini-coefficient([1, 2, 3])","let { running-gini-coefficient } = import(vector);\nrunning-gini-coefficient([1, 1, 3])"],seeAlso:["vector.gini-coefficient","vector.moving-gini-coefficient","vector.centered-moving-gini-coefficient"]},entropy:{category:"vector",description:"Calculates the **entropy** of a `vector`. The entropy is a measure of the uncertainty associated with a random variable.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **entropy** of. Minimum length is 1."}},variants:[{argumentNames:["vector"]}],examples:["let { entropy } = import(vector);\nentropy([1, 1, 2, 3, 3, 3])","let { entropy } = import(vector);\nentropy([1, 2, 3])","let { entropy } = import(vector);\nentropy([1, 2, 2, 3])","let { entropy } = import(vector);\nentropy([0])","let { entropy } = import(vector);\nentropy([1])","let { entropy } = import(vector);\nentropy([1, 2])"],seeAlso:["vector.moving-entropy","vector.centered-moving-entropy","vector.running-entropy","vector.gini-coefficient"]},"moving-entropy":{category:"vector",description:"Calculates the **moving entropy** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving entropy** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-entropy } = import(vector);\nmoving-entropy([1, 1, 2, 3, 3, 3], 4)","let { moving-entropy } = import(vector);\nmoving-entropy([1, 1, 2, 3, 3, 3], 3)","let { moving-entropy } = import(vector);\nmoving-entropy([1, 2], 2)"],seeAlso:["vector.entropy","vector.centered-moving-entropy","vector.running-entropy"]},"centered-moving-entropy":{category:"vector",description:"Calculates the **centered moving entropy** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving entropy** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-entropy } = import(vector);\ncentered-moving-entropy([1, 1, 2, 3, 3, 3], 4)","let { centered-moving-entropy } = import(vector);\ncentered-moving-entropy([1, 1, 2, 3, 3, 3], 3)","let { centered-moving-entropy } = import(vector);\ncentered-moving-entropy([1, 2], 2)"],seeAlso:["vector.entropy","vector.moving-entropy","vector.running-entropy"]},"running-entropy":{category:"vector",description:"Calculates the **running entropy** of a `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running entropy** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-entropy } = import(vector);\nrunning-entropy([1, 1, 2, 3, 3, 3])","let { running-entropy } = import(vector);\nrunning-entropy([1, 2])"],seeAlso:["vector.entropy","vector.moving-entropy","vector.centered-moving-entropy"]},"monotonic?":{category:"vector",description:"Checks if a vector is monotonic.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { monotonic? } = import(vector);\nmonotonic?([1, 2, 3])","let { monotonic? } = import(vector);\nmonotonic?([1, 2, 2, 3])","let { monotonic? } = import(vector);\nmonotonic?([3, 2, 1])","let { monotonic? } = import(vector);\nmonotonic?([3, 2, 1, 1])","let { monotonic? } = import(vector);\nmonotonic?([3, 2, 1, 2])","let { monotonic? } = import(vector);\nmonotonic?([1])","let { monotonic? } = import(vector);\nmonotonic?([])"],seeAlso:["vector.strictly-monotonic?","vector.increasing?","vector.decreasing?"]},"strictly-monotonic?":{category:"vector",description:"Checks if a vector is strictly monotonic.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([1, 2, 3])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([1, 2, 2, 3])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([3, 2, 1])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([3, 2, 1, 1])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([3, 2, 1, 2])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([1])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([])"],seeAlso:["vector.monotonic?","vector.strictly-increasing?","vector.strictly-decreasing?"]},"increasing?":{category:"vector",description:"Checks if a vector is increasing.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { increasing? } = import(vector);\nincreasing?([1, 2, 3])","let { increasing? } = import(vector);\nincreasing?([1, 2, 2, 3])","let { increasing? } = import(vector);\nincreasing?([3, 2, 1])","let { increasing? } = import(vector);\nincreasing?([3, 2, 1, 1])","let { increasing? } = import(vector);\nincreasing?([3, 2, 1, 2])","let { increasing? } = import(vector);\nincreasing?([1])","let { increasing? } = import(vector);\nincreasing?([])"],seeAlso:["vector.strictly-increasing?","vector.decreasing?","vector.strictly-decreasing?","vector.monotonic?"]},"decreasing?":{category:"vector",description:"Checks if a vector is decreasing.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { decreasing? } = import(vector);\ndecreasing?([1, 2, 3])","let { decreasing? } = import(vector);\ndecreasing?([1, 2, 2, 3])","let { decreasing? } = import(vector);\ndecreasing?([3, 2, 1])","let { decreasing? } = import(vector);\ndecreasing?([3, 2, 1, 1])","let { decreasing? } = import(vector);\ndecreasing?([3, 2, 1, 2])","let { decreasing? } = import(vector);\ndecreasing?([1])","let { decreasing? } = import(vector);\ndecreasing?([])"],seeAlso:["vector.strictly-decreasing?","vector.increasing?","vector.strictly-increasing?","vector.monotonic?"]},"strictly-increasing?":{category:"vector",description:"Checks if a vector is strictly increasing.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { strictly-increasing? } = import(vector);\nstrictly-increasing?([1, 2, 3])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([1, 2, 2, 3])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([3, 2, 1])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([3, 2, 1, 1])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([3, 2, 1, 2])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([1])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([])"],seeAlso:["vector.increasing?","vector.decreasing?","vector.strictly-decreasing?","vector.strictly-monotonic?"]},"strictly-decreasing?":{category:"vector",description:"Checks if a vector is strictly decreasing.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([1, 2, 3])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([1, 2, 2, 3])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([3, 2, 1])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([3, 2, 1, 1])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([3, 2, 1, 2])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([1])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([])"],seeAlso:["vector.increasing?","vector.strictly-increasing?","vector.decreasing?","vector.strictly-monotonic?"]},mode:{category:"vector",description:"Returns the mode of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to calculate the mode of."}},variants:[{argumentNames:["vector"]}],examples:["let { mode } = import(vector);\nmode([1, 2, 3])","let { mode } = import(vector);\nmode([1, 2, -3, 1])","let { mode } = import(vector);\nmode([2, 2, 3, 3, 4])","let { mode } = import(vector);\nmode([2, 2, 3, 3])","let { mode } = import(vector);\nmode([1, 2, 3, 2, 1, 2])"],seeAlso:["mean","median"]},"min-index":{category:"vector",description:"Returns the index of the minimum value of all elements in the vector.",returns:{type:"integer"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the minimum index of."}},variants:[{argumentNames:["vector"]}],examples:["let { min-index } = import(vector);\nmin-index([1, 2, 3])","let { min-index } = import(vector);\nmin-index([1, 1, 2, 3, 3])","let { min-index } = import(vector);\nmin-index([1, 2, -3])","let { min-index } = import(vector);\nmin-index([1, 2, 3, 4])","let { min-index } = import(vector);\nmin-index([1, 2, -3, 4])"],seeAlso:["vector.max-index","min"]},"max-index":{category:"vector",description:"Returns the index of the maximum value of all elements in the vector.",returns:{type:"integer"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the maximum index of."}},variants:[{argumentNames:["vector"]}],examples:["let { max-index } = import(vector);\nmax-index([1, 2, 3])","let { max-index } = import(vector);\nmax-index([1, 1, 2, 3, 3])","let { max-index } = import(vector);\nmax-index([1, 2, -3])","let { max-index } = import(vector);\nmax-index([1, 2, 3, 4])","let { max-index } = import(vector);\nmax-index([1, 2, -3, 4])"],seeAlso:["vector.min-index","max"]},"sort-indices":{category:"vector",description:"Returns the indices of the elements in the vector sorted in ascending order.",returns:{type:"vector"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the sorted indices of."}},variants:[{argumentNames:["vector"]}],examples:["let { sort-indices } = import(vector);\nsort-indices([1, 2, 3])","let { sort-indices } = import(vector);\nsort-indices([1, 1, 2, 3, 3])","let { sort-indices } = import(vector);\nsort-indices([1, 2, -3])","let { sort-indices } = import(vector);\nsort-indices([1, 2, 3, 4])","let { sort-indices } = import(vector);\nsort-indices([1, 2, -3, 4])"],seeAlso:["sort"]},"count-values":{category:"vector",description:"Counts the number of occurrences of each value in the vector.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"Vector to count the values of."}},variants:[{argumentNames:["vector"]}],examples:["let { count-values } = import(vector);\ncount-values([1, 2, 3])","let { count-values } = import(vector);\ncount-values([1, 1, 2, 3, 3])","let { count-values } = import(vector);\ncount-values([1, 2, -3])","let { count-values } = import(vector);\ncount-values([1, 2, 2, 1, 3, 2, 4, 2, 1, 2, 2, 1, 3, 2, 4])"],seeAlso:["sequence.frequencies","vector.bincount"]},linspace:{category:"vector",description:"Generates a vector of evenly spaced numbers between two values.",returns:{type:"number",array:!0},args:{start:{type:"number",description:"The starting value."},stop:{type:"number",description:"The ending value."},n:{type:"integer",description:"The number of values to generate."}},variants:[{argumentNames:["start","stop","n"]}],examples:["let { linspace } = import(vector);\nlinspace(0, 10, 6)","let { linspace } = import(vector);\nlinspace(10, 20, 25)"],seeAlso:["range"]},cumsum:{category:"vector",description:"Calculates the cumulative sum of a vector.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The vector to calculate the cumulative sum of."}},variants:[{argumentNames:["vector"]}],examples:["let { cumsum } = import(vector);\ncumsum([1, 2, 3])","let { cumsum } = import(vector);\ncumsum([1, 2, -3])","let { cumsum } = import(vector);\ncumsum([])"],seeAlso:["vector.cumprod","sum","vector.running-sum"]},cumprod:{category:"vector",description:"Calculates the cumulative product of a vector.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The vector to calculate the cumulative product of."}},variants:[{argumentNames:["vector"]}],examples:["let { cumprod } = import(vector);\ncumprod([1, 2, 3])","let { cumprod } = import(vector);\ncumprod([1, 2, -3, 0, 10])","let { cumprod } = import(vector);\ncumprod([])"],seeAlso:["vector.cumsum","prod","vector.running-prod"]},quartiles:{category:"vector",description:"Calculates the quartiles of a vector. Returns an array containing the first, second (median), and third quartiles.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The vector to calculate the quartiles of. Minimum length is 4."}},variants:[{argumentNames:["vector"]}],examples:["let { quartiles } = import(vector);\nquartiles([1, 2, 3, 4])","let { quartiles } = import(vector);\nquartiles([5, 4, 3, 2, 1, 2, 3, 4, 5])","let { quartiles } = import(vector);\nquartiles(range(1, 1000))","let { quartiles } = import(vector);\nquartiles(map(range(1000), -> 1e6 / ($ + 1) ^ 2))","let { quartiles } = import(vector);\nlet { ln } = import(math);\nquartiles(map(range(1000), -> ln($ + 1)))"],seeAlso:["vector.percentile","vector.quantile","median","vector.iqr"]},percentile:{category:"vector",description:"Calculates the percentile of a vector. Returns the value at the specified percentile.",returns:{type:"number"},args:{vector:{type:"vector",description:"The non empty vector to calculate the percentile of."},percentile:{type:"number",description:"The percentile to calculate. Must be between 0 and 1."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["vector","percentile"]}],examples:["let { percentile } = import(vector);\npercentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 35)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 0)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 10)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 20)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 30)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 40)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 50)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 60)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 70)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 80)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 90)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 100)"],seeAlso:["vector.quantile","vector.quartiles","median","vector.ecdf","vector.winsorize"]},quantile:{category:"vector",description:"Calculates the quantile of a vector. Returns the value at the specified quantile.",returns:{type:"number"},args:{vector:{type:"vector",description:"The non empty vector to calculate the quantile of."},quantile:{type:"number",description:"The quantile to calculate. Must be between 0 and 1."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["vector","quantile"]}],examples:["let { quantile } = import(vector);\nquantile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0.35)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.1)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.2)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.3)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.4)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.5)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.6)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.7)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.8)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.9)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 1)"],seeAlso:["vector.percentile","vector.quartiles","vector.ecdf"]},histogram:{category:"vector",description:"Creates a histogram from a numeric `array` by dividing the data range into the specified number of bins. Returns an `array` of `[binStart, binEnd, count]` tuples representing each bin's range and the number of values within it. Handles empty arrays, identical values, and properly places maximum values in the last bin.",returns:{type:"array",array:!0},args:{vector:{type:"vector",description:"The numeric array to create a histogram from."},bins:{type:"integer",description:"The number of bins to divide the data range into."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["vector","bins"]}],examples:["let { histogram } = import(vector);\nhistogram([1, 2, 2, 3, 2, 6, 4, 3, 2, 4, 1, 3, 2, 9], 3)","let { histogram } = import(vector);\nhistogram([1, 2, 3, 4, 5], 5)","let { histogram } = import(vector);\nhistogram([1, 2, 3, 4, 5], 10)","let { histogram } = import(vector);\nhistogram([1, 2, 3, 4, 5], 1)"],seeAlso:["vector.bincount","vector.ecdf"]},ecdf:{category:"vector",description:"Calculates the empirical cumulative distribution function value for a given threshold in a non empty dataset. Returns the proportion of values in the `array` that are less than or equal to the specified threshold.",returns:{type:"number"},args:{vector:{type:"vector",description:"The numeric array to calculate the ECDF from."},threshold:{type:"number",description:"The threshold value to calculate the ECDF for."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["vector","threshold"]}],examples:["let { ecdf } = import(vector);\necdf([1, 2, 2, 3, 2, 6, 4, 3, 2, 4, 1, 3, 2, 9, 10, 12], 5)","let { ecdf } = import(vector);\necdf([1, 2, 3, 4, 5], 3)","let { ecdf } = import(vector);\necdf([1, 2, 3, 4, 5], 0)","let { ecdf } = import(vector);\necdf([1, 2, 3, 4, 5], 10)","let { ecdf } = import(vector);\necdf([1, 2, 3, 4, 5], 2)"],seeAlso:["vector.histogram","vector.percentile","vector.quantile"]},"outliers?":{category:"vector",description:"Checks if the `vector` contains outliers based on the interquartile range (IQR) method. Returns `true` if outliers are present, `false` otherwise.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The `vector` to check for outliers."}},variants:[{argumentNames:["vector"]}],examples:["let { outliers? } = import(vector);\noutliers?([1, 2, 3])","let { outliers? } = import(vector);\noutliers?([1, 2, -3])","let { outliers? } = import(vector);\noutliers?([1, 2, 3, 2, 4, 120])"],seeAlso:["vector.outliers","vector.winsorize","vector.iqr"]},outliers:{category:"vector",description:"Identifies outliers in the `vector` based on the interquartile range (IQR) method. Returns an array of outlier values.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The `vector` to check for outliers."}},variants:[{argumentNames:["vector"]}],examples:["let { outliers } = import(vector);\noutliers([1, 2, 3])","let { outliers } = import(vector);\noutliers([1, 2, -3])","let { outliers } = import(vector);\noutliers([1, 2, 3, 2, 4, 120])"],seeAlso:["vector.outliers?","vector.winsorize","vector.iqr"]},bincount:{category:"vector",description:"counts occurrences of each `integer` in a vector, returning an array where index `i` contains the count of value `i`, with optional **minimum size** and **weights parameters**.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The vector to count occurrences in."},minSize:{type:"integer",description:"Optional minimum size of the output array."},weights:{type:"number",array:!0,description:"Optional weights for each element in the vector."}},variants:[{argumentNames:["vector"]},{argumentNames:["vector","minSize"]},{argumentNames:["vector","minSize","weights"]}],examples:["let { bincount } = import(vector);\nbincount([1, 2, 3])","let { bincount } = import(vector);\nbincount([1, 2, 2, 3, 3])"],seeAlso:["vector.count-values","vector.histogram"],hideOperatorForm:!0},winsorize:{category:"vector",description:"Limits extreme values in a `vector` by replacing values below the **lower quantile** and above the **upper quantile** with the values at those quantiles. The function takes a `vector` of values and **quantile thresholds** (between 0 and 1), with the upper quantile. Winsorization reduces the influence of outliers while preserving the overall distribution shape, making statistical analyses more robust.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The vector to winsorize."},"lower-quantile":{type:"number",description:"The lower quantile threshold (between 0 and 1)."},"upper-quantile":{type:"number",description:"Optional Upper quantile threshold (between 0 and 1). Defaults to `(1 - lower-quantile)` if `lower-quantile <= 0.5` otherwise `1`."}},variants:[{argumentNames:["vector","lower-quantile"]},{argumentNames:["vector","lower-quantile","upper-quantile"]}],examples:["let { winsorize } = import(vector);\nwinsorize([2, 5, 8, 10, 15, 18, 20, 35, 60, 100], 0.25)","let { winsorize } = import(vector);\nwinsorize([2, 5, 8, 10, 15, 18, 20, 35, 60, 100], 0.25, 0.75)","let { winsorize } = import(vector);\nwinsorize([2, 5, 8, 10, 15, 18, 20, 35, 60, 100], 0.25, 0.5)"],seeAlso:["vector.outliers","vector.outliers?","vector.percentile"],hideOperatorForm:!0},mse:{category:"vector",description:"Calculates the **Mean Squared Error (MSE)** between two vectors. Returns the average of the squared differences between corresponding elements.",returns:{type:"number"},args:{a:{type:"vector",description:"The first vector."},b:{type:"vector",description:"The second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { mse } = import(vector);\nmse([1, 2, 3], [1, 2, 3])","let { mse } = import(vector);\nmse([1, 2, 3], [4, 5, 6])","let { mse } = import(vector);\nmse([1, 2, 3], [2, 2, 2])","let { mse } = import(vector);\nmse([1, 2], [3, 3])","let { mse } = import(vector);\nmse([1], [3])"],seeAlso:["vector.rmse","vector.mae","vector.smape"]},rmse:{category:"vector",description:"Calculates the **Root Mean Squared Error (RMSE)** between two vectors. Returns the square root of the average of the squared differences between corresponding elements.",returns:{type:"number"},args:{a:{type:"vector",description:"The first vector."},b:{type:"vector",description:"The second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { rmse } = import(vector);\nrmse([1, 2, 3], [1, 2, 3])","let { rmse } = import(vector);\nrmse([1, 2, 3], [4, 5, 6])","let { rmse } = import(vector);\nrmse([1, 2, 3], [2, 2, 2])","let { rmse } = import(vector);\nrmse([1, 2], [3, 3])","let { rmse } = import(vector);\nrmse([1], [3])"],seeAlso:["vector.mse","vector.mae","vector.smape"]},mae:{category:"vector",description:"Calculates the **Mean Absolute Error (MAE)** between two vectors. Returns the average of the absolute differences between corresponding elements.",returns:{type:"number"},args:{a:{type:"vector",description:"The first vector."},b:{type:"vector",description:"The second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { mae } = import(vector);\nmae([1, 2, 3], [1, 2, 3])","let { mae } = import(vector);\nmae([1, 2, 3], [4, 5, 6])","let { mae } = import(vector);\nmae([1, 2, 3], [2, 2, 2])","let { mae } = import(vector);\nmae([1, 2], [3, 3])","let { mae } = import(vector);\nmae([1], [3])"],seeAlso:["vector.mse","vector.rmse","vector.smape"]},smape:{category:"vector",description:"Calculates the **Symmetric Mean Absolute Percentage Error (SMAPE)** between two vectors. Returns the average of the absolute percentage differences between corresponding elements.",returns:{type:"number"},args:{a:{type:"vector",description:"The first vector."},b:{type:"vector",description:"The second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { smape } = import(vector);\nsmape([1, 2, 3], [1, 2, 3])","let { smape } = import(vector);\nsmape([1, 2, 3], [4, 5, 6])","let { smape } = import(vector);\nsmape([1, 2, 3], [2, 2, 2])","let { smape } = import(vector);\nsmape([1, 2], [3, 3])","let { smape } = import(vector);\nsmape([1], [3])"],seeAlso:["vector.mse","vector.rmse","vector.mae"]}};function Hr(e){if(e.length<=1)return[];const t=[...e].sort((e,t)=>e-t),r=Math.floor(.25*t.length),n=t.length%4==0?(t[r-1]+t[r])/2:t[r],o=Math.floor(.75*t.length),a=t.length%4==0?(t[o-1]+t[o])/2:t[o],i=a-n,s=n-1.5*i,c=a+1.5*i;return e.filter(e=>e<s||e>c)}function Xr(e,t){const r=[...e].sort((e,t)=>e-t);if(0===t)return r[0];if(100===t)return r[r.length-1];const n=t/100*(r.length-1);if(Number.isInteger(n))return r[n];const o=Math.floor(n),a=Math.ceil(n),i=n-o;return r[o]*(1-i)+r[a]*i}function Zr(e){const t=[...e].sort((e,t)=>e-t),r=t.length/2;let n;n=t.length%2==0?(t[r-1]+t[r])/2:t[Math.floor(r)];const o=t.slice(0,Math.floor(t.length/2)),a=t.slice(Math.ceil(t.length/2));let i,s;if(o.length%2==0){const e=o.length/2;i=(o[e-1]+o[e])/2}else i=o[Math.floor(o.length/2)];if(a.length%2==0){const e=a.length/2;s=(a[e-1]+a[e])/2}else s=a[Math.floor(a.length/2)];return[i,n,s]}function Qr(e){if(0===e.length)return 0;return e.reduce((e,t)=>e+t,0)/e.length}const en={"geometric-mean":e=>{if(e.some(e=>e<0))throw new Error("Geometric mean is not defined for non-positive numbers");return Math.exp(e.reduce((e,t)=>e+Math.log(t),0)/e.length)}};function tn(e){const t=[...e].sort((e,t)=>e-t),r=Math.floor(t.length/2);return t.length%2==0?(t[r-1]+t[r])/2:t[r]}const rn={median:e=>tn(e)};function nn(e,t){const r=t??Qr(e);return e.reduce((e,t)=>e+(t-r)**2,0)/e.length}const on={variance:e=>nn(e)},an={"sample-variance":e=>function(e){const t=Qr(e);return e.reduce((e,r)=>e+(r-t)**2,0)/(e.length-1)}(e),minLength:2};function sn(e,t){const r=nn(e,t);return Math.sqrt(r)}const cn={stdev:e=>sn(e)},ln={"sample-stdev":e=>function(e,t){const r=nn(e,t);return Math.sqrt(r*(e.length/(e.length-1)))}(e),minLength:2},mn={iqr:e=>{const[t,,r]=Zr(e);return r-t},minLength:4},un={span:e=>0===e.length?0:Math.max(...e)-Math.min(...e),minLength:0};const pn={skewness:e=>function(e){const t=Qr(e),r=sn(e);if(0===r)throw new Error("Standard deviation is zero, skewness is undefined");return e.reduce((e,r)=>e+(r-t)**3,0)/(e.length*r**3)}(e),minLength:3},gn={"sample-skewness":e=>function(e){const t=e.length,r=e.reduce((e,t)=>e+t,0)/t;let n=0,o=0;for(const t of e){const e=t-r;n+=e*e,o+=e*e*e}const a=n/(t-1),i=Math.sqrt(a);if(0===i)throw new Error("Cannot calculate sample skewness when standard deviation is 0");return t/((t-1)*(t-2))*o/i**3}(e),minLength:3};function hn(e){const t=Qr(e),r=sn(e);if(0===r)throw new Error("Standard deviation is zero, kurtosis is undefined");return e.reduce((e,r)=>e+(r-t)**4,0)/(e.length*r**4)}const dn={kurtosis:e=>hn(e),minLength:4},yn={"excess-kurtosis":e=>function(e){return hn(e)-3}(e),minLength:4},vn={"sample-kurtosis":e=>function(e){const t=e.length,r=e.reduce((e,t)=>e+t,0)/t,n=e.reduce((e,t)=>e+(t-r)**2,0)/(t-1);if(0===n)throw new Error("Variance is zero, kurtosis is undefined");return t*(t+1)*e.reduce((e,t)=>e+(t-r)**4,0)/((t-1)*(t-2)*(t-3)*n**2)}(e),minLength:4},fn={"sample-excess-kurtosis":e=>function(e){const t=e.length,r=e.reduce((e,t)=>e+t,0)/t,n=e.reduce((e,t)=>e+(t-r)**2,0)/(t-1);if(0===n)throw new Error("Variance is zero, kurtosis is undefined");return t*(t+1)*e.reduce((e,t)=>e+(t-r)**4,0)/((t-1)*(t-2)*(t-3)*n**2)-3*(t-1)*(t-1)/((t-2)*(t-3))}(e),minLength:4},bn={rms:e=>Math.sqrt(e.reduce((e,t)=>e+t**2,0)/e.length)};const xn={mad:e=>function(e){const t=tn(e);return e.reduce((e,r)=>e+Math.abs(r-t),0)/e.length}(e)};function wn(e){const t=tn(e);return 1.4826*tn(e.map(e=>Math.abs(e-t)))}const kn={medad:e=>wn(e)},qn={"gini-coefficient":e=>{if(e.some(e=>e<0))throw new Error("Gini coefficient is not defined for negative values");const t=[...e].sort((e,t)=>e-t),r=t.length,n=t.reduce((e,t)=>e+t,0);if(0===n)return 0;return 2*t.reduce((e,t,r)=>e+(r+1)*t,0)/(r*n)-(r+1)/r},minLength:1};const An={entropy:e=>function(e){const t=new Map;for(const r of e)t.set(r,(t.get(r)||0)+1);const r=e.length;let n=0;for(const e of t.values()){const t=e/r;t>0&&(n-=t*Math.log2(t))}return n}(e),minLength:1},Nn={};function $n(e){for(const[t,r]of Object.entries(e)){if(Nn[t])throw new Error(`Duplicate normal expression key found: ${t}`);if("minLength"!==t&&"padding"!==t&&"function"==typeof r){const n=r,o=t.replace(/^/,""),a=`moving-${o}`,i=`centered-moving-${o}`,s=`running-${o}`,c=e.minLength??1;ee(c,void 0,{integer:!0,finite:!0,gte:0}),Nn[t]=Tn(n,c),Nn[a]=zn(n,c),Nn[i]=Sn(n,c,e.padding??null),Nn[s]=En(n,c)}}}function Tn(e,t){return{evaluate:([n],o)=>{if(Ze(n,o),n.length<t)throw new r(`Vector length must be at least ${t}`,o);try{return e(n)}catch(e){throw new r(e,o)}},arity:ae(1)}}function zn(e,t){return{evaluate:([n,o],a)=>{if(Ze(n,a),ee(o,a,{integer:!0,finite:!0,gte:t,lte:n.length}),0===n.length)return[];try{if(o>=n.length)return[e(n)];const t=[];for(let r=0;r<n.length-o+1;r+=1)t.push(e(n.slice(r,r+o)));return t}catch(e){throw new r(e,a)}},arity:ae(2)}}function Sn(e,t,n){return{evaluate:([o,a,i,s],c)=>{if(Ze(o,c),o.length<t)throw new r(`Vector length must be at least ${t}`,c);if(ee(a,c,{integer:!0,finite:!0,gte:t,lte:o.length}),null!==(i=i??n)&&ee(i,c,{finite:!0}),null!==(s=s??n)&&ee(s,c,{finite:!0}),0===o.length)return[];const l=Math.floor(a/2),m=[...Array(l).fill(i),...o,...Array(l).fill(s)],u="number"==typeof i?0:l,p=o.length-("number"==typeof s?0:a-l-1),g=[...Array(u).fill(null)];try{for(let t=u;t<p;t+=1)g.push(e(m.slice(t,t+a)))}catch(e){throw new r(e,c)}return g.push(...Array(o.length-p).fill(null)),g},arity:{min:2,max:4}}}function En(e,t){return{evaluate:([n],o)=>{if(Ze(n,o),n.length<t)throw new r(`Vector length must be at least ${t}`,o);if(0===n.length)return[];try{const r=Math.max(t-1,0),o=Array(r).fill(null);for(let t=r;t<n.length;t+=1)o.push(e(n.slice(0,t+1)));return o}catch(e){throw new r(e,o)}},arity:ae(1)}}$n({mean:e=>Qr(e)}),$n(en),$n({"harmonic-mean":e=>e.length/e.reduce((e,t)=>e+1/t,0)}),$n(rn),$n({sum:e=>e.reduce((e,t)=>e+t,0),minLength:0}),$n({prod:e=>e.reduce((e,t)=>e*t,1),padding:1,minLength:0}),$n(on),$n(an),$n(cn),$n(ln),$n(mn),$n(un),$n(pn),$n(gn),$n(yn),$n(dn),$n(fn),$n(vn),$n(bn),$n(xn),$n(kn),$n(qn),$n(An),delete Nn.sum,delete Nn.prod,delete Nn.mean,delete Nn.median;const jn={"monotonic?":{evaluate:([e],t)=>(Ze(e,t),e.every((t,r)=>0===r||t>=e[r-1])||e.every((t,r)=>0===r||t<=e[r-1])),arity:ae(1)},"strictly-monotonic?":{evaluate:([e],t)=>(Ze(e,t),e.every((t,r)=>0===r||t>e[r-1])||e.every((t,r)=>0===r||t<e[r-1])),arity:ae(1)},"increasing?":{evaluate:([e],t)=>(Ze(e,t),e.every((t,r)=>0===r||t>=e[r-1])),arity:ae(1)},"decreasing?":{evaluate:([e],t)=>(Ze(e,t),e.every((t,r)=>0===r||t<=e[r-1])),arity:ae(1)},"strictly-increasing?":{evaluate:([e],t)=>(Ze(e,t),e.every((t,r)=>0===r||t>e[r-1])),arity:ae(1)},"strictly-decreasing?":{evaluate:([e],t)=>(Ze(e,t),e.every((t,r)=>0===r||t<e[r-1])),arity:ae(1)},mode:{evaluate:([e],t)=>(tt(e,t),function(e){const t=new Map;for(const r of e)t.set(r,(t.get(r)||0)+1);let r=0;for(const e of t.values())e>r&&(r=e);if(1===r)return e;const n=[];for(const[e,o]of t.entries())o===r&&n.push(e);return n}(e)),arity:ae(1)},"min-index":{evaluate:([e],t)=>(tt(e,t),e.reduce((t,r,n)=>r<e[t]?n:t,0)),arity:ae(1)},"max-index":{evaluate:([e],t)=>(tt(e,t),e.reduce((t,r,n)=>r>e[t]?n:t,0)),arity:ae(1)},"sort-indices":{evaluate:([e],t)=>(Ze(e,t),[...e.keys()].sort((t,r)=>e[t]-e[r])),arity:ae(1)},"count-values":{evaluate:([e],t)=>{Ze(e,t);const r=new Map;for(const t of e)r.set(t,(r.get(t)||0)+1);return[...r.entries()].sort((e,t)=>{const r=t[1]-e[1];return 0!==r?r:e[0]-t[0]})},arity:ae(1)},linspace:{evaluate:([e,t,r],n)=>{if(ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),ee(r,n,{integer:!0,nonNegative:!0}),0===r)return[];if(1===r)return[e];const o=(t-e)/(r-1);return Array.from({length:r},(t,r)=>e+r*o)},arity:ae(3)},cumsum:{evaluate:([e],t)=>(Ze(e,t),e.reduce((e,t)=>{const r=e[e.length-1]??0;return e.push(r+t),e},[])),arity:ae(1)},cumprod:{evaluate:([e],t)=>(Ze(e,t),e.reduce((e,t)=>{const r=e[e.length-1]??1;return e.push(r*t),e},[])),arity:ae(1)},quartiles:{evaluate:([e],t)=>{if(Ze(e,t),e.length<4)throw new r("Quartiles require at least four values",t);return Zr(e)},arity:ae(1)},percentile:{evaluate:([e,t],r)=>(tt(e,r),ee(t,r,{finite:!0,nonNegative:!0,lte:100}),Xr(e,t)),arity:ae(2)},quantile:{evaluate:([e,t],r)=>(Ze(e,r),ee(t,r,{finite:!0,nonNegative:!0,lte:1}),Xr(e,100*t)),arity:ae(2)},histogram:{evaluate:([e,t],r)=>(Ze(e,r),ee(t,r,{integer:!0,positive:!0}),function(e,t){if(0===e.length){const e=[];for(let r=0;r<t;r++)e.push([0,0,0]);return e}const r=Math.min(...e),n=Math.max(...e);if(r===n){const n=[];for(let e=0;e<t;e++)n.push([r,r,0]);return n[0][2]=e.length,n}const o=(n-r)/t,a=[];for(let e=0;e<t;e++){const i=r+e*o,s=e===t-1?n:r+(e+1)*o;a.push([i,s,0])}for(const i of e)i===n?a[t-1][2]+=1:a[Math.min(Math.floor((i-r)/o),t-1)][2]+=1;return a}(e,t)),arity:ae(2)},ecdf:{evaluate:([e,t],r)=>{tt(e,r),ee(t,r,{finite:!0});const n=[...e].sort((e,t)=>e-t),o=n.findIndex(e=>e>t);return-1===o?1:o/n.length},arity:ae(2)},"outliers?":{evaluate:([e],t)=>(Ze(e,t),function(e){return Hr(e).length>0}(e)),arity:ae(1)},outliers:{evaluate:([e],t)=>(Ze(e,t),Hr(e)),arity:ae(1)},bincount:{evaluate:(e,t)=>{const n=e[0];Ze(n,t),n.forEach(e=>ee(e,t,{finite:!0,integer:!0,nonNegative:!0}));const o=e[1]??0;ee(o,t,{integer:!0,nonNegative:!0});const a=e[2]??void 0;if(void 0!==a){if(Ze(a,t),a.length!==n.length)throw new r("Weights vector must be the same length as the input vector",t);a.forEach(e=>ee(e,t,{finite:!0}))}return function(e,t=0,r){if(0===e.length)return Array.from({length:t},()=>0);const n=Math.max(...e),o=Math.max(n+1,t),a=Array.from({length:o},()=>0);for(let t=0;t<e.length;t++){const n=Math.floor(e[t]);n<o&&(a[n]+=r?r[t]:1)}return a}(n,o,a)},arity:{min:1,max:3}},winsorize:{evaluate:([e,t,r],n)=>{if(Ze(e,n),ee(t,n,{finite:!0,gte:0,lte:1}),r??=t>.5?1:1-t,ee(r,n,{finite:!0,gte:t,lte:1}),0===e.length)return[];const o=[...e].sort((e,t)=>e-t),a=Math.max(0,Math.floor(t*e.length)),i=Math.min(e.length-1,Math.max(0,Math.floor(r*e.length)-1)),s=o[a],c=o[i];return e.map(e=>Math.max(s,Math.min(e,c)))},arity:{min:2,max:3}},mse:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+(r-t[n])**2,0)/e.length},arity:ae(2)},rmse:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return Math.sqrt(e.reduce((e,r,n)=>e+(r-t[n])**2,0)/e.length)},arity:ae(2)},mae:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+Math.abs(r-t[n]),0)/e.length},arity:ae(2)},smape:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>{const o=Math.abs(r-t[n]),a=(Math.abs(r)+Math.abs(t[n]))/2;return e+(0===a?0:o/a)},0)/e.length},arity:ae(2)}};!function(e){for(const[t,r]of Object.entries(e)){if(jn[t])throw new Error(`Duplicate normal expression key found: ${t}`);jn[t]=r}}(Nn);for(const[e,t]of Object.entries(Yr))jn[e]&&(jn[e].docs=t);const Mn={name:"vector",functions:jn},Cn={reflect:{category:"linear-algebra",description:"Reflects a vector across a given axis.",returns:{type:"vector"},args:{a:{type:"vector",description:"Vector to reflect."},b:{type:"vector",description:"Axis of reflection."}},variants:[{argumentNames:["a","b"]}],examples:["let { reflect } = import(linear-algebra);\nreflect([1, 2], [0, 1])","let { reflect } = import(linear-algebra);\nreflect([1, 2, 3], [0, 0, 1])"],seeAlso:["linear-algebra.refract","linear-algebra.projection"]},refract:{category:"linear-algebra",description:"Refracts a vector across a given axis.",returns:{type:"vector"},args:{vector:{type:"vector",description:"Vector to refract."},axis:{type:"vector",description:"Axis of refraction."},eta:{type:"number",description:"Refraction index."}},variants:[{argumentNames:["vector","axis","eta"]}],examples:["let { refract } = import(linear-algebra);\nrefract([1, 2], [0, 1], 1.5)","let { refract } = import(linear-algebra);\nrefract([1, 2, 3], [0, 0, 1], 1.5)"],seeAlso:["linear-algebra.reflect"]},lerp:{category:"linear-algebra",description:"Performs linear interpolation between two vectors.",returns:{type:"vector"},args:{a:{type:"vector",description:"Start vector."},b:{type:"vector",description:"End vector."},t:{type:"number",description:"Interpolation factor (0 to 1)."}},variants:[{argumentNames:["a","b","t"]}],examples:["let { lerp } = import(linear-algebra);\nlerp([1, 2], [3, 4], 0.5)","let { lerp } = import(linear-algebra);\nlerp([1, 2], [3, 4], 2)","let { lerp } = import(linear-algebra);\nlerp([1, 2], [3, 4], -1)","let { lerp } = import(linear-algebra);\nlerp([1, 2, 3], [4, 5, 6], 0.25)"],seeAlso:["linear-algebra.projection"]},rotate2d:{category:"linear-algebra",description:"Rotates a 2D vector by a given angle in radians.",returns:{type:"vector"},args:{a:{type:"vector",description:"Vector to rotate."},b:{type:"number",description:"Angle in b."}},variants:[{argumentNames:["a","b"]}],examples:["let { rotate2d } = import(linear-algebra);\nrotate2d([1, 0], PI / 2)","let { rotate2d } = import(linear-algebra);\nrotate2d([0, 1], PI)"],seeAlso:["linear-algebra.rotate3d","linear-algebra.angle"]},rotate3d:{category:"linear-algebra",description:"Rotates a 3D vector around a given axis by a given angle in radians.",returns:{type:"vector"},args:{v:{type:"vector",description:"Vector to rotate."},axis:{type:"vector",description:"Axis of rotation."},radians:{type:"number",description:"Angle in radians."}},variants:[{argumentNames:["v","axis","radians"]}],examples:["let { rotate3d } = import(linear-algebra);\nrotate3d([1, 0, 0], [0, 1, 0], PI / 2)","let { rotate3d } = import(linear-algebra);\nrotate3d([0, 1, 0], [1, 0, 0], PI)"],seeAlso:["linear-algebra.rotate2d","linear-algebra.angle"]},dot:{category:"linear-algebra",description:"Calculates the dot product of two vectors. The result is a scalar.",returns:{type:"number"},args:{a:{type:"vector",description:"First vector."},b:{type:"vector",description:"Second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { dot } = import(linear-algebra);\ndot([1, 2], [3, 4])","let { dot } = import(linear-algebra);\ndot([1, 2, 3], [4, 5, 6])"],seeAlso:["linear-algebra.cross","linear-algebra.cosine-similarity","linear-algebra.angle","linear-algebra.projection","linear-algebra.orthogonal?"]},cross:{category:"linear-algebra",description:"Calculates the cross product of two 3D vectors. The result is a vector perpendicular to both input vectors.",returns:{type:"vector"},args:{a:{type:"vector",description:"First vector (3D)."},b:{type:"vector",description:"Second vector (3D)."}},variants:[{argumentNames:["a","b"]}],examples:["let { cross } = import(linear-algebra);\ncross([1, 2, 3], [4, 5, 6])","let { cross } = import(linear-algebra);\ncross([1, 0, 0], [0, 1, 0])","let { cross } = import(linear-algebra);\ncross([0, 0, 1], [1, 0, 0])","let { cross } = import(linear-algebra);\ncross([1, 2, 3], [0, 0, 0])","let { cross } = import(linear-algebra);\ncross([0, 0, 0], [1, 2, 3])"],seeAlso:["linear-algebra.dot"]},"normalize-minmax":{category:"linear-algebra",description:"Normalizes the vector using min-max normalization. The result is a vector with values between 0 and 1.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, 3])","let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, -3])","let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, 3, 4])","let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, -3, 4])","let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-zscore","linear-algebra.normalize-robust","linear-algebra.normalize-l1","linear-algebra.normalize-l2","linear-algebra.normalize-log"]},"normalize-zscore":{category:"linear-algebra",description:"Normalizes the vector using z-score normalization. The result is a vector with mean 0 and standard deviation 1.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, 3])","let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, -3])","let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, 3, 4])","let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, -3, 4])","let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-minmax","linear-algebra.normalize-robust","linear-algebra.normalize-l1","linear-algebra.normalize-l2","linear-algebra.normalize-log"]},"normalize-robust":{category:"linear-algebra",description:"Normalizes the vector using robust normalization. The result is a vector with median 0 and median absolute deviation 1.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, 3])","let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, -3])","let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, 3, 4])","let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, -3, 4])","let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-minmax","linear-algebra.normalize-zscore"]},"normalize-l1":{category:"linear-algebra",description:"Normalizes the vector using L1 normalization. The result is a vector with L1 norm equal to 1.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, 3])","let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, -3])","let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, 3, 4])","let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, -3, 4])","let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-l2","linear-algebra.normalize-minmax","linear-algebra.manhattan-norm","linear-algebra.normalize-zscore"]},"normalize-l2":{category:"linear-algebra",description:"Normalizes the vector using L2 normalization. The result is a vector with L2 norm equal to 1.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, 3])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, 3])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, -3])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, 3, 4])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, -3, 4])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-l1","linear-algebra.normalize-minmax","linear-algebra.euclidean-norm","linear-algebra.normalize-zscore"]},"normalize-log":{category:"linear-algebra",description:"Normalizes the vector using natural log normalization. The result is a vector with log-transformed values.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-log } = import(linear-algebra);\nnormalize-log([1, 2, 3])","let { normalize-log } = import(linear-algebra);\nnormalize-log([1, 2, 3, 4])","let { normalize-log } = import(linear-algebra);\nnormalize-log([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-minmax","linear-algebra.normalize-zscore"]},angle:{category:"linear-algebra",description:"Calculates the **angle** between two vectors in radians.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { angle } = import(linear-algebra);\nangle([1, 0], [0, 1])","let { angle } = import(linear-algebra);\nangle([1, 0, 1], [0, 1, 0])"],seeAlso:["linear-algebra.dot","linear-algebra.collinear?","linear-algebra.orthogonal?","linear-algebra.rotate2d","linear-algebra.rotate3d","linear-algebra.parallel?","linear-algebra.cosine-similarity","linear-algebra.to-polar"]},projection:{category:"linear-algebra",description:"Calculates the **projection** of vector `a` onto vector `b`.",returns:{type:"vector"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { projection } = import(linear-algebra);\nprojection([1, 2], [3, 4])","let { projection } = import(linear-algebra);\nprojection([1, 2, 3], [4, 5, 6])"],seeAlso:["linear-algebra.dot","linear-algebra.reflect","linear-algebra.lerp"]},"collinear?":{category:"linear-algebra",description:"Checks if two vectors are **collinear**.",returns:{type:"boolean"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { collinear? } = import(linear-algebra);\ncollinear?([1, 2], [2, 4])","let { collinear? } = import(linear-algebra);\ncollinear?([1, 2], [-2, -4])","let { collinear? } = import(linear-algebra);\ncollinear?([1, 2, 3], [2, 4, 6])"],seeAlso:["linear-algebra.parallel?","linear-algebra.orthogonal?","linear-algebra.angle"]},"parallel?":{category:"linear-algebra",description:"Checks if two vectors are **parallel**.",returns:{type:"boolean"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { parallel? } = import(linear-algebra);\nparallel?([1, 2], [2, 4])","let { parallel? } = import(linear-algebra);\nparallel?([1, 2], [-2, -4])","let { parallel? } = import(linear-algebra);\nparallel?([1, 2, 3], [2, 4, 6])","let { parallel? } = import(linear-algebra);\nparallel?([1, 2], [3, 4])"],seeAlso:["linear-algebra.collinear?","linear-algebra.orthogonal?","linear-algebra.angle"]},"orthogonal?":{category:"linear-algebra",description:"Checks if two vectors are **orthogonal**.",returns:{type:"boolean"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { orthogonal? } = import(linear-algebra);\northogonal?([1, 0], [0, 1])","let { orthogonal? } = import(linear-algebra);\northogonal?([1, 0, 1], [0, 1, 0])","let { orthogonal? } = import(linear-algebra);\northogonal?([1, 2], [2, -1])"],seeAlso:["linear-algebra.collinear?","linear-algebra.parallel?","linear-algebra.dot","matrix.orthogonal-matrix?","linear-algebra.angle"]},"cosine-similarity":{category:"linear-algebra",description:"Calculates the **cosine similarity** between two vectors. The result is a value between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { cosine-similarity } = import(linear-algebra);\ncosine-similarity([1, 2], [3, 4])","let { cosine-similarity } = import(linear-algebra);\ncosine-similarity([1, 2, 3], [4, 5, 6])","let { cosine-similarity } = import(linear-algebra);\ncosine-similarity([1, 0], [0, 1])"],seeAlso:["linear-algebra.dot","linear-algebra.angle","linear-algebra.euclidean-distance"]},"euclidean-distance":{category:"linear-algebra",description:"Calculates the **Euclidean distance** between two vectors. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { euclidean-distance } = import(linear-algebra);\neuclidean-distance([1, 2], [3, 4])","let { euclidean-distance } = import(linear-algebra);\neuclidean-distance([1, 2, 3], [4, 5, 6])","let { euclidean-distance } = import(linear-algebra);\neuclidean-distance([1, 0], [0, 1])"],seeAlso:["linear-algebra.manhattan-distance","linear-algebra.chebyshev-distance","linear-algebra.minkowski-distance","linear-algebra.euclidean-norm","linear-algebra.cosine-similarity","linear-algebra.hamming-distance"]},"euclidean-norm":{category:"linear-algebra",description:"Calculates the **Euclidean norm** (L2 norm) of a vector. The result is a non-negative number.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to calculate the norm for."}},variants:[{argumentNames:["v"]}],examples:["let { euclidean-norm } = import(linear-algebra);\neuclidean-norm([1, 2])","let { euclidean-norm } = import(linear-algebra);\neuclidean-norm([3, 4])","let { euclidean-norm } = import(linear-algebra);\neuclidean-norm([1, 2, 3])"],seeAlso:["linear-algebra.manhattan-norm","linear-algebra.chebyshev-norm","linear-algebra.minkowski-norm","linear-algebra.euclidean-distance","linear-algebra.normalize-l2","linear-algebra.hamming-norm"]},"manhattan-distance":{category:"linear-algebra",description:"Calculates the **Manhattan distance** between two vectors. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { manhattan-distance } = import(linear-algebra);\nmanhattan-distance([1, 2], [3, 4])","let { manhattan-distance } = import(linear-algebra);\nmanhattan-distance([1, 2, 3], [4, 5, 6])","let { manhattan-distance } = import(linear-algebra);\nmanhattan-distance([1, 0], [0, 1])"],seeAlso:["linear-algebra.euclidean-distance","linear-algebra.chebyshev-distance","linear-algebra.minkowski-distance","linear-algebra.manhattan-norm","linear-algebra.hamming-distance"]},"manhattan-norm":{category:"linear-algebra",description:"Calculates the **Manhattan norm** (L1 norm) of a vector. The result is a non-negative number.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to calculate the norm for."}},variants:[{argumentNames:["v"]}],examples:["let { manhattan-norm } = import(linear-algebra);\nmanhattan-norm([1, 2])","let { manhattan-norm } = import(linear-algebra);\nmanhattan-norm([3, 4])","let { manhattan-norm } = import(linear-algebra);\nmanhattan-norm([1, 2, 3])"],seeAlso:["linear-algebra.euclidean-norm","linear-algebra.chebyshev-norm","linear-algebra.minkowski-norm","linear-algebra.manhattan-distance","linear-algebra.normalize-l1","linear-algebra.hamming-norm"]},"hamming-distance":{category:"linear-algebra",description:"Calculates the **Hamming distance** between two vectors. The result is a non-negative integer.",returns:{type:"integer"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { hamming-distance } = import(linear-algebra);\nhamming-distance([1, 2], [3, 4])","let { hamming-distance } = import(linear-algebra);\nhamming-distance([1, 2, 3], [4, 5, 6])","let { hamming-distance } = import(linear-algebra);\nhamming-distance([1, 0], [0, 1])"],seeAlso:["linear-algebra.euclidean-distance","linear-algebra.manhattan-distance","linear-algebra.hamming-norm"]},"hamming-norm":{category:"linear-algebra",description:"Calculates the **Hamming norm** of a vector. The result is a non-negative integer.",returns:{type:"integer"},args:{v:{type:"vector",description:"Vector to calculate the norm for."}},variants:[{argumentNames:["v"]}],examples:["let { hamming-norm } = import(linear-algebra);\nhamming-norm([1, 2])","let { hamming-norm } = import(linear-algebra);\nhamming-norm([3, 4])","let { hamming-norm } = import(linear-algebra);\nhamming-norm([1, 2, 3])"],seeAlso:["linear-algebra.euclidean-norm","linear-algebra.manhattan-norm","linear-algebra.hamming-distance"]},"chebyshev-distance":{category:"linear-algebra",description:"Calculates the **Chebyshev distance** between two vectors. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { chebyshev-distance } = import(linear-algebra);\nchebyshev-distance([1, 2], [3, 4])","let { chebyshev-distance } = import(linear-algebra);\nchebyshev-distance([1, 2, 3], [4, 5, 6])","let { chebyshev-distance } = import(linear-algebra);\nchebyshev-distance([1, 0], [0, 1])"],seeAlso:["linear-algebra.euclidean-distance","linear-algebra.manhattan-distance","linear-algebra.minkowski-distance","linear-algebra.chebyshev-norm"]},"chebyshev-norm":{category:"linear-algebra",description:"Calculates the **Chebyshev norm** of a vector. The result is a non-negative number.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to calculate the norm for."}},variants:[{argumentNames:["v"]}],examples:["let { chebyshev-norm } = import(linear-algebra);\nchebyshev-norm([1, 2])","let { chebyshev-norm } = import(linear-algebra);\nchebyshev-norm([3, 4])","let { chebyshev-norm } = import(linear-algebra);\nchebyshev-norm([1, 2, 3])"],seeAlso:["linear-algebra.euclidean-norm","linear-algebra.manhattan-norm","linear-algebra.minkowski-norm","linear-algebra.chebyshev-distance"]},"minkowski-distance":{category:"linear-algebra",description:"Calculates the **Minkowski distance** between two vectors. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"},p:{type:"number",description:"Order of the norm (p)."}},variants:[{argumentNames:["a","b","p"]}],examples:["let { minkowski-distance } = import(linear-algebra);\nminkowski-distance([1, 2], [3, 4], 2)","let { minkowski-distance } = import(linear-algebra);\nminkowski-distance([1, 2, 3], [4, 5, 6], 3)","let { minkowski-distance } = import(linear-algebra);\nminkowski-distance([1, 0], [0, 1], 1)"],seeAlso:["linear-algebra.euclidean-distance","linear-algebra.manhattan-distance","linear-algebra.chebyshev-distance","linear-algebra.minkowski-norm"]},"minkowski-norm":{category:"linear-algebra",description:"Calculates the **Minkowski norm** of a vector. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector",description:"Vector to calculate the norm for."},b:{type:"number",description:"Order of the norm (p)."}},variants:[{argumentNames:["a","b"]}],examples:["let { minkowski-norm } = import(linear-algebra);\nminkowski-norm([1, 2], 2)","let { minkowski-norm } = import(linear-algebra);\nminkowski-norm([3, 4], 3)","let { minkowski-norm } = import(linear-algebra);\nminkowski-norm([1, 2, 3], 4)"],seeAlso:["linear-algebra.euclidean-norm","linear-algebra.manhattan-norm","linear-algebra.chebyshev-norm","linear-algebra.minkowski-distance"]},cov:{category:"linear-algebra",description:"Calculates the **covariance** between two vectors. The result is a number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { cov } = import(linear-algebra);\ncov([1, 2], [3, 4])","let { cov } = import(linear-algebra);\ncov([1, 2, 3], [4, 5, 6])","let { cov } = import(linear-algebra);\ncov([1, 0], [0, 1])"],seeAlso:["linear-algebra.corr","linear-algebra.pearson-corr","vector.variance"]},corr:{category:"linear-algebra",description:"Calculates the **correlation** between two vectors. The result is a number between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { corr } = import(linear-algebra);\ncorr([1, 2], [3, 4])","let { corr } = import(linear-algebra);\ncorr([1, 2, 3], [4, 5, 6])","let { corr } = import(linear-algebra);\ncorr([1, 0], [0, 1])"],seeAlso:["linear-algebra.cov","linear-algebra.pearson-corr","linear-algebra.spearman-corr","linear-algebra.kendall-tau","linear-algebra.autocorrelation","linear-algebra.cross-correlation"]},"spearman-corr":{category:"linear-algebra",description:"Calculates the **Spearman rank correlation** between two vectors. The result is a number between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { spearman-corr } = import(linear-algebra);\nspearman-corr([1, 2], [3, 4])","let { spearman-corr } = import(linear-algebra);\nspearman-corr([1, 2, 3], [4, 5, 6])","let { spearman-corr } = import(linear-algebra);\nspearman-corr([1, 0], [0, 1])"],seeAlso:["linear-algebra.pearson-corr","linear-algebra.kendall-tau","linear-algebra.corr"]},"pearson-corr":{category:"linear-algebra",description:"Calculates the **Pearson correlation** between two vectors. The result is a number between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { pearson-corr } = import(linear-algebra);\npearson-corr([1, 2], [3, 4])","let { pearson-corr } = import(linear-algebra);\npearson-corr([1, 2, 3], [4, 5, 6])","let { pearson-corr } = import(linear-algebra);\npearson-corr([1, 0], [0, 1])"],seeAlso:["linear-algebra.spearman-corr","linear-algebra.kendall-tau","linear-algebra.corr","linear-algebra.cov"]},"kendall-tau":{category:"linear-algebra",description:"Calculates the **Kendall Tau** rank correlation coefficient between two vectors. The result is a number between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { kendall-tau } = import(linear-algebra);\nkendall-tau([1, 2], [3, 4])","let { kendall-tau } = import(linear-algebra);\nkendall-tau([1, 2, 3], [4, 5, 6])","let { kendall-tau } = import(linear-algebra);\nkendall-tau([1, 0], [0, 1])"],seeAlso:["linear-algebra.spearman-corr","linear-algebra.pearson-corr","linear-algebra.corr"]},autocorrelation:{category:"linear-algebra",description:"Calculates the **autocorrelation** of a vector. The result is a vector of autocorrelation coefficients.",returns:{type:"vector"},args:{a:{type:"vector",description:"Vector to calculate the autocorrelation for."},b:{type:"integer",description:"Lag value for the autocorrelation."}},variants:[{argumentNames:["a","b"]}],examples:["let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], -2)","let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], -1)","let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], 0)","let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], 1)","let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], 2)"],seeAlso:["linear-algebra.cross-correlation","linear-algebra.corr"]},"cross-correlation":{category:"linear-algebra",description:"Calculates the **cross-correlation** between two vectors. The result is a vector of cross-correlation coefficients.",returns:{type:"vector"},args:{a:{type:"vector"},b:{type:"vector"},lag:{type:"integer",description:"Lag value for the cross-correlation."}},variants:[{argumentNames:["a","b","lag"]}],examples:["let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], -2)","let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], -1)","let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], 0)","let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], 1)","let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], 2)"],seeAlso:["linear-algebra.autocorrelation","linear-algebra.corr"]},rref:{category:"linear-algebra",description:"Calculates the **Reduced Row Echelon Form** (RREF) of a matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"Matrix to calculate the RREF for."}},variants:[{argumentNames:["m"]}],examples:["let { rref } = import(linear-algebra);\nrref([[1, 2], [3, 4]])","let { rref } = import(linear-algebra);\nrref([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { rref } = import(linear-algebra);\nrref([[1, 2, 3], [7, 8, 9], [4, 5, 7]])"],seeAlso:["linear-algebra.solve","matrix.rank"]},solve:{category:"linear-algebra",description:"Solves a system of linear equations represented by a matrix and a vector.",returns:{type:"vector"},args:{a:{type:"matrix"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { solve } = import(linear-algebra);\nsolve([\n [2, 1, -1, 1], \n [4, 5, -3, 2], \n [6, -2, 5, -3], \n [8, 3, 2, 4]\n], [5, 10, 2, 17])","let { solve } = import(linear-algebra);\nsolve([[2, 0, 0], [3, 1, 0], [4, 5, 6]], [4, 5, 38])","let { solve } = import(linear-algebra);\nsolve([[2, 3], [1, -1]], [8, 2])"],seeAlso:["linear-algebra.rref","matrix.inv"]},"to-polar":{category:"linear-algebra",description:"Converts a 2D vector to polar coordinates.",returns:{type:"vector"},args:{vector:{type:"vector",description:"2D Vector to convert."}},variants:[{argumentNames:["vector"]}],examples:["let { to-polar } = import(linear-algebra);\nto-polar([1, 2])","let { to-polar } = import(linear-algebra);\nto-polar([3, 4])"],seeAlso:["linear-algebra.from-polar","linear-algebra.angle"]},"from-polar":{category:"linear-algebra",description:"Converts polar coordinates to a 2D vector.",returns:{type:"vector"},args:{polar:{type:"vector",description:"Polar coordinates to convert."}},variants:[{argumentNames:["polar"]}],examples:["let { from-polar } = import(linear-algebra);\nfrom-polar([1, PI / 4])","let { from-polar } = import(linear-algebra);\nfrom-polar([1, 0])","let { from-polar } = import(linear-algebra);\nfrom-polar([1, -PI / 2])"],seeAlso:["linear-algebra.to-polar"]}};function Pn(e){const t=e.map(e=>[...e]),r=t.length,n=t[0].length;let o=0,a=0;for(let e=0;e<n;e++){let i=-1;for(let n=a;n<r;n++)if(!be(t[n][e])){i=n;break}if(-1===i)continue;o+=1,i!==a&&([t[i],t[a]]=[t[a],t[i]]);const s=t[a][e];for(let r=e;r<n;r++)t[a][r]/=s;for(let o=0;o<r;o++)if(o!==a&&!be(t[o][e])){const r=t[o][e];for(let i=e;i<n;i++)t[o][i]-=r*t[a][i]}if(a++,a===r)break}return[t,o]}function Rn(e,t){const r=e=>e.every(e=>be(e));if(r(e)||r(t))return!0;let n=0;for(;n<e.length&&be(e[n]);)n++;const o=t[n]/e[n];for(let r=0;r<e.length;r++)if(!be(e[r])||!be(t[r])){if(be(e[r]))return!1;if(!fe(t[r]/e[r],o))return!1}return!0}function In(e){return e.every(e=>be(e))}function On(e,t){const r=Qr(e),n=Qr(t);let o=0,a=0,i=0;for(let s=0;s<e.length;s++){const c=e[s]-r,l=t[s]-n;o+=c*l,a+=c*c,i+=l*l}if(0===a||0===i)throw new Error("Cannot calculate Pearson correlation coefficient: one of the vectors has zero variance.");return o/(Math.sqrt(a)*Math.sqrt(i))}function Fn(e){const t=[...e.keys()].sort((t,r)=>e[t]-e[r]),r=Array.from({length:e.length}).fill(0);let n=1,o=0;for(;o<t.length;){const a=e[t[o]];let i=o;for(;i<t.length&&e[t[i]]===a;)i++;const s=n+(i-o-1)/2;for(let e=o;e<i;e++)r[t[e]]=s;n+=i-o,o=i}return r}function Un(e,t){const r=Qr(e),n=Qr(t);let o=0;for(let a=0;a<e.length;a++)o+=(e[a]-r)*(t[a]-n);return o/e.length}function Dn(e,t){if(0===e.length)return e;const n=Math.sqrt(e.reduce((e,t)=>e+t**2,0));if(be(n))throw new r("The vector must not be zero",t);return e.map(e=>e/n)}function Wn(e,t){return e.reduce((e,r,n)=>e+r*t[n],0)}function Gn(e,t){return e.map((e,r)=>e-t[r])}function Vn(e,t){return e.map(e=>e*t)}const Bn={rotate2d:{evaluate:([e,t],r)=>{if(Qe(e,r),In(e))return e;ee(t,r,{finite:!0});const n=Math.cos(t),o=Math.sin(t);return[e[0]*n-e[1]*o,e[0]*o+e[1]*n]},arity:ae(2)},rotate3d:{evaluate:([e,t,n],o)=>{if(et(e,o),In(e))return e;if(ee(n,o,{finite:!0}),et(t,o),In(t))throw new r("Rotation axis must not be zero",o);const a=Math.cos(n),i=Math.sin(n),[s,c,l]=Dn(t,o),m=e[0]*s+e[1]*c+e[2]*l;return[m*s*(1-a)+e[0]*a+(-l*e[1]+c*e[2])*i,m*c*(1-a)+e[1]*a+(l*e[0]-s*e[2])*i,m*l*(1-a)+e[2]*a+(-c*e[0]+s*e[1])*i]},arity:ae(3)},reflect:{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);if(In(t))throw new r("Reflection normal must not be zero",n);if(In(e))return e;const o=Dn(t,n);return Gn(e,Vn(o,2*Wn(e,o)))},arity:ae(2)},refract:{evaluate:([e,t,n],o)=>{if(Ze(e,o),Ze(t,o),ee(n,o,{finite:!0,positive:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",o);if(In(t))throw new r("Refraction normal must not be zero",o);if(In(e))return e;const a=Dn(e,o),i=Dn(t,o),s=Wn(a,i),c=1-n*n*(1-s*s);if(c<0)return e;return Gn(Vn(a,n),Vn(i,n*s+Math.sqrt(c)))},arity:ae(3)},lerp:{evaluate:([e,t,n],o)=>{if(Ze(e,o),Ze(t,o),ee(n,o,{finite:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",o);return e.map((e,r)=>e+(t[r]-e)*n)},arity:ae(3)},dot:{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return Wn(e,t)},arity:ae(2)},cross:{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),3!==e.length||3!==t.length)throw new r("Cross product is only defined for 3D vectors",n);return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]},arity:ae(2)},"normalize-minmax":{evaluate:([e],t)=>{if(Ze(e,t),0===e.length)return[];const r=e.reduce((e,t)=>t<e?t:e,e[0]),n=e.reduce((e,t)=>t>e?t:e,e[0]);return r===n?e.map(()=>0):e.map(e=>(e-r)/(n-r))},arity:ae(1)},"normalize-robust":{evaluate:([e],t)=>{if(Ze(e,t),0===e.length)return[];const r=tn(e),n=wn(e);return 0===n?e.map(e=>e-r):e.map(e=>(e-r)/n)},arity:ae(1)},"normalize-zscore":{evaluate:([e],t)=>{Ze(e,t);const r=Qr(e),n=sn(e);return 0===n?e.map(()=>0):e.map(e=>(e-r)/n)},arity:ae(1)},"normalize-l1":{evaluate:([e],t)=>{if(Ze(e,t),0===e.length)return[];const r=e.reduce((e,t)=>e+Math.abs(t),0);return 0===r?e.map(()=>0):e.map(e=>e/r)},arity:ae(1)},"normalize-l2":{evaluate:([e],t)=>(Ze(e,t),Dn(e,t)),arity:ae(1)},"normalize-log":{evaluate:([e],t)=>{if(Ze(e,t),0===e.length)return[];const n=Math.min(...e);if(n<=0)throw new r("Log normalization requires all values to be positive",t);return e.map(e=>Math.log(e/n))},arity:ae(1)},angle:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),In(e)||In(t))throw new r("Cannot calculate angle with zero-length vector",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);const o=e.reduce((e,r,n)=>e+r*t[n],0),a=Math.sqrt(e.reduce((e,t)=>e+t*t,0)),i=Math.sqrt(t.reduce((e,t)=>e+t*t,0));return Math.acos(o/(a*i))},arity:ae(2)},projection:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),In(t))throw new r("Cannot project onto zero-length vector",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);const o=e.reduce((e,r,n)=>e+r*t[n],0),a=Math.sqrt(t.reduce((e,t)=>e+t*t,0));return t.map(e=>o/a**2*e)},arity:ae(2)},"orthogonal?":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return 0===e.reduce((e,r,n)=>e+r*t[n],0)},arity:ae(2)},"parallel?":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return function(e,t){if(!Rn(e,t))return!1;for(let r=0;r<e.length;r++)if(!be(e[r])&&!be(t[r]))return Math.sign(e[r])===Math.sign(t[r]);return!0}(e,t)},arity:ae(2)},"collinear?":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return Rn(e,t)},arity:ae(2)},"cosine-similarity":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),In(e)||In(t))throw new r("Cannot calculate cosine similarity with zero-length vector",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+r*t[n],0)/(Math.sqrt(e.reduce((e,t)=>e+t*t,0))*Math.sqrt(t.reduce((e,t)=>e+t*t,0)))},arity:ae(2)},"euclidean-distance":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return Math.sqrt(e.reduce((e,r,n)=>e+(r-t[n])**2,0))},arity:ae(2)},"euclidean-norm":{evaluate:([e],t)=>(tt(e,t),function(e){return Math.sqrt(e.reduce((e,t)=>e+t**2,0))}(e)),arity:ae(1)},"manhattan-distance":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+Math.abs(r-t[n]),0)},arity:ae(2)},"manhattan-norm":{evaluate:([e],t)=>(tt(e,t),e.reduce((e,t)=>e+Math.abs(t),0)),arity:ae(1)},"hamming-distance":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+(r!==t[n]?1:0),0)},arity:ae(2)},"hamming-norm":{evaluate:([e],t)=>(tt(e,t),e.reduce((e,t)=>e+(0!==t?1:0),0)),arity:ae(1)},"chebyshev-distance":{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return Math.max(...e.map((e,r)=>Math.abs(e-t[r])))},arity:ae(2)},"chebyshev-norm":{evaluate:([e],t)=>(tt(e,t),Math.max(...e.map(e=>Math.abs(e)))),arity:ae(1)},"minkowski-distance":{evaluate:([e,t,n],o)=>{if(tt(e,o),tt(t,o),ee(n,o,{finite:!0,positive:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",o);return e.reduce((e,r,o)=>e+Math.abs(r-t[o])**n,0)**(1/n)},arity:ae(3)},"minkowski-norm":{evaluate:([e,t],r)=>(tt(e,r),ee(t,r,{finite:!0,positive:!0}),e.reduce((e,r)=>e+Math.abs(r)**t,0)**(1/t)),arity:ae(2)},cov:{evaluate:([e,t],n)=>{if(tt(e,n),tt(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return 1===e.length?0:Un(e,t)},arity:ae(2)},corr:{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length<=1)throw new r("Vectors must have at least 2 elements for corr",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);const o=Qr(e),a=Qr(t);return e.reduce((e,r,n)=>e+(r-o)*(t[n]-a),0)/Math.sqrt(e.reduce((e,t)=>e+(t-o)**2,0)*t.reduce((e,t)=>e+(t-a)**2,0))},arity:ae(2)},"spearman-corr":{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length<=1)throw new r("Vectors must have at least 2 elements for corr",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);const o=Fn(e),a=Fn(t);try{return On(o,a)}catch(e){throw new r(e,n)}},arity:ae(2)},"pearson-corr":{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length<=1)throw new r("Vectors must have at least 2 elements for pearson-corr",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);try{return On(e,t)}catch(e){throw new r(e,n)}},arity:ae(2)},"kendall-tau":{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length<2)throw new r("Vectors must have at least 2 elements for kendall-tau",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);try{return function(e,t,r=1e-10){let n=0,o=0,a=0,i=0;for(let s=0;s<e.length;s++)for(let c=s+1;c<e.length;c++){const l=e[s]-e[c],m=t[s]-t[c],u=Math.abs(l)<r,p=Math.abs(m)<r;u&&p||(u?a+=1:p?i+=1:l*m>0?n+=1:o+=1)}const s=n+o+a,c=n+o+i;if(0===s||0===c)throw new Error("Not enough data to calculate Kendall's Tau");return(n-o)/Math.sqrt(s*c)}(e,t)}catch(e){throw new r(e,n)}},arity:ae(2)},autocorrelation:{evaluate:([e,t],n)=>{if(Ze(e,n),e.length<2)throw new r("Vector must have at least 2 elements for autocorrelation",n);if(ee(t,n,{integer:!0,lt:e.length,gt:-e.length}),0===t)return 1;const o=Math.abs(t),a=Qr(e);let i=0;const s=e.length;for(let r=0;r<s-o;r++){const n=t<0?r:r+o;i+=(e[t<0?r+o:r]-a)*(e[n]-a)}let c=0;for(let t=0;t<s;t++)c+=(e[t]-a)**2;return 0===c?0:i/c},arity:ae(2)},"cross-correlation":{evaluate:([e,t,n],o)=>{if(Ze(e,o),Ze(t,o),e.length<2)throw new r("Vectors must have at least 2 elements",o);if(e.length!==t.length)throw new r("Vectors must be of the same length",o);if(ee(n,o,{integer:!0,lt:e.length,gt:-e.length}),0===n&&e.length===t.length&&e.every((e,r)=>e===t[r]))return 1;const[a,i]=function(e,t,r){const n=Math.abs(r),o=e.length-n;let a=[],i=[];return r>=0?(a=e.slice(0,o),i=t.slice(r,r+o)):(a=e.slice(n),i=t.slice(0,o)),[a,i]}(e,t,n);return function(e,t){const r=Qr(e),n=Qr(t),o=sn(e,r),a=sn(t,n);return 0===o||0===a?0===o&&0===a&&r===n?1:0:Un(e,t)/(o*a)}(a,i)},arity:ae(3)},rref:{evaluate:([e],t)=>{at(e,t);const[r]=Pn(e);return r},arity:ae(1)},solve:{evaluate:([e,t],n)=>{if(it(e,n),Ze(t,n),e.length!==t.length)throw new r(`The number of rows in the matrix must be equal to the length of the vector, but got ${e.length} and ${t.length}`,n);return function(e,t){const r=e.length,n=e.map((e,r)=>[...e,t[r]]),[o]=Pn(n);for(let e=0;e<r;e+=1)if(be(o[e][e]))return null;const a=Array.from({length:r},()=>0);for(let e=r-1;e>=0;e--){let t=0;for(let n=e+1;n<r;n++)t+=o[e][n]*a[n];a[e]=(o[e][r]-t)/o[e][e]}return a}(e,t)},arity:ae(2)},"to-polar":{evaluate:([e],t)=>{if(Qe(e,t),In(e))return[0,0];return[Math.sqrt(e[0]**2+e[1]**2),Math.atan2(e[1],e[0])]},arity:ae(1)},"from-polar":{evaluate:([e],t)=>{Qe(e,t);const[r,n]=e;return 0===r?[0,0]:[r*Math.cos(n),r*Math.sin(n)]},arity:ae(1)}};for(const[e,t]of Object.entries(Cn))Bn[e]&&(Bn[e].docs=t);const Ln={name:"linear-algebra",functions:Bn},_n={mul:{category:"matrix",description:"Multiplies two `matrices` using standard `matrix` multiplication based on **dot products** of rows and columns.",returns:{type:"matrix"},args:{a:{type:"matrix"},b:{type:"matrix"}},variants:[{argumentNames:["a","b"]}],examples:["let { mul } = import(matrix);\nmul([[1, 2], [3, 4]], [[5, 6], [7, 8]])","let { mul } = import(matrix);\nmul([[1, 2, 3], [4, 5, 6]], [[7, 8], [9, 10], [11, 12]])"],seeAlso:["matrix.det","matrix.inv"]},det:{category:"matrix",description:"Calculates the **determinant** of a square matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the determinant of."}},variants:[{argumentNames:["m"]}],examples:["let { det } = import(matrix);\ndet([[1, 2], [3, 4]])","let { det } = import(matrix);\ndet([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.inv","matrix.cofactor","matrix.adj","matrix.trace","matrix.rank","matrix.invertible?","matrix.mul","matrix.minor"]},inv:{category:"matrix",description:"Calculates the **inverse** of a square matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"The `matrix` to calculate the inverse of."}},variants:[{argumentNames:["m"]}],examples:["let { inv } = import(matrix);\ninv([[1, 2], [3, 4]])","let { inv } = import(matrix);\ninv([[1, 2, 3], [4, 5, 7], [7, 8, 10]])"],seeAlso:["matrix.det","matrix.adj","matrix.invertible?","linear-algebra.solve","matrix.mul","matrix.orthogonal-matrix?"]},adj:{category:"matrix",description:"Calculates the **adjugate** of a square matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"The `matrix` to calculate the adjugate of."}},variants:[{argumentNames:["m"]}],examples:["let { adj } = import(matrix);\nadj([[1, 2], [3, 4]])","let { adj } = import(matrix);\nadj([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { adj } = import(matrix);\nadj([[1, 2, 3], [7, 8, 9], [4, 5, 6]])"],seeAlso:["matrix.cofactor","matrix.det","matrix.inv"]},cofactor:{category:"matrix",description:"Calculates the **cofactor** of a square matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"The `matrix` to calculate the cofactor of."}},variants:[{argumentNames:["m"]}],examples:["let { cofactor } = import(matrix);\ncofactor([[1, 2], [3, 4]])","let { cofactor } = import(matrix);\ncofactor([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { cofactor } = import(matrix);\ncofactor([[1, 2, 3], [7, 8, 9], [4, 5, 6]])"],seeAlso:["matrix.adj","matrix.minor","matrix.det"]},minor:{category:"matrix",description:"Calculates the **minor** of a square matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"The `matrix` to calculate the minor of."},row:{type:"integer",description:"The row index of the element to calculate the minor for."},col:{type:"integer",description:"The column index of the element to calculate the minor for."}},variants:[{argumentNames:["m","row","col"]}],examples:["let { minor } = import(matrix);\nminor([[1, 2], [3, 4]], 0, 1)","let { minor } = import(matrix);\nminor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 1, 1)"],seeAlso:["matrix.cofactor","matrix.det"]},trace:{category:"matrix",description:"Calculates the **trace** of a square matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the trace of."}},variants:[{argumentNames:["m"]}],examples:["let { trace } = import(matrix);\ntrace([[1, 2], [3, 4]])","let { trace } = import(matrix);\ntrace([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.det","matrix.diagonal?"]},"symmetric?":{category:"matrix",description:"Checks if a `matrix` is **symmetric**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for symmetry."}},variants:[{argumentNames:["m"]}],examples:["let { symmetric? } = import(matrix);\nsymmetric?([[1, 2], [2, 1]])","let { symmetric? } = import(matrix);\nsymmetric?([[1, 2, 3], [2, 1, 4], [3, 4, 1]])"],seeAlso:["matrix.orthogonal-matrix?","matrix.diagonal?","matrix.square?","matrix.hilbert"]},"triangular?":{category:"matrix",description:"Checks if a `matrix` is **triangular**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for triangularity."}},variants:[{argumentNames:["m"]}],examples:["let { triangular? } = import(matrix);\ntriangular?([[2, 0], [0, 1]])","let { triangular? } = import(matrix);\ntriangular?([[1, 2, 3], [0, 4, 5], [0, 0, 6]])"],seeAlso:["matrix.upper-triangular?","matrix.lower-triangular?","matrix.diagonal?","matrix.banded?"]},"upper-triangular?":{category:"matrix",description:"Checks if a `matrix` is **upper triangular**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for upper triangularity."}},variants:[{argumentNames:["m"]}],examples:["let { upper-triangular? } = import(matrix);\nupper-triangular?([[1, 2], [0, 3]])","let { upper-triangular? } = import(matrix);\nupper-triangular?([[1, 2, 3], [0, 4, 5], [0, 0, 6]])"],seeAlso:["matrix.lower-triangular?","matrix.triangular?","matrix.diagonal?"]},"lower-triangular?":{category:"matrix",description:"Checks if a `matrix` is **lower triangular**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for lower triangularity."}},variants:[{argumentNames:["m"]}],examples:["let { lower-triangular? } = import(matrix);\nlower-triangular?([[1, 0], [2, 3]])","let { lower-triangular? } = import(matrix);\nlower-triangular?([[1, 0, 0], [2, 3, 0], [4, 5, 6]])"],seeAlso:["matrix.upper-triangular?","matrix.triangular?","matrix.diagonal?"]},"diagonal?":{category:"matrix",description:"Checks if a `matrix` is **diagonal**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for diagonal property."}},variants:[{argumentNames:["m"]}],examples:["let { diagonal? } = import(matrix);\ndiagonal?([[1, 0], [0, 2]])","let { diagonal? } = import(matrix);\ndiagonal?([[1, 0, 0], [0, 2, 0], [0, 0, 3]])","let { diagonal? } = import(matrix);\ndiagonal?([[1, 0, 0], [2, 2, 2], [0, 0, 3]])"],seeAlso:["matrix.identity?","matrix.symmetric?","matrix.triangular?","matrix.trace","matrix.upper-triangular?","matrix.lower-triangular?","matrix.band","matrix.banded?"]},"square?":{category:"matrix",description:"Checks if a `matrix` is **square**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for square property."}},variants:[{argumentNames:["m"]}],examples:["let { square? } = import(matrix);\nsquare?([[1, 2], [3, 4]])","let { square? } = import(matrix);\nsquare?([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { square? } = import(matrix);\nsquare?([[1, 2, 3], [4, 5, 6]])"],seeAlso:["matrix.symmetric?","matrix.identity?","matrix.invertible?"]},"orthogonal-matrix?":{category:"matrix",description:"Checks if a `matrix` is **orthogonal**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for **orthogonality**."}},variants:[{argumentNames:["m"]}],examples:["let { orthogonal-matrix? } = import(matrix);\northogonal-matrix?([[1, 0], [0, 1]])","let { orthogonal-matrix? } = import(matrix);\northogonal-matrix?([[1, 0], [0, -1]])","let { orthogonal-matrix? } = import(matrix);\northogonal-matrix?([[1, 2], [3, 4]])"],seeAlso:["matrix.symmetric?","matrix.inv","matrix.identity?","linear-algebra.orthogonal?"]},"identity?":{category:"matrix",description:"Checks if a `matrix` is an **identity matrix**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for identity property."}},variants:[{argumentNames:["m"]}],examples:["let { identity? } = import(matrix);\nidentity?([[1, 0], [0, 1]])","let { identity? } = import(matrix);\nidentity?([[1, 0, 0], [0, 1, 0], [0, 0, 1]])","let { identity? } = import(matrix);\nidentity?([[1, 0, 0], [0, 1, 0], [0, 0, 0]])"],seeAlso:["matrix.diagonal?","matrix.square?","matrix.orthogonal-matrix?"]},"invertible?":{category:"matrix",description:"Checks if a `matrix` is **invertible**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for invertibility."}},variants:[{argumentNames:["m"]}],examples:["let { invertible? } = import(matrix);\ninvertible?([[1, 2], [3, 4]])","let { invertible? } = import(matrix);\ninvertible?([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { invertible? } = import(matrix);\ninvertible?([[1, 2], [2, 4]])"],seeAlso:["matrix.det","matrix.inv","matrix.rank","matrix.square?"]},hilbert:{category:"matrix",description:"Generates a **Hilbert matrix** of size `n`.",returns:{type:"matrix"},args:{n:{type:"integer",description:"The size of the Hilbert matrix."}},variants:[{argumentNames:["n"]}],examples:["let { hilbert } = import(matrix);\nhilbert(3)","let { hilbert } = import(matrix);\nhilbert(4)"],seeAlso:["matrix.vandermonde","matrix.symmetric?"]},vandermonde:{category:"matrix",description:"Generates a **Vandermonde matrix** from a vector.",returns:{type:"matrix"},args:{v:{type:"vector",description:"The vector to generate the Vandermonde matrix from."}},variants:[{argumentNames:["v"]}],examples:["let { vandermonde } = import(matrix);\nvandermonde([1, 2, 3])","let { vandermonde } = import(matrix);\nvandermonde([1, 0, 1])"],seeAlso:["matrix.hilbert","matrix.band"]},band:{category:"matrix",description:"Generates a **banded matrix** of size `n` with lower band index `lband` and upper band index `uband`.",returns:{type:"matrix"},args:{n:{type:"integer",description:"The size of the banded matrix."},lband:{type:"integer",description:"The lower band index."},uband:{type:"integer",description:"The upper band index."}},variants:[{argumentNames:["n","lband","uband"]}],examples:["let { band } = import(matrix);\nband(3, 1, 1)","let { band } = import(matrix);\nband(4, 1, 2)"],seeAlso:["matrix.banded?","matrix.diagonal?","matrix.vandermonde"]},"banded?":{category:"matrix",description:"Checks if a `matrix` is **banded** with lower band index `lband` and upper band index `uband`.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for **banded** property."},lband:{type:"integer",description:"The lower band index."},uband:{type:"integer",description:"The upper band index."}},variants:[{argumentNames:["m","lband","uband"]}],examples:["let { banded? } = import(matrix);\nbanded?([\n [1, 1, 1, 0],\n [1, 1, 1, 1],\n [1, 1, 1, 1],\n [0, 1, 1, 1],\n], 2, 2)","let { banded? } = import(matrix);\nbanded?([\n [1, 1, 1, 0],\n [1, 1, 1, 1],\n [1, 1, 1, 1],\n [0, 1, 1, 1],\n], 1, 1)"],seeAlso:["matrix.band","matrix.triangular?","matrix.diagonal?"]},rank:{category:"matrix",description:"Calculates the **rank** of a matrix using **Gaussian elimination**.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the rank of."}},variants:[{argumentNames:["m"]}],examples:["let { rank } = import(matrix);\nrank([[1, 0, 0], [0, 1, 0], [0, 0, 1]])","let { rank } = import(matrix);\nrank([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { rank } = import(matrix);\nrank([[2, 4, 6], [3, 6, 9], [4, 8, 12]])"],seeAlso:["matrix.det","matrix.invertible?","linear-algebra.rref"]},"frobenius-norm":{category:"matrix",description:"Calculates the **Frobenius norm** of a matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the Frobenius norm of."}},variants:[{argumentNames:["m"]}],examples:["let { frobenius-norm } = import(matrix);\nfrobenius-norm([[1, 2], [3, 4]])","let { frobenius-norm } = import(matrix);\nfrobenius-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.one-norm","matrix.inf-norm","matrix.max-norm"]},"one-norm":{category:"matrix",description:"Calculates the **one-norm** (column norm) of a matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the one-norm of."}},variants:[{argumentNames:["m"]}],examples:["let { one-norm } = import(matrix);\none-norm([[1, 2], [3, 4]])","let { one-norm } = import(matrix);\none-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.frobenius-norm","matrix.inf-norm","matrix.max-norm"]},"inf-norm":{category:"matrix",description:"Calculates the **infinity norm** of a matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the infinity norm of."}},variants:[{argumentNames:["m"]}],examples:["let { inf-norm } = import(matrix);\ninf-norm([[1, 2], [3, 4]])","let { inf-norm } = import(matrix);\ninf-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.frobenius-norm","matrix.one-norm","matrix.max-norm"]},"max-norm":{category:"matrix",description:"Calculates the **max norm** of a matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the max norm of."}},variants:[{argumentNames:["m"]}],examples:["let { max-norm } = import(matrix);\nmax-norm([[1, 2], [3, 4]])","let { max-norm } = import(matrix);\nmax-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.frobenius-norm","matrix.one-norm","matrix.inf-norm"]}};function Kn(e){const t=e.length,r=[];for(let n=0;n<t;n++)r[n]=[...e[n]];if(1===t)return r[0][0];if(2===t)return r[0][0]*r[1][1]-r[0][1]*r[1][0];let n=1;for(let e=0;e<t-1;e+=1){let o=e;for(let n=e+1;n<t;n+=1)Math.abs(r[n][e])>Math.abs(r[o][e])&&(o=n);if(be(r[o][e]))return 0;o!==e&&([r[e],r[o]]=[r[o],r[e]],n=-n);for(let n=e+1;n<t;n+=1){const o=r[n][e]/r[e][e];for(let a=e;a<t;a++)r[n][a]-=o*r[e][a]}}let o=n;for(let e=0;e<t;e++)o*=r[e][e];return o}function Jn(e,t,r){const n=e.length,o=[];for(let a=0;a<n;a++)if(a!==t){const t=[];for(let o=0;o<n;o++)o!==r&&t.push(e[a][o]);o.push(t)}return o}function Yn(e){const t=e.length,r=[];for(let n=0;n<t;n++){r[n]=[];for(let o=0;o<t;o++){const t=(-1)**(n+o)*Kn(Jn(e,o,n));r[n][o]=t}}return r}function Hn(e){return e.length===e[0].length}function Xn(e){if(!Hn(e))return!1;const t=e.length;for(let r=0;r<t;r++)for(let n=0;n<t;n++)if(r===n){if(!fe(e[r][n],1))return!1}else if(!be(e[r][n]))return!1;return!0}function Zn(e,t){if(0===e.length||0===t.length||e[0].length!==t.length)throw new Error("Matrix dimensions do not match for multiplication");const r=e.length,n=e[0].length,o=t[0].length,a=Array(r).fill(0).map(()=>Array(o).fill(0));for(let i=0;i<r;i++)for(let r=0;r<n;r++){const n=e[i][r];for(let e=0;e<o;e++)a[i][e]+=n*t[r][e]}return a}const Qn={mul:{evaluate:([e,t],n)=>{at(e,n),at(t,n);try{return Zn(e,t)}catch(o){throw new r(`The number of columns in the first matrix must be equal to the number of rows in the second matrix, but got ${e[0].length} and ${t.length}`,n)}},arity:ae(2)},det:{evaluate:([e],t)=>(it(e,t),Kn(e)),arity:ae(1)},inv:{evaluate:([e],t)=>{it(e,t);const n=function(e){const t=e.length;if(1===t){const t=e[0][0];return be(t)?null:[[1/t]]}const r=Kn(e);if(be(r))return null;const n=Yn(e),o=[];for(let e=0;e<t;e++){o[e]=[];for(let a=0;a<t;a++)o[e][a]=n[e][a]/r}return o}(e);if(null===n)throw new r("The matrix must be invertible",t);return n},arity:ae(1)},adj:{evaluate:([e],t)=>(it(e,t),Yn(e)),arity:ae(1)},cofactor:{evaluate:([e],t)=>(it(e,t),function(e){const t=e.length,r=[];for(let n=0;n<t;n++){r[n]=[];for(let o=0;o<t;o++){const t=Jn(e,n,o),a=(-1)**(n+o);r[n][o]=a*Kn(t)}}return r}(e)),arity:ae(1)},minor:{evaluate:([e,t,r],n)=>(at(e,n),ee(t,n,{integer:!0,nonNegative:!0,lte:e.length}),ee(r,n,{integer:!0,nonNegative:!0,lte:e[0].length}),Jn(e,t,r)),arity:ae(3)},trace:{evaluate:([e],t)=>(it(e,t),function(e){return e.reduce((e,t,r)=>e+t[r],0)}(e)),arity:ae(1)},"symmetric?":{evaluate:([e],t)=>(at(e,t),function(e){const t=e.length;if(!Hn(e))return!1;for(let r=0;r<t;r+=1)for(let t=0;t<r;t+=1)if(e[r][t]!==e[t][r])return!1;return!0}(e)),arity:ae(1)},"triangular?":{evaluate:([e],t)=>(at(e,t),function(e){if(!Hn(e))return!1;const t=e.length;let r=!0,n=!0;for(let o=0;o<t;o++)for(let a=0;a<t;a++){if(o>a&&0!==e[o][a]&&(r=!1,!n))return!1;o<a&&0!==e[o][a]&&(n=!1)}return r||n}(e)),arity:ae(1)},"upper-triangular?":{evaluate:([e],t)=>(at(e,t),function(e){if(!Hn(e))return!1;const t=e.length;for(let r=0;r<t;r++)for(let t=0;t<r;t++)if(0!==e[r][t])return!1;return!0}(e)),arity:ae(1)},"lower-triangular?":{evaluate:([e],t)=>(at(e,t),function(e){if(!Hn(e))return!1;const t=e.length;if(!e.every(e=>e.length===t))return!1;for(let r=0;r<t;r++)for(let n=r+1;n<t;n++)if(0!==e[r][n])return!1;return!0}(e)),arity:ae(1)},"diagonal?":{evaluate:([e],t)=>(at(e,t),function(e){if(!Hn(e))return!1;const t=e.length;for(let r=0;r<t;r+=1)for(let n=0;n<t;n+=1)if(r!==n&&0!==e[r][n])return!1;return!0}(e)),arity:ae(1)},"square?":{evaluate:([e],t)=>(at(e,t),Hn(e)),arity:ae(1)},"orthogonal-matrix?":{evaluate:([e],t)=>(at(e,t),function(e){return!!Hn(e)&&Xn(Zn(e,Wr(e)))}(e)),arity:ae(1)},"identity?":{evaluate:([e],t)=>(at(e,t),Xn(e)),arity:ae(1)},"invertible?":{evaluate:([e],t)=>(at(e,t),!!function(e){return!!ot(e)&&e.length===e[0].length}(e)&&!be(Kn(e))),arity:ae(1)},hilbert:{evaluate:([e],t)=>{ee(e,t,{integer:!0,positive:!0});const r=[];for(let t=0;t<e;t+=1){const n=[];for(let r=0;r<e;r+=1)n.push(1/(t+r+1));r.push(n)}return r},arity:ae(1)},vandermonde:{evaluate:([e],t)=>{Ze(e,t);const r=[];for(let t=0;t<e.length;t+=1){const n=[];for(let r=0;r<e.length;r+=1)n.push(e[t]**r);r.push(n)}return r},arity:ae(1)},band:{evaluate:([e,t,r],n)=>(ee(e,n,{integer:!0,positive:!0}),ee(t,n,{integer:!0,nonNegative:!0,lt:e}),ee(r,n,{integer:!0,nonNegative:!0,lte:e}),function(e,t,r){const n=Array.from({length:e},()=>Array.from({length:e},()=>0));for(let o=0;o<e;o++)for(let a=Math.max(0,o-t);a<=Math.min(e-1,o+r);a++)n[o][a]=1;return n}(e,t,r)),arity:ae(3)},"banded?":{evaluate:([e,t,r],n)=>{at(e,n);const o=Math.max(e.length,e[0].length);return ee(t,n,{integer:!0,nonNegative:!0,lt:o}),ee(r,n,{integer:!0,nonNegative:!0,lt:o}),function(e,t,r){const n=e.length,o=e[0].length;for(let a=0;a<n;a++)for(let n=0;n<o;n++)if(0!==e[a][n]&&(a-n>t||n-a>r))return!1;return!0}(e,t,r)},arity:ae(3)},rank:{evaluate:([e],t)=>{at(e,t);const[,r]=Pn(e);return r},arity:ae(1)},"frobenius-norm":{evaluate:([e],t)=>(at(e,t),Math.sqrt(e.reduce((e,t)=>e+t.reduce((e,t)=>e+t*t,0),0))),arity:ae(1)},"one-norm":{evaluate:([e],t)=>(at(e,t),function(e){const t=e.length,r=e[0].length;let n=0;for(let o=0;o<r;o+=1){let r=0;for(let n=0;n<t;n+=1)r+=Math.abs(e[n][o]);n=Math.max(n,r)}return n}(e)),arity:ae(1)},"inf-norm":{evaluate:([e],t)=>(at(e,t),e.reduce((e,t)=>Math.max(e,t.reduce((e,t)=>e+Math.abs(t),0)),0)),arity:ae(1)},"max-norm":{evaluate:([e],t)=>(at(e,t),e.reduce((e,t)=>{const r=t.reduce((e,t)=>Math.max(e,Math.abs(t)),0);return Math.max(e,r)},0)),arity:ae(1)}};for(const[e,t]of Object.entries(_n))Qn[e]&&(Qn[e].docs=t);const eo={name:"matrix",functions:Qn},to={"abundant-seq":{category:"number-theory",description:"Generates the abundant numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { abundant-seq } = import(number-theory);\nabundant-seq(1)","let { abundant-seq } = import(number-theory);\nabundant-seq(5)"],seeAlso:["number-theory.abundant-nth","number-theory.abundant-take-while","number-theory.abundant?","number-theory.deficient-seq","number-theory.perfect-seq"]},"abundant-take-while":{category:"number-theory",description:"Generates the abundant numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { abundant-take-while } = import(number-theory);\nabundant-take-while(-> $ < 100)"],seeAlso:["number-theory.abundant-seq","number-theory.abundant-nth","number-theory.abundant?"]},"abundant-nth":{category:"number-theory",description:"Generates the nth term of the abundant numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the number in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { abundant-nth } = import(number-theory);\nabundant-nth(1)","let { abundant-nth } = import(number-theory);\nabundant-nth(5)"],seeAlso:["number-theory.abundant-seq","number-theory.abundant-take-while","number-theory.abundant?"]},"abundant?":{category:"number-theory",description:"Checks if a number is abundant.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { abundant? } = import(number-theory);\nabundant?(12)","let { abundant? } = import(number-theory);\nabundant?(15)"],seeAlso:["number-theory.abundant-seq","number-theory.abundant-nth","number-theory.deficient?","number-theory.perfect?","number-theory.sigma","number-theory.divisors","number-theory.abundant-take-while"]},"arithmetic-seq":{category:"number-theory",description:"Generates the arithmetic sequence for a given $start, $step, and $length.",returns:{type:"integer",array:!0},args:{start:{type:"number",description:"The starting term of the sequence."},step:{type:"number",description:"The common difference of the sequence."},length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["start","step","length"]}],examples:["let { arithmetic-seq } = import(number-theory);\narithmetic-seq(3, 2, 2)","let { arithmetic-seq } = import(number-theory);\narithmetic-seq(2, 3, 2)","let { arithmetic-seq } = import(number-theory);\narithmetic-seq(1, 2, 2)","let { arithmetic-seq } = import(number-theory);\narithmetic-seq(1, 1.5, 12)"],seeAlso:["number-theory.arithmetic-nth","number-theory.arithmetic-take-while","number-theory.arithmetic?","number-theory.geometric-seq"]},"arithmetic-take-while":{category:"number-theory",description:"Generates the arithmetic sequence while a condition is met.",returns:{type:"integer",array:!0},args:{start:{type:"number",description:"The starting term of the sequence."},step:{type:"number",description:"The common difference of the sequence."},takeWhile:{type:"function",description:"A function that takes a number and an index and returns a boolean."}},variants:[{argumentNames:["start","step","takeWhile"]}],examples:["let { arithmetic-take-while } = import(number-theory);\narithmetic-take-while(1, 0.25, -> $ < 3)"],seeAlso:["number-theory.arithmetic-seq","number-theory.arithmetic-nth","number-theory.arithmetic?"]},"arithmetic-nth":{category:"number-theory",description:"Generates the nth term of the arithmetic sequence.",returns:{type:"integer"},args:{start:{type:"number",description:"The starting term of the sequence."},step:{type:"number",description:"The common difference of the sequence."},n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["start","step","n"]}],examples:["let { arithmetic-nth } = import(number-theory);\narithmetic-nth(3, 2, 2)","let { arithmetic-nth } = import(number-theory);\narithmetic-nth(2, 3, 2)","let { arithmetic-nth } = import(number-theory);\narithmetic-nth(1, 2, 2)","let { arithmetic-nth } = import(number-theory);\narithmetic-nth(1, 1.5, 12)"],seeAlso:["number-theory.arithmetic-seq","number-theory.arithmetic-take-while","number-theory.arithmetic?"]},"arithmetic?":{category:"number-theory",description:"Checks if a number is part of the arithmetic sequence.",returns:{type:"boolean"},args:{start:{type:"number",description:"The starting term of the sequence."},step:{type:"number",description:"The common difference of the sequence."},n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["start","step","n"]}],examples:["let { arithmetic? } = import(number-theory);\narithmetic?(3, 2, 2)","let { arithmetic? } = import(number-theory);\narithmetic?(2, 3, 2)","let { arithmetic? } = import(number-theory);\narithmetic?(1, 2, 2)","let { arithmetic? } = import(number-theory);\narithmetic?(1, 1.5, 12)"],seeAlso:["number-theory.arithmetic-seq","number-theory.arithmetic-nth","number-theory.geometric?","number-theory.arithmetic-take-while"]},"bell-seq":{category:"number-theory",description:"Generates the Bell sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 22 (the maximum length of the pre-calculated bell numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { bell-seq } = import(number-theory);\nbell-seq(5)","let { bell-seq } = import(number-theory);\nbell-seq(10)","let { bell-seq } = import(number-theory);\nbell-seq()"],seeAlso:["number-theory.bell-nth","number-theory.bell-take-while","number-theory.bell?","number-theory.catalan-seq","number-theory.stirling-second","number-theory.stirling-first"]},"bell-take-while":{category:"number-theory",description:"Generates the Bell sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { bell-take-while } = import(number-theory);\nbell-take-while(-> $ < 1000)"],seeAlso:["number-theory.bell-seq","number-theory.bell-nth","number-theory.bell?"]},"bell-nth":{category:"number-theory",description:"Generates the nth term of the Bell sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { bell-nth } = import(number-theory);\nbell-nth(5)","let { bell-nth } = import(number-theory);\nbell-nth(10)"],seeAlso:["number-theory.bell-seq","number-theory.bell-take-while","number-theory.bell?"]},"bell?":{category:"number-theory",description:"Checks if a number is in the Bell sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { bell? } = import(number-theory);\nbell?(1)","let { bell? } = import(number-theory);\nbell?(27644437)","let { bell? } = import(number-theory);\nbell?(27644436)"],seeAlso:["number-theory.bell-seq","number-theory.bell-nth","number-theory.catalan?","number-theory.bell-take-while"]},"bernoulli-seq":{category:"number-theory",description:"Generates the Bernoulli sequence up to a specified length.",returns:{type:"number",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { bernoulli-seq } = import(number-theory);\nbernoulli-seq(5)","let { bernoulli-seq } = import(number-theory);\nbernoulli-seq(10)"],seeAlso:["number-theory.bernoulli-nth","number-theory.bernoulli-take-while"]},"bernoulli-take-while":{category:"number-theory",description:"Generates the Bernoulli sequence while a condition is met.",returns:{type:"number",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { bernoulli-take-while } = import(number-theory);\nbernoulli-take-while(-> abs($) < 100)"],seeAlso:["number-theory.bernoulli-seq","number-theory.bernoulli-nth"]},"bernoulli-nth":{category:"number-theory",description:"Generates the nth term of the Bernoulli sequence.",returns:{type:"number"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { bernoulli-nth } = import(number-theory);\nbernoulli-nth(5)","let { bernoulli-nth } = import(number-theory);\nbernoulli-nth(10)","let { bernoulli-nth } = import(number-theory);\nbernoulli-nth(23)"],seeAlso:["number-theory.bernoulli-seq","number-theory.bernoulli-take-while"]},"catalan-seq":{category:"number-theory",description:"Generates the Catalan sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 30 (the maximum length of the pre-calculated catalan numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { catalan-seq } = import(number-theory);\ncatalan-seq(5)","let { catalan-seq } = import(number-theory);\ncatalan-seq(10)","let { catalan-seq } = import(number-theory);\ncatalan-seq()"],seeAlso:["number-theory.catalan-nth","number-theory.catalan-take-while","number-theory.catalan?","number-theory.bell-seq"]},"catalan-take-while":{category:"number-theory",description:"Generates the Catalan sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { catalan-take-while } = import(number-theory);\ncatalan-take-while(-> $ < 1000)"],seeAlso:["number-theory.catalan-seq","number-theory.catalan-nth","number-theory.catalan?"]},"catalan-nth":{category:"number-theory",description:"Generates the nth term of the Catalan sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { catalan-nth } = import(number-theory);\ncatalan-nth(5)","let { catalan-nth } = import(number-theory);\ncatalan-nth(10)"],seeAlso:["number-theory.catalan-seq","number-theory.catalan-take-while","number-theory.catalan?"]},"catalan?":{category:"number-theory",description:"Determines if a number is in the Catalan sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { catalan? } = import(number-theory);\ncatalan?(5)","let { catalan? } = import(number-theory);\ncatalan?(10)"],seeAlso:["number-theory.catalan-seq","number-theory.catalan-nth","number-theory.bell?","number-theory.catalan-take-while"]},"collatz-seq":{category:"number-theory",description:"Generates the collatz sequence starting from a given integer.",returns:{type:"integer",array:!0},args:{start:{type:"integer",description:"The starting integer for the collatz sequence."}},variants:[{argumentNames:["start"]}],examples:["let { collatz-seq } = import(number-theory);\ncollatz-seq(3)","let { collatz-seq } = import(number-theory);\ncollatz-seq(11)"],seeAlso:["number-theory.juggler-seq"]},"composite-seq":{category:"number-theory",description:"Generates the composite sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { composite-seq } = import(number-theory);\ncomposite-seq(1)","let { composite-seq } = import(number-theory);\ncomposite-seq(2)","let { composite-seq } = import(number-theory);\ncomposite-seq(10)"],seeAlso:["number-theory.composite-nth","number-theory.composite-take-while","number-theory.composite?","number-theory.prime-seq"]},"composite-take-while":{category:"number-theory",description:"Generates the composite sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { composite-take-while } = import(number-theory);\ncomposite-take-while(-> $ < 50)"],seeAlso:["number-theory.composite-seq","number-theory.composite-nth","number-theory.composite?"]},"composite-nth":{category:"number-theory",description:"Generates the nth term of the composite sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the composite number to retrieve."}},variants:[{argumentNames:["n"]}],examples:["let { composite-nth } = import(number-theory);\ncomposite-nth(1)","let { composite-nth } = import(number-theory);\ncomposite-nth(2)","let { composite-nth } = import(number-theory);\ncomposite-nth(10)"],seeAlso:["number-theory.composite-seq","number-theory.composite-take-while","number-theory.composite?"]},"composite?":{category:"number-theory",description:"Determines if a number is composite.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { composite? } = import(number-theory);\ncomposite?(4)","let { composite? } = import(number-theory);\ncomposite?(5)","let { composite? } = import(number-theory);\ncomposite?(11)"],seeAlso:["number-theory.composite-seq","number-theory.composite-nth","number-theory.prime?","number-theory.prime-factors","number-theory.composite-take-while"]},"deficient-seq":{category:"number-theory",description:"Generates the deficient numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { deficient-seq } = import(number-theory);\ndeficient-seq(1)","let { deficient-seq } = import(number-theory);\ndeficient-seq(5)"],seeAlso:["number-theory.deficient-nth","number-theory.deficient-take-while","number-theory.deficient?","number-theory.abundant-seq","number-theory.perfect-seq"]},"deficient-take-while":{category:"number-theory",description:"Generates the deficient numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { deficient-take-while } = import(number-theory);\ndeficient-take-while(-> $ < 100)"],seeAlso:["number-theory.deficient-seq","number-theory.deficient-nth","number-theory.deficient?"]},"deficient-nth":{category:"number-theory",description:"Generates the nth term of the deficient numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the number in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { deficient-nth } = import(number-theory);\ndeficient-nth(5)","let { deficient-nth } = import(number-theory);\ndeficient-nth(12)"],seeAlso:["number-theory.deficient-seq","number-theory.deficient-take-while","number-theory.deficient?"]},"deficient?":{category:"number-theory",description:"Checks if a number is deficient.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { deficient? } = import(number-theory);\ndeficient?(12)","let { deficient? } = import(number-theory);\ndeficient?(15)"],seeAlso:["number-theory.deficient-seq","number-theory.deficient-nth","number-theory.abundant?","number-theory.perfect?","number-theory.sigma","number-theory.divisors","number-theory.deficient-take-while"]},"factorial-seq":{category:"number-theory",description:"Generates the factorial sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 19 (the maximum length of the pre-calculated factorial numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { factorial-seq } = import(number-theory);\nfactorial-seq(1)","let { factorial-seq } = import(number-theory);\nfactorial-seq(2)","let { factorial-seq } = import(number-theory);\nfactorial-seq(3)","let { factorial-seq } = import(number-theory);\nfactorial-seq(4)","let { factorial-seq } = import(number-theory);\nfactorial-seq(5)","let { factorial-seq } = import(number-theory);\nfactorial-seq(10)"],seeAlso:["number-theory.factorial-nth","number-theory.factorial-take-while","number-theory.factorial?","number-theory.factorial"]},"factorial-take-while":{category:"number-theory",description:"Generates the factorial sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { factorial-take-while } = import(number-theory);\nfactorial-take-while(-> $ < 1000)"],seeAlso:["number-theory.factorial-seq","number-theory.factorial-nth","number-theory.factorial?"]},"factorial-nth":{category:"number-theory",description:"Generates the nth term of the factorial sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { factorial-nth } = import(number-theory);\nfactorial-nth(1)","let { factorial-nth } = import(number-theory);\nfactorial-nth(2)","let { factorial-nth } = import(number-theory);\nfactorial-nth(3)","let { factorial-nth } = import(number-theory);\nfactorial-nth(4)","let { factorial-nth } = import(number-theory);\nfactorial-nth(5)","let { factorial-nth } = import(number-theory);\nfactorial-nth(10)"],seeAlso:["number-theory.factorial-seq","number-theory.factorial-take-while","number-theory.factorial?","number-theory.factorial"]},"factorial?":{category:"number-theory",description:"Checks if a number is in the factorial sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { factorial? } = import(number-theory);\nfactorial?(1)","let { factorial? } = import(number-theory);\nfactorial?(2)","let { factorial? } = import(number-theory);\nfactorial?(3)","let { factorial? } = import(number-theory);\nfactorial?(4)","let { factorial? } = import(number-theory);\nfactorial?(5)","let { factorial? } = import(number-theory);\nfactorial?(6)","let { factorial? } = import(number-theory);\nfactorial?(7)","let { factorial? } = import(number-theory);\nfactorial?(8)","let { factorial? } = import(number-theory);\nfactorial?(9)","let { factorial? } = import(number-theory);\nfactorial?(3628800)"],seeAlso:["number-theory.factorial-seq","number-theory.factorial-nth","number-theory.factorial","number-theory.factorial-take-while"]},"fibonacci-seq":{category:"number-theory",description:"Generates the fibonacci sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 79 (the maximum length of the pre-calculated Fibonacci numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { fibonacci-seq } = import(number-theory);\nfibonacci-seq(1)","let { fibonacci-seq } = import(number-theory);\nfibonacci-seq(2)","let { fibonacci-seq } = import(number-theory);\nfibonacci-seq()"],seeAlso:["number-theory.fibonacci-nth","number-theory.fibonacci-take-while","number-theory.fibonacci?","number-theory.lucas-seq","number-theory.tribonacci-seq","number-theory.pell-seq","number-theory.padovan-seq"]},"fibonacci-take-while":{category:"number-theory",description:"Generates the fibonacci sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { fibonacci-take-while } = import(number-theory);\nfibonacci-take-while(-> $ < 100)"],seeAlso:["number-theory.fibonacci-seq","number-theory.fibonacci-nth","number-theory.fibonacci?"]},"fibonacci-nth":{category:"number-theory",description:"Generates the nth term of the fibonacci sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { fibonacci-nth } = import(number-theory);\nfibonacci-nth(5)","let { fibonacci-nth } = import(number-theory);\nfibonacci-nth(50)"],seeAlso:["number-theory.fibonacci-seq","number-theory.fibonacci-take-while","number-theory.fibonacci?"]},"fibonacci?":{category:"number-theory",description:"Determines if a number is in the fibonacci sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { fibonacci? } = import(number-theory);\nfibonacci?(0)","let { fibonacci? } = import(number-theory);\nfibonacci?(1)","let { fibonacci? } = import(number-theory);\nfibonacci?(2)","let { fibonacci? } = import(number-theory);\nfibonacci?(3)","let { fibonacci? } = import(number-theory);\nfibonacci?(4)","let { fibonacci? } = import(number-theory);\nfibonacci?(5)","let { fibonacci? } = import(number-theory);\nfibonacci?(6)","let { fibonacci? } = import(number-theory);\nfibonacci?(7)","let { fibonacci? } = import(number-theory);\nfibonacci?(8)","let { fibonacci? } = import(number-theory);\nfibonacci?(9)"],seeAlso:["number-theory.fibonacci-seq","number-theory.fibonacci-nth","number-theory.lucas?","number-theory.fibonacci-take-while","number-theory.tribonacci?","number-theory.padovan?","number-theory.pell?"]},"geometric-seq":{category:"number-theory",description:"Generates the geometric sequence for a given $start, $ratio, and $length.",returns:{type:"integer",array:!0},args:{start:{type:"number",description:"The starting term of the sequence."},ratio:{type:"number",description:"The common ratio of the sequence."},length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["start","ratio","length"]}],examples:["let { geometric-seq } = import(number-theory);\ngeometric-seq(3, 2, 2)","let { geometric-seq } = import(number-theory);\ngeometric-seq(2, 3, 2)","let { geometric-seq } = import(number-theory);\ngeometric-seq(1, 2, 2)","let { geometric-seq } = import(number-theory);\ngeometric-seq(1, 1.5, 12)"],seeAlso:["number-theory.geometric-nth","number-theory.geometric-take-while","number-theory.geometric?","number-theory.arithmetic-seq"]},"geometric-take-while":{category:"number-theory",description:"Generates the geometric sequence while a condition is met.",returns:{type:"integer",array:!0},args:{start:{type:"number",description:"The starting term of the sequence."},ratio:{type:"number",description:"The common ratio of the sequence."},takeWhile:{type:"function",description:"A function that takes a number and an index and returns a boolean."}},variants:[{argumentNames:["start","ratio","takeWhile"]}],examples:["let { geometric-take-while } = import(number-theory);\ngeometric-take-while(1, 1.5, -> $ < 10)"],seeAlso:["number-theory.geometric-seq","number-theory.geometric-nth","number-theory.geometric?"]},"geometric-nth":{category:"number-theory",description:"Generates the nth term of the geometric sequence.",returns:{type:"integer"},args:{start:{type:"number",description:"The starting term of the sequence."},ratio:{type:"number",description:"The common ratio of the sequence."},n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["start","ratio","n"]}],examples:["let { geometric-nth } = import(number-theory);\ngeometric-nth(3, 2, 2)","let { geometric-nth } = import(number-theory);\ngeometric-nth(2, 3, 2)","let { geometric-nth } = import(number-theory);\ngeometric-nth(1, 2, 2)","let { geometric-nth } = import(number-theory);\ngeometric-nth(1, 1.5, 4)"],seeAlso:["number-theory.geometric-seq","number-theory.geometric-take-while","number-theory.geometric?"]},"geometric?":{category:"number-theory",description:"Checks if a number is in the geometric sequence.",returns:{type:"boolean"},args:{start:{type:"number",description:"The starting term of the sequence."},ratio:{type:"number",description:"The common ratio of the sequence."},n:{type:"number",description:"The number to check."}},variants:[{argumentNames:["start","ratio","n"]}],examples:["let { geometric? } = import(number-theory);\ngeometric?(1, 2, 1)","let { geometric? } = import(number-theory);\ngeometric?(2, 3, 2)","let { geometric? } = import(number-theory);\ngeometric?(3, 2, 2)","let { geometric? } = import(number-theory);\ngeometric?(1, 1.5, 2.25)","let { geometric? } = import(number-theory);\ngeometric?(1, 1.5, -4)"],seeAlso:["number-theory.geometric-seq","number-theory.geometric-nth","number-theory.arithmetic?","number-theory.geometric-take-while"]},"golomb-seq":{category:"number-theory",description:"Generates the Golomb sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { golomb-seq } = import(number-theory);\ngolomb-seq(5)","let { golomb-seq } = import(number-theory);\ngolomb-seq(20)"],seeAlso:["number-theory.golomb-nth","number-theory.golomb-take-while","number-theory.golomb?","number-theory.recaman-seq"]},"golomb-take-while":{category:"number-theory",description:"Generates the Golomb sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { golomb-take-while } = import(number-theory);\ngolomb-take-while(-> $ <= 10)"],seeAlso:["number-theory.golomb-seq","number-theory.golomb-nth","number-theory.golomb?"]},"golomb-nth":{category:"number-theory",description:"Generates the nth term of the Golomb sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { golomb-nth } = import(number-theory);\ngolomb-nth(5)","let { golomb-nth } = import(number-theory);\ngolomb-nth(1000)"],seeAlso:["number-theory.golomb-seq","number-theory.golomb-take-while","number-theory.golomb?"]},"golomb?":{category:"number-theory",description:"Checks if a number is in the Golomb sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { golomb? } = import(number-theory);\ngolomb?(1)","let { golomb? } = import(number-theory);\ngolomb?(2)","let { golomb? } = import(number-theory);\ngolomb?(3345)","let { golomb? } = import(number-theory);\ngolomb?(67867864)"],seeAlso:["number-theory.golomb-seq","number-theory.golomb-nth","number-theory.golomb-take-while"]},"happy-seq":{category:"number-theory",description:"Generates the happy sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 20 (the maximum length of the pre-calculated happy numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { happy-seq } = import(number-theory);\nhappy-seq(1)","let { happy-seq } = import(number-theory);\nhappy-seq(2)","let { happy-seq } = import(number-theory);\nhappy-seq(20)"],seeAlso:["number-theory.happy-nth","number-theory.happy-take-while","number-theory.happy?","number-theory.lucky-seq"]},"happy-take-while":{category:"number-theory",description:"Generates the happy sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { happy-take-while } = import(number-theory);\nhappy-take-while(-> $ < 100)"],seeAlso:["number-theory.happy-seq","number-theory.happy-nth","number-theory.happy?"]},"happy-nth":{category:"number-theory",description:"Generates the nth term of the happy sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the happy number to return."}},variants:[{argumentNames:["n"]}],examples:["let { happy-nth } = import(number-theory);\nhappy-nth(1)","let { happy-nth } = import(number-theory);\nhappy-nth(2)","let { happy-nth } = import(number-theory);\nhappy-nth(20)"],seeAlso:["number-theory.happy-seq","number-theory.happy-take-while","number-theory.happy?"]},"happy?":{category:"number-theory",description:"Determines if a number is a happy number.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { happy? } = import(number-theory);\nhappy?(1)","let { happy? } = import(number-theory);\nhappy?(2)","let { happy? } = import(number-theory);\nhappy?(100)"],seeAlso:["number-theory.happy-seq","number-theory.happy-nth","number-theory.happy-take-while"]},"juggler-seq":{category:"number-theory",description:"Generates the Juggler sequence starting from a given integer.",returns:{type:"integer",array:!0},args:{start:{type:"integer",description:"The starting integer for the Juggler sequence."}},variants:[{argumentNames:["start"]}],examples:["let { juggler-seq } = import(number-theory);\njuggler-seq(3)","let { juggler-seq } = import(number-theory);\njuggler-seq(5)"],seeAlso:["number-theory.collatz-seq"]},"look-and-say-seq":{category:"number-theory",description:"Generates the Look-and-Say sequence up to a specified length.",returns:{type:"string",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { look-and-say-seq } = import(number-theory);\nlook-and-say-seq(5)"],seeAlso:["number-theory.look-and-say-nth","number-theory.look-and-say-take-while","number-theory.look-and-say?"]},"look-and-say-take-while":{category:"number-theory",description:"Generates the Look-and-Say sequence while a condition is met.",returns:{type:"string",array:!0},args:{takeWhile:{type:"function",description:"A function that takes a string and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { look-and-say-take-while } = import(number-theory);\nlook-and-say-take-while((term, index) -> count(term) < 10)","let { look-and-say-take-while } = import(number-theory);\nlook-and-say-take-while(-> $2 <= 10)"],seeAlso:["number-theory.look-and-say-seq","number-theory.look-and-say-nth","number-theory.look-and-say?"]},"look-and-say-nth":{category:"number-theory",description:"Generates the nth term of the Look-and-Say sequence.",returns:{type:"string"},args:{n:{type:"integer",description:"The index of the term in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { look-and-say-nth } = import(number-theory);\nlook-and-say-nth(5)"],seeAlso:["number-theory.look-and-say-seq","number-theory.look-and-say-take-while","number-theory.look-and-say?"]},"look-and-say?":{category:"number-theory",description:"Checks if a string is a valid Look-and-Say term.",returns:{type:"boolean"},args:{term:{type:"string",description:"The term to check."}},variants:[{argumentNames:["term"]}],examples:['let { look-and-say? } = import(number-theory);\nlook-and-say?("111221")','let { look-and-say? } = import(number-theory);\nlook-and-say?("123")'],seeAlso:["number-theory.look-and-say-seq","number-theory.look-and-say-nth","number-theory.look-and-say-take-while"]},"lucas-seq":{category:"number-theory",description:"Generates the lucas sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 77 (the maximum length of the pre-calculated Lucas numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { lucas-seq } = import(number-theory);\nlucas-seq(1)","let { lucas-seq } = import(number-theory);\nlucas-seq(2)","let { lucas-seq } = import(number-theory);\nlucas-seq()"],seeAlso:["number-theory.lucas-nth","number-theory.lucas-take-while","number-theory.lucas?","number-theory.fibonacci-seq"]},"lucas-take-while":{category:"number-theory",description:"Generates the lucas sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { lucas-take-while } = import(number-theory);\nlucas-take-while(-> $ < 100)"],seeAlso:["number-theory.lucas-seq","number-theory.lucas-nth","number-theory.lucas?"]},"lucas-nth":{category:"number-theory",description:"Generates the nth term of the lucas sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { lucas-nth } = import(number-theory);\nlucas-nth(1)","let { lucas-nth } = import(number-theory);\nlucas-nth(2)","let { lucas-nth } = import(number-theory);\nlucas-nth(10)"],seeAlso:["number-theory.lucas-seq","number-theory.lucas-take-while","number-theory.lucas?"]},"lucas?":{category:"number-theory",description:"Determines if a number is in the lucas sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { lucas? } = import(number-theory);\nlucas?(1)","let { lucas? } = import(number-theory);\nlucas?(2)","let { lucas? } = import(number-theory);\nlucas?(10)"],seeAlso:["number-theory.lucas-seq","number-theory.lucas-nth","number-theory.fibonacci?","number-theory.lucas-take-while"]},"lucky-seq":{category:"number-theory",description:"Generates the lucky sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { lucky-seq } = import(number-theory);\nlucky-seq(1)","let { lucky-seq } = import(number-theory);\nlucky-seq(2)","let { lucky-seq } = import(number-theory);\nlucky-seq(20)"],seeAlso:["number-theory.lucky-nth","number-theory.lucky-take-while","number-theory.lucky?","number-theory.happy-seq","number-theory.prime-seq"]},"lucky-take-while":{category:"number-theory",description:"Generates the lucky sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { lucky-take-while } = import(number-theory);\nlucky-take-while(-> $ < 100)"],seeAlso:["number-theory.lucky-seq","number-theory.lucky-nth","number-theory.lucky?"]},"lucky-nth":{category:"number-theory",description:"Generates the nth term of the lucky sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The position in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { lucky-nth } = import(number-theory);\nlucky-nth(1)","let { lucky-nth } = import(number-theory);\nlucky-nth(2)","let { lucky-nth } = import(number-theory);\nlucky-nth(20)"],seeAlso:["number-theory.lucky-seq","number-theory.lucky-take-while","number-theory.lucky?"]},"lucky?":{category:"number-theory",description:"Checks if a number is a lucky number.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { lucky? } = import(number-theory);\nlucky?(4)","let { lucky? } = import(number-theory);\nlucky?(7)","let { lucky? } = import(number-theory);\nlucky?(33)"],seeAlso:["number-theory.lucky-seq","number-theory.lucky-nth","number-theory.prime?","number-theory.lucky-take-while"]},"mersenne-seq":{category:"number-theory",description:"Generates the Mersenne sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 9 (the maximum length of the pre-calculated mersenne numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { mersenne-seq } = import(number-theory);\nmersenne-seq(1)","let { mersenne-seq } = import(number-theory);\nmersenne-seq(5)","let { mersenne-seq } = import(number-theory);\nmersenne-seq()"],seeAlso:["number-theory.mersenne-nth","number-theory.mersenne-take-while","number-theory.mersenne?","number-theory.prime-seq"]},"mersenne-take-while":{category:"number-theory",description:"Generates the Mersenne sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { mersenne-take-while } = import(number-theory);\nmersenne-take-while(-> $ < 1000)"],seeAlso:["number-theory.mersenne-seq","number-theory.mersenne-nth","number-theory.mersenne?"]},"mersenne-nth":{category:"number-theory",description:"Generates the nth term of the Mersenne sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { mersenne-nth } = import(number-theory);\nmersenne-nth(1)","let { mersenne-nth } = import(number-theory);\nmersenne-nth(5)"],seeAlso:["number-theory.mersenne-seq","number-theory.mersenne-take-while","number-theory.mersenne?"]},"mersenne?":{category:"number-theory",description:"Checks if a number is in the Mersenne sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { mersenne? } = import(number-theory);\nmersenne?(3)","let { mersenne? } = import(number-theory);\nmersenne?(4)","let { mersenne? } = import(number-theory);\nmersenne?(7)"],seeAlso:["number-theory.mersenne-seq","number-theory.mersenne-nth","number-theory.prime?","number-theory.mersenne-take-while"]},"padovan-seq":{category:"number-theory",description:"Generates the Padovan sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { padovan-seq } = import(number-theory);\npadovan-seq(5)","let { padovan-seq } = import(number-theory);\npadovan-seq(10)","let { padovan-seq } = import(number-theory);\npadovan-seq(20)"],seeAlso:["number-theory.padovan-nth","number-theory.padovan-take-while","number-theory.padovan?","number-theory.fibonacci-seq"]},"padovan-take-while":{category:"number-theory",description:"Generates the Padovan sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { padovan-take-while } = import(number-theory);\npadovan-take-while(-> $ < 1000)"],seeAlso:["number-theory.padovan-seq","number-theory.padovan-nth","number-theory.padovan?"]},"padovan-nth":{category:"number-theory",description:"Generates the nth term of the Padovan sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { padovan-nth } = import(number-theory);\npadovan-nth(5)","let { padovan-nth } = import(number-theory);\npadovan-nth(10)","let { padovan-nth } = import(number-theory);\npadovan-nth(20)"],seeAlso:["number-theory.padovan-seq","number-theory.padovan-take-while","number-theory.padovan?"]},"padovan?":{category:"number-theory",description:"Checks if a number is in the Padovan sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { padovan? } = import(number-theory);\npadovan?(1)","let { padovan? } = import(number-theory);\npadovan?(265)","let { padovan? } = import(number-theory);\npadovan?(6)"],seeAlso:["number-theory.padovan-seq","number-theory.padovan-nth","number-theory.fibonacci?","number-theory.padovan-take-while"]},"partition-seq":{category:"number-theory",description:"Generates the partition numbers up to a specified length. If no length is provided, it defaults to 299 (the maximum length of the pre-calculated partition numbers).",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { partition-seq } = import(number-theory);\npartition-seq(1)","let { partition-seq } = import(number-theory);\npartition-seq(10)","let { partition-seq } = import(number-theory);\npartition-seq()"],seeAlso:["number-theory.partition-nth","number-theory.partition-take-while","number-theory.partition?","number-theory.partitions","number-theory.count-partitions"]},"partition-take-while":{category:"number-theory",description:"Generates the partition numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { partition-take-while } = import(number-theory);\npartition-take-while(-> $ < 1000)"],seeAlso:["number-theory.partition-seq","number-theory.partition-nth","number-theory.partition?"]},"partition-nth":{category:"number-theory",description:"Generates the nth term of the partition numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the partition number to generate."}},variants:[{argumentNames:["n"]}],examples:["let { partition-nth } = import(number-theory);\npartition-nth(1)","let { partition-nth } = import(number-theory);\npartition-nth(5)"],seeAlso:["number-theory.partition-seq","number-theory.partition-take-while","number-theory.partition?"]},"partition?":{category:"number-theory",description:"Checks if a number is in the partition numbers.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { partition? } = import(number-theory);\npartition?(0)","let { partition? } = import(number-theory);\npartition?(1)","let { partition? } = import(number-theory);\npartition?(2)","let { partition? } = import(number-theory);\npartition?(3)","let { partition? } = import(number-theory);\npartition?(4)","let { partition? } = import(number-theory);\npartition?(5)"],seeAlso:["number-theory.partition-seq","number-theory.partition-nth","number-theory.partitions","number-theory.partition-take-while"]},"pell-seq":{category:"number-theory",description:"Generates the Pell sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 42 (the maximum length of the pre-calculated Pell numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { pell-seq } = import(number-theory);\npell-seq(5)","let { pell-seq } = import(number-theory);\npell-seq(10)","let { pell-seq } = import(number-theory);\npell-seq()"],seeAlso:["number-theory.pell-nth","number-theory.pell-take-while","number-theory.pell?","number-theory.fibonacci-seq"]},"pell-take-while":{category:"number-theory",description:"Generates the Pell sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { pell-take-while } = import(number-theory);\npell-take-while(-> $ < 1000)"],seeAlso:["number-theory.pell-seq","number-theory.pell-nth","number-theory.pell?"]},"pell-nth":{category:"number-theory",description:"Generates the nth term of the Pell sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { pell-nth } = import(number-theory);\npell-nth(5)","let { pell-nth } = import(number-theory);\npell-nth(10)","let { pell-nth } = import(number-theory);\npell-nth(20)"],seeAlso:["number-theory.pell-seq","number-theory.pell-take-while","number-theory.pell?"]},"pell?":{category:"number-theory",description:"Checks if a number is a Pell number.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { pell? } = import(number-theory);\npell?(1)","let { pell? } = import(number-theory);\npell?(470832)","let { pell? } = import(number-theory);\npell?(10)"],seeAlso:["number-theory.pell-seq","number-theory.pell-nth","number-theory.fibonacci?","number-theory.pell-take-while"]},"perfect-seq":{category:"number-theory",description:"Generates the perfect numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"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)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { perfect-seq } = import(number-theory);\nperfect-seq(1)","let { perfect-seq } = import(number-theory);\nperfect-seq(5)","let { perfect-seq } = import(number-theory);\nperfect-seq()"],seeAlso:["number-theory.perfect-nth","number-theory.perfect-take-while","number-theory.perfect?","number-theory.abundant-seq","number-theory.deficient-seq","number-theory.amicable?"]},"perfect-take-while":{category:"number-theory",description:"Generates the perfect numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { perfect-take-while } = import(number-theory);\nperfect-take-while(-> $ < 1000)"],seeAlso:["number-theory.perfect-seq","number-theory.perfect-nth","number-theory.perfect?"]},"perfect-nth":{category:"number-theory",description:"Generates the nth term of the perfect numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the perfect number to generate."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-nth } = import(number-theory);\nperfect-nth(1)","let { perfect-nth } = import(number-theory);\nperfect-nth(5)"],seeAlso:["number-theory.perfect-seq","number-theory.perfect-take-while","number-theory.perfect?"]},"perfect?":{category:"number-theory",description:"Checks if a number is in the perfect numbers.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect? } = import(number-theory);\nperfect?(0)","let { perfect? } = import(number-theory);\nperfect?(1)","let { perfect? } = import(number-theory);\nperfect?(2)","let { perfect? } = import(number-theory);\nperfect?(3)","let { perfect? } = import(number-theory);\nperfect?(4)","let { perfect? } = import(number-theory);\nperfect?(5)","let { perfect? } = import(number-theory);\nperfect?(6)","let { perfect? } = import(number-theory);\nperfect?(7)","let { perfect? } = import(number-theory);\nperfect?(8)","let { perfect? } = import(number-theory);\nperfect?(9)"],seeAlso:["number-theory.perfect-seq","number-theory.perfect-nth","number-theory.abundant?","number-theory.deficient?","number-theory.sigma","number-theory.perfect-take-while","number-theory.amicable?","number-theory.proper-divisors"]},"perfect-square-seq":{category:"number-theory",description:"Generates the perfect square numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { perfect-square-seq } = import(number-theory);\nperfect-square-seq(5)","let { perfect-square-seq } = import(number-theory);\nperfect-square-seq(20)"],seeAlso:["number-theory.perfect-square-nth","number-theory.perfect-square-take-while","number-theory.perfect-square?","number-theory.perfect-cube-seq","number-theory.perfect-power-seq","number-theory.polygonal-seq"]},"perfect-square-take-while":{category:"number-theory",description:"Generates the perfect square numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { perfect-square-take-while } = import(number-theory);\nperfect-square-take-while(-> $ <= 100)"],seeAlso:["number-theory.perfect-square-seq","number-theory.perfect-square-nth","number-theory.perfect-square?"]},"perfect-square-nth":{category:"number-theory",description:"Generates the nth term of the perfect square numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-square-nth } = import(number-theory);\nperfect-square-nth(1)","let { perfect-square-nth } = import(number-theory);\nperfect-square-nth(5)"],seeAlso:["number-theory.perfect-square-seq","number-theory.perfect-square-take-while","number-theory.perfect-square?"]},"perfect-square?":{category:"number-theory",description:"Checks if a number is a perfect square.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-square? } = import(number-theory);\nperfect-square?(16)","let { perfect-square? } = import(number-theory);\nperfect-square?(20)"],seeAlso:["number-theory.perfect-square-seq","number-theory.perfect-square-nth","number-theory.perfect-cube?","number-theory.perfect-power?","number-theory.perfect-square-take-while","number-theory.perfect-power","number-theory.polygonal?"]},"perfect-cube-seq":{category:"number-theory",description:"Generates the perfect cube numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { perfect-cube-seq } = import(number-theory);\nperfect-cube-seq(5)","let { perfect-cube-seq } = import(number-theory);\nperfect-cube-seq(20)"],seeAlso:["number-theory.perfect-cube-nth","number-theory.perfect-cube-take-while","number-theory.perfect-cube?","number-theory.perfect-square-seq","number-theory.perfect-power-seq"]},"perfect-cube-take-while":{category:"number-theory",description:"Generates the perfect cube numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { perfect-cube-take-while } = import(number-theory);\nperfect-cube-take-while(-> $ <= 100)"],seeAlso:["number-theory.perfect-cube-seq","number-theory.perfect-cube-nth","number-theory.perfect-cube?"]},"perfect-cube-nth":{category:"number-theory",description:"Generates the nth term of the perfect cube numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-cube-nth } = import(number-theory);\nperfect-cube-nth(1)","let { perfect-cube-nth } = import(number-theory);\nperfect-cube-nth(5)"],seeAlso:["number-theory.perfect-cube-seq","number-theory.perfect-cube-take-while","number-theory.perfect-cube?"]},"perfect-cube?":{category:"number-theory",description:"Checks if a number is in the perfect cube numbers.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-cube? } = import(number-theory);\nperfect-cube?(7)","let { perfect-cube? } = import(number-theory);\nperfect-cube?(8)","let { perfect-cube? } = import(number-theory);\nperfect-cube?(9)"],seeAlso:["number-theory.perfect-cube-seq","number-theory.perfect-cube-nth","number-theory.perfect-square?","number-theory.perfect-power?","number-theory.perfect-cube-take-while","number-theory.perfect-power"]},"perfect-power-seq":{category:"number-theory",description:"Generates the perfect power numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { perfect-power-seq } = import(number-theory);\nperfect-power-seq(5)","let { perfect-power-seq } = import(number-theory);\nperfect-power-seq(20)"],seeAlso:["number-theory.perfect-power-nth","number-theory.perfect-power-take-while","number-theory.perfect-power?","number-theory.perfect-power","number-theory.perfect-square-seq","number-theory.perfect-cube-seq"]},"perfect-power-take-while":{category:"number-theory",description:"Generates the perfect power numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { perfect-power-take-while } = import(number-theory);\nperfect-power-take-while(-> $ <= 100)"],seeAlso:["number-theory.perfect-power-seq","number-theory.perfect-power-nth","number-theory.perfect-power?"]},"perfect-power-nth":{category:"number-theory",description:"Generates the nth term of the perfect power numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-power-nth } = import(number-theory);\nperfect-power-nth(3)","let { perfect-power-nth } = import(number-theory);\nperfect-power-nth(15)"],seeAlso:["number-theory.perfect-power-seq","number-theory.perfect-power-take-while","number-theory.perfect-power?"]},"perfect-power?":{category:"number-theory",description:"Checks if a number is in the perfect power numbers.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-power? } = import(number-theory);\nperfect-power?(7)","let { perfect-power? } = import(number-theory);\nperfect-power?(8)","let { perfect-power? } = import(number-theory);\nperfect-power?(9)","let { perfect-power? } = import(number-theory);\nperfect-power?(10)"],seeAlso:["number-theory.perfect-power-seq","number-theory.perfect-power-nth","number-theory.perfect-power","number-theory.perfect-square?","number-theory.perfect-cube?","number-theory.perfect-power-take-while"]},"polygonal-seq":{category:"number-theory",description:"Generates the polygonal sequence for a given number of sides and length.",returns:{type:"integer",array:!0},args:{sides:{type:"integer",description:"The number of sides of the polygon."},length:{type:"integer",description:"The length of the sequence to generate."},a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["sides","length"]}],examples:["let { polygonal-seq } = import(number-theory);\npolygonal-seq(3, 2)","let { polygonal-seq } = import(number-theory);\npolygonal-seq(4, 2)","let { polygonal-seq } = import(number-theory);\npolygonal-seq(5, 3)","let { polygonal-seq } = import(number-theory);\npolygonal-seq(6, 5)","let { polygonal-seq } = import(number-theory);\npolygonal-seq(100, 10)"],seeAlso:["number-theory.polygonal-nth","number-theory.polygonal-take-while","number-theory.polygonal?","number-theory.perfect-square-seq"]},"polygonal-take-while":{category:"number-theory",description:"Generates the polygonal sequence while a condition is met.",returns:{type:"integer",array:!0},args:{sides:{type:"integer",description:"The number of sides of the polygon."},takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."},a:{type:"integer"},b:{type:"function"}},variants:[{argumentNames:["sides","takeWhile"]}],examples:["let { polygonal-take-while } = import(number-theory);\npolygonal-take-while(15, -> $ < 1000)"],seeAlso:["number-theory.polygonal-seq","number-theory.polygonal-nth","number-theory.polygonal?"]},"polygonal-nth":{category:"number-theory",description:"Generates the nth term of the polygonal sequence.",returns:{type:"integer"},args:{sides:{type:"integer",description:"The number of sides of the polygon."},n:{type:"integer",description:"The index of the term to generate."},a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["sides","n"]}],examples:["let { polygonal-nth } = import(number-theory);\npolygonal-nth(3, 9)","let { polygonal-nth } = import(number-theory);\npolygonal-nth(4, 5)","let { polygonal-nth } = import(number-theory);\npolygonal-nth(5, 5)"],seeAlso:["number-theory.polygonal-seq","number-theory.polygonal-take-while","number-theory.polygonal?"]},"polygonal?":{category:"number-theory",description:"Checks if a number is in the polygonal sequence.",returns:{type:"boolean"},args:{sides:{type:"integer",description:"The number of sides of the polygon."},n:{type:"integer",description:"The number to check."},a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["sides","n"]}],examples:["let { polygonal? } = import(number-theory);\npolygonal?(3, 10)","let { polygonal? } = import(number-theory);\npolygonal?(3, 9)","let { polygonal? } = import(number-theory);\npolygonal?(4, 10000)","let { polygonal? } = import(number-theory);\npolygonal?(4, 1000)","let { polygonal? } = import(number-theory);\npolygonal?(6, 45)"],seeAlso:["number-theory.polygonal-seq","number-theory.polygonal-nth","number-theory.perfect-square?","number-theory.polygonal-take-while"]},"prime-seq":{category:"number-theory",description:"Generates the prime sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { prime-seq } = import(number-theory);\nprime-seq(1)","let { prime-seq } = import(number-theory);\nprime-seq(2)","let { prime-seq } = import(number-theory);\nprime-seq(10)"],seeAlso:["number-theory.prime-nth","number-theory.prime-take-while","number-theory.prime?","number-theory.composite-seq","number-theory.mersenne-seq","number-theory.lucky-seq"]},"prime-take-while":{category:"number-theory",description:"Generates the prime sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { prime-take-while } = import(number-theory);\nprime-take-while(-> $ < 50)"],seeAlso:["number-theory.prime-seq","number-theory.prime-nth","number-theory.prime?"]},"prime-nth":{category:"number-theory",description:"Generates the nth term of the prime sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { prime-nth } = import(number-theory);\nprime-nth(1)","let { prime-nth } = import(number-theory);\nprime-nth(2)","let { prime-nth } = import(number-theory);\nprime-nth(10)"],seeAlso:["number-theory.prime-seq","number-theory.prime-take-while","number-theory.prime?"]},"prime?":{category:"number-theory",description:"Determines if a number is prime.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { prime? } = import(number-theory);\nprime?(1)","let { prime? } = import(number-theory);\nprime?(2)","let { prime? } = import(number-theory);\nprime?(3)","let { prime? } = import(number-theory);\nprime?(4)","let { prime? } = import(number-theory);\nprime?(997)","let { prime? } = import(number-theory);\nprime?(1001)"],seeAlso:["number-theory.prime-seq","number-theory.prime-nth","number-theory.composite?","number-theory.prime-factors","number-theory.mersenne?","number-theory.prime-take-while","number-theory.lucky?"]},"recaman-seq":{category:"number-theory",description:"Generates the Recaman sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { recaman-seq } = import(number-theory);\nrecaman-seq(5)","let { recaman-seq } = import(number-theory);\nrecaman-seq(10)","let { recaman-seq } = import(number-theory);\nrecaman-seq(20)"],seeAlso:["number-theory.recaman-nth","number-theory.recaman-take-while","number-theory.recaman?","number-theory.golomb-seq"]},"recaman-take-while":{category:"number-theory",description:"Generates the Recaman sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { recaman-take-while } = import(number-theory);\nrecaman-take-while(-> $ < 10)"],seeAlso:["number-theory.recaman-seq","number-theory.recaman-nth","number-theory.recaman?"]},"recaman-nth":{category:"number-theory",description:"Generates the nth term of the Recaman sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { recaman-nth } = import(number-theory);\nrecaman-nth(5)","let { recaman-nth } = import(number-theory);\nrecaman-nth(10)","let { recaman-nth } = import(number-theory);\nrecaman-nth(20)"],seeAlso:["number-theory.recaman-seq","number-theory.recaman-take-while","number-theory.recaman?"]},"recaman?":{category:"number-theory",description:"Checks if a number is in the Recaman sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { recaman? } = import(number-theory);\nrecaman?(5)","let { recaman? } = import(number-theory);\nrecaman?(10)","let { recaman? } = import(number-theory);\nrecaman?(20)"],seeAlso:["number-theory.recaman-seq","number-theory.recaman-nth","number-theory.recaman-take-while"]},"sylvester-seq":{category:"number-theory",description:"Generates the Sylvester sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 6 (the maximum length of the pre-calculated Sylvester numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { sylvester-seq } = import(number-theory);\nsylvester-seq(5)","let { sylvester-seq } = import(number-theory);\nsylvester-seq()","let { sylvester-seq } = import(number-theory);\nsylvester-seq()"],seeAlso:["number-theory.sylvester-nth","number-theory.sylvester-take-while","number-theory.sylvester?"]},"sylvester-take-while":{category:"number-theory",description:"Generates the Sylvester sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { sylvester-take-while } = import(number-theory);\nsylvester-take-while(-> $ < 100000)"],seeAlso:["number-theory.sylvester-seq","number-theory.sylvester-nth","number-theory.sylvester?"]},"sylvester-nth":{category:"number-theory",description:"Generates the nth term of the Sylvester sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { sylvester-nth } = import(number-theory);\nsylvester-nth(1)","let { sylvester-nth } = import(number-theory);\nsylvester-nth(5)"],seeAlso:["number-theory.sylvester-seq","number-theory.sylvester-take-while","number-theory.sylvester?"]},"sylvester?":{category:"number-theory",description:"Checks if a number is in the Sylvester sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { sylvester? } = import(number-theory);\nsylvester?(2)","let { sylvester? } = import(number-theory);\nsylvester?(3)","let { sylvester? } = import(number-theory);\nsylvester?(6)"],seeAlso:["number-theory.sylvester-seq","number-theory.sylvester-nth","number-theory.sylvester-take-while"]},"thue-morse-seq":{category:"number-theory",description:"Generates the Thue-Morse sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { thue-morse-seq } = import(number-theory);\nthue-morse-seq(5)","let { thue-morse-seq } = import(number-theory);\nthue-morse-seq(10)","let { thue-morse-seq } = import(number-theory);\nthue-morse-seq(20)"],seeAlso:["number-theory.thue-morse-nth","number-theory.thue-morse-take-while","number-theory.thue-morse?"]},"thue-morse-take-while":{category:"number-theory",description:"Generates the Thue-Morse sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { thue-morse-take-while } = import(number-theory);\nthue-morse-take-while(-> $2 < 10)"],seeAlso:["number-theory.thue-morse-seq","number-theory.thue-morse-nth","number-theory.thue-morse?"]},"thue-morse-nth":{category:"number-theory",description:"Generates the nth term of the Thue-Morse sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { thue-morse-nth } = import(number-theory);\nthue-morse-nth(5)","let { thue-morse-nth } = import(number-theory);\nthue-morse-nth(10)","let { thue-morse-nth } = import(number-theory);\nthue-morse-nth(20)"],seeAlso:["number-theory.thue-morse-seq","number-theory.thue-morse-take-while","number-theory.thue-morse?"]},"thue-morse?":{category:"number-theory",description:"Checks if a number is part of the Thue-Morse sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { thue-morse? } = import(number-theory);\nthue-morse?(1)","let { thue-morse? } = import(number-theory);\nthue-morse?(2)"],seeAlso:["number-theory.thue-morse-seq","number-theory.thue-morse-nth","number-theory.thue-morse-take-while"]},"tribonacci-seq":{category:"number-theory",description:"Generates the tribonacci sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { tribonacci-seq } = import(number-theory);\ntribonacci-seq(1)","let { tribonacci-seq } = import(number-theory);\ntribonacci-seq(2)","let { tribonacci-seq } = import(number-theory);\ntribonacci-seq(10)"],seeAlso:["number-theory.tribonacci-nth","number-theory.tribonacci-take-while","number-theory.tribonacci?","number-theory.fibonacci-seq"]},"tribonacci-take-while":{category:"number-theory",description:"Generates the tribonacci sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { tribonacci-take-while } = import(number-theory);\ntribonacci-take-while(-> $ < 100)"],seeAlso:["number-theory.tribonacci-seq","number-theory.tribonacci-nth","number-theory.tribonacci?"]},"tribonacci-nth":{category:"number-theory",description:"Generates the nth term of the tribonacci sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { tribonacci-nth } = import(number-theory);\ntribonacci-nth(1)","let { tribonacci-nth } = import(number-theory);\ntribonacci-nth(2)","let { tribonacci-nth } = import(number-theory);\ntribonacci-nth(10)"],seeAlso:["number-theory.tribonacci-seq","number-theory.tribonacci-take-while","number-theory.tribonacci?"]},"tribonacci?":{category:"number-theory",description:"Determines if a number is in the tribonacci sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { tribonacci? } = import(number-theory);\ntribonacci?(0)","let { tribonacci? } = import(number-theory);\ntribonacci?(1)","let { tribonacci? } = import(number-theory);\ntribonacci?(2)","let { tribonacci? } = import(number-theory);\ntribonacci?(3)","let { tribonacci? } = import(number-theory);\ntribonacci?(4)","let { tribonacci? } = import(number-theory);\ntribonacci?(5)","let { tribonacci? } = import(number-theory);\ntribonacci?(6)","let { tribonacci? } = import(number-theory);\ntribonacci?(7)","let { tribonacci? } = import(number-theory);\ntribonacci?(8)","let { tribonacci? } = import(number-theory);\ntribonacci?(9)","let { tribonacci? } = import(number-theory);\ntribonacci?(10)"],seeAlso:["number-theory.tribonacci-seq","number-theory.tribonacci-nth","number-theory.fibonacci?","number-theory.tribonacci-take-while"]},"count-combinations":{category:"number-theory",description:"Calculates the number of combinations of n items taken k at a time.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { count-combinations } = import(number-theory);\ncount-combinations(5, 3)","let { count-combinations } = import(number-theory);\ncount-combinations(10, 2)"],seeAlso:["number-theory.combinations","number-theory.count-permutations","number-theory.factorial","number-theory.multinomial","number-theory.stirling-second","number-theory.count-partitions","number-theory.count-power-set"]},combinations:{category:"number-theory",description:"Generates all possible combinations of a specified size from a collection.",returns:{type:"array",array:!0},args:{set:{type:"array",array:!0,description:"The input collection to generate combinations from."},n:{type:"integer",description:"The size of each combination."},a:{type:"array"},b:{type:"integer"}},variants:[{argumentNames:["set","n"]}],examples:["let { combinations } = import(number-theory);\ncombinations([1, 2, 3], 2)",'let { combinations } = import(number-theory);\ncombinations(["a", "b", "c"], 2)',"let { combinations } = import(number-theory);\ncombinations([1, 2, 3], 0)","let { combinations } = import(number-theory);\ncombinations([1, 2, 3], 1)","let { combinations } = import(number-theory);\ncombinations([1, 2, 3], 3)"],seeAlso:["number-theory.count-combinations","number-theory.permutations","number-theory.power-set","number-theory.cartesian-product","number-theory.partitions"]},"count-derangements":{category:"number-theory",description:"Calculates the number of derangements (permutations where no element appears in its original position) of n items.",returns:{type:"integer"},args:{n:{type:"integer",description:"The total number of items."}},variants:[{argumentNames:["n"]}],examples:["let { count-derangements } = import(number-theory);\ncount-derangements(4)","let { count-derangements } = import(number-theory);\ncount-derangements(5)"],seeAlso:["number-theory.derangements","number-theory.count-permutations","number-theory.factorial"]},derangements:{category:"number-theory",description:"Generates all derangements (permutations where no element appears in its original position) of a set.",returns:{type:"array",array:!0},args:{set:{type:"array",array:!0,description:"The input collection to generate derangements from."}},variants:[{argumentNames:["set"]}],examples:["let { derangements } = import(number-theory);\nderangements([1, 2, 3, 4])",'let { derangements } = import(number-theory);\nderangements(["a", "b", "c"])'],seeAlso:["number-theory.count-derangements","number-theory.permutations"]},divisors:{category:"number-theory",description:"Returns the divisors of a number.",returns:{type:"integer",array:!0},args:{n:{type:"integer",description:"The number to find divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { divisors } = import(number-theory);\ndivisors(12)","let { divisors } = import(number-theory);\ndivisors(100)","let { divisors } = import(number-theory);\ndivisors(37)"],seeAlso:["number-theory.count-divisors","number-theory.proper-divisors","number-theory.sigma","number-theory.prime-factors","number-theory.divisible-by?","number-theory.lcm","number-theory.abundant?","number-theory.deficient?","number-theory.count-proper-divisors"]},"count-divisors":{category:"number-theory",description:"Returns the number of divisors of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { count-divisors } = import(number-theory);\ncount-divisors(12)","let { count-divisors } = import(number-theory);\ncount-divisors(100)","let { count-divisors } = import(number-theory);\ncount-divisors(37)"],seeAlso:["number-theory.divisors","number-theory.count-proper-divisors","number-theory.sigma"]},"proper-divisors":{category:"number-theory",description:"Returns the proper divisors of a number.",returns:{type:"integer",array:!0},args:{n:{type:"integer",description:"The number to find proper divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { proper-divisors } = import(number-theory);\nproper-divisors(12)","let { proper-divisors } = import(number-theory);\nproper-divisors(100)","let { proper-divisors } = import(number-theory);\nproper-divisors(37)"],seeAlso:["number-theory.count-proper-divisors","number-theory.divisors","number-theory.amicable?","number-theory.perfect?"]},"count-proper-divisors":{category:"number-theory",description:"Returns the number of proper divisors of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count proper divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { count-proper-divisors } = import(number-theory);\ncount-proper-divisors(12)","let { count-proper-divisors } = import(number-theory);\ncount-proper-divisors(100)","let { count-proper-divisors } = import(number-theory);\ncount-proper-divisors(37)"],seeAlso:["number-theory.proper-divisors","number-theory.count-divisors","number-theory.divisors"]},factorial:{category:"number-theory",description:"Calculates the factorial of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the factorial for."}},variants:[{argumentNames:["n"]}],examples:["let { factorial } = import(number-theory);\nfactorial(5)","let { factorial } = import(number-theory);\nfactorial(0)","let { factorial } = import(number-theory);\nfactorial(10)","let { factorial } = import(number-theory);\nfactorial(20)"],seeAlso:["number-theory.factorial-seq","number-theory.factorial-nth","number-theory.factorial?","number-theory.count-combinations","number-theory.count-permutations","number-theory.multinomial","number-theory.count-derangements"]},partitions:{category:"number-theory",description:"Generates all partitions of a number.",returns:{type:"array",array:!0},args:{n:{type:"integer",description:"The number to partition."}},variants:[{argumentNames:["n"]}],examples:["let { partitions } = import(number-theory);\npartitions(4)","let { partitions } = import(number-theory);\npartitions(8)"],seeAlso:["number-theory.count-partitions","number-theory.partition-seq","number-theory.combinations","number-theory.partition?"]},"count-partitions":{category:"number-theory",description:"Returns the number of partitions of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count partitions for."}},variants:[{argumentNames:["n"]}],examples:["let { count-partitions } = import(number-theory);\ncount-partitions(4)","let { count-partitions } = import(number-theory);\ncount-partitions(8)","let { count-partitions } = import(number-theory);\ncount-partitions(15)"],seeAlso:["number-theory.partitions","number-theory.partition-seq","number-theory.count-combinations"]},permutations:{category:"number-theory",description:"Generates all permutations of a collection.",returns:{type:"array",array:!0},args:{set:{type:"array",array:!0,description:"The input collection to generate permutations from."}},variants:[{argumentNames:["set"]}],examples:["let { permutations } = import(number-theory);\npermutations([1, 2, 3])",'let { permutations } = import(number-theory);\npermutations(["a", "b", "c"])',"let { permutations } = import(number-theory);\npermutations([1, 2, 3, 4])","let { permutations } = import(number-theory);\npermutations([1, 2])","let { permutations } = import(number-theory);\npermutations([1])","let { permutations } = import(number-theory);\npermutations([])"],seeAlso:["number-theory.count-permutations","number-theory.combinations","number-theory.derangements","number-theory.cartesian-product"]},"count-permutations":{category:"number-theory",description:"Returns the number of permutations of n items taken k at a time.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { count-permutations } = import(number-theory);\ncount-permutations(5, 3)","let { count-permutations } = import(number-theory);\ncount-permutations(10, 2)","let { count-permutations } = import(number-theory);\ncount-permutations(10, 10)","let { count-permutations } = import(number-theory);\ncount-permutations(10, 0)","let { count-permutations } = import(number-theory);\ncount-permutations(10, 1)"],seeAlso:["number-theory.permutations","number-theory.count-combinations","number-theory.factorial","number-theory.multinomial","number-theory.stirling-first","number-theory.count-derangements"]},"power-set":{category:"number-theory",description:"Generates the power set of a collection.",returns:{type:"array",array:!0},args:{set:{type:"any",array:!0,description:"The input collection to generate the power set from."}},variants:[{argumentNames:["set"]}],examples:['let { power-set } = import(number-theory);\npower-set(["a", "b", "c"])',"let { power-set } = import(number-theory);\npower-set([1, 2])","let { power-set } = import(number-theory);\npower-set([1])","let { power-set } = import(number-theory);\npower-set([])"],seeAlso:["number-theory.count-power-set","number-theory.combinations","number-theory.cartesian-product"]},"count-power-set":{category:"number-theory",description:"Returns the number of subsets of a set.",returns:{type:"integer"},args:{n:{type:"integer",description:"The size of the set."}},variants:[{argumentNames:["n"]}],examples:["let { count-power-set } = import(number-theory);\ncount-power-set(3)","let { count-power-set } = import(number-theory);\ncount-power-set(5)","let { count-power-set } = import(number-theory);\ncount-power-set(10)"],seeAlso:["number-theory.power-set","number-theory.count-combinations"]},"prime-factors":{category:"number-theory",description:"Returns the prime factors of a number.",returns:{type:"integer",array:!0},args:{n:{type:"integer",description:"The number to factor."}},variants:[{argumentNames:["n"]}],examples:["let { prime-factors } = import(number-theory);\nprime-factors(12)","let { prime-factors } = import(number-theory);\nprime-factors(100)","let { prime-factors } = import(number-theory);\nprime-factors(37)"],seeAlso:["number-theory.count-prime-factors","number-theory.distinct-prime-factors","number-theory.prime?","number-theory.divisors","number-theory.euler-totient","number-theory.mobius","number-theory.composite?","number-theory.count-distinct-prime-factors"]},"count-prime-factors":{category:"number-theory",description:"Returns the number of prime factors of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count prime factors for."}},variants:[{argumentNames:["n"]}],examples:["let { count-prime-factors } = import(number-theory);\ncount-prime-factors(12)","let { count-prime-factors } = import(number-theory);\ncount-prime-factors(100)","let { count-prime-factors } = import(number-theory);\ncount-prime-factors(37)"],seeAlso:["number-theory.prime-factors","number-theory.distinct-prime-factors","number-theory.count-distinct-prime-factors"]},"distinct-prime-factors":{category:"number-theory",description:"Returns the distinct prime factors of a number.",returns:{type:"integer",array:!0},args:{n:{type:"integer",description:"The number to find distinct prime factors for."}},variants:[{argumentNames:["n"]}],examples:["let { distinct-prime-factors } = import(number-theory);\ndistinct-prime-factors(12)","let { distinct-prime-factors } = import(number-theory);\ndistinct-prime-factors(100)","let { distinct-prime-factors } = import(number-theory);\ndistinct-prime-factors(37)"],seeAlso:["number-theory.prime-factors","number-theory.count-distinct-prime-factors","number-theory.count-prime-factors"]},"count-distinct-prime-factors":{category:"number-theory",description:"Returns the number of distinct prime factors of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count distinct prime factors for."}},variants:[{argumentNames:["n"]}],examples:["let { count-distinct-prime-factors } = import(number-theory);\ncount-distinct-prime-factors(12)","let { count-distinct-prime-factors } = import(number-theory);\ncount-distinct-prime-factors(100)","let { count-distinct-prime-factors } = import(number-theory);\ncount-distinct-prime-factors(37)"],seeAlso:["number-theory.distinct-prime-factors","number-theory.prime-factors","number-theory.count-prime-factors"]},"coprime?":{category:"number-theory",description:"Checks if two numbers are coprime (i.e., their GCD is 1).",returns:{type:"boolean"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { coprime? } = import(number-theory);\ncoprime?(12, 8)","let { coprime? } = import(number-theory);\ncoprime?(12, 5)","let { coprime? } = import(number-theory);\ncoprime?(37, 1)","let { coprime? } = import(number-theory);\ncoprime?(0, 0)","let { coprime? } = import(number-theory);\ncoprime?(0, 5)","let { coprime? } = import(number-theory);\ncoprime?(5, 0)","let { coprime? } = import(number-theory);\ncoprime?(1, 0)","let { coprime? } = import(number-theory);\ncoprime?(0, 1)","let { coprime? } = import(number-theory);\ncoprime?(1, 1)","let { coprime? } = import(number-theory);\ncoprime?(2, 3)"],seeAlso:["number-theory.gcd","number-theory.euler-totient","number-theory.divisible-by?","number-theory.lcm","number-theory.carmichael-lambda"]},"divisible-by?":{category:"number-theory",description:"Checks if a number is divisible by another number.",returns:{type:"boolean"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { divisible-by? } = import(number-theory);\ndivisible-by?(12, 4)","let { divisible-by? } = import(number-theory);\ndivisible-by?(12, 5)","let { divisible-by? } = import(number-theory);\ndivisible-by?(37, 1)","let { divisible-by? } = import(number-theory);\ndivisible-by?(0, 0)","let { divisible-by? } = import(number-theory);\ndivisible-by?(0, 5)","let { divisible-by? } = import(number-theory);\ndivisible-by?(5, 0)"],seeAlso:["number-theory.divisors","number-theory.gcd","number-theory.coprime?"]},gcd:{category:"number-theory",description:"Calculates the greatest common divisor (GCD) of two numbers.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { gcd } = import(number-theory);\ngcd(100, 25)","let { gcd } = import(number-theory);\ngcd(37, 1)","let { gcd } = import(number-theory);\ngcd(0, 0)","let { gcd } = import(number-theory);\ngcd(0, 5)","let { gcd } = import(number-theory);\ngcd(5, 0)"],seeAlso:["number-theory.lcm","number-theory.extended-gcd","number-theory.coprime?","number-theory.divisible-by?"]},lcm:{category:"number-theory",description:"Calculates the least common multiple (LCM) of two numbers.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { lcm } = import(number-theory);\nlcm(100, 25)","let { lcm } = import(number-theory);\nlcm(37, 1)","let { lcm } = import(number-theory);\nlcm(0, 5)","let { lcm } = import(number-theory);\nlcm(5, 0)"],seeAlso:["number-theory.gcd","number-theory.divisors","number-theory.coprime?"]},multinomial:{category:"number-theory",description:"Calculates the multinomial coefficient from of a list of numbers representing the sizes of each group.",returns:{type:"integer"},args:{args:{type:"integer",rest:!0,description:"The numbers representing the sizes of each group."}},variants:[{argumentNames:["args"]}],examples:["let { multinomial } = import(number-theory);\nmultinomial(5, 2, 3)","let { multinomial } = import(number-theory);\nmultinomial(10, 2, 3, 5)"],seeAlso:["number-theory.count-combinations","number-theory.factorial","number-theory.count-permutations"],hideOperatorForm:!0},"amicable?":{category:"number-theory",description:"Checks if two numbers are amicable (i.e., the sum of the proper divisors of each number equals the other number).",returns:{type:"boolean"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { amicable? } = import(number-theory);\namicable?(220, 284)","let { amicable? } = import(number-theory);\namicable?(1184, 1210)","let { amicable? } = import(number-theory);\namicable?(2620, 2924)","let { amicable? } = import(number-theory);\namicable?(5020, 5564)","let { amicable? } = import(number-theory);\namicable?(6232, 6368)"],seeAlso:["number-theory.proper-divisors","number-theory.perfect?","number-theory.sigma","number-theory.perfect-seq"]},"euler-totient":{category:"number-theory",description:"Calculates the Euler's totient function (φ(n)) of a number, which counts the integers up to n that are coprime to n.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the totient for."}},variants:[{argumentNames:["n"]}],examples:["let { euler-totient } = import(number-theory);\neuler-totient(1)","let { euler-totient } = import(number-theory);\neuler-totient(2)","let { euler-totient } = import(number-theory);\neuler-totient(10)","let { euler-totient } = import(number-theory);\neuler-totient(20)"],seeAlso:["number-theory.coprime?","number-theory.carmichael-lambda","number-theory.mobius","number-theory.prime-factors","number-theory.mertens"]},mobius:{category:"number-theory",description:"Calculates the Möbius function (μ(n)) of a number, which is used in number theory.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the Möbius function for."}},variants:[{argumentNames:["n"]}],examples:["let { mobius } = import(number-theory);\nmobius(1)","let { mobius } = import(number-theory);\nmobius(2)","let { mobius } = import(number-theory);\nmobius(3)","let { mobius } = import(number-theory);\nmobius(4)","let { mobius } = import(number-theory);\nmobius(6)","let { mobius } = import(number-theory);\nmobius(12)","let { mobius } = import(number-theory);\nmobius(30)"],seeAlso:["number-theory.mertens","number-theory.euler-totient","number-theory.prime-factors"]},mertens:{category:"number-theory",description:"Calculates the Mertens function (M(n)) of a number, which is the sum of the Möbius function up to n.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the Mertens function for."}},variants:[{argumentNames:["n"]}],examples:["let { mobius } = import(number-theory);\nmobius(1)","let { mobius } = import(number-theory);\nmobius(2)","let { mobius } = import(number-theory);\nmobius(3)","let { mobius } = import(number-theory);\nmobius(4)","let { mobius } = import(number-theory);\nmobius(6)","let { mobius } = import(number-theory);\nmobius(12)","let { mobius } = import(number-theory);\nmobius(30)"],seeAlso:["number-theory.mobius","number-theory.euler-totient"]},sigma:{category:"number-theory",description:"Calculates the sum of divisors function (σ(n)) of a number, which is the sum of all positive divisors of n.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the sum of divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { sigma } = import(number-theory);\nsigma(1)","let { sigma } = import(number-theory);\nsigma(2)","let { sigma } = import(number-theory);\nsigma(3)","let { sigma } = import(number-theory);\nsigma(4)","let { sigma } = import(number-theory);\nsigma(6)","let { sigma } = import(number-theory);\nsigma(12)","let { sigma } = import(number-theory);\nsigma(30)"],seeAlso:["number-theory.divisors","number-theory.perfect?","number-theory.abundant?","number-theory.deficient?","number-theory.amicable?","number-theory.count-divisors"]},"carmichael-lambda":{category:"number-theory",description:"Calculates the Carmichael function (λ(n)) of a number, which is the smallest positive integer m such that a^m ≡ 1 (mod n) for all integers a coprime to n.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the Carmichael function for."}},variants:[{argumentNames:["n"]}],examples:["let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(1)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(2)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(3)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(4)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(6)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(12)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(30)"],seeAlso:["number-theory.euler-totient","number-theory.mod-exp","number-theory.coprime?"]},"cartesian-product":{category:"number-theory",description:"Calculates the Cartesian product of two or more sets.",returns:{type:"array",array:!0},args:{sets:{type:"array",array:!0,description:"The input collections to calculate the Cartesian product from."},a:{type:"array"},b:{type:"array"}},variants:[{argumentNames:["sets"]}],examples:['let { cartesian-product } = import(number-theory);\ncartesian-product([1, 2], ["a", "b"])','let { cartesian-product } = import(number-theory);\ncartesian-product([1, 2], ["a", "b"], [true, false])','let { cartesian-product } = import(number-theory);\ncartesian-product([1, 2, 3], ["x", "y", "z"])'],seeAlso:["number-theory.combinations","number-theory.power-set","number-theory.permutations"]},"perfect-power":{category:"number-theory",description:"Returns a tuple of the base and exponent if the number is a perfect power, otherwise returns null.",returns:{type:"array",array:!0},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-power } = import(number-theory);\nperfect-power(1)","let { perfect-power } = import(number-theory);\nperfect-power(2)","let { perfect-power } = import(number-theory);\nperfect-power(4)","let { perfect-power } = import(number-theory);\nperfect-power(8)","let { perfect-power } = import(number-theory);\nperfect-power(9)","let { perfect-power } = import(number-theory);\nperfect-power(16)","let { perfect-power } = import(number-theory);\nperfect-power(19)"],seeAlso:["number-theory.perfect-power?","number-theory.perfect-power-seq","number-theory.perfect-square?","number-theory.perfect-cube?"]},"mod-exp":{category:"number-theory",description:"Calculates the modular exponentiation of a base raised to an exponent modulo a modulus.",returns:{type:"integer"},args:{base:{type:"integer"},exponent:{type:"integer"},modulus:{type:"integer"}},variants:[{argumentNames:["base","exponent","modulus"]}],examples:["let { mod-exp } = import(number-theory);\nmod-exp(2, 3, 5)","let { mod-exp } = import(number-theory);\nmod-exp(3, 4, 7)","let { mod-exp } = import(number-theory);\nmod-exp(5, 6, 11)","let { mod-exp } = import(number-theory);\nmod-exp(7, 8, 13)"],seeAlso:["number-theory.mod-inv","number-theory.carmichael-lambda","number-theory.chinese-remainder"]},"mod-inv":{category:"number-theory",description:"Calculates the modular multiplicative inverse of a number modulo another number.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","m"]}],examples:["let { mod-inv } = import(number-theory);\nmod-inv(3, 11)","let { mod-inv } = import(number-theory);\nmod-inv(10, 17)","let { mod-inv } = import(number-theory);\nmod-inv(5, 13)","let { mod-inv } = import(number-theory);\nmod-inv(7, 19)"],seeAlso:["number-theory.mod-exp","number-theory.extended-gcd","number-theory.chinese-remainder"]},"extended-gcd":{category:"number-theory",description:"Calculates the extended greatest common divisor (GCD) of two numbers, returning the GCD and the coefficients of Bézout's identity.",returns:{type:"integer",array:!0},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { extended-gcd } = import(number-theory);\nextended-gcd(30, 12)","let { extended-gcd } = import(number-theory);\nextended-gcd(56, 98)","let { extended-gcd } = import(number-theory);\nextended-gcd(101, 10)","let { extended-gcd } = import(number-theory);\nextended-gcd(17, 13)"],seeAlso:["number-theory.gcd","number-theory.mod-inv","number-theory.chinese-remainder"]},"chinese-remainder":{category:"number-theory",description:"Solves a system of simultaneous congruences using the Chinese Remainder Theorem.",returns:{type:"integer"},args:{remainders:{type:"integer",array:!0,description:"The remainders of the congruences."},moduli:{type:"integer",array:!0,description:"The moduli of the congruences."},a:{type:"array"},b:{type:"array"}},variants:[{argumentNames:["remainders","moduli"]}],examples:["let { chinese-remainder } = import(number-theory);\nchinese-remainder([2, 3], [3, 5])","let { chinese-remainder } = import(number-theory);\nchinese-remainder([1, 2], [3, 4])","let { chinese-remainder } = import(number-theory);\nchinese-remainder([0, 1], [2, 3])","let { chinese-remainder } = import(number-theory);\nchinese-remainder([1, 2, 3], [4, 5, 7])"],seeAlso:["number-theory.mod-exp","number-theory.mod-inv","number-theory.extended-gcd"]},"stirling-first":{category:"number-theory",description:"Calculates the Stirling numbers of the first kind, which count the number of permutations of n elements with k cycles.",returns:{type:"integer"},args:{a:{type:"integer",description:"The number of elements."},b:{type:"integer",description:"The number of cycles."}},variants:[{argumentNames:["a","b"]}],examples:["let { stirling-first } = import(number-theory);\nstirling-first(5, 2)","let { stirling-first } = import(number-theory);\nstirling-first(4, 3)","let { stirling-first } = import(number-theory);\nstirling-first(6, 1)","let { stirling-first } = import(number-theory);\nstirling-first(7, 4)","let { stirling-first } = import(number-theory);\nstirling-first(8, 5)"],seeAlso:["number-theory.stirling-second","number-theory.bell-seq","number-theory.count-permutations"]},"stirling-second":{category:"number-theory",description:"Calculates the Stirling numbers of the second kind, which count the number of ways to partition n elements into k non-empty subsets.",returns:{type:"integer"},args:{a:{type:"integer",description:"The number of elements."},b:{type:"integer",description:"The number of subsets."}},variants:[{argumentNames:["a","b"]}],examples:["let { stirling-second } = import(number-theory);\nstirling-second(5, 2)","let { stirling-second } = import(number-theory);\nstirling-second(4, 3)","let { stirling-second } = import(number-theory);\nstirling-second(6, 1)","let { stirling-second } = import(number-theory);\nstirling-second(7, 4)","let { stirling-second } = import(number-theory);\nstirling-second(8, 5)"],seeAlso:["number-theory.stirling-first","number-theory.bell-seq","number-theory.count-combinations"]}};function ro(e,t){if(0===t||t===e)return 1;let r=1;for(let n=0;n<t;n++)r*=(e-n)/(n+1);return r}function no(e,t){if(1===t)return e.map(e=>[e]);const r=[];for(let n=0;n<=e.length-t;n++){const o=e[n],a=no(e.slice(n+1),t-1);for(const e of a)r.push([o,...e])}return r}const oo={combinations:{evaluate:([e,t],r)=>(we(e,r),ee(t,r,{integer:!0,nonNegative:!0,lte:e.length}),0===t?[[]]:no(e,t)),arity:ae(2)},"count-combinations":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0,nonNegative:!0}),ee(t,r,{integer:!0,nonNegative:!0,lte:e}),ro(e,t)),arity:ae(2)}};const ao={derangements:{evaluate:([e],t)=>(we(e,t),function(e){const t=e.length,r=[],n=Array.from({length:t},()=>!1),o=Array.from({length:t});return function a(i){if(i!==t)for(let r=0;r<t;r++)n[r]||r===i||(n[r]=!0,o[i]=e[r],a(i+1),n[r]=!1);else r.push([...o])}(0),r}(e)),arity:ae(1)},"count-derangements":{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),function(e){if(1===e)return 0;let t=1,r=0,n=0;for(let o=2;o<=e;o++)n=(o-1)*(t+r),t=r,r=n;return n}(e)),arity:ae(1)}};function io(e){const t=[];for(let r=1;r<=Math.sqrt(e);r++)e%r===0&&(t.push(r),r!==e/r&&t.push(e/r));return t}function so(e){return io(e).sort((e,t)=>e-t)}function co(e){return so(e).slice(0,-1)}const lo={divisors:{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),so(e)),arity:ae(1)},"count-divisors":{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),io(e).length),arity:ae(1)},"proper-divisors":{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),co(e)),arity:ae(1)},"count-proper-divisors":{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),io(e).length-1),arity:ae(1)}},mo=[1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368e3,20922789888e3,355687428096e3,6402373705728e3];function uo(e){if(e<0)throw new Error("Factorial is not defined for negative numbers");if(0===e||1===e)return 1;if(e<=18)return mo[e];let t=mo[18];for(let r=19;r<=e;r++)t*=r;return t}const po={factorial:{evaluate:([e],t)=>(ee(e,t,{integer:!0,nonNegative:!0,lte:170}),uo(e)),arity:ae(1)}},go=[1,2,3,5,7,11,15,22,30,42,56,77,101,135,176,231,297,385,490,627,792,1002,1255,1575,1958,2436,3010,3718,4565,5604,6842,8349,10143,12310,14883,17977,21637,26015,31185,37338,44583,53174,63261,75175,89134,105558,124754,147273,173525,204226,239943,281589,329931,386155,451276,526823,614154,715220,831820,966467,1121505,1300156,1505499,1741630,2012558,2323520,2679689,3087735,3554345,4087968,4697205,5392783,6185689,7089500,8118264,9289091,10619863,12132164,13848650,15796476,18004327,20506255,23338469,26543660,30167357,34262962,38887673,44108109,49995925,56634173,64112359,72533807,82010177,92669720,104651419,118114304,133230930,150198136,169229875,190569292,214481126,241265379,271248950,304801365,342325709,384276336,431149389,483502844,541946240,607163746,679903203,761002156,851376628,952050665,1064144451,1188908248,1327710076,1482074143,1653668665,1844349560,2056148051,2291320912,2552338241,2841940500,3163127352,3519222692,3913864295,4351078600,4835271870,5371315400,5964539504,6620830889,7346629512,8149040695,9035836076,10015581680,11097645016,12292341831,13610949895,15065878135,16670689208,18440293320,20390982757,22540654445,24908858009,27517052599,30388671978,33549419497,37027355200,40853235313,45060624582,49686288421,54770336324,60356673280,66493182097,73232243759,80630964769,88751778802,97662728555,107438159466,118159068427,129913904637,142798995930,156919475295,172389800255,189334822579,207890420102,228204732751,250438925115,274768617130,301384802048,330495499613,362326859895,397125074750,435157697830,476715857290,522115831195,571701605655,625846753120,684957390936,749474411781,819876908323,896684817527,980462880430,0xf98dace281,1171432692373,1280011042268,1398341745571,1527273599625,1667727404093,1820701100652,1987276856363,2168627105469,2366022741845,2580840212973,2814570987591,3068829878530,3345365983698,3646072432125,3972999029388,4328363658647,4714566886083,5134205287973,5590088317495,6085253859260,6622987708040,7206841706490,7840656226137,8528581302375,9275102575355,0x92c1cc50847,0x9f8afdf968b,0xad6918d4f36,0xbc72dde1287,0xccc0de0d1d7,0xde6da02b061,0xf195c5ba10a,18028182516671,19573856161145,21248279009367,23061871173849,25025873760111,27152408925615,29454549941750,31946390696157,34643126322519,37561133582570,40718063627362,44132934884255,47826239745920,51820051838712,56138148670947,60806135438329,65851585970275,71304185514919,77195892663512,83561103925871,90436839668817,97862933703585,0x604ca1b434ad,0x682ca0bc6d4e,0x70ad06a4328b,0x79da3e8e4df8,0x83c1a359c63d,0x8e7190d8114a,0x99f976fff202,0xa669edb53a4a,0xb3d4caca1bc8,0xc24d38b78151,0xd1e7cfd30909,0xe2bab064772f,0xf4dd9f8523e3,290726957916112,313891991306665,338854264248680,365749566870782,394723676655357,425933084409356,459545750448675,495741934760846,534715062908609,576672674947168,621837416509615,670448123060170,722760953690372,779050629562167,839611730366814,904760108316360,974834369944625,0x3bb262854d36d,0x404dafd2efa2e,0x4541ae2536f6d,0x4a94ddd83ba57,0x504e363fd1eca,0x56752ddfc97e7,0x5d11c356f6b53,0x642c86bff69f5,0x6bcea3db036a0,0x7401ecbfdbd63,0x7cd0e571c49d4,0x8646d010a1b6f,0x906fba0855202,0x9b5889f52508f,0xa70f0ea631153,0xb3a20ef033ec5,0xc1215ac210755,0xcf9ddd28cfa8d,0xdf29afbd9f60e,0xefd82f26a7157,4534253126900886,4872038056472084,5234371069753672,5622992691950605,6039763882095515,6486674127079088,6965850144195831,7479565078510584,8030248384943040,8620496275465025];const ho={partitions:{evaluate:([e],t)=>(ee(e,t,{integer:!0,nonNegative:!0}),function(e){if(e<=0)return[[]];if(1===e)return[[1]];const t=[];return function e(r,n,o){if(0!==r)for(let t=Math.min(n,r);t>=1;t--)o.push(t),e(r-t,t,o),o.pop();else t.push([...o])}(e,e,[]),t}(e)),arity:ae(1)},"count-partitions":{evaluate:([e],t)=>{if(ee(e,t,{integer:!0,nonNegative:!0}),0===e)return 1;if(e>go.length)throw new r(`n is too large. The maximum value is ${go.length-1}.`,t);return go[e-1]},arity:ae(1)}};function yo(e){if(0===e.length)return[[]];const t=[];for(let r=0;r<e.length;r++){const n=e[r],o=yo([...e.slice(0,r),...e.slice(r+1)]);for(const e of o)t.push([n,...e])}return t}const vo={permutations:{evaluate:([e],t)=>(we(e,t),yo(e)),arity:ae(1)},"count-permutations":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0,nonNegative:!0}),ee(t,r,{integer:!0,nonNegative:!0,lte:e}),uo(e)/uo(e-t)),arity:ae(2)}};const fo={"power-set":{evaluate:([e],t)=>(we(e,t),function(e){const t=[[]];for(const r of e){const e=t.map(e=>[...e,r]);t.push(...e)}return t}(e)),arity:ae(1)},"count-power-set":{evaluate:([e],t)=>(ee(e,t,{integer:!0,nonNegative:!0}),e>=53?1/0:2**e),arity:ae(1)}};function bo(e){if(1===e)return[];const t=[];let r=2;for(;e>1;)e%r===0?(t.push(r),e/=r):r++;return t}const xo={"prime-factors":{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),bo(e)),arity:ae(1)},"distinct-prime-factors":{evaluate:([e],t)=>{ee(e,t,{finite:!0,integer:!0,positive:!0});const r=bo(e),n=new Set(r);return Array.from(n)},arity:ae(1)},"count-prime-factors":{evaluate:([e],t)=>(ee(e,t,{finite:!0,integer:!0,positive:!0}),bo(e).length),arity:ae(1)},"count-distinct-prime-factors":{evaluate:([e],t)=>{ee(e,t,{finite:!0,integer:!0,positive:!0});const r=bo(e);return new Set(r).size},arity:ae(1)}};function wo(e){return co(e).reduce((e,t)=>e+t,0)>e}const ko={"abundant-seq":e=>{const t=[];let r=2;for(;t.length<e;)wo(r)&&t.push(r),r+=1;return t},"abundant?":e=>wo(e),"abundant-take-while":e=>{const t=[];return function r(n){return wo(n)?Ae(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(2)}};const qo={"arithmetic-seq":{evaluate:([e,t,r],n)=>(ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),ee(r,n,{integer:!0,positive:!0}),Array.from({length:r},(r,n)=>e+n*t)),arity:ae(3)},"arithmetic-take-while":{evaluate:([e,t,r],n,o,{executeFunction:a})=>{ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),L(r,n);const i=e,s=t,c=r,l=[];return function e(t){const r=i+t*s;return Ae(a(c,[r,t],o,n),n=>n?(l.push(r),e(t+1)):l)}(0)},arity:ae(3)},"arithmetic-nth":{evaluate:([e,t,r],n)=>(ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),ee(r,n,{integer:!0,positive:!0}),e+(r-1)*t),arity:ae(3)},"arithmetic?":{evaluate:([e,t,r],n)=>(ee(r,n),ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),function(e,t,r){if(0===t)return fe(r,e);const n=(r-e)/t;if(n<0)return!1;const o=Math.round(n),a=e+t*o;return fe(n,o)&&fe(a,r)}(e,t,r)),arity:ae(3)}};function Ao(e){const t=[1];for(let r=1;r<e;r+=1){let e=0;for(let n=0;n<r;n+=1)e+=ro(r+1,n)*t[n];t[r]=r>1&&r%2==1?0:-e/(r+1)}return t}const No={"bernoulli-seq":{evaluate:([e],t)=>(ee(e,t,{integer:!0,positive:!0}),Ao(e)),arity:ae(1)},"bernoulli-nth":{evaluate:([e],t)=>{ee(e,t,{integer:!0,positive:!0});return Ao(e)[e-1]},arity:ae(1)},"bernoulli-take-while":{evaluate:([e],t,r,{executeFunction:n})=>{L(e,t);const o=e;return function(e){const t=[1];return function r(n){let o=0;for(let e=0;e<n;e++)o+=ro(n+1,e)*t[e];const a=n>1&&n%2==1?0:-o/(n+1);return Ae(e(a,n),e=>e?(t.push(a),r(n+1)):t)}(1)}((e,t)=>Ae(n(o,[e,t],r),e=>!!e))},arity:ae(1)}};function $o(e){if(e<=1)return!1;if(e<=3)return!0;if(e%2==0||e%3==0)return!1;for(let t=5;t*t<=e;t+=6)if(e%t===0||e%(t+2)===0)return!1;return!0}const To={"prime-seq":e=>{const t=[];let r=2;for(;t.length<e;)$o(r)&&t.push(r),r+=1;return t},"prime?":e=>$o(e),"prime-take-while":e=>{const t=[];return function r(n){return $o(n)?Ae(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(2)}};function zo(e){return!(e<=1)&&!$o(e)}const So={"composite-seq":e=>{const t=[];let r=2;for(;t.length<e;)zo(r)&&t.push(r),r+=1;return t},"composite?":e=>zo(e),"composite-take-while":e=>{const t=[];return function r(n){return zo(n)?Ae(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(4)}};function Eo(e){return co(e).reduce((e,t)=>e+t,0)<e}const jo={"deficient-seq":e=>{const t=[];let r=1;for(;t.length<e;)Eo(r)&&t.push(r),r+=1;return t},"deficient?":e=>Eo(e),"deficient-take-while":e=>{const t=[];return function r(n){return Eo(n)?Ae(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(1)}};const Mo={"geometric-seq":{evaluate:([e,t,r],n)=>(ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),ee(r,n,{integer:!0,positive:!0}),Array.from({length:r},(r,n)=>e*t**n)),arity:ae(3)},"geometric-take-while":{evaluate:([e,t,r],n,o,{executeFunction:a})=>{ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),L(r,n);const i=e,s=t,c=r,l=[];return function e(t){const r=i*s**t;return Ae(a(c,[r,t],o,n),n=>n?(l.push(r),e(t+1)):l)}(0)},arity:ae(3)},"geometric-nth":{evaluate:([e,t,r],n)=>(ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),ee(r,n,{integer:!0,positive:!0}),e*t**(r-1)),arity:ae(3)},"geometric?":{evaluate:([e,t,r],n)=>(ee(r,n),ee(e,n,{finite:!0}),ee(t,n,{finite:!0}),function(e,t,r){if(fe(e,0))return fe(r,0);if(fe(t,1))return fe(r,e);if(fe(t,0))return fe(r,0)||fe(r,e);if(fe(r,e))return!0;if(fe(t,-1))return fe(r,e)||fe(r,-e);if(t<0){const n=Math.log(Math.abs(r/e))/Math.log(Math.abs(t)),o=Math.round(n);if(!fe(o,n)||o<0)return!1;const a=o%2==0?Math.sign(e):Math.sign(e)*Math.sign(t);return Math.sign(r)===a}if(t>1&&r<e||t<1&&r>e)return!1;const n=Math.log(r/e)/Math.log(t),o=Math.round(n);return!(!fe(o,n)||o<0)&&fe(e*t**o,r)}(e,t,r)),arity:ae(3)}};const Co={"golomb-seq":e=>function(e){const t=[0,1];for(let r=2;r<=e;r+=1)t.push(1+t[r-t[t[r-1]]]);return t.slice(1)}(e),"golomb?":()=>!0,"golomb-take-while":e=>function(e){const t=[0,1];return Ae(e(1,0),r=>r?function r(n){const o=1+t[n-t[t[n-1]]];return Ae(e(o,n-1),e=>e?(t.push(o),r(n+1)):t.slice(1))}(2):[])}(e)};function Po(e){if(e<=0)return!1;const t=new Set;for(;1!==e&&!t.has(e);)t.add(e),e=Ro(e);return 1===e}function Ro(e){let t=0;for(;e>0;){const r=e%10;t+=r*r,e=Math.floor(e/10)}return t}const Io={"happy-seq":e=>{const t=[];for(let r=1;t.length<e;r++){let e=r;const n=new Set;for(;1!==e&&!n.has(e);)n.add(e),e=String(e).split("").reduce((e,t)=>e+Number(t)**2,0);1===e&&t.push(r)}return t},"happy?":e=>Po(e),"happy-take-while":e=>{const t=[];return function r(n){return Po(n)?Ae(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(1)}},Oo={"juggler-seq":e=>{let t=e;const r=[t];for(;t>1;)t=t%2==0?Math.floor(Math.sqrt(t)):Math.floor(t**1.5),r.push(t);return r},noNth:!0};function Fo(e){let t="",r=1;for(let n=0;n<e.length;n++)n+1<e.length&&e[n]===e[n+1]?r++:(t+=r.toString()+e[n],r=1);return t}const Uo={string:!0,"look-and-say-seq":e=>{const t=["1"];for(let r=1;r<e;r+=1){const e=t[r-1].replace(/(\d)\1*/g,e=>`${e.length}${e[0]}`);t[r]=e}return t},"look-and-say-take-while":e=>{const t=[];return Ae(e("1",0),r=>{if(!r)return t;return t.push("1"),function r(n){const o=t[n-1].replace(/(\d)\1*/g,e=>`${e.length}${e[0]}`);return Ae(e(o,n),e=>e?(t.push(o),r(n+1)):t)}(1)})},"look-and-say?":e=>function(e){let t="1";if(t===e)return!0;for(;;){if(t=Fo(t),t===e)return!0;if(t.length>e.length)return!1}}(e)};function Do(e){const t=[];for(let e=1;e<=2e3;e++)t.push(e);let r=[1];for(let e=1;e<t.length;e++)t[e]%2!=0&&r.push(t[e]);const n=[1];let o=1;return Ae(e(1,0),t=>{if(!t)return[];let a=1;return function t(){const i=r[a];return Ae(e(i,o),e=>{if(!e)return n;n.push(i),o++;const s=i,c=[];for(let e=0;e<r.length;e++)(e+1)%s!==0&&c.push(r[e]);if(r=c,a++,a>=r.length-5){let e=r[r.length-1]+2;for(;r.length<a+1e3;)r.push(e),e+=2}return t()})}()})}const Wo={"lucky-seq":e=>function(e){const t=[];let r=1;const n=e*(e<100?20:30);for(;t.length<n;)t.push(r),r+=2;let o=1;for(;o<t.length&&o<e;){const e=t[o];let r=0;for(let n=0;n<t.length;n++)(n+1)%e!==0&&(t[r++]=t[n]);t.length=r,o<t.length&&o++}return t.slice(0,e)}(e),"lucky?":e=>Do(t=>t<=e).includes(e),"lucky-take-while":e=>Do(e)};const Go={"padovan-seq":e=>{const t=[1,1,1];for(let r=3;r<e;r+=1)t[r]=t[r-2]+t[r-3];return t.slice(0,e)},"padovan?":e=>function(e){if(!Number.isInteger(e)||e<=0)return!1;if(1===e)return!0;const t=[1,1,1,2,2,3,4,5,7,9,12,16,21,28,37,49,65,86,114,151,200,265,351,465,616,816,1081,1432,1897,2513,3329,4410,5842,7739,10252,13581,17991,23833,31572,41824,55405,73396,97229];if(t.includes(e))return!0;if(e>t[t.length-1]&&e<=Number.MAX_SAFE_INTEGER){let r,n=t[t.length-3],o=t[t.length-2],a=t[t.length-1];for(;a<e;){if(r=n+o,n=o,o=a,a=r,a===e)return!0;if(!Number.isSafeInteger(a))return!1}}return!1}(e),"padovan-take-while":e=>{const t=[];return Ae(e(1,0),r=>r?(t.push(1),Ae(e(1,1),r=>r?(t.push(1),Ae(e(1,2),r=>{if(!r)return t;t.push(1);let n=1,o=1,a=1;return function r(i){const s=n+o;return n=o,o=a,a=s,Ae(e(a,i),e=>e?(t.push(a),r(i+1)):t)}(4)})):t)):t)}},Vo={"perfect-cube-seq":e=>{const t=[];for(let r=1;r<=e;r++)t.push(r**3);return t},"perfect-cube?":e=>e>0&&Number.isInteger(Math.cbrt(e)),"perfect-cube-take-while":e=>{const t=[];return function r(n){const o=n**3;return Ae(e(o,n),e=>e?(t.push(o),r(n+1)):t)}(1)}};function Bo(e){if(e<2)return 1===e?[1,2]:null;const t=Math.floor(Math.log2(e))+1;for(let r=2;r<=t;r++){const t=e**(1/r),n=Math.round(t);if(fe(n**r,e))return[n,r]}return null}const Lo={"perfect-power-seq":e=>{const t=[];for(let r=1;t.length<e;r++)Bo(r)&&t.push(r);return t},"perfect-power?":e=>null!==Bo(e),"perfect-power-take-while":e=>{const t=[];return function r(n){return Bo(n)?Ae(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(1)}},_o={"perfect-square-seq":e=>{const t=[];for(let r=1;r<=e;r++)t.push(r**2);return t},"perfect-square?":e=>e>0&&Number.isInteger(Math.sqrt(e)),"perfect-square-take-while":e=>{const t=[];return function r(n){const o=n**2;return Ae(e(o,n),e=>e?(t.push(o),r(n+1)):t)}(1)}},Ko={"polygonal-seq":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0,gte:3}),ee(t,r,{integer:!0,positive:!0});const n=[];for(let r=1;r<=t;r+=1)n[r-1]=(r*r*(e-2)-r*(e-4))/2;return n},arity:ae(2)},"polygonal-take-while":{evaluate:([e,t],r,n,{executeFunction:o})=>{ee(e,r,{integer:!0,gte:3}),L(t,r);const a=e,i=t,s=[];return function e(t){const c=(t*t*(a-2)-t*(a-4))/2;return Ae(o(i,[c,t],n,r),r=>r?(s.push(c),e(t+1)):s)}(1)},arity:ae(2)},"polygonal-nth":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0,gte:3}),ee(t,r,{integer:!0,positive:!0}),(t*t*(e-2)-t*(e-4))/2),arity:ae(2)},"polygonal?":{evaluate:([e,t],r)=>{if(ee(t,r,{integer:!0}),ee(e,r,{integer:!0,gte:3}),t<=0)return!1;const n=e-2,o=e-4,a=8*n*t+o*o,i=Math.sqrt(a);if(!Number.isInteger(i))return!1;const s=i+o;if(s%(2*n)!=0)return!1;const c=s/(2*n);return Number.isInteger(c)&&c>0},arity:ae(2)}};const Jo={"recaman-seq":e=>function(e){if(1===e)return[0];const t=[0],r=new Set([0]);for(let n=1;n<e;n++){let e=t[n-1]-n;(e<=0||r.has(e))&&(e=t[n-1]+n),t.push(e),r.add(e)}return t}(e),"recaman-take-while":e=>{const t=[],r=new Set([0]);return Ae(e(0,0),n=>{if(!n)return t;return t.push(0),function n(o){let a=t[o-1]-o;return(a<=0||r.has(a))&&(a=t[o-1]+o),Ae(e(a,o),e=>e?(t.push(a),r.add(a),n(o+1)):t)}(1)})},"recaman?":()=>!0},Yo={"thue-morse-seq":e=>{const t=[];for(let r=0;r<e;r+=1)t[r]=Ho(r)%2;return t},"thue-morse-take-while":e=>{const t=[];return function r(n){const o=Ho(n)%2;return Ae(e(o,n),e=>e?(t.push(o),r(n+1)):t)}(0)},"thue-morse?":e=>1===e||0===e};function Ho(e){let t=0;for(;e;)t+=1&e,e>>=1;return t}const Xo={};function Zo(e){for(const[t,r]of Object.entries(e)){if(Xo[t])throw new Error(`Duplicate normal expression key found: ${t}`);Xo[t]=r}}function Qo(e,t){return{[`${e}-seq`]:ta(e=>t.slice(0,e),t.length),[`${e}-take-while`]:ra(e=>function r(n){return n>=t.length?t.slice(0,n):Ae(e(t[n],n),e=>e?r(n+1):t.slice(0,n))}(0),t.length),[`${e}-nth`]:na(()=>t,t.length),[`${e}?`]:oa(e=>t.includes(e))}}function ea(e){for(const[t,r]of Object.entries(e)){if(Xo[t])throw new Error(`Duplicate normal expression key found: ${t}`);t.endsWith("seq")?(Xo[t]=ta(r,e.maxLength),e.noNth||(Xo[t.replace(/seq$/,"nth")]=na(r,e.maxLength))):t.endsWith("take-while")?Xo[t]=ra(r,e.maxLength):t.endsWith("?")&&(e.string?Xo[t]=aa(r):Xo[t]=oa(r))}}function ta(e,t){return{evaluate:(n,o)=>{const a=n[0]??t;ee(a,o,{integer:!0,positive:!0,lte:t});const i=e(a,o);if("number"==typeof i[0]&&i.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",o);return i},arity:"number"==typeof t?{max:1}:ae(1)}}function ra(e,t){return{evaluate:(t,n,o,{executeFunction:a})=>{const i=t[0];L(i,n);const s=e((e,t)=>Ae(a(i,[e,t],o),e=>!!e),n);return Ae(s,e=>{if("number"==typeof e[0]&&e.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",n);return e})},arity:"number"==typeof t?{max:1}:ae(1)}}function na(e,t){return{evaluate:(n,o)=>{const a=n[0];ee(a,o,{integer:!0,positive:!0,lte:t});const i=e(a,o);if("number"==typeof i[0]&&i.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",o);return i[a-1]},arity:ae(1)}}function oa(e){return{evaluate:(t,r)=>{const n=t[0];return ee(n,r),e(n,r)},arity:ae(1)}}function aa(e){return{evaluate:(t,r)=>{const n=t[0];return K(n,r),e(n,r)},arity:ae(1)}}function ia(e,t){for(;0!==t;){const r=t;t=e%t,e=r}return Math.abs(e)}function sa(e,t){return Math.floor(e*t/ia(e,t))}function ca(e){if(1===e)return 1;const t=bo(e);return new Set(t).size!==t.length?0:t.length%2==0?1:-1}function la(e,t){if(0===t)return[e,1,0];const[r,n,o]=la(t,e%t);return[r,o,n-Math.floor(e/t)*o]}function ma(e,t){const[r,n]=la(e,t);if(1!==r)throw new Error(`Modular inverse does not exist (gcd(${e}, ${t}) = ${r})`);return(n%t+t)%t}ea(ko),ea({"collatz-seq":e=>{let t=e;const r=[t];for(;1!==t;)t%2==0?t/=2:t=3*t+1,r.push(t);return r},noNth:!0}),ea(So),ea(jo),ea(Co),ea(Io),ea(Oo),ea(Uo),ea(Wo),ea(Go),ea(_o),ea(Vo),ea(Lo),ea(To),ea(Jo),ea(Yo),Zo(Qo("tribonacci",[0,1,1,2,4,7,13,24,44,81,149,274,504,927,1705,3136,5768,10609,19513,35890,66012,121415,223317,410744,755476,1389537,2555757,4700770,8646064,15902591,29249425,53798080,98950096,181997601,334745777,615693474,1132436852,2082876103,3831006429,7046319384,12960201916,23837527729,43844049029,80641778674,148323355432,272809183135,501774317241,922906855808,1697490356184,3122171529233,5742568741225,0x99b36012952,19426970897100,35731770264967,65720971788709,0x6df08059d9f8,0xca35cf00a924,408933139743937,752145307699165,0x4ea34736b35c2,0x90a3317d5c260,4680045560037375,8607945812375585])),Zo(Qo("catalan",[1,2,5,14,42,132,429,1430,4862,16796,58786,208012,742900,2674440,9694845,35357670,129644790,477638700,1767263190,6564120420,24466267020,91482563640,343059613650,1289904147324,4861946401452,18367353072152,69533550916004,0xefe09af96cd8,0x38f88b34d6a68,0xd8db5c347b610])),Zo(Qo("factorial",mo)),Zo(Qo("fibonacci",[0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,1134903170,1836311903,2971215073,4807526976,7778742049,12586269025,20365011074,32951280099,53316291173,86267571272,139583862445,225851433717,365435296162,591286729879,956722026041,1548008755920,2504730781961,4052739537881,6557470319842,0x9a661ca20bb,0xf9d297a859d,27777890035288,44945570212853,72723460248141,0x6b04f4c2fe42,0xad2934c6d08f,308061521170129,498454011879264,806515533049393,0x4a2dce62b0d91,0x780626e057bc2,0xc233f54308953,5527939700884757,8944394323791464])),Zo(Qo("lucas",[2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,0xd55fbe3dc94,23725150497407,38388099893011,62113250390418,0x5b67cb4878a5,0x93e5a9822a37,0xef4d74caa2dc,425730551631123,688846502588399,0x3f5b3b1643d02,0x66834447bacf1,0xa5de7f5dfe9f3,4721424167835364,7639424778862807])),Zo(Qo("mersenne",[3,7,31,127,2047,8191,131071,524287,2147483647])),Zo(Qo("partition",go)),Zo(Qo("pell",[1,2,5,12,29,70,169,408,985,2378,5741,13860,33461,80782,195025,470832,1136689,2744210,6625109,15994428,38613965,93222358,225058681,543339720,1311738121,3166815962,7645370045,18457556052,44560482149,107578520350,259717522849,627013566048,1513744654945,3654502875938,8822750406821,21300003689580,51422757785981,0x70e8e1937766,299713796309065,723573111879672,0x634c28af7f039,0xefb9b143d586a])),Zo(Qo("perfect",[6,28,496,8128,33550336,8589869056,137438691328])),Zo(Qo("sylvester",[2,6,42,1806,3263442,0x9afa8dc8416])),Zo(Qo("bell",[1,2,5,15,52,203,877,4140,21147,115975,678570,4213597,27644437,190899322,1382958545,10480142147,82864869804,682076806159,5832742205057,51724158235372,474869816156751,4506715738447323])),Zo(qo),Zo(No),Zo(Mo),Zo(Ko);const ua={"coprime?":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0}),1===ia(e,t)),arity:ae(2)},"divisible-by?":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0}),0!==t&&e%t===0),arity:ae(2)},gcd:{evaluate:([e,t],r)=>(ee(e,r),ee(t,r),ia(e,t)),arity:ae(2)},lcm:{evaluate:([e,t],r)=>(ee(e,r),ee(t,r),sa(e,t)),arity:ae(2)},multinomial:{evaluate:([...e],t)=>{Ze(e,t);return uo(e.reduce((e,r)=>(ee(r,t,{integer:!0,nonNegative:!0}),e+r),0))/e.reduce((e,t)=>e*uo(t),1)},arity:{min:1}},"amicable?":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0,positive:!0}),ee(t,r,{integer:!0,positive:!0});const n=co(e).reduce((e,t)=>e+t,0),o=co(t).reduce((e,t)=>e+t,0);return n===t&&o===e&&e!==t},arity:ae(2)},"euler-totient":{evaluate:([e],t)=>{ee(e,t,{integer:!0,positive:!0});let r=e;for(let t=2;t*t<=e;t+=1)if(e%t===0){for(;e%t===0;)e/=t;r-=r/t}return e>1&&(r-=r/e),r},arity:ae(1)},mobius:{evaluate:([e],t)=>{if(ee(e,t,{integer:!0,positive:!0}),1===e)return 1;const r=bo(e);return new Set(r).size!==r.length?0:r.length%2==0?1:-1},arity:ae(1)},mertens:{evaluate:([e],t)=>{if(ee(e,t,{integer:!0,positive:!0}),1===e)return 1;let r=0;for(let t=1;t<=e;t++){r+=ca(t)}return r},arity:ae(1)},sigma:{evaluate:([e],t)=>(ee(e,t,{integer:!0,positive:!0}),so(e).reduce((e,t)=>e+t,0)),arity:ae(1)},"carmichael-lambda":{evaluate:([e],t)=>{if(ee(e,t,{integer:!0,positive:!0}),1===e)return 1;const r=bo(e),n=new Map;for(const e of r)n.set(e,(n.get(e)||0)+1);const o=[];for(const[e,t]of n.entries())2===e?1===t?o.push(1):2===t?o.push(2):o.push(2**(t-2)):o.push((e-1)*e**(t-1));return o.reduce((e,t)=>sa(e,t),1)},arity:ae(1)},"cartesian-product":{evaluate:(e,t)=>{e.forEach(e=>{we(e,t)});return e.reduce((e,t)=>{const r=[];return e.forEach(e=>{t.forEach(t=>{r.push([...e,t])})}),r},[[]])},arity:{min:1}},"perfect-power":{evaluate:([e],t)=>{ee(e,t,{integer:!0,positive:!0});return Bo(e)||null},arity:ae(1)},"mod-exp":{evaluate:([e,t,r],n)=>(ee(e,n,{finite:!0}),ee(t,n,{integer:!0,positive:!0}),ee(r,n,{integer:!0,positive:!0}),function(e,t,r){if(1===r)return 0;let n=1;for(e%=r;t>0;)t%2==1&&(n=n*e%r),t>>=1,e=e*e%r;return n}(e,t,r)),arity:ae(3)},"mod-inv":{evaluate:([e,t],n)=>{ee(e,n,{integer:!0,positive:!0}),ee(t,n,{integer:!0,positive:!0});try{return ma(e,t)}catch(e){throw new r(e,n)}},arity:ae(2)},"extended-gcd":{evaluate:([e,t],r)=>(ee(e,r,{integer:!0}),ee(t,r,{integer:!0}),la(e,t)),arity:ae(2)},"chinese-remainder":{evaluate:([e,t],n)=>{if(Ze(e,n),Ze(t,n),e.length!==t.length)throw new r("Remainders and moduli must have the same length.",n);try{return function(e,t){for(let e=0;e<t.length;e++)for(let r=e+1;r<t.length;r++){const n=la(t[e],t[r])[0];if(1!==n)throw new Error(`Moduli must be pairwise coprime, but gcd(${t[e]}, ${t[r]}) = ${n}`)}const r=t.reduce((e,t)=>e*t,1);let n=0;for(let o=0;o<e.length;o++){const a=e[o],i=t[o],s=r/i;n=(n+a*s*ma(s,i))%r}return n}(e,t)}catch(e){throw new r(e.message,n)}},arity:ae(2)},"stirling-first":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0,positive:!0}),ee(t,r,{integer:!0,positive:!0,lte:e});const n=Array.from({length:e+1},()=>Array(t+1).fill(0));n[0][0]=1;for(let r=1;r<=e;r++)for(let e=1;e<=Math.min(r,t);e++)n[r][e]=n[r-1][e-1]+(r-1)*n[r-1][e];return n[e][t]},arity:ae(2)},"stirling-second":{evaluate:([e,t],r)=>{if(ee(e,r,{integer:!0,positive:!0}),ee(t,r,{integer:!0,positive:!0,lte:e}),1===t)return 1;if(t===e)return 1;const n=Array.from({length:e+1},()=>Array(t+1).fill(0));n[0][0]=1;for(let r=1;r<=e;r++)for(let e=1;e<=Math.min(r,t);e++)n[r][e]=e*n[r-1][e]+n[r-1][e-1];return n[e][t]},arity:ae(2)}};function pa(e){for(const[t,r]of Object.entries(e)){if(ua[t])throw new Error(`Duplicate normal expression key found: ${t}`);ua[t]=r}}!function(e){for(const[t,r]of Object.entries(e)){if(ua[t])throw new Error(`Duplicate normal expression key found: ${t}`);ua[t]=r}}(Xo),pa(po),pa(lo),pa(oo),pa(vo),pa(ho),pa(xo),pa(ao),pa(fo);for(const[e,t]of Object.entries(to))ua[e]&&(ua[e].docs=t);const ga={name:"number-theory",functions:ua},ha={"string-repeat":{evaluate:([e,t],r)=>(K(e,r),ee(t,r,{integer:!0,nonNegative:!0}),e.repeat(t)),arity:ae(2),docs:{category:"string",returns:{type:"number"},args:{a:{type:"string"},b:{type:"integer"},s:{type:"string"},n:{type:"integer"}},variants:[{argumentNames:["s","n"]}],description:"Repeates $s $n times.",seeAlso:["str","repeat"],examples:['let { string-repeat } = import(string);\n"*" string-repeat 10','let { string-repeat } = import(string);\nstring-repeat("*", 10)','let { string-repeat } = import(string);\nstring-repeat("***", 0)']}},"from-char-code":{evaluate:([e],t)=>{ee(e,t,{finite:!0});const n=ue(e);try{return String.fromCodePoint(n)}catch(e){throw new r(e,t)}},arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{code:{type:"number"}},variants:[{argumentNames:["code"]}],description:"Return character for code point $code.",seeAlso:["string.to-char-code"],examples:["let { from-char-code } = import(string);\nfrom-char-code(65)","let { from-char-code } = import(string);\nfrom-char-code(0)"]}},"to-char-code":{evaluate:([e],t)=>(K(e,t,{nonEmpty:!0}),f(e.codePointAt(0),t)),arity:ae(1),docs:{category:"string",returns:{type:"number"},args:{c:{type:"string"}},variants:[{argumentNames:["c"]}],description:"Return code point for first character in $c.",seeAlso:["string.from-char-code"],examples:['let { to-char-code } = import(string);\nto-char-code("A")','let { to-char-code } = import(string);\nto-char-code("Albert")']}},"trim-left":{evaluate:([e],t)=>(K(e,t),e.replace(/^\s+/,"")),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns a new string with leading whitespaces removed.",seeAlso:["trim","string.trim-right"],examples:['let { trim-left } = import(string);\ntrim-left(" Albert ")','let { trim-left } = import(string);\ntrim-left(" ")','let { trim-left } = import(string);\ntrim-left("")']}},"trim-right":{evaluate:([e],t)=>(K(e,t),e.replace(/\s+$/,"")),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns a new string with trailing whitespaces removed.",seeAlso:["trim","string.trim-left"],examples:['let { trim-right } = import(string);\ntrim-right(" Albert ")','let { trim-right } = import(string);\ntrim-right(" ")','let { trim-right } = import(string);\ntrim-right("")']}},"split-lines":{evaluate:([e],t)=>(K(e,t),e.split(/\r\n|\n|\r/).filter(e=>""!==e)),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Divides $s into an array of substrings, each representing a line.",seeAlso:["split"],examples:['let { split-lines } = import(string);\nsplit-lines("Albert\nMojir\n")','let { split-lines } = import(string);\nsplit-lines("Albert\n\nMojir")','let { split-lines } = import(string);\nsplit-lines("Albert\nMojir\n\n")','let { split-lines } = import(string);\nsplit-lines("")']}},"pad-left":{evaluate:([e,t,r],n)=>(K(e,n),ee(t,n,{integer:!0}),void 0!==r&&K(r,n),e.padStart(t,r)),arity:{min:2,max:3},docs:{category:"string",returns:{type:"string"},args:{a:{type:"string"},b:{type:"integer"},s:{type:"string"},length:{type:"integer"},padString:{type:"string"}},variants:[{argumentNames:["s","length"]},{argumentNames:["s","length","padString"]}],description:"Pads from the start of $s with `padString` (multiple times, if needed) until the resulting string reaches the given $length.",seeAlso:["string.pad-right"],examples:['let { pad-left } = import(string);\n"Albert" pad-left 20','let { pad-left } = import(string);\npad-left("Albert", 20)','let { pad-left } = import(string);\npad-left("Albert", 20, "-*-")','let { pad-left } = import(string);\npad-left("Albert", 5)','let { pad-left } = import(string);\npad-left("Albert", -1)']}},"pad-right":{evaluate:([e,t,r],n)=>(K(e,n),ee(t,n,{integer:!0}),void 0!==r&&K(r,n),e.padEnd(t,r)),arity:{min:2,max:3},docs:{category:"string",returns:{type:"string"},args:{a:{type:"string"},b:{type:"integer"},s:{type:"string"},length:{type:"integer"},padString:{type:"string"}},variants:[{argumentNames:["s","length"]},{argumentNames:["s","length","padString"]}],description:"Pads from the start of $s with `padString` (multiple times, if needed) until the resulting string reaches the given `length`.",seeAlso:["string.pad-left"],examples:['let { pad-right } = import(string);\n"Albert" pad-right 20','let { pad-right } = import(string);\npad-right("Albert", 20)','let { pad-right } = import(string);\npad-right("Albert", 20, "-*-")','let { pad-right } = import(string);\npad-right("Albert", 5)','let { pad-right } = import(string);\npad-right("Albert", -1)']}},template:{evaluate:([e,...t],r)=>{K(e,r),we(t,r);const n=e.split("||||");if(n.length<=1)return ya(n[0],t,r);{const e=t[0];ee(e,r,{integer:!0,nonNegative:!0});const o=[`${e}`,...t.slice(1)];if(2===n.length){return ya(n[1===e?0:1],o,r)}return ya(n[Math.min(e,n.length-1)],o,r)}},arity:{min:1,max:10},docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"},params:{type:"any",rest:!0}},variants:[{argumentNames:["s","params"]}],description:"Applies placeholders to a string. Support for basic pluralization - see examples. If pluralization is used, first placeholder must be a number.",seeAlso:["str"],examples:['let { template } = import(string);\ntemplate("Hi, $1 and $2", "Carl", "Larry")','let { template } = import(string);\ntemplate("Hi $1, $2, $3, $4, $5, $6, $7, $8 and $9", "A", "B", "C", "D", "E", "F", "G", "H", "I")','let { template } = import(string);\ntemplate("$1 book||||$1 books", 0)','let { template } = import(string);\ntemplate("$1 book||||$1 books", 1)','let { template } = import(string);\ntemplate("$1 book||||$1 books", 2)','let { template } = import(string);\ntemplate("No book||||$1 book||||$1 books", 0)','let { template } = import(string);\ntemplate("No book||||$1 book||||$1 books", 1)','let { template } = import(string);\ntemplate("No book||||$1 book||||$1 books", 10)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 0)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 1)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 2)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 3)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 4)'],hideOperatorForm:!0}},"encode-base64":{evaluate:([e],t)=>(K(e,t),btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16))))),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns a Base64 encoded string from $s.",seeAlso:["string.decode-base64"],examples:['let { encode-base64 } = import(string);\nencode-base64("Albert")']}},"decode-base64":{evaluate:([e],t)=>{K(e,t);try{return decodeURIComponent(Array.prototype.map.call(atob(e),e=>`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}catch(e){throw new r(e,t)}},arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{base64string:{type:"string"}},variants:[{argumentNames:["base64string"]}],description:"Returns a Base64 decoded string from $base64string.",seeAlso:["string.encode-base64"],examples:['let { decode-base64 } = import(string);\ndecode-base64("QWxiZXJ0IPCfkLs=")']}},"encode-uri-component":{evaluate:([e],t)=>(K(e,t),encodeURIComponent(e)),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns an escaped `URI` string.",seeAlso:["string.decode-uri-component"],examples:['let { encode-uri-component } = import(string);\nencode-uri-component("Hi everyone!?")']}},"decode-uri-component":{evaluate:([e],t)=>{K(e,t);try{return decodeURIComponent(e)}catch(e){throw new r(e,t)}},arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns an un-escaped `URI` string.",seeAlso:["string.encode-uri-component"],examples:['let { decode-uri-component } = import(string);\ndecode-uri-component("Hi%20everyone!%3F%20%F0%9F%91%8D")']}},capitalize:{evaluate:([e],t)=>(K(e,t),e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()),arity:ae(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns $s with the first character converted to uppercase and the rest to lowercase.",seeAlso:["lower-case","upper-case"],examples:['let { capitalize } = import(string);\ncapitalize("albert")','let { capitalize } = import(string);\ncapitalize("ALBERT")','let { capitalize } = import(string);\ncapitalize("aLBERT")','let { capitalize } = import(string);\ncapitalize("")']}}},da=/\$\$/g;function ya(e,t,r){for(let n=0;n<9;n+=1){const o=new RegExp(`(\\$\\$|[^$]|^)\\$${n+1}`,"g");if(o.test(e)){const a=H(t[n],r);e=e.replace(o,`$1${a}`)}}return e=e.replace(da,"$")}const va={name:"string",functions:ha};function fa(e,t){if(O(e)){if("string"==typeof t&&ce(e,t))return pe(e[t])}else if(Q(t,{nonNegative:!0,integer:!0})&&t>=0&&t<e.length)return pe(e[t])}function ba(e,t,r,n){if(W(e,n),Array.isArray(e)||"string"==typeof e){if(ee(t,n,{integer:!0}),ee(t,n,{gte:0}),ee(t,n,{lte:e.length}),"string"==typeof e)return K(r,n,{char:!0}),`${e.slice(0,t)}${r}${e.slice(t+1)}`;const o=[...e];return o[t]=r,o}K(t,n);const o={...e};return o[t]=r,o}function xa(e,t,r,n,o,a,i){if(O(e)){K(t,i);const s={...e};return Ae(a(r,[s[t],...n],o,i),e=>(s[t]=e,s))}{ee(t,i);const s=ue(t);if(ee(s,i,{lte:e.length}),Array.isArray(e))return Ae(Ne(Array.from({length:e.length+(s===e.length?1:0)}),(t,c)=>s===c?a(r,[e[c],...n],o,i):e[c]),e=>e);{const t=e.split("");return Ae(Ne(Array.from({length:t.length+(s===t.length?1:0)}),(e,c)=>s===c?Ae(a(r,[t[c],...n],o,i),e=>J(e,i,{char:!0})):t[c]),e=>e.join(""))}}}function wa(e,t,r){const n=he(e);return{coll:n,innerCollMeta:t.slice(0,t.length-1).reduce((e,t)=>{const n=e.coll;let o;return Array.isArray(n)?(ee(t,r),o=D(n[t],r)):(F(n,r),K(t,r),ce(e.coll,t)||(n[t]={}),o=D(n[t],r)),{coll:o,parent:n}},{coll:n,parent:{}})}}const ka={"get-in":{evaluate:(e,t)=>{let r=pe(e[0]);const n=e[1]??[],o=pe(e[2]);we(n,t);for(const e of n){if(X(e,t),!U(r))return o;{const t=fa(r,e);if(void 0===t)return o;r=t}}return r},arity:{min:2,max:3},docs:{category:"collection",returns:{type:"any"},args:{a:{type:"collection"},b:{type:"array"},"not-found":{type:"any"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","not-found"]}],description:"Returns the value in a nested collection, where $b is an array of keys. Returns $not-found if the key is not present. If $not-found is not set, `null` is returned.",seeAlso:["get","collection.assoc-in","collection.update-in"],examples:['\nlet cu = import(collection);\ncu.get-in(\n [[1, 2, 3], [4, { a: "Kalle" }, 6]],\n [1, 1, "a", 0]\n)','\nlet cu = import(collection);\ncu.get-in(\n [[1, 2, 3], [4, { a: "Kalle" }, 6]],\n [1, 1, "b", 0]\n)','\nlet cu = import(collection);\ncu.get-in(\n [[1, 2, 3], [4, { a: "Kalle" }, 6]],\n [1, 1, "b", 0],\n "Lisa"\n)']}},"assoc-in":{evaluate:([e,t,r],n)=>{if(W(e,n),we(t,n),C(r,n),1===t.length)return X(t[0],n),ba(e,t[0],r,n);const{coll:o,innerCollMeta:a}=wa(e,t,n),i=H(t[t.length-1],n),s=H(t[t.length-2],n);return Array.isArray(a.parent)?(ee(s,n),a.parent[s]=ba(a.coll,i,r,n)):(K(s,n),a.parent[s]=ba(a.coll,i,r,n)),o},arity:ae(3),docs:{category:"collection",returns:{type:"collection"},args:{coll:{type:"collection"},ks:{type:["number","string"],array:!0},value:{type:"any"}},variants:[{argumentNames:["coll","ks","value"]}],description:"\nAssociates a value in the nested collection $coll, where $ks is an array of keys and $value is the new value.\n\nIf any levels do not exist, objects will be created - and the corresponding keys must be of type string.",seeAlso:["assoc","collection.get-in","collection.update-in"],examples:['\nlet cu = import(collection);\ncu.assoc-in(\n {},\n ["a", "b", "c"],\n "Albert"\n)','\nlet cu = import(collection);\ncu.assoc-in(\n [1, 2, [1, 2, 3]],\n [2, 1],\n "Albert"\n)','\nlet cu = import(collection);\ncu.assoc-in(\n [1, 2, { name: "albert" }],\n [2, "name", 0],\n "A"\n)']}},update:{evaluate:([e,t,r,...n],o,a,{executeFunction:i})=>(W(e,o),X(t,o),L(r,o),xa(e,t,r,n,a,i,o)),arity:{min:3},docs:{category:"collection",returns:{type:"collection"},args:{coll:{type:"collection"},key:{type:["string","number"]},fun:{type:"function"},"fun-args":{type:"any",rest:!0}},variants:[{argumentNames:["coll","value","fun"]},{argumentNames:["coll","value","fun","fun-args"]}],description:"\nUpdates a value in the $coll collection, where $key is a key. $fun is a function\nthat will take the old value and any supplied $fun-args and\nreturn the new value.\nIf the key does not exist, `null` is passed as the old value.",seeAlso:["collection.update-in","assoc"],examples:['\nlet cu = import(collection);\nlet x = { a: 1, b: 2 };\ncu.update(x, "a", inc)','\nlet cu = import(collection);\nlet x = { a: 1, b: 2 };\ncu.update(\n x,\n "c",\n val -> null?(val) ? 0 : inc(val)\n)']}},"update-in":{evaluate:([e,t,r,...n],o,a,{executeFunction:i})=>{if(W(e,o),we(t,o),L(r,o),1===t.length)return X(t[0],o),xa(e,t[0],r,n,a,i,o);const{coll:s,innerCollMeta:c}=wa(e,t,o),l=H(t[t.length-1],o),m=H(t[t.length-2],o);return Array.isArray(c.parent)?(ee(m,o),Ae(xa(c.coll,l,r,n,a,i,o),e=>(c.parent[m]=e,s))):(K(m,o),Ae(xa(c.coll,l,r,n,a,i,o),e=>(c.parent[m]=e,s)))},arity:{min:3},docs:{category:"collection",returns:{type:"collection"},args:{coll:{type:"collection"},ks:{type:"array"},fun:{type:"function"},"fun-args":{type:"any",rest:!0}},variants:[{argumentNames:["coll","ks","fun"]},{argumentNames:["coll","ks","fun","fun-args"]}],description:"Updates a value in the $coll collection, where $ks is an array of\nkeys and $fun is a function that will take the old value and\nany supplied $fun-args and return the new value. If any levels do not exist,\nobjects will be created - and the corresponding keys must be of type string.",seeAlso:["collection.update","collection.assoc-in","collection.get-in"],examples:['\nlet cu = import(collection);\ncu.update-in(\n { a: [1, 2, 3] },\n ["a", 1],\n -> null?($) ? 0 : inc($)\n)','\nlet cu = import(collection);\ncu.update-in(\n { a: { foo: "bar"} },\n ["a", "foo"],\n -> null?($) ? "?" : "!"\n)','\nlet cu = import(collection);\ncu.update-in(\n { a: { foo: "bar"} },\n ["a", "baz"],\n -> null?($) ? "?" : "!"\n)','\nlet cu = import(collection);\ncu.update-in(\n { a: [1, 2, 3] },\n ["a", 1],\n *,\n 10,\n 10,\n 10,\n)']}},filteri:{evaluate:([e,t],r,n,{executeFunction:o})=>(W(e,r),L(t,r),Array.isArray(e)?Ie(e,(e,a)=>o(t,[e,a],n,r)):"string"==typeof e?Ae(Ie(e.split(""),(e,a)=>o(t,[e,a],n,r)),e=>e.join("")):Ae(Ie(Object.entries(e),([e,a])=>o(t,[a,e],n,r)),e=>e.reduce((e,[t,r])=>(e[t]=r,e),{}))),arity:ae(2),docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function",description:"The function to call for each element in the collection. The function should take two arguments: the element itself and the index."}},variants:[{argumentNames:["a","b"]}],description:"Creates a new collection with all elements that pass the test implemented by $b. The function is called for each element in the collection, and it should take two arguments: the element itself and the index.",seeAlso:["filter","collection.mapi"],examples:["let cu = import(collection); cu.filteri([1, 2, 3], (x, i) -> i % 2 == 0)","let cu = import(collection); cu.filteri([1, 2, 3], (x, i) -> x % 2 == 0)","let cu = import(collection); cu.filteri([1, 2, 3], (x, i) -> x + i > 3)"]}},mapi:{evaluate:([e,t],r,n,{executeFunction:o})=>{if(W(e,r),L(t,r),Array.isArray(e))return Ne(e,(e,a)=>o(t,[e,a],n,r));if("string"==typeof e)return Ae(Ne(e.split(""),(e,a)=>o(t,[e,a],n,r)),e=>e.join(""));return Te(Object.entries(e),(e,[a,i])=>Ae(o(t,[i,a],n,r),t=>(e[a]=t,e)),{})},arity:ae(2),docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function",description:"The function to call for each element in the collection. The function should take two arguments: the element itself and the index."}},variants:[{argumentNames:["a","b"]}],description:"Creates a new collection populated with the results of calling $b on every element in $a. The function is called for each element in the collection, and it should take two arguments: the element itself and the index.",seeAlso:["map","collection.filteri"],examples:["let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x + i)","let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x * i)","let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x - i)","let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x / i)","let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x % inc(i))"]}},reducei:{evaluate:([e,t,r],n,o,{executeFunction:a})=>(W(e,n),L(t,n),C(r,n),"string"==typeof e?(K(r,n),0===e.length?r:Te(e.split("").map((e,t)=>({elem:e,index:t})),(e,{elem:r,index:i})=>a(t,[e,r,i],o,n),r)):Array.isArray(e)?0===e.length?r:Te(e.map((e,t)=>({elem:e,index:t})),(e,{elem:r,index:i})=>a(t,[e,r,i],o,n),r):0===Object.keys(e).length?r:Te(Object.entries(e),(e,[r,i])=>a(t,[e,i,r],o,n),r)),arity:ae(3),docs:{category:"collection",returns:{type:"any"},args:{coll:{type:"collection"},fun:{type:"function",description:"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:{type:"any",description:"The initial value to use as the accumulator."}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Runs $fun function on each element of the $coll, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.",seeAlso:["reduce","collection.reducei-right","collection.reductionsi"],examples:["let cu = import(collection); cu.reducei([1, 2, 3], (acc, x, i) -> acc + x + i, 0)",'let cu = import(collection); cu.reducei("Albert", (acc, x, i) -> acc ++ x ++ i, "")','let cu = import(collection); cu.reducei({ a: 1, b: 2 }, -> $1 ++ $3, "")']}},"reduce-right":{evaluate:([e,t,r],n,o,{executeFunction:a})=>(W(e,n),L(t,n),C(r,n),"string"==typeof e?0===e.length?r:Te(Array.from(e.split("")).reverse(),(e,r)=>a(t,[e,r],o,n),r):Array.isArray(e)?0===e.length?r:Te(Array.from(e).reverse(),(e,r)=>a(t,[e,r],o,n),r):0===Object.keys(e).length?r:Te(Object.entries(e).reverse(),(e,[,r])=>a(t,[e,r],o,n),r)),arity:ae(3),docs:{category:"collection",returns:{type:"any"},args:{fun:{type:"function"},coll:{type:"collection"},initial:{type:"any"}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Runs $fun function on each element of the $coll (starting from the last item), passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value.",seeAlso:["reduce","collection.reducei-right"],examples:['let cu = import(collection); cu.reduce-right(["A", "B", "C"], str, "")',"let cu = import(collection); cu.reduce-right({ a: 1, b: 2 }, +, 0)"]}},"reducei-right":{evaluate:([e,t,r],n,o,{executeFunction:a})=>(W(e,n),L(t,n),C(r,n),"string"==typeof e?0===e.length?r:Te(Array.from(e.split("")).reverse().map((e,t,r)=>({elem:e,index:r.length-1-t})),(e,{elem:r,index:i})=>a(t,[e,r,i],o,n),r):Array.isArray(e)?0===e.length?r:Te(Array.from(e).reverse().map((e,t,r)=>({elem:e,index:r.length-1-t})),(e,{elem:r,index:i})=>a(t,[e,r,i],o,n),r):0===Object.keys(e).length?r:Te(Object.entries(e).reverse(),(e,[r,i])=>a(t,[e,i,r],o,n),r)),arity:ae(3),docs:{category:"collection",returns:{type:"any"},args:{coll:{type:"collection"},fun:{type:"function",description:"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:{type:"any",description:"The initial value to use as the accumulator."}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Runs $fun function on each element of the $coll (starting from the last item), passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.",seeAlso:["collection.reducei","collection.reduce-right"],examples:["let cu = import(collection); cu.reducei-right([1, 2, 3], (acc, x, i) -> acc + x + i, 0)",'let cu = import(collection); cu.reducei-right("Albert", (acc, x, i) -> acc ++ x ++ i, "")','let cu = import(collection); cu.reducei-right({ a: 1, b: 2 }, -> $1 ++ $3, "")']}},reductions:{evaluate:([e,t,r],n,o,{executeFunction:a})=>{W(e,n),L(t,n),C(r,n),C(r,n);const i="string"==typeof e?(K(r,n),0===e.length?[]:e.split("")):Array.isArray(e)?0===e.length?[]:Array.from(e):0===Object.keys(e).length?[]:Object.entries(e).map(([,e])=>e);if(0===i.length)return[r];const s=[r];return Ae(Te(i,(e,r)=>Ae(a(t,[e,r],o,n),e=>(s.push(e),e)),r),()=>s)},arity:ae(3),docs:{category:"collection",returns:{type:"any",array:!0},args:{fun:{type:"function"},coll:{type:"collection"},initial:{type:"any"}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Returns an array of the intermediate values of the reduction (see `reduce`) of $coll by $fun.",seeAlso:["reduce","collection.reductionsi"],examples:["let cu = import(collection); cu.reductions([1, 2, 3], +, 0)","let cu = import(collection); cu.reductions([1, 2, 3], +, 10)","let cu = import(collection); cu.reductions([], +, 0)","let cu = import(collection); cu.reductions({ a: 1, b: 2 }, +, 0)","\nlet cu = import(collection);\ncu.reductions(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + (even?(value) ? value : 0),\n 0\n)"]}},reductionsi:{evaluate:([e,t,r],n,o,{executeFunction:a})=>{W(e,n),L(t,n),C(r,n),C(r,n);const i=(e,t)=>({elem:e,key:t}),s="string"==typeof e?(K(r,n),0===e.length?[]:e.split("").map((e,t)=>i(e,t))):Array.isArray(e)?0===e.length?[]:e.map((e,t)=>i(e,t)):0===Object.keys(e).length?[]:Object.entries(e).map(([e,t])=>i(t,e));if(0===s.length)return[r];const c=[r];return Ae(Te(s,(e,{elem:r,key:i})=>Ae(a(t,[e,r,i],o,n),e=>(c.push(e),e)),r),()=>c)},arity:ae(3),docs:{category:"collection",returns:{type:"any",array:!0},args:{coll:{type:"collection"},fun:{type:"function",description:"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:{type:"any",description:"The initial value to use as the accumulator."}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Returns an array of the intermediate values of the reduction (see `reduce`) of $coll by $fun. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.",seeAlso:["collection.reductions","collection.reducei"],examples:["let cu = import(collection); cu.reductionsi([1, 2, 3], (acc, x, i) -> acc + x + i, 0)",'let cu = import(collection); cu.reductionsi("Albert", (acc, x, i) -> acc ++ x ++ i, "")','let cu = import(collection); cu.reductionsi({ a: 1, b: 2 }, -> $1 ++ $3, "")']}},"not-empty":{evaluate:([e],t)=>null===e?null:(W(e,t),"string"==typeof e||Array.isArray(e)?e.length>0?e:null:Object.keys(e).length>0?e:null),arity:ae(1),docs:{category:"collection",returns:{type:"boolean"},args:{coll:{type:["collection","null"]}},variants:[{argumentNames:["coll"]}],description:"Returns `null` if $coll is empty or `null`, otherwise $coll.",seeAlso:["empty?","not-empty?"],examples:["let cu = import(collection); cu.not-empty([])","let cu = import(collection); cu.not-empty([1, 2, 3])","let cu = import(collection); cu.not-empty({})","let cu = import(collection); cu.not-empty({ a: 2 })",'let cu = import(collection); cu.not-empty("")','let cu = import(collection); cu.not-empty("Albert")',"let cu = import(collection); cu.not-empty(null)"]}},"every?":{evaluate:([e,t],r,n,{executeFunction:o})=>{W(e,r),L(t,r);return Pe(Array.isArray(e)?e:"string"==typeof e?e.split(""):Object.entries(e),e=>o(t,[e],n,r))},arity:ae(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:"collection"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns `true` if all entries in $a pass the test implemented by $b, otherwise returns `false`.",seeAlso:["collection.any?","collection.not-every?","collection.not-any?","functional.every-pred","grid.cell-every?"],examples:["let cu = import(collection); cu.every?([1, 2, 3], number?)","let cu = import(collection); cu.every?([1, 2, 3], even?)",'\nlet cu = import(collection);\ncu.every?(\n ["Albert", "Mojir", 160, [1, 2]],\n string?,\n)',"\nlet cu = import(collection);\ncu.every?(\n [50, 100, 150, 200],\n -> $ > 10,\n)","let cu = import(collection); cu.every?([], number?)",'let cu = import(collection); cu.every?("", number?)',"let cu = import(collection); cu.every?({}, number?)","\nlet cu = import(collection);\ncu.every?(\n { a: 2, b: 4},\n -> even?(second($))\n)","\nlet cu = import(collection);\ncu.every?(\n { a: 2, b: 3 },\n -> even?(second($))\n)"]}},"any?":{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),W(e,r);return Me(Array.isArray(e)?e:"string"==typeof e?e.split(""):Object.entries(e),e=>o(t,[e],n,r))},arity:ae(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:"collection"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns `true` if any element in $a pass the test implemented by $b, otherwise returns `false`.",seeAlso:["collection.every?","collection.not-any?","collection.not-every?","functional.some-pred","some","grid.some?"],examples:['\nlet cu = import(collection);\ncu.any?(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nlet cu = import(collection);\ncu.any?(\n [50, 100, 150, 200],\n x -> x > 10\n)","let cu = import(collection); cu.any?([], number?)",'let cu = import(collection); cu.any?("", number?)',"let cu = import(collection); cu.any?({}, number?)","\nlet cu = import(collection);\ncu.any?(\n { a: 2, b: 3 },\n -> even?(second($))\n)","\nlet cu = import(collection);\ncu.any?(\n { a: 1, b: 3 },\n -> even?(second($))\n)"]}},"not-any?":{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),W(e,r);return Ae(Me(Array.isArray(e)?e:"string"==typeof e?e.split(""):Object.entries(e),e=>o(t,[e],n,r)),e=>!e)},arity:ae(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:"collection"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns `false` if any element in $a pass the test implemented by $b, otherwise returns `true`.",seeAlso:["collection.any?","collection.every?","collection.not-every?"],examples:['\nlet cu = import(collection);\ncu.not-any?(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nlet cu = import(collection);\ncu.not-any?(\n [50, 100, 150, 200],\n x -> x > 10\n)","let cu = import(collection); cu.not-any?([], number?)",'let cu = import(collection); cu.not-any?("", number?)',"let cu = import(collection); cu.not-any?({}, number?)","\nlet cu = import(collection);\ncu.not-any?(\n { a: 2, b: 3 },\n -> even?(second($))\n)","\nlet cu = import(collection);\ncu.not-any?(\n { a: 1, b: 3 },\n -> even?(second($))\n)"]}},"not-every?":{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),W(e,r);return Ae(Pe(Array.isArray(e)?e:"string"==typeof e?e.split(""):Object.entries(e),e=>o(t,[e],n,r)),e=>!e)},arity:ae(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:"collection"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns `true` if at least one element in $a does not pass the test implemented by $b, otherwise returns `false`.",seeAlso:["collection.every?","collection.any?","collection.not-any?"],examples:['\nlet cu = import(collection);\ncu.not-every?(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nlet cu = import(collection);\ncu.not-every?(\n [50, 100, 150, 200],\n x -> x > 10\n)","let cu = import(collection); cu.not-every?([], number?)",'let cu = import(collection); cu.not-every?("", number?)',"let cu = import(collection); cu.not-every?({}, number?)","\nlet cu = import(collection);\ncu.not-every?(\n { a: 2, b: 4 },\n -> even?(second($))\n)","\nlet cu = import(collection);\ncu.not-every?(\n { a: 2, b: 3 },\n -> even?(second($))\n)"]}}},qa={name:"collection",functions:ka},Aa={position:{evaluate:([e,t],r,n,{executeFunction:o})=>{if(L(t,r),null===e)return null;I(e,r);return Ae(Fe("string"==typeof e?e.split(""):e,e=>o(t,[e],n,r)),e=>-1!==e?e:null)},arity:ae(2),docs:{category:"sequence",returns:{type:["number","null"]},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:["sequence","null"]},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns the index of the first elements that passes the test implemented by $fun. If no element was found, `null` is returned.",seeAlso:["index-of","some","find"],examples:['\nlet su = import(sequence);\nsu.position(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nlet su = import(sequence);\nsu.position(\n [5, 10, 15, 20],\n -> $ > 10\n)","\nlet su = import(sequence);\nsu.position(\n [5, 10, 15, 20],\n -> $ > 100\n)","\nlet su = import(sequence);\nsu.position(\n null,\n -> $ > 100\n)"]}},"last-index-of":{evaluate:([e,t],r)=>{if(C(t,r),null===e)return null;if(I(e,r),"string"==typeof e){K(t,r);const n=e.lastIndexOf(t);return-1!==n?n:null}{const n=e.findLastIndex(e=>me(M(e,r),t),r);return-1!==n?n:null}},arity:ae(2),docs:{category:"sequence",returns:{type:["number","null"]},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:["sequence","null"]},x:{type:"any"}},variants:[{argumentNames:["seq","x"]}],description:"Returns the last index of $x in $seq. If element is not present in $seq `null` is returned.",seeAlso:["index-of"],examples:["let su = import(sequence); su.last-index-of([[1], [2], [1], [2]], [1])",'let su = import(sequence); su.last-index-of(["Albert", "Mojir", 160, [1, 2]], "Mojir")',"let su = import(sequence); su.last-index-of([5, 10, 15, 20, 15], 15)","let su = import(sequence); su.last-index-of([5, 10, 15, 20], 1)","let su = import(sequence); su.last-index-of(null, 1)"]}},splice:{evaluate:(e,t)=>{const[r,n,o,...a]=e;I(r,t),ee(n,t,{integer:!0}),ee(o,t,{integer:!0,nonNegative:!0});const i=n<0?r.length+n:n;return Array.isArray(r)?[...r.slice(0,i),...a,...r.slice(i+o)]:(a.forEach(e=>K(e,t)),`${r.substring(0,i)}${a.join("")}${r.substring(i+o)}`)},arity:{min:3},docs:{category:"sequence",returns:{type:"sequence"},args:{seq:{type:"sequence",rest:!0},start:{type:"integer"},deleteCount:{type:"integer"},items:{type:"any",rest:!0}},variants:[{argumentNames:["seq","start","deleteCount"]},{argumentNames:["seq","start","deleteCount","items"]}],description:"Returns a a spliced array. Removes $deleteCount elements from $seq starting at $start and replaces them with $items. If $start is negative, it is counting from the end of the array.",seeAlso:["slice","sequence.remove-at"],examples:['let su = import(sequence); su.splice([1, 2, 3, 4, 5], 2, 2, "x")','let su = import(sequence); su.splice([1, 2, 3, 4, 5], -2, 1, "x")','let su = import(sequence); su.splice("Albert", 2, 2, "fo")']}},"sort-by":{evaluate:(e,t,r,{executeFunction:n})=>{const[o,a]=e,i=2===e.length;I(o,t),L(a,t);const s=i?null:e[2],c="string"==typeof o,l=c?o.split(""):[...o];return Ae(Ne(l,e=>n(a,[e],r,t)),e=>{if(i){const r=l.map((t,r)=>({elem:t,key:e[r]}));r.sort((e,r)=>(X(e.key,t),X(r.key,t),le(e.key,r.key,t)));const n=r.map(e=>e.elem);return c?n.join(""):n}{L(s,t);const o=l.map((t,r)=>({elem:t,key:e[r]}));o.sort((e,o)=>{const a=n(s,[e.key,o.key],r,t);if(a instanceof Promise)throw new TypeError("Async functions cannot be used as sort-by comparators");return ee(a,t,{finite:!0}),a});const a=o.map(e=>e.elem);return c?a.join(""):a}})},arity:{min:2,max:3},docs:{category:"sequence",returns:{type:"any",rest:!0},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},keyfn:{type:"function"},comparer:{type:"function"}},variants:[{argumentNames:["seq","keyfn"]},{argumentNames:["seq","keyfn","comparer"]}],description:"Returns a sorted sequence of the items in $seq, where the sort order is determined by comparing `(keyfn item)`. If no $comparer is supplied, uses builtin `compare`.",seeAlso:["sort","compare"],examples:['let su = import(sequence); su.sort-by(["Albert", "Mojir", "Nina"], count)','let su = import(sequence); su.sort-by(["Albert", "Mojir", "Nina"], count)','let su = import(sequence); su.sort-by("Albert", lower-case, -> $2 compare $1)']}},unshift:{evaluate:([e,...t],r)=>{if(I(e,r),"string"==typeof e)return qe(t,r),[...t,e].join("");const n=[...e];return n.unshift(...t),n},arity:{min:2},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:"sequence"},values:{type:"any",rest:!0}},variants:[{argumentNames:["seq","values"]}],description:"Returns copy of $seq with $values added to the beginning.",seeAlso:["push","++"],examples:["let su = import(sequence); su.unshift([1, 2, 3], 4)","let su = import(sequence); su.unshift([1, 2, 3], 4)","let su = import(sequence); su.unshift([1, 2, 3], 4, 5, 6)","\nlet su = import(sequence);\nlet l = [1, 2, 3];\nsu.unshift(l, 4);\nl"]}},distinct:{evaluate:([e],t)=>{if(I(e,t),Array.isArray(e)){const r=[];for(const n of e)C(n,t),r.some(e=>me(e,n,t))||r.push(n);return r}return Array.from(new Set(e.split(""))).join("")},arity:ae(1),docs:{category:"sequence",returns:{type:"sequence"},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"Returns a copy of $seq with no duplicates.",seeAlso:["sequence.frequencies"],examples:["let su = import(sequence); su.distinct([[1], [2], [3], [1], [3], [5]])","let su = import(sequence); su.distinct([1, 2, 3, 1, 3, 5])",'let su = import(sequence); su.distinct("Albert Mojir")',"let su = import(sequence); su.distinct([])",'let su = import(sequence); su.distinct("")']}},remove:{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),I(e,r);return Ae(Ie(Array.isArray(e)?e:e.split(""),e=>Ae(o(t,[e],n,r),e=>!e)),t=>"string"==typeof e?t.join(""):t)},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns a new sequence of items in $seq for witch `pred(item)` returns a falsy value.",seeAlso:["filter","sequence.remove-at"],examples:["let su = import(sequence); su.remove([1, 2, 3, 1, 3, 5], odd?)","let su = import(sequence); su.remove([1, 2, 3, 1, 3, 5], even?)",'let su = import(sequence); su.remove("Albert Mojir", -> "aoueiyAOUEIY" contains? $)']}},"remove-at":{evaluate:([e,t],r)=>{ee(t,r,{integer:!0}),I(e,r);const n=t<0?e.length+t:t;return n<0||n>=e.length?e:Array.isArray(e)?e.filter((e,t)=>t!==n):`${e.substring(0,n)}${e.substring(n+1)}`},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence"},n:{type:"number"}},variants:[{argumentNames:["seq","n"]}],description:"Returns a new sequence of all items in $seq except item at position $n. If $n is negative, it is counting from the end of the sequence.",seeAlso:["sequence.remove","sequence.splice"],examples:["let su = import(sequence); su.remove-at([1, 2, 3, 1, 3, 5], 2)",'let su = import(sequence); su.remove-at("Albert", -2)',"let su = import(sequence); su.remove-at([1, 2, 3, 1, 3, 5], 0)","let su = import(sequence); su.remove-at([1, 2, 3, 1, 3, 5], -1)",'let su = import(sequence); su.remove-at("Albert Mojir", 6)']}},"split-at":{evaluate:([e,t],r)=>{ee(t,r,{integer:!0}),I(e,r);const n=t<0?e.length+t:t;return[e.slice(0,n),e.slice(n)]},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence"},n:{type:"number"}},variants:[{argumentNames:["seq","n"]}],description:"Returns a pair of sequence `[take(pos input), drop(pos input)]`.",seeAlso:["sequence.split-with","take","drop"],examples:["let su = import(sequence); su.split-at([1, 2, 3, 4, 5], 2)",'let su = import(sequence); su.split-at("Albert", -2)',"let su = import(sequence); su.split-at([1, 2, 3, 4, 5], -2)",'let su = import(sequence); su.split-at("Albert", 2)']}},"split-with":{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),I(e,r);const a=Array.isArray(e);return Ae(Fe(a?e:e.split(""),e=>Ae(o(t,[e],n,r),e=>!e)),t=>-1===t?[e,a?[]:""]:[e.slice(0,t),e.slice(t)])},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns a pair of sequences `[take-while(input, fun), drop-while(input, fun)]`.",seeAlso:["sequence.split-at","take-while","drop-while"],examples:["let su = import(sequence); su.split-with([1, 2, 3, 4, 5], odd?)","let su = import(sequence); su.split-with([1, 2, 3, 4, 5], -> $ > 3)",'let su = import(sequence); su.split-with("Albert", -> $ <= "o")']}},frequencies:{evaluate:([e],t)=>{I(e,t);return("string"==typeof e?e.split(""):e).reduce((e,r)=>(K(r,t),ce(e,r)?e[r]=e[r]+1:e[r]=1,e),{})},arity:ae(1),docs:{category:"sequence",returns:{type:"object"},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"Returns an object from distinct items in $seq to the number of times they appear. Note that all items in $seq must be valid object keys i.e. strings.",seeAlso:["sequence.group-by","sequence.distinct","vector.count-values"],examples:['let su = import(sequence); su.frequencies(["Albert", "Mojir", "Nina", "Mojir"])','let su = import(sequence); su.frequencies("Pneumonoultramicroscopicsilicovolcanoconiosis")']}},"group-by":{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),I(e,r);return Te(Array.isArray(e)?e:e.split(""),(e,a)=>Ae(o(t,[a],n,r),t=>(K(t,r),ce(e,t)||(e[t]=[]),e[t].push(a),e)),{})},arity:ae(2),docs:{category:"sequence",returns:{type:"object"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns an object of the elements of $seq keyed by the result of $fun on each element. The value at each key will be an array of the corresponding elements.",seeAlso:["sequence.frequencies","sequence.partition-by"],examples:['let su = import(sequence); su.group-by([{ name: "Albert" }, { name: "Albert" }, { name: "Mojir" }], "name")','let su = import(sequence); su.group-by([{name: "Albert"}, {name: "Albert"}, {name: "Mojir"}], "name")','let su = import(sequence); su.group-by("Albert Mojir", -> "aoueiAOUEI" contains? $ ? "vowel" : "other")']}},partition:{evaluate:(e,t)=>{const r=R(e[0],t),n=ue(te(e[1],t)),o=e.length>=3?ue(te(e[2],t)):n,a=4===e.length?null===e[3]?[]:function(e,t){return we(e,t),e}(e[3],t):void 0;return Na(n,o,r,a,t)},arity:{min:2,max:4},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"number"},seq:{type:"sequence"},n:{type:"number"},step:{type:"number"},pad:{type:"array"}},variants:[{argumentNames:["seq","n"]},{argumentNames:["seq","n","step"]},{argumentNames:["seq","n","step","pad"]}],description:"Returns an array of sequences of $n items each, at offsets $step apart. If $step is not supplied, defaults to $n. If a $pad array is supplied, use its elements as necessary to complete last partition upto $n items. In case there are not enough padding elements, return a partition with less than $n items.",seeAlso:["sequence.partition-all","sequence.partition-by"],examples:["let su = import(sequence); su.partition(range(20), 4)","let su = import(sequence); su.partition(range(20), 4)","let su = import(sequence); su.partition(range(22), 4)","let su = import(sequence); su.partition(range(20), 4, 6)","let su = import(sequence); su.partition(range(20), 4, 3)",'let su = import(sequence); su.partition(range(20), 3, 6, ["a"])','let su = import(sequence); su.partition(range(20), 4, 6, ["a"])','let su = import(sequence); su.partition(range(20), 4, 6, ["a", "b", "c", "d"])','let su = import(sequence); su.partition(["a", "b", "c", "d", "e", "f"], 3, 1)',"let su = import(sequence); su.partition([1, 2, 3, 4], 10)","let su = import(sequence); su.partition([1, 2, 3, 4], 10, 10)","let su = import(sequence); su.partition([1, 2, 3, 4], 10, 10, [])","let su = import(sequence); su.partition([1, 2, 3, 4], 10, 10, null)",'let su = import(sequence); su.partition("superfragilistic", 5)','let su = import(sequence); su.partition("superfragilistic", 5, 5, null)',"let su = import(sequence); let foo = [5, 6, 7, 8]; su.partition(foo, 2, 1, foo)"]}},"partition-all":{evaluate:(e,t)=>{const r=R(e[0],t),n=ue(te(e[1],t));return Na(n,3===e.length?ue(te(e[2],t)):n,r,[],t)},arity:{min:2,max:3},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"number"},seq:{type:"sequence"},n:{type:"number"},step:{type:"number"}},variants:[{argumentNames:["seq","n"]},{argumentNames:["seq","n","step"]}],description:"Returns an array of sequences like partition, but may include partitions with fewer than n items at the end.",seeAlso:["sequence.partition","sequence.partition-by"],examples:["let su = import(sequence); su.partition-all([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 4)","let su = import(sequence); su.partition-all([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 4)","let su = import(sequence); su.partition([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 4)","let su = import(sequence); su.partition-all([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 2, 4)"]}},"partition-by":{evaluate:([e,t],r,n,{executeFunction:o})=>{L(t,r),I(e,r);const a="string"==typeof e;return Ae(Te(a?e.split(""):e,(e,a)=>Ae(o(t,[a],n,r),t=>(t!==e.oldValue&&(e.result.push([]),e.oldValue=t),e.result[e.result.length-1].push(a),e)),{result:[],oldValue:void 0}),({result:e})=>a?e.map(e=>e.join("")):e)},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Applies $fun to each value in $seq, splitting it each time $fun returns a new value. Returns an array of sequences.",seeAlso:["sequence.partition","sequence.partition-all","sequence.group-by"],examples:["let su = import(sequence); su.partition-by([1, 2, 3, 4, 5], odd?)","let su = import(sequence); su.partition-by([1, 2, 3, 4, 5], -> $ == 3)","let su = import(sequence); su.partition-by([1, 1, 1, 2, 2, 3, 3], odd?)",'let su = import(sequence); su.partition-by("Leeeeeerrroyyy", identity)']}},"ends-with?":{evaluate:([e,t],r)=>(I(e,r),"string"==typeof e?(K(t,r),e.endsWith(t)):me(M(e.at(-1),r),M(t,r),r)),arity:ae(2),docs:{category:"sequence",returns:{type:"boolean"},args:{a:{type:"sequence"},b:{type:"sequence"},seq:{type:"sequence"},suffix:{type:"sequence"}},variants:[{argumentNames:["seq","suffix"]}],description:"Returns `true` if $seq ends with $suffix, otherwise `false`.",seeAlso:["sequence.starts-with?"],examples:["let su = import(sequence); su.ends-with?([[1], [2], [3], [4], [5]], [5])","let su = import(sequence); su.ends-with?([[1], [2], [3], [4], [5]], 5)","let su = import(sequence); su.ends-with?([1, 2, 3, 4, 5], 5)","let su = import(sequence); su.ends-with?([1, 2, 3, 4, 5], [5])",'let su = import(sequence); su.ends-with?("Albert", "rt")','let su = import(sequence); su.ends-with?("Albert", "RT")']}},"starts-with?":{evaluate:([e,t],r)=>(I(e,r),"string"==typeof e?(K(t,r),e.startsWith(t)):me(M(e[0],r),M(t,r),r)),arity:ae(2),docs:{category:"sequence",returns:{type:"boolean"},args:{a:{type:"sequence"},b:{type:"sequence"},seq:{type:"sequence"},prefix:{type:"sequence"}},variants:[{argumentNames:["seq","prefix"]}],description:"Returns `true` if $seq starts with $prefix, otherwise `false`.",seeAlso:["sequence.ends-with?"],examples:["let su = import(sequence); su.starts-with?([[1], [2], [3], [4], [5]], [1])","let su = import(sequence); su.starts-with?([1, 2, 3, 4, 5], 1)","let su = import(sequence); su.starts-with?([1, 2, 3, 4, 5], [1])",'let su = import(sequence); su.starts-with?("Albert", "Al")','let su = import(sequence); su.starts-with?("Albert", "al")']}},interleave:{evaluate:([...e],t)=>{const r="string"==typeof e[0],n=r?e.map(e=>(K(e,t),e.split(""))):e.map(e=>(we(e,t),e)),o=Math.min(...n.map(e=>e.length)),a=[];for(let e=0;e<o;e+=1)for(const t of n)e<t.length&&a.push(t[e]);return r?a.join(""):a},arity:{min:1},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"sequence"},seqs:{type:"sequence",rest:!0}},variants:[{argumentNames:["seqs"]}],description:"Returns a sequence of the first item from each of the $seqs, then the second item from each of the $seqs, until all items from the shortest seq are exhausted.",seeAlso:["sequence.interpose","zipmap"],examples:["let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6])",'let su = import(sequence); su.interleave("Albert", ".,.,.,")',"let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6])","let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [7, 8, 9])","let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [7, 8])","let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [7])","let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [])","let su = import(sequence); su.interleave([1, 2, 3], [])","let su = import(sequence); su.interleave([])"]}},interpose:{evaluate:([e,t],r)=>{if(I(e,r),"string"==typeof e)return K(t,r),e.split("").join(t);if(0===e.length)return[];const n=[];for(let r=0;r<e.length-1;r+=1)n.push(e[r],t);return n.push(e[e.length-1]),n},arity:ae(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:"sequence"},separator:{type:"any"}},variants:[{argumentNames:["seq","separator"]}],description:"Returns a sequence of the elements of $seq separated by $separator. If $seq is a string, the separator must be a string.",seeAlso:["sequence.interleave","join"],examples:['let su = import(sequence); su.interpose("Albert", "-")','let su = import(sequence); su.interpose([1, 2, 3, 4, 5], "a")','let su = import(sequence); su.interpose(["Albert", "Mojir", "Nina"], ", ")','let su = import(sequence); su.interpose("Albert", ".")']}}};function Na(e,t,r,n,o){ee(t,o,{positive:!0});const a="string"==typeof r,i=[];let s=0;e:for(;s<r.length;){const o=[];for(let a=s;a<s+e;a+=1)if(a>=r.length){const e=a-r.length;if(!n){s+=t;continue e}if(e>=n.length)break;o.push(n[e])}else o.push(r[a]);i.push(o),s+=t}return a?i.map(e=>e.join("")):i}const $a={name:"sequence",functions:Aa};function Ta(e){return([t],n)=>{const[o,a]=function(e,t){if(Xe(e))return["vector",e];if(ot(e))return["matrix",e];if(!Q(e))throw new r("Invalid parameter type: "+typeof e,t);return["number",e]}(t,n);return"number"===o?e(a):"vector"===o?a.map(t=>e(t)):a.map(t=>t.map(t=>e(t)))}}const za={name:"math",functions:{sin:{evaluate:Ta(e=>Math.sin(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `sin` function computes the sine of an angle (in radians), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the sine of each element while preserving the original structure.",seeAlso:["math.asin","math.sinh","math.cos","math.tan","math.to-rad"],examples:["let { sin } = import(math);\nsin(0)","let { sin } = import(math);\nsin(1)","let { sin } = import(math);\nsin(PI)","let { sin } = import(math);\nsin(-0.5)","let { sin } = import(math);\nsin([1, 2, 3])","let { sin } = import(math);\nsin([[1, 2], [3, 4]])"]}},asin:{evaluate:Ta(e=>Math.asin(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `asin` function computes the arcsine (inverse sine) of a `number` in radians, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the arcsine of each element while preserving the original structure.",seeAlso:["math.sin","math.asinh","math.acos","math.atan"],examples:["let { asin } = import(math);\nasin(0)","let { asin } = import(math);\nasin(1)","let { asin } = import(math);\nasin(-0.5)","let { asin } = import(math);\nasin([1, 2, 3])","let { asin } = import(math);\nasin([[1, 2], [3, 4]])"]}},sinh:{evaluate:Ta(e=>Math.sinh(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `sinh` function computes the hyperbolic sine of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the hyperbolic sine of each element while preserving the original structure.",seeAlso:["math.asinh","math.sin","math.cosh","math.tanh"],examples:["let { sinh } = import(math);\nsinh(0)","let { sinh } = import(math);\nsinh(1)","let { sinh } = import(math);\nsinh(-0.5)","let { sinh } = import(math);\nsinh([0.1, 0.2, 0.3])","let { sinh } = import(math);\nsinh([[0.1, 0.2], [0.3, 0.4]])"]}},asinh:{evaluate:Ta(e=>Math.asinh(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `asinh` function computes the inverse hyperbolic sine of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the inverse hyperbolic sine of each element while preserving the original structure.",seeAlso:["math.sinh","math.asin","math.acosh","math.atanh"],examples:["let { asinh } = import(math);\nasinh(10)","let { asinh } = import(math);\nasinh(90)","let { asinh } = import(math);\nasinh(50)","let { asinh } = import(math);\nasinh([10, 20, 30])","let { asinh } = import(math);\nasinh([[10, 20], [30, 40]])"]}},cos:{evaluate:Ta(e=>Math.cos(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `cos` function computes the cosine of an angle (in radians), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the cosine of each element while preserving the original structure.",seeAlso:["math.acos","math.cosh","math.sin","math.tan","math.to-rad"],examples:["let { cos } = import(math);\ncos(0)","let { cos } = import(math);\ncos(1)","let { cos } = import(math);\ncos(PI)","let { cos } = import(math);\ncos(-0.5)","let { cos } = import(math);\ncos([1, 2, 3])","let { cos } = import(math);\ncos([[1, 2], [3, 4]])"]}},acos:{evaluate:Ta(e=>Math.acos(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `acos` function computes the arccosine (inverse cosine) of a `number` in radians, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the arccosine of each element while preserving the original structure.",seeAlso:["math.cos","math.acosh","math.asin","math.atan"],examples:["let { acos } = import(math);\nacos(0)","let { acos } = import(math);\nacos(1)","let { acos } = import(math);\nacos(-0.5)","let { acos } = import(math);\nacos([0.1, 0.2, 0.3])","let { acos } = import(math);\nacos([[0.1, 0.2], [0.3, 0.4]])"]}},cosh:{evaluate:Ta(e=>Math.cosh(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `cosh` function computes the hyperbolic cosine of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the hyperbolic cosine of each element while preserving the original structure.",seeAlso:["math.acosh","math.cos","math.sinh","math.tanh"],examples:["let { cosh } = import(math);\ncosh(0)","let { cosh } = import(math);\ncosh(1)","let { cosh } = import(math);\ncosh(-0.5)","let { cosh } = import(math);\ncosh([0.1, 0.2, 0.3])","let { cosh } = import(math);\ncosh([[0.1, 0.2], [0.3, 0.4]])"]}},acosh:{evaluate:Ta(e=>Math.acosh(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `acosh` function computes the inverse hyperbolic cosine of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the inverse hyperbolic cosine of each element while preserving the original structure.",seeAlso:["math.cosh","math.acos","math.asinh","math.atanh"],examples:["let { acosh } = import(math);\nacosh(1)","let { acosh } = import(math);\nacosh(2)","let { acosh } = import(math);\nacosh(100)","let { acosh } = import(math);\nacosh(50)","let { acosh } = import(math);\nacosh([1, 2, 3])","let { acosh } = import(math);\nacosh([[1, 2], [3, 4]])"]}},tan:{evaluate:Ta(e=>Math.tan(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `tan` function computes the tangent of an angle (in radians), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the tangent of each element while preserving the original structure.",seeAlso:["math.atan","math.tanh","math.sin","math.cos","math.to-rad"],examples:["let { tan } = import(math);\ntan(0)","let { tan } = import(math);\ntan(1)","let { tan } = import(math);\ntan(PI)","let { tan } = import(math);\ntan(-0.5)","let { tan } = import(math);\ntan([1, 2, 3])","let { tan } = import(math);\ntan([[1, 2], [3, 4]])"]}},atan:{evaluate:Ta(e=>Math.atan(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `atan` function computes the arctangent (inverse tangent) of a `number` in radians, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the arctangent of each element while preserving the original structure.",seeAlso:["math.tan","math.atanh","math.asin","math.acos"],examples:["let { atan } = import(math);\natan(0)","let { atan } = import(math);\natan(1)","let { atan } = import(math);\natan(-0.5)","let { atan } = import(math);\natan([0.1, 0.2, 0.3])","let { atan } = import(math);\natan([[0.1, 0.2], [0.3, 0.4]])"]}},tanh:{evaluate:Ta(e=>Math.tanh(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `tanh` function computes the hyperbolic tangent of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the hyperbolic tangent of each element while preserving the original structure.",seeAlso:["math.atanh","math.tan","math.sinh","math.cosh"],examples:["let { tanh } = import(math);\ntanh(0)","let { tanh } = import(math);\ntanh(1)","let { tanh } = import(math);\ntanh(-0.5)","let { tanh } = import(math);\ntanh(50)"]}},atanh:{evaluate:Ta(e=>Math.atanh(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `atanh` function computes the inverse hyperbolic tangent of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the inverse hyperbolic tangent of each element while preserving the original structure.",seeAlso:["math.tanh","math.atan","math.asinh","math.acosh"],examples:["let { atanh } = import(math);\natanh(0)","let { atanh } = import(math);\natanh(0.9)","let { atanh } = import(math);\natanh(-0.5)","let { atanh } = import(math);\natanh([0.1, 0.2, 0.3])","let { atanh } = import(math);\natanh([[0.1, 0.2], [0.3, 0.4]])"]}},ln:{evaluate:Ta(e=>Math.log(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `ln` function computes the natural logarithm (base `e`) of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the natural logarithm of each element while preserving the original structure.",seeAlso:["math.log2","math.log10","^"],examples:["let { ln } = import(math);\nln(0.01)","let { ln } = import(math);\nln(2.5)","let { ln } = import(math);\nln(E)","let { ln } = import(math);\nln([1, 2, 3])","let { ln } = import(math);\nln([[1, 2], [3, 4]])"]}},log2:{evaluate:Ta(e=>Math.log2(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `log2` function computes the base `2` logarithm of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the base-2 logarithm of each element while preserving the original structure.",seeAlso:["math.ln","math.log10"],examples:["let { log2 } = import(math);\nlog2(0.01)","let { log2 } = import(math);\nlog2(2 ^ 12)","let { log2 } = import(math);\nlog2(2.5)","let { log2 } = import(math);\nlog2([1, 2, 3])","let { log2 } = import(math);\nlog2([[1, 2], [3, 4]])"]}},log10:{evaluate:Ta(e=>Math.log10(e)),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `log10` function computes the base `10` logarithm of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the base-10 logarithm of each element while preserving the original structure.",seeAlso:["math.ln","math.log2"],examples:["let { log10 } = import(math);\nlog10(0.01)","let { log10 } = import(math);\nlog10(10 ^ 12)","let { log10 } = import(math);\nlog10(2.5)","let { log10 } = import(math);\nlog10([1, 2, 3])","let { log10 } = import(math);\nlog10([[1, 2], [3, 4]])"]}},"to-rad":{evaluate:Ta(e=>e*Math.PI/180),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `to-rad` function converts an angle from degrees to radians, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it converts each element while preserving the original structure.",seeAlso:["math.to-deg","math.sin","math.cos","math.tan"],examples:["let { to-rad } = import(math);\nto-rad(0)","let { to-rad } = import(math);\nto-rad(90)","let { to-rad } = import(math);\nto-rad(180)","let { to-rad } = import(math);\nto-rad(360)","let { to-rad } = import(math);\nto-rad([0, 90, 180])","let { to-rad } = import(math);\nto-rad([[0, 90], [180, 360]])"]}},"to-deg":{evaluate:Ta(e=>180*e/Math.PI),arity:ae(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `to-deg` function converts an angle from radians to degrees, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it converts each element while preserving the original structure.",seeAlso:["math.to-rad"],examples:["let { to-deg } = import(math);\nto-deg(0)","let { to-deg } = import(math);\nto-deg(PI)","let { to-deg } = import(math);\nto-deg(PI / 2)","let { to-deg } = import(math);\nto-deg(3 * PI / 2)","let { to-deg } = import(math);\nto-deg([0, PI, PI / 2])","let { to-deg } = import(math);\nto-deg([[0, PI], [PI / 2, 3 * PI / 2]])"]}}}},Sa={name:"functional",functions:{juxt:{evaluate:(e,t)=>{e.forEach(e=>L(e,t));const n=function(e){return e.reduce((e,t)=>{if(null===e)return null;const r="number"==typeof t||U(t)?ae(1):t.arity,{min:n,max:o}=r,{min:a,max:i}=e,s="number"==typeof n&&"number"==typeof a?Math.max(n,a):"number"==typeof n?n:"number"==typeof a?a:void 0,c="number"==typeof o&&"number"==typeof i?Math.min(o,i):"number"==typeof o?o:"number"==typeof i?i:void 0;return"number"==typeof s&&"number"==typeof c&&s>c?null:{min:s,max:c}},{})}(e);if(null===n)throw new r("All functions must accept the same number of arguments",t);return{[u]:!0,sourceCodeInfo:t,functionType:"Juxt",params:e,arity:n}},arity:{min:1},docs:{category:"functional",returns:{type:"function"},args:{a:{type:"function"},b:{type:"function"},fun:{type:"function"},fns:{type:"function",rest:!0}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","fns"]}],description:"Takes one or many function and returns a function that is the juxtaposition of those functions.\nThe returned function takes a variable number of args,\nand returns a vector containing the result of applying each function to the args (left-to-right).",seeAlso:["comp"],examples:["let { juxt } = import(functional);\njuxt(+, *, min, max)(\n 3,\n 4,\n 6,\n)",'let { juxt } = import(functional);\njuxt("a", "b")(\n {\n a: 1,\n b: 2,\n c: 3,\n d: 4\n }\n)',"let { juxt } = import(functional);\njuxt(+, *, min, max) apply range(1, 11)"]}},complement:{evaluate:([e],t)=>{const r=B(e,t);return{[u]:!0,sourceCodeInfo:t,functionType:"Complement",function:r,arity:re(r)}},arity:ae(1),docs:{category:"functional",returns:{type:"function"},args:{fun:{type:"function"}},variants:[{argumentNames:["fun"]}],description:"Takes a function $fun and returns a new function that takes the same arguments as f, has the same effects, if any, and returns the opposite truth value.",seeAlso:["comp","functional.every-pred","functional.some-pred"],examples:["let { complement } = import(functional);\ncomplement(>)(1, 3)","let { complement } = import(functional);\ncomplement(<)(1, 3)","let { complement } = import(functional);\ncomplement(+)(1, 3)","let { complement } = import(functional);\ncomplement(+)(0, 0)"]}},"every-pred":{evaluate:(e,t)=>({[u]:!0,sourceCodeInfo:t,functionType:"EveryPred",params:e,arity:{min:1,max:1}}),arity:{min:1},docs:{category:"functional",returns:{type:"function"},args:{fun:{type:"function"},fns:{type:"function",rest:!0}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","fns"]}],description:"\nTakes a number of predicates and returns a function that returns `true` if all predicates\nreturn a truthy value against all of its arguments, else it returns `false`.",seeAlso:["functional.some-pred","functional.complement","collection.every?"],examples:['let { every-pred } = import(functional);\nevery-pred(string?, -> count($) > 3)(\n "Albert",\n "Mojir"\n)','let { every-pred } = import(functional);\n(string? every-pred -> count($) > 3)(\n "Albert",\n "M"\n)'],hideOperatorForm:!0}},"some-pred":{evaluate:(e,t)=>({[u]:!0,sourceCodeInfo:t,functionType:"SomePred",params:e,arity:{min:1,max:1}}),arity:{min:1},docs:{category:"functional",returns:{type:"function"},args:{fun:{type:"function"},fns:{type:"function",rest:!0}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","fns"]}],description:"Takes a number of `predicates` and returns a function that returns `true` if at least one of the `predicates` return a truthy `true` value against at least one of its arguments, else it returns `false`.",seeAlso:["functional.every-pred","functional.complement","collection.any?"],examples:['let { some-pred } = import(functional);\nsome-pred(string?, -> count($) > 3)("Albert", "Mojir")','let { some-pred } = import(functional);\nsome-pred(string?, -> count($) > 3)("a", "M")','let { some-pred } = import(functional);\nsome-pred(string?, -> count($) > 3)("a", [1, 2, 3])',"let { some-pred } = import(functional);\nsome-pred(string?, -> count($) > 3)([1, 2, 3], [2])"],hideOperatorForm:!0}},fnull:{evaluate:([e,...t],r)=>{const n=B(e,r);return{[u]:!0,sourceCodeInfo:r,functionType:"Fnull",function:n,params:t,arity:re(n)}},arity:{min:2},docs:{category:"functional",returns:{type:"function"},args:{a:{type:"function"},b:{type:"any"},fun:{type:"function"},arg:{type:"any"},args:{type:"any",rest:!0}},variants:[{argumentNames:["fun","arg"]},{argumentNames:["fun","arg","args"]}],description:"Takes a function $fun, and returns a function that calls $fun, replacing a null argument to the corresponding argument.",seeAlso:["identity","constantly"],examples:["let { fnull } = import(functional);\nfnull(inc, 0)(1)","let { fnull } = import(functional);\nfnull(inc, 0)(null)","let { fnull } = import(functional);\n(inc fnull 0)(null)","let { fnull } = import(functional);\nfnull(+, 1, 2)(null, 0)","let { fnull } = import(functional);\nfnull(+, 1, 2)(0, null)","let { fnull } = import(functional);\nfnull(+, 1, 2)(null, null)","let { fnull } = import(functional);\nfnull(+, 1, 2)(null, null, 3, 4)"]}}}};function Ea(e,t){return{a:{type:e},b:{type:t}}}const ja={name:"bitwise",functions:{"bit-not":{evaluate:([e],t)=>(ee(e,t,{integer:!0}),~e),arity:ae(1),docs:{category:"bitwise",returns:{type:"integer"},args:{a:{type:"integer"}},variants:[{argumentNames:["a"]}],description:"Returns bitwise `not` of $a.",seeAlso:["&","|","xor","bitwise.bit-and-not"],examples:["let { bit-not } = import(bitwise);\nbit-not(0)","let { bit-not } = import(bitwise);\nbit-not(255)"]}},"bit-and-not":{evaluate:([e,...t],r)=>(ee(e,r,{integer:!0}),t.reduce((e,t)=>(ee(t,r,{integer:!0}),e&~t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...Ea("integer","integer"),c:{type:"integer",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Returns bitwise `and` with complement.",seeAlso:["&","|","xor","bitwise.bit-not"],examples:["let { bit-and-not } = import(bitwise);\n0b0011 bit-and-not 0b0110","let { bit-and-not } = import(bitwise);\nbit-and-not(0b0011, 0b0110)","let { bit-and-not } = import(bitwise);\nbit-and-not(0b0011, 0b0110, 0b1001)"]}},"bit-flip":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0});return e^1<<t},arity:ae(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...Ea("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Flips bit number $b.",seeAlso:["bitwise.bit-set","bitwise.bit-clear","bitwise.bit-test"],examples:["let { bit-flip } = import(bitwise);\n0b0011 bit-flip 1","let { bit-flip } = import(bitwise);\nbit-flip(0b0011, 1)","let { bit-flip } = import(bitwise);\nbit-flip(0b1100, 1)"]}},"bit-set":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0});return e|1<<t},arity:ae(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...Ea("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Sets bit number $b.",seeAlso:["bitwise.bit-flip","bitwise.bit-clear","bitwise.bit-test"],examples:["let { bit-set } = import(bitwise);\n0b0010 bit-set 1","let { bit-set } = import(bitwise);\nbit-set(0b0011, 1)","let { bit-set } = import(bitwise);\nbit-set(0b1100, 1)"]}},"bit-clear":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0});return e&~(1<<t)},arity:ae(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...Ea("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Clears bit number $b.",seeAlso:["bitwise.bit-flip","bitwise.bit-set","bitwise.bit-test"],examples:["let { bit-clear } = import(bitwise);\n0b0011 bit-clear 1","let { bit-clear } = import(bitwise);\nbit-clear(0b0011, 1)","let { bit-clear } = import(bitwise);\nbit-clear(0b1100, 1)"]}},"bit-test":{evaluate:([e,t],r)=>{ee(e,r,{integer:!0}),ee(t,r,{integer:!0,nonNegative:!0});return!!(e&1<<t)},arity:ae(2),docs:{category:"bitwise",returns:{type:"boolean"},args:{...Ea("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Checks if bit number $b is set.",seeAlso:["bitwise.bit-flip","bitwise.bit-set","bitwise.bit-clear"],examples:["let { bit-test } = import(bitwise);\n0b0011 bit-test 1","let { bit-test } = import(bitwise);\nbit-test(0b0011, 1)","let { bit-test } = import(bitwise);\nbit-test(0b1100, 1)"]}}}},Ma={baseUnit:"rad",description:"angle",units:{deg:Math.PI/180,rad:1,grad:Math.PI/200,turn:2*Math.PI}};function Ca(e,t){switch(e){case"c":return t;case"f":return 9*t/5+32;case"k":return t+273.15}}function Pa(e,t){switch(e){case"c":return t;case"f":return 5*(t-32)/9;case"k":return t-273.15}}const Ra=["c","f","k"],Ia={angstrom:"ångströms",um:"micrometers",mm:"millimeters",cm:"centimeters",m:"meters",km:"kilometers",in:"inches",ft:"feet",yd:"yards",mi:"miles",nmi:"nautical miles",mg:"milligrams",g:"grams",kg:"kilograms",t:"metric tons",oz:"ounces",lb:"pounds",st:"stones",ml:"milliliters",cl:"centiliters",dl:"deciliters",l:"liters",tsp:"teaspoons",tbsp:"tablespoons","fl-oz":"fluid ounces",cup:"cups",pt:"pints",qt:"quarts",gal:"gallons",ms:"milliseconds",s:"seconds",min:"minutes",h:"hours",day:"days",week:"weeks",mm2:"square millimeters",cm2:"square centimeters",m2:"square meters",km2:"square kilometers",in2:"square inches",ft2:"square feet",yd2:"square yards",acre:"acres",hectare:"hectares","m/s":"meters per second","km/h":"kilometers per hour",mph:"miles per hour",kn:"knots","ft/s":"feet per second",b:"bytes",kb:"kilobytes",mb:"megabytes",gb:"gigabytes",tb:"terabytes",pb:"petabytes",pa:"pascals",kpa:"kilopascals",bar:"bars",atm:"atmospheres",psi:"pounds per square inch",mmhg:"millimeters of mercury",j:"joules",kj:"kilojoules",cal:"calories",kcal:"kilocalories",wh:"watt-hours",kwh:"kilowatt-hours",btu:"British thermal units",w:"watts",kw:"kilowatts",mw:"megawatts",hp:"horsepower",hz:"hertz",khz:"kilohertz",mhz:"megahertz",ghz:"gigahertz",deg:"degrees",rad:"radians",grad:"gradians",turn:"turns",c:"Celsius",f:"Fahrenheit",k:"Kelvin"};function Oa(e){const t={},r=Object.keys(e.units);for(const n of r)for(const o of r){if(n===o)continue;const a=e.units[n]/e.units[o],i=`${n}->${o}`,s=Ia[n],c=Ia[o],l=[`convert.${o}->${n}`,...r.filter(e=>e!==n&&e!==o).map(e=>`convert.${n}->${e}`)];t[i]={evaluate:([e],t)=>(ee(e,t),e*a),arity:ae(1),docs:{category:"convert",returns:{type:"number"},args:{value:{type:"number",description:`Value in ${s}`}},variants:[{argumentNames:["value"]}],description:`Converts a value from ${s} (\`${n}\`) to ${c} (\`${o}\`).`,seeAlso:l,examples:[`let { ${i} } = import(convert);\n${i}(1)`]}}}return t}const Fa={name:"convert",functions:{...Oa({baseUnit:"m",description:"length",units:{angstrom:1e-10,um:1e-6,mm:.001,cm:.01,m:1,km:1e3,in:.0254,ft:.3048,yd:.9144,mi:1609.344,nmi:1852}}),...Oa({baseUnit:"kg",description:"weight",units:{mg:1e-6,g:.001,kg:1,t:1e3,oz:.028349523125,lb:.45359237,st:6.35029318}}),...Oa({baseUnit:"l",description:"volume",units:{ml:.001,cl:.01,dl:.1,l:1,tsp:.00492892159375,tbsp:.01478676478125,"fl-oz":.0295735295625,cup:.2365882365,pt:.473176473,qt:.946352946,gal:3.785411784}}),...Oa({baseUnit:"s",description:"time",units:{ms:.001,s:1,min:60,h:3600,day:86400,week:604800}}),...Oa({baseUnit:"m2",description:"area",units:{mm2:1e-6,cm2:1e-4,m2:1,km2:1e6,in2:64516e-8,ft2:.09290304,yd2:.83612736,acre:4046.8564224,hectare:1e4}}),...Oa({baseUnit:"m/s",description:"speed",units:{"m/s":1,"km/h":1/3.6,mph:.44704,kn:.514444,"ft/s":.3048}}),...Oa({baseUnit:"b",description:"data",units:{b:1,kb:1e3,mb:1e6,gb:1e9,tb:1e12,pb:1e15}}),...Oa({baseUnit:"pa",description:"pressure",units:{pa:1,kpa:1e3,bar:1e5,atm:101325,psi:6894.757293168,mmhg:133.322387415}}),...Oa({baseUnit:"j",description:"energy",units:{j:1,kj:1e3,cal:4.184,kcal:4184,wh:3600,kwh:36e5,btu:1055.06}}),...Oa({baseUnit:"w",description:"power",units:{w:1,kw:1e3,mw:1e6,hp:745.7}}),...Oa({baseUnit:"hz",description:"frequency",units:{hz:1,khz:1e3,mhz:1e6,ghz:1e9}}),...Oa(Ma),...function(){const e={};for(const t of Ra)for(const r of Ra){if(t===r)continue;const n=`${t}->${r}`,o=Ia[t],a=Ia[r],i=[`convert.${r}->${t}`,...Ra.filter(e=>e!==t&&e!==r).map(e=>`convert.${t}->${e}`)];e[n]={evaluate:([e],n)=>{ee(e,n);const o=Pa(t,e);return Ca(r,o)},arity:ae(1),docs:{category:"convert",returns:{type:"number"},args:{value:{type:"number",description:`Value in ${o}`}},variants:[{argumentNames:["value"]}],description:`Converts a temperature from ${o} (\`${t}\`) to ${a} (\`${r}\`).`,seeAlso:i,examples:[`let { ${n} } = import(convert);\n${n}(100)`]}}}return e}()}},Ua={"-type-number":{datatype:!0,title:"number",category:"datatype",description:"A `number`",examples:["42","3.14"]},"-type-string":{datatype:!0,title:"string",category:"datatype",description:"A `string`",examples:['"hello"','""']},"-type-object":{datatype:!0,title:"object",category:"datatype",description:"An `object`, a collection of key-value pairs where keys are `strings`",examples:["{}","{ a: 1, b: 2}"]},"-type-array":{datatype:!0,title:"array",category:"datatype",description:"An `array`",examples:["[]","[1, 2, 3]",'["a", null, true]']},"-type-vector":{datatype:!0,title:"vector",category:"datatype",description:"An `array` of `numbers`",examples:["[]","[1, 2, 3]"]},"-type-matrix":{datatype:!0,title:"matrix",category:"datatype",description:"A `matrix`, a two-dimensional `array` with `numbers` where each row has the same number of columns. A `matrix` is also a `grid`.",examples:["[[]]","[[1, 2], [3, 4]]","[[1, 2], [3, 4], [5, 6]]"]},"-type-grid":{datatype:!0,title:"grid",category:"datatype",description:"A `grid`, a two-dimensional `array` where each row has the same number of columns",examples:["[[]]","[[1, 2], [3, 4]]",'[["a", "b"], [3, 4], [5, 6]]']},"-type-boolean":{datatype:!0,title:"boolean",category:"datatype",description:"A `boolean`",examples:["true","false"]},"-type-function":{datatype:!0,title:"function",category:"datatype",description:"A `function`",examples:["x -> x + 1","(a, b, c) -> (a + b) * c","() -> 42","-> $1 + $2"]},"-type-integer":{datatype:!0,title:"integer",category:"datatype",description:"An `integer`",examples:["42","-42"]},"-type-any":{datatype:!0,title:"any",category:"datatype",description:"`Any` value",examples:["42",'"hello"',"true","null"]},"-type-null":{datatype:!0,title:"null",category:"datatype",description:"The value `null`",examples:["null"]},"-type-collection":{datatype:!0,title:"collection",category:"datatype",description:"A collection, an `object`, an `array` or a `string`",examples:["{ foo: 42 }","[1, 2, 3]",'"hello"']},"-type-sequence":{datatype:!0,title:"sequence",category:"datatype",description:"A sequence, an `array` or a `string`",examples:["[1, 2, 3]",'"hello"']},"-type-regexp":{datatype:!0,title:"regexp",category:"datatype",description:"A regular expression",examples:['regexp("^\\\\s*(.*)$")','#"albert"ig']},"-type-never":{datatype:!0,title:"never",category:"datatype",description:"A value that can never be created",examples:['\n// throw("error") will never return a value\ntry throw("error") catch "never" end']}},Da={"-short-regexp":{shorthand:!0,title:'#"pattern"',category:"shorthand",description:"Shorthand for `regexp(pattern)`. Only difference is that escaping is not needed.",examples:['#"^\\s*(.*)$"','#"albert"ig'],seeAlso:["regexp","re-match","replace","replace-all"]},"-short-fn":{shorthand:!0,title:"-> expression",category:"shorthand",description:"\nShorthand for `(args, ...) -> expression`.\n`$1, $2, $3, ...` are shorthand for the first, second, third, ... argument.\n\nYou can reference the first argument using either `$1` or `$`.\nHowever, please note that `$1` and `$` are mutually exclusive and cannot be used simultaneously.\nE.g. `-> $ * $1` is not valid.",examples:["-> $1 + $2","(-> $ * $)(9)"]}};function Wa(e){const t={};for(const[r,n]of Object.entries(e)){const e=n.docs;if(!e)throw new Error(`Missing docs for expression "${r}"`);t[r]={title:r,category:e.category,description:e.description,returns:e.returns,args:e.args,variants:e.variants,examples:e.examples,...e.seeAlso?{seeAlso:e.seeAlso}:{},...e.hideOperatorForm?{noOperatorDocumentation:!0}:{}}}return t}function Ga(e,t){const r={};for(const[n,o]of Object.entries(t)){const t=o.docs;if(!t)throw new Error(`Missing docs for ${e}.${n}`);const a=`${e}.${n}`;r[a]={title:a,category:t.category,description:t.description,returns:t.returns,args:t.args,variants:t.variants,examples:t.examples,...t.seeAlso?{seeAlso:t.seeAlso}:{},...t.hideOperatorForm?{noOperatorDocumentation:!0}:{}}}return r}const Va=Wa(Z),Ba=Wa(se),La=Wa(We),_a=Wa(De),Ka=Wa(bt),Ja=Wa(ut),Ya=Wa(kt({})),Ha=Wa(gt),Xa=Wa(ht),Za=Wa(dt),Qa=Wa(yt),ei=Wa(Ge),ti=Wa(ft),ri=Wa(qt);const ni=function(){const e={};for(const[t,r]of Object.entries(wr)){const n=kr[r],o=n?.docs;o&&(Ir(o)?e[t]={title:t,category:o.category,description:o.description,returns:o.returns,args:o.args,variants:o.variants,examples:o.examples,...o.seeAlso?{seeAlso:o.seeAlso}:{},...o.hideOperatorForm?{noOperatorDocumentation:!0}:{}}:e[t]={title:t,category:o.category,description:o.description,customVariants:o.customVariants,...o.details?{details:o.details}:{},...o.returns?{returns:o.returns}:{},examples:o.examples,...o.seeAlso?{seeAlso:o.seeAlso}:{}})}return e}();function oi(e){return"returns"in e&&"args"in e&&"variants"in e}function ai(e){return"customVariants"in e}function ii(e){return"shorthand"in e}function si(e){return"datatype"in e}const ci={...Va,...Ba,..._a,...La,...ei,...Ja,...Ka,...Ya,...Ha,...Xa,...Za,...Qa,...ti,...ri},li={...Ga(Ur.name,Ur.functions),...Ga(Vr.name,Vr.functions),...Ga(Jr.name,Jr.functions),...Ga(Mn.name,Mn.functions),...Ga(Ln.name,Ln.functions),...Ga(eo.name,eo.functions),...Ga(ga.name,ga.functions),...Ga(va.name,va.functions),...Ga(qa.name,qa.functions),...Ga($a.name,$a.functions),...Ga(za.name,za.functions),...Ga(Sa.name,Sa.functions),...Ga(ja.name,ja.functions),...Ga(Fa.name,Fa.functions)};Object.entries(ci).forEach(([e,t])=>{if(!$t[e])throw new Error(`Missing normal expression ${e} in normalExpressions`);const r=$t[e].arity;!t.noOperatorDocumentation&&oe(r)&&(t._isOperator=!0,Cr(e)&&(t._prefereOperator=!0))}),Object.entries(ni).forEach(([e,t])=>{if(oi(t)){const r=kr[wr[e]]?.arity;r&&oe(r)&&(t._isOperator=!0)}});const mi=pi({...{...ci,...ni},...Da,...Ua}),ui=pi({...mi,...li});function pi(e){return Object.fromEntries(Object.entries(e).sort(([e,t],[r,n])=>{const o="special-expression"===t.category?"":t.category,a="special-expression"===n.category?"":n.category;return o!==a?o.localeCompare(a):e.localeCompare(r)}))}var gi;Object.values(ui).forEach(e=>{e.title=e.title.replace(/"/g,""")}),gi=ci,Object.assign(At,gi);const hi=(e,t,r,n)=>{const o=Array.isArray(e)?e:[[s.SpecialExpression,[wr.block,e.body]]],a=new Set;for(const e of o)di(e,t,r,n)?.forEach(e=>a.add(e));return a};function di(e,t,n,o){const a=e[0];switch(a){case s.UserDefinedSymbol:{const r=e;return null===t.lookUp(r)?new Set([r[1]]):null}case s.NormalBuiltinSymbol:case s.SpecialBuiltinSymbol:case s.String:case s.Number:case s.ReservedSymbol:case s.Binding:return null;case s.NormalExpression:{const r=e,a=new Set;if(Ht(r)){const[,[e]]=r;if(_t(e)){null===t.lookUp(e)&&a.add(e[1])}}else{const[,[e]]=r;di(e,t,n,o)?.forEach(e=>a.add(e))}for(const e of r[1][1])di(e,t,n,o)?.forEach(e=>a.add(e));return a}case s.SpecialExpression:{const r=e,a=r[1][0];return(0,n.specialExpressions[a].getUndefinedSymbols)(r,t,{getUndefinedSymbols:hi,builtin:n,evaluateNode:o})}case s.Spread:return di(e[1],t,n,o);default:throw new r(`Unhandled node type: ${a}`,e[2])}}const yi=(1+Math.sqrt(5))/2,vi={E:Math.E,"-E":-Math.E,"ε":Math.E,"-ε":-Math.E,PI:Math.PI,"-PI":-Math.PI,"π":Math.PI,"-π":-Math.PI,PHI:yi,"-PHI":-yi,"φ":yi,"-φ":-yi,POSITIVE_INFINITY:Number.POSITIVE_INFINITY,"∞":Number.POSITIVE_INFINITY,NEGATIVE_INFINITY:Number.NEGATIVE_INFINITY,"-∞":Number.NEGATIVE_INFINITY,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,MIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,MAX_VALUE:Number.MAX_VALUE,MIN_VALUE:Number.MIN_VALUE,NaN:Number.NaN},fi={true:!0,false:!1,null:null,do:null,else:null,case:null,each:null,in:null,when:null,while:null,catch:null,function:null,as:null,then:null,end:null,_:null,...vi};const bi={NativeJsFunction:(e,t,n,o)=>{if(o.pure&&!e.nativeFn.pure)throw new r(`Cannot call impure native function '${e.name}' in pure mode`,n);try{const o=e.nativeFn.fn(...t);return o instanceof Promise?o.then(e=>pe(e),e=>{const t="string"==typeof e?e:x(e)&&"string"==typeof e.message?e.message:"<no message>";throw new r(`Native function threw: "${t}"`,n)}):pe(o)}catch(e){const t="string"==typeof e?e:x(e)&&"string"==typeof e.message?e.message:"<no message>";throw new r(`Native function threw: "${t}"`,n)}},UserDefined:(e,n,o,a,{evaluateNode:i})=>{function s(n){if(!function(e,t){const{min:r}=e;return!("number"==typeof r&&t<r)}(e.arity,n.length))throw new r(`Expected ${e.arity} arguments, got ${n.length}.`,o);const c=e.evaluatedfunction,l=c[0],m=l.filter(e=>e[0]!==Mt).length,u=a.create(e.evaluatedfunction[2]),p={self:{value:e}},g=[];let h,d;for(let e=0;e<n.length;e+=1)if(e<m){const t=e;h=Ae(h,()=>{const e=pe(n[t]);return Ae(Ft(l[t],e,e=>i(e,u.create(p))),e=>{Object.entries(e).forEach(([e,t])=>{p[e]={value:t}})})})}else g.push(pe(n[e]));for(let e=n.length;e<m;e++){const t=e;d=Ae(d,()=>{const e=l[t];return Ae(i(e[1][1],a.create(p)),t=>Ae(Ft(e,t,e=>i(e,a.create(p))),e=>{Object.entries(e).forEach(([e,t])=>{p[e]={value:t}})}))})}return Ae(h,()=>Ae(d,()=>{const e=l.find(e=>e[0]===Mt),r=void 0!==e?Ae(Ft(e,g,e=>i(e,a.create(p))),e=>{Object.entries(e).forEach(([e,t])=>{p[e]={value:t}})}):void 0;return Ae(r,()=>{const e=u.create(p),r=Te(c[1],(t,r)=>i(r,e),null);return r instanceof Promise?r.catch(e=>{if(e instanceof t)return s(e.params);throw e}):r})}))}for(;;)try{return s(n)}catch(e){if(e instanceof t){n=e.params;continue}throw e}},Partial:(e,t,n,o,{executeFunction:a})=>{const i=[...e.params];if(t.length!==e.placeholders.length)throw new r(`(partial) expects ${e.placeholders.length} arguments, got ${t.length}.`,n);const s=[...t];for(const t of e.placeholders)i.splice(t,0,s.shift());return a(e.function,i,o,n)},Comp:(e,t,n,o,{executeFunction:a})=>{const{params:i}=e;if(0===i.length){if(1!==t.length)throw new r(`(comp) expects one argument, got ${d(t.length)}.`,n);return M(t[0],n)}let s=t;for(let e=i.length-1;e>=0;e--){const t=i[e];s=Ae(s,e=>Ae(a(B(t,n),e,o,n),e=>[e]))}return Ae(s,e=>M(e[0],n))},Constantly:e=>e.value,Juxt:(e,t,r,n,{executeFunction:o})=>Ne(e.params,e=>o(B(e,r),t,n,r)),Complement:(e,t,r,n,{executeFunction:o})=>Ae(o(e.function,t,n,r),e=>!e),EveryPred:(e,t,r,n,{executeFunction:o})=>{const a=[];for(const i of e.params)for(const e of t)a.push(()=>o(B(i,r),[e],n,r));return Te(a,(e,t)=>!!e&&Ae(t(),e=>!!e),!0)},SomePred:(e,t,r,n,{executeFunction:o})=>{const a=[];for(const i of e.params)for(const e of t)a.push(()=>o(B(i,r),[e],n,r));return Te(a,(e,t)=>!!e||Ae(t(),e=>!!e),!1)},Fnull:(e,t,r,n,{executeFunction:o})=>{const a=t.map((t,r)=>null===t?pe(e.params[r]):t);return o(B(e.function,r),a,n,r)},Builtin:(e,t,n,o,{executeFunction:a})=>{const i=f(zt[e.normalBuiltinSymbolType],n);if(o.pure&&!1===i.pure)throw new r(`Cannot call impure function '${e.name}' in pure mode`,n);return i.evaluate(t,n,o,{executeFunction:a})},SpecialBuiltin:(e,t,n,o,{executeFunction:a})=>{const i=f(kr[e.specialBuiltinSymbolType],n);if(i.evaluateAsNormalExpression)return i.evaluateAsNormalExpression(t,n,o,{executeFunction:a});throw new r(`Special builtin function ${e.specialBuiltinSymbolType} is not supported as normal expression.`,n)},Module:(e,t,n,o,{executeFunction:a})=>{const i=o.getModule(e.moduleName);if(!i)throw new r(`Module '${e.moduleName}' not found.`,n);const s=i.functions[e.functionName];if(!s)throw new r(`Function '${e.functionName}' not found in module '${e.moduleName}'.`,n);if(o.pure&&!1===s.pure)throw new r(`Cannot call impure function '${e.functionName}' in pure mode`,n);return ne(s.arity,t.length,n),s.evaluate(t,n,o,{executeFunction:a})}};function xi(e,t){return Te(e.body,(e,r)=>wi(r,t),null)}function wi(e,t){switch(e[0]){case s.Number:case s.String:return function(e){return e[1]}(e);case s.NormalBuiltinSymbol:case s.SpecialBuiltinSymbol:case s.UserDefinedSymbol:return t.evaluateSymbol(e);case s.ReservedSymbol:return function(e){const t=e[1];if(!["true","false","null"].includes(t))throw new r(`Reserved symbol ${t} cannot be evaluated`,e[2]);return f(fi[t],e[2])}(e);case s.NormalExpression:{const n=function(e,t){const n=e[2];return Ae(function(e,t){const n=[],o=[],a=Se(e,(e,a)=>Xt(e)?Ae(wi(e[1],t),t=>{if(!Array.isArray(t))throw new r(`Spread operator requires an array, got ${d(e)}`,e[2]);n.push(...t)}):e[0]!==s.ReservedSymbol||"_"!==e[1]?Ae(wi(e,t),e=>{n.push(e)}):void o.push(a));return Ae(a,()=>({params:n,placeholders:o}))}(e[1][1],t),({params:o,placeholders:i})=>{if(Ht(e)){const s=e[1][0];if(i.length>0){return Ae(wi(s,t),e=>({[u]:!0,function:B(e,n),functionType:"Partial",params:o,placeholders:i,sourceCodeInfo:n,arity:ae(i.length)}))}if(Jt(s)){const n=s[1],a=qr.allNormalExpressions[n];if(t.pure&&!1===a.pure)throw new r(`Cannot call impure function '${a.name}' in pure mode`,e[2]);return a.evaluate(o,e[2],t,{executeFunction:ki})}{const r=t.getValue(s[1]);if(void 0!==r)return ki(B(r,n),o,t,n);throw new a(s[1],e[2])}}return Ae(wi(e[1][0],t),e=>{const r=B(e,n);if(i.length>0){return{[u]:!0,function:r,functionType:"Partial",params:o,placeholders:i,sourceCodeInfo:n,arity:ae(i.length)}}return ki(r,o,t,n)})})}(e,t);return Ae(n,t=>{if("number"==typeof t&&Number.isNaN(t))throw new r("Number is NaN",e[2]);return He(t)})}case s.SpecialExpression:return Ae(function(e,t){const r=e[1][0],n=f(qr.specialExpressions[r],e[2]);return(0,n.evaluate)(e,t,{evaluateNode:wi,builtin:qr,getUndefinedSymbols:hi})}(e,t),e=>He(e));default:throw new r(`${l(e[0])}-node cannot be evaluated`,e[2])}}function ki(e,t,n,o){if(w(e))return bi[e.functionType](e,t,o,n,{evaluateNode:wi,executeFunction:ki});if(Array.isArray(e))return function(e,t,n){if(1!==t.length)throw new r("Array as function requires one non negative integer parameter.",n);const o=t[0];return ee(o,n,{integer:!0,nonNegative:!0}),pe(e[o])}(e,t,o);if(O(e))return function(e,t,n){if(1!==t.length)throw new r("Object as function requires one string parameter.",n);const o=t[0];return K(o,n),pe(e[o])}(e,t,o);if("string"==typeof e)return function(e,t,n){if(1!==t.length)throw new r("String as function requires one Obj parameter.",n);const o=pe(t[0]);if(O(o))return pe(o[e]);if(Q(o,{integer:!0}))return pe(e[o]);throw new r(`string as function expects Obj or integer parameter, got ${d(o)}`,n)}(e,t,o);if(Q(e))return function(e,t,n){if(ee(e,n,{integer:!0}),1!==t.length)throw new r("Number as function requires one Arr parameter.",n);const o=t[0];return I(o,n),pe(o[e])}(e,t,o);throw new r("Unexpected function type",o)}class qi{contexts;globalContext;values;nativeJsFunctions;modules;valueModules;pure;constructor({contexts:e,values:t,nativeJsFunctions:r,modules:n,valueModules:o,pure:a}){this.globalContext=f(e[0]),this.contexts=e,this.values=t,this.nativeJsFunctions=r,this.modules=n??new Map,this.valueModules=o??new Map,this.pure=a??!1}getModule(e){return this.modules.get(e)}getValueModule(e){return this.valueModules.has(e)?{value:this.valueModules.get(e),found:!0}:{value:void 0,found:!1}}registerValueModule(e,t){this.valueModules.set(e,t)}create(e){const t=this.globalContext,r=new qi({contexts:[e,...this.contexts],values:this.values,nativeJsFunctions:this.nativeJsFunctions,modules:this.modules,valueModules:this.valueModules,pure:this.pure});return r.globalContext=t,r}new(e){return new qi({contexts:[{},e],modules:this.modules,valueModules:this.valueModules,pure:this.pure})}addValues(e,t){const n=this.contexts[0];for(const[o,a]of Object.entries(e)){if(n[o])throw new r(`Cannot redefine value "${o}"`,t);const e=Ai(o);if(e)throw new r(`Cannot shadow ${e}`,t);n[o]={value:pe(a)}}}getValue(e){for(const t of this.contexts){const r=t[e];if(r)return r.value}const t=this.nativeJsFunctions?.[e];return t||this.values?.[e]}lookUp(e){const t=e[1];for(const e of this.contexts){const r=e[t];if(r)return r}const r=this.values?.[t];if(void 0!==r)return{value:pe(r)};const n=this.nativeJsFunctions?.[t];return n?{value:n}:null}evaluateSymbol(e){if(Yt(e)){const t=e[1];switch(t){case wr["&&"]:case wr["||"]:case wr.array:case wr.object:case wr["defined?"]:case wr.recur:case wr.throw:case wr["??"]:{const r=f(qr.specialExpressions[t],e[2]);return{[u]:!0,functionType:"SpecialBuiltin",specialBuiltinSymbolType:t,sourceCodeInfo:e[2],arity:r.arity}}default:throw new r(`Unknown special builtin symbol type: ${t}`,e[2])}}if(Jt(e)){const t=e[1],r=zt[t],n=r.name;return{[u]:!0,functionType:"Builtin",normalBuiltinSymbolType:t,sourceCodeInfo:e[2],arity:r.arity,name:n}}const t=this.lookUp(e);if(x(n=t)&&void 0!==n.value)return t.value;var n;throw new a(e[1],e[2])}}function Ai(e){return Nr.includes(e)?`special expression "${e}"`:Ar.includes(e)?`builtin function "${e}"`:"self"===e?`builtin value "${e}"`:null}function Ni(e){const t=Ai(e);if(t)throw new r(`Cannot shadow ${t}`,void 0)}function $i(e={},t,n){const o=e.globalContext??{},a=e.contexts?[o,...e.contexts]:[o];let i,s;if(e.bindings)for(const[t,n]of Object.entries(e.bindings)){if(t.includes("."))throw new r(`Dots are not allowed in binding keys: "${t}"`,void 0);if("function"==typeof n){const e={fn:n};Ni(t),s||(s={}),s[t]={functionType:"NativeJsFunction",nativeFn:e,name:t,[u]:!0,arity:e.arity??{},docString:e.docString??""}}else Ni(t),i||(i={}),i[t]=n}const c=new qi({contexts:a,values:i,modules:t,nativeJsFunctions:s,pure:n});return e.globalModuleScope?c:c.create({})}const Ti=["(",")","[","]","{","}","'",'"',"`",",",".",";"," ","\n","\r","\t"],zi=["0","1","2","3","4","5","6","7","8","9",...Ti],Si=new Set(Ti),Ei=new Set(zi),ji=/\s/,Mi=[0],Ci=(e,t)=>{if('"'!==e[t])return Mi;let r='"',n=1,o=e[t+n],a=!1;for(;o&&('"'!==o||a);)n+=1,a?(a=!1,r+=o):("\\"===o&&(a=!0),r+=o),o=e[t+n];return o?(r+='"',[n+1,["string",r]]):[n,["Error",r,void 0,`Unclosed string at position ${t}`]]};function Pi(e,t,r,n){return t===r.slice(n,n+t.length)?[t.length,[e,t]]:Mi}const Ri=/\d/,Ii=/[0-7]/,Oi=/[0-9a-f]/i,Fi=/[01]/,Ui=/[\s)\]}(,;]/,Di=(e,t)=>{let r=e[t];if("'"===r){let n=1,o=e[t+n],a=!1;for(;"'"!==o||a;){if(void 0===o)return[n,["Error",r,void 0,`Unclosed quoted symbol at position ${t}`]];n+=1,a?(a=!1,r+=o):("\\"===o&&(a=!0),r+=o),o=e[t+n]}return r+="'",[n+1,["Symbol",r]]}if(!Ei.has(r)){const n=t;let o=e[t+=1];for(;o&&!Si.has(o);)r+=o,o=e[t+=1];return r.endsWith(":")?[t-n-1,["Symbol",r.slice(0,-1)]]:[t-n,["Symbol",r]]}return Mi},Wi=[(e,t)=>{let r=e[t];if(!r||!ji.test(r))return Mi;let n=r;for(r=e[t+=1];r&&ji.test(r);)n+=r,r=e[t+=1];return[n.length,["Whitespace",n]]},(e,t)=>{if("/"===e[t]&&"*"===e[t+1]){let r=2,n="/*";for(;("*"!==e[t+r]||"/"!==e[t+r+1])&&t+r+1<e.length;)n+=e[t+r],r+=1;return t+r+1>=e.length?[r,["Error",n,void 0,`Unclosed multi-line comment at position ${t}`]]:(n+="*/",r+=2,[r,["MultiLineComment",n]])}return Mi},(e,t)=>{if("/"===e[t]&&"/"===e[t+1]){let r=2,n="//";for(;"\n"!==e[t+r]&&t+r<e.length;)n+=e[t+r],r+=1;return[r,["SingleLineComment",n]]}return Mi},(e,t)=>{const r=Di(e,t);if(0===r[0]||!r[1])return Mi;let n=r[1][1];n=n.startsWith("'")?n.slice(1,n.length-1):n;return void 0===fi[n]?Mi:[r[0],["ReservedSymbol",n]]},(e,t)=>Pi("LParen","(",e,t),(e,t)=>Pi("RParen",")",e,t),(e,t)=>Pi("LBracket","[",e,t),(e,t)=>Pi("RBracket","]",e,t),(e,t)=>Pi("LBrace","{",e,t),(e,t)=>Pi("RBrace","}",e,t),(e,t)=>{if('"'!==e[t]||'"'!==e[t+1]||'"'!==e[t+2])return Mi;let r='"""',n=3,o=e[t+n],a=e.slice(t+n,t+n+3),i=!1;for(;o&&('"""'!==a||i);)n+=1,i?(i=!1,r+=o):("\\"===o&&(i=!0),r+=o),o=e[t+n],a=e.slice(t+n,t+n+3);return o?(r+='"""',[n+3,["DocString",r]]):[n,["Error",r,void 0,`Unclosed doc string at position ${t}`]]},Ci,(e,t)=>{if("#"!==e[t])return Mi;const[r,n]=Ci(e,t+1);if(!n)return Mi;if("Error"===n[0]){return[r+1,["Error",`#${n[1]}`,void 0,`Unclosed regexp at position ${t}`]]}t+=r+1;let o=r+1,a="";for(;"g"===e[t]||"i"===e[t];)if(a+=e[t],o+=1,t+=1,a.includes(e[t]))return[o,["Error",`#${n[1]}${a}`,void 0,`Duplicated regexp option "${e[t]}"`]];return[o,["RegexpShorthand",`#${n[1]}${a}`]]},(e,t)=>{if("0"!==e[t])return Mi;const r=e[t+1],n="b"===r||"B"===r?"binary":"o"===r||"O"===r?"octal":"x"===r||"X"===r?"hex":null;if(null===n)return Mi;let o;for(o=t+2;o<e.length;o+=1){const t=e[o];if("binary"===n&&!Fi.test(t))break;if("octal"===n&&!Ii.test(t))break;if("hex"===n&&!Oi.test(t))break}const a=o-t;if(a<=2)return Mi;const i=e[o];return i&&!Ui.test(i)?Mi:[a,["BasePrefixedNumber",e.substring(t,o)]]},(e,t)=>{let r;const n="-"===e[t],o="+"===e[t],a=n||o?t+1:t;let i=!1,s=!1;for(r=a;r<e.length;r+=1){const n=e[r];if("_"===n){if(!Ri.test(e[r-1])||!Ri.test(e[r+1]))return r===a?Mi:[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]]}else if("."===n){if(r===a)return Mi;if(i||s)return[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]];i=!0}else if("e"===n||"E"===n){if(r===a)return Mi;if(s)return[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]];if("."===e[r-1]||"+"===e[r-1]||"-"===e[r-1])return[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]];"+"!==e[r+1]&&"-"!==e[r+1]||(r+=1),s=!0}else if(!Ri.test(n))break}if((n||o)&&r===a)return Mi;const c=r-t;if(0===c)return Mi;const l=e[r];return l&&":"!==l&&!Ui.test(l)?[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]]:[c,["Number",e.substring(t,r)]]},(e,t)=>{const r=e.slice(t,t+3);if(t+2<e.length&&Cr(r))return[3,["Operator",r]];const n=e.slice(t,t+2);if(t+1<e.length&&Cr(n))return[2,["Operator",n]];const o=e[t]??"";return Cr(o)?[1,["Operator",o]]:Mi},Di];function Gi(e,t,r){const n=e.substring(0,t+1).split(/\r\n|\r|\n/),o=n[n.length-1],a=function(e,t){return e.split(/\r\n|\r|\n/)[t]}(e,n.length-1);return{code:a,position:{line:n.length,column:o.length},filePath:r}}function Vi(e,t){const r=t;if(0===t){const[n,o]=((e,t)=>{if("#"===e[t]&&"!"===e[t+1]){let r=2,n="#!";for(;"\n"!==e[t+r]&&t+r<e.length;)n+=e[t+r],r+=1;return[r,["SingleLineComment",n]]}return Mi})(e,t);if(t+=n,n>0)return[t-r,o]}for(const n of Wi){const[o,a]=n(e,t);if(t+=o,0!==o)return[t-r,a]}return[1,["Error",e[r],void 0,"Unrecognized character"]]}function Bi(e,t){return"Symbol"===e?.[0]&&(!t||e[1]===t)}function Li(e,t){return function(e,t){Bi(e,t)||ps("Symbol",void 0,e)}(e,t),e}function _i(e,t){return"ReservedSymbol"===e?.[0]&&(!t||e[1]===t)}function Ki(e,t){_i(e,t)||ps("ReservedSymbol",t,e)}function Ji(e,t){return Ki(e,t),e}function Yi(e,t){return"Operator"===e?.[0]&&(!t||e[1]===t)}function Hi(e,t){Yi(e,t)||ps("Operator",t,e)}function Xi(e){return"Number"===e?.[0]}function Zi(e){return"BasePrefixedNumber"===e?.[0]}function Qi(e){return"LParen"===e?.[0]}function es(e){Qi(e)||ps("LParen",void 0,e)}function ts(e){return"RParen"===e?.[0]}function rs(e){ts(e)||ps("RParen",void 0,e)}function ns(e){return"LBracket"===e?.[0]}function os(e){return function(e){ns(e)||ps("LBracket",void 0,e)}(e),e}function as(e){return"RBracket"===e?.[0]}function is(e){as(e)||ps("RBracket",void 0,e)}function ss(e){return"LBrace"===e?.[0]}function cs(e){return function(e){ss(e)||ps("LBrace",void 0,e)}(e),e}function ls(e){return"RBrace"===e?.[0]}function ms(e){return"string"===e?.[0]}function us(e){return"Operator"===e?.[0]&&jr(e[1])}function ps(e,t,n){const o=n?`${n[0]} '${n[1]}'`:"end of input";throw new r(`Unexpected token: ${o}, expected ${e}${t?` '${t}'`:""}`,n?.[2])}function gs(e,{removeWhiteSpace:t}){const r=e.tokens.filter(e=>!(function(e){return"SingleLineComment"===e?.[0]}(e)||function(e){return"MultiLineComment"===e?.[0]}(e)||function(e){return"Shebang"===e?.[0]}(e)||t&&function(e){return"Whitespace"===e?.[0]}(e)));return{...e,tokens:r}}const hs=new Set([...Ar,...Nr,...Object.keys(fi)]);class ds{originalProgram;originalPosition;prefixProgram="";suffixProgram="";searchString="";suggestions=[];suggestionIndex=null;constructor(e,t,r,n){this.originalProgram=e,this.originalPosition=t;const o=this.originalProgram.slice(0,this.originalPosition),a=r.tokenize(o).tokens.at(-1);a&&"Error"!==a[0]&&(this.searchString=a[1],this.prefixProgram=this.originalProgram.slice(0,this.originalPosition-this.searchString.length),this.suffixProgram=this.originalProgram.slice(this.prefixProgram.length+this.searchString.length),this.originalProgram.slice(this.prefixProgram.length+this.searchString.length),this.suggestions=this.generateSuggestions(n))}getNextSuggestion(){return this.getAutoCompleteSuggestionResult(this.getNextSuggestionSymbol())}getPreviousSuggestion(){return this.getAutoCompleteSuggestionResult(this.getPreviousSuggestionSymbol())}getAutoCompleteSuggestionResult(e){return null===e?null:{program:this.prefixProgram+e+this.suffixProgram,position:this.prefixProgram.length+e.length}}getNextSuggestionSymbol(){return 0===this.suggestions.length?null:(null===this.suggestionIndex?this.suggestionIndex=0:(this.suggestionIndex+=1,this.suggestionIndex>=this.suggestions.length&&(this.suggestionIndex=0)),this.suggestions[this.suggestionIndex])}getPreviousSuggestionSymbol(){return 0===this.suggestions.length?null:(null===this.suggestionIndex?this.suggestionIndex=this.suggestions.length-1:(this.suggestionIndex-=1,this.suggestionIndex<0&&(this.suggestionIndex=this.suggestions.length-1)),this.suggestions[this.suggestionIndex])}getSuggestions(){return[...this.suggestions]}getSearchString(){return this.searchString}generateSuggestions(e){const t=new Set(["0_defn","0_lambda"]),r=this.generateWithPredicate(e,e=>!t.has(e)&&e.startsWith(this.searchString));r.forEach(e=>t.add(e));const n=this.generateWithPredicate(e,e=>!t.has(e)&&e.toLowerCase().startsWith(this.searchString.toLowerCase()));n.forEach(e=>t.add(e));const o=this.generateWithPredicate(e,e=>!t.has(e)&&e.includes(this.searchString));o.forEach(e=>t.add(e));const a=this.generateWithPredicate(e,e=>!t.has(e)&&e.includes(this.searchString.toLowerCase()));return a.forEach(e=>t.add(e)),[...r,...n,...o,...a]}generateWithPredicate(e,t){const r=new Set;return hs.forEach(e=>{t(e)&&r.add(e)}),Object.keys(e.globalContext??{}).filter(t).forEach(e=>r.add(e)),e.contexts?.forEach(e=>{Object.keys(e).filter(t).forEach(e=>r.add(e))}),Object.keys(e.bindings??{}).filter(t).forEach(e=>r.add(e)),[...r].sort((e,t)=>e.localeCompare(t))}}function ys(e){return"object"==typeof e&&null!==e&&"string"==typeof e.program&&Array.isArray(e.fileModules)}function vs(e,t){return t&&(e[2]=t),e}function fs(e,t){return void 0!==wr[e]&&"fn"!==e&&"defn"!==e?vs([s.SpecialBuiltinSymbol,wr[e]],t):void 0!==Tt[e]?vs([s.NormalBuiltinSymbol,Tt[e]],t):vs([s.UserDefinedSymbol,e],t)}function bs(e){return e.substring(1,e.length-1).replace(/(\\{2})|(\\')|\\(.)/g,(e,t,r,n)=>t?"\\":r?"'":`\\${n}`)}const xs=Object.entries(Tt).reduce((e,[t,r])=>(e[r]=t,e),[]),ws=Object.entries(wr).reduce((e,[t,r])=>(e[r]=t,e),[]);function ks(e){return _t(e)?e[1]:Jt(e)?xs[e[1]]:ws[e[1]]}function qs(e,t,r){const n=vs([s.NormalExpression,[e,t]],r);return Jt(e)&&ne(zt[e[1]].arity,n[1][1].length,r),n}function As(e){if(e.isAtEnd())return!0;const t=e.tryPeek();return Yi(t)?[";",",",":"].includes(t[1]):!!_i(t)&&["else","when","while","case","catch","let","then","end","do"].includes(t[1])}function Ns(e,t,n,o,a){const i=e[1];switch(i){case"^":case"*":case"/":case"%":case"+":case"-":case"<<":case">>":case">>>":case"++":case"<":case"<=":case"≤":case">":case">=":case"≥":case"==":case"!=":case"&":case"xor":case"|":case"|>":return qs(t,[n,o],a);case"&&":case"||":case"??":return vs([s.SpecialExpression,[wr[i],[n,o]]],a);default:throw new r(`Unknown binary operator: ${i}`,a)}}class $s{tokens;position;storedPosition=0;parseExpression;constructor(e){this.tokens=e.tokens,this.position=0}advance(){this.position+=1}tryPeek(){return this.tokens[this.position]}peek(){const e=this.tokens[this.position];if(!e){const e=this.tokens.at(-1),t=e?e[2]:void 0;throw new r("Unexpected end of input",t)}return e}isAtEnd(){return this.position>=this.tokens.length}peekSourceCodeInfo(){const e=this.tryPeek();return e?e[2]:this.tokens.at(-1)?.[2]}storePosition(){return this.storedPosition=this.position}restorePosition(){this.position=this.storedPosition}peekAhead(e){return this.tokens[this.position+e]}getPosition(){return this.position}getTokenAt(e){return this.tokens[e]}}function Ts(e,t){switch(e){case"^":return 12;case"*":case"/":case"%":return 11;case"+":case"-":return 10;case"<<":case">>":case">>>":return 9;case"++":return 8;case"<":case"<=":case"≤":case">":case">=":case"≥":return 7;case"==":case"!=":return 6;case"&":case"xor":case"|":return 5;case"&&":case"||":case"??":return 4;case"|>":return 2;default:throw new r(`Unknown binary operator: ${e}`,t)}}function zs(e,t){const n=[];for(;!e.isAtEnd()&&!Ss(e,t);)Yi(e.tryPeek(),";")?e.advance():n.push(e.parseExpression());if(function(e,t){if(!Ss(e,t))throw new r(`Expected ${t.map(e=>e[1]).join(" or ")}`,e.peekSourceCodeInfo())}(e,t),0===n.length)throw new r("Expected expression",e.peekSourceCodeInfo());return 1===n.length?n[0]:vs([s.SpecialExpression,[wr.block,n]],e.peekSourceCodeInfo())}function Ss(e,t){for(const r of t)if(_i(e.tryPeek(),r))return!0;return!1}function Es(e,t){e.advance();const r=t[1].substring(1,t[1].length-1).replace(/(\\{2})|(\\")|(\\n)|(\\t)|(\\r)|(\\b)|(\\f)|\\(.)/g,(e,t,r,n,o,a,i,s,c)=>t?"\\":n?"\n":o?"\t":a?"\r":i?"\b":s?"\f":r?'"':c);return vs([s.String,r],t[2])}function js(e,t=!1){const n=Ji(e.tryPeek(),"do");e.advance();let o="";t&&function(e){return"DocString"===e?.[0]}(e.tryPeek())&&(o=function(e){const t=e.peek(),r=t[2]?["string",t[1].slice(2,-2),t[2]]:["string",t[1].slice(2,-2)],n=Es(e,r);return xe(n[1])}(e),e.isAtEnd()||_i(e.tryPeek(),"end")||(Hi(e.tryPeek(),";"),e.advance()));const a=[];for(;!e.isAtEnd()&&!_i(e.tryPeek(),"end");)if(a.push(e.parseExpression()),Yi(e.tryPeek(),";"))e.advance();else if(!_i(e.tryPeek(),"end"))throw new r("Expected end",e.peekSourceCodeInfo());return Ki(e.tryPeek(),"end"),e.advance(),[vs([s.SpecialExpression,[wr.block,a]],n[2]),o]}function Ms(e){const t=e.peek();if(e.advance(),!Bi(t))throw new r(`Expected symbol token, got ${t[0]}`,t[2]);return"'"===t[1][0]?fs(bs(t[1]),t[2]):fs(t[1],t[2])}function Cs(e){const t=e.peek();e.advance();const r=t[1],n="-"===r[0],o=(n?r.substring(1):r).replace(/_/g,"");return vs([s.Number,n?-Number(o):Number(o)],t[2])}function Ps(e,{requireDefaultValue:t,noRest:n,allowLiteralPatterns:o}={}){const a=e.tryPeek();if(o&&_i(a,"_"))return e.advance(),vs([It,[]],a[2]);if(o&&Is(a)){if(Xi(a)||Zi(a)){const t=Cs(e);return vs([Rt,[t]],a[2])}if(ms(a)){const t=Es(e,a);return vs([Rt,[t]],a[2])}if(_i(a,"true")){e.advance();const t=vs([s.ReservedSymbol,"true"],a[2]);return vs([Rt,[t]],a[2])}if(_i(a,"false")){e.advance();const t=vs([s.ReservedSymbol,"false"],a[2]);return vs([Rt,[t]],a[2])}if(_i(a,"null")){e.advance();const t=vs([s.ReservedSymbol,"null"],a[2]);return vs([Rt,[t]],a[2])}}if(Bi(a)){const n=Ms(e);if(!_t(n))throw new r("Expected user defined symbol",a[2]);const o=Rs(e);if(t&&!o)throw new r("Expected assignment",e.peekSourceCodeInfo());return vs([jt,[n,o]],a[2])}if(Yi(a,"...")){if(n)throw new r("Rest element not allowed",a[2]);e.advance();const t=Kt(Ms(e));if(Yi(e.tryPeek(),"="))throw new r("Rest argument can not have default value",e.peekSourceCodeInfo());return vs([Mt,[t[1],void 0]],a[2])}if(ns(a)){e.advance();const n=[];let i=e.peek(),s=!1;for(;!as(i);){if(s)throw new r("Rest argument must be last",i[2]);if(Yi(i,",")){n.push(null),e.advance(),i=e.peek();continue}const t=Ps(e,{allowLiteralPatterns:o});t[0]===Mt&&(s=!0),n.push(t),i=e.peek(),as(i)||(Hi(i,","),e.advance()),i=e.peek()}e.advance();const c=Rs(e);if(t&&!c)throw new r("Expected assignment",e.peekSourceCodeInfo());return vs([Pt,[n,c]],a[2])}if(ss(a)){e.advance();const n={};let i=e.peek(),s=!1;for(;!ls(i);){if(s)throw new r("Rest argument must be last",i[2]);Yi(i,"...")&&(s=!0,e.advance());const t=Ms(e),c=ks(t);if(i=e.peek(),_i(i,"as")){if(s)throw new r("Rest argument can not have alias",i[2]);e.advance();const t=Kt(Ms(e));if(n[t[1]])throw new r(`Duplicate binding name: ${t}`,i[2]);n[c]=vs([jt,[t,Rs(e)]],a[2])}else if(ls(i)||Yi(i,",")||Yi(i,"=")){const o=Kt(t,t[2]);if(n[o[1]])throw new r(`Duplicate binding name: ${o}`,i[2]);if(s&&Yi(e.tryPeek(),"="))throw new r("Rest argument can not have default value",e.peekSourceCodeInfo());n[o[1]]=vs(s?[Mt,[o[1],Rs(e)]]:[jt,[o,Rs(e)]],a[2])}else if(Yi(i,":")){if(e.advance(),i=e.peek(),o){if(!ss(i)&&!ns(i)&&!Is(i))throw new r("Expected literal, object or array pattern",i[2])}else if(!ss(i)&&!ns(i))throw new r("Expected object or array",i[2]);n[c]=Ps(e,{allowLiteralPatterns:o})}ls(e.peek())||(Hi(e.peek(),","),e.advance()),i=e.peek()}e.advance(),i=e.peek();const c=Rs(e);if(t&&!c)throw new r("Expected assignment",i[2]);return vs([Ct,[n,c]],a[2])}throw new r("Expected symbol",e.peekSourceCodeInfo())}function Rs(e){if(Yi(e.tryPeek(),"="))return e.advance(),e.parseExpression()}function Is(e){return Xi(e)||Zi(e)||ms(e)||_i(e,"true")||_i(e,"false")||_i(e,"null")}function Os(e,t){e.advance();const r=Ps(e,{requireDefaultValue:!0,noRest:!0}),n=r[1][1];r[1][1]=void 0;const o=vs([s.Binding,[r,n]],t[2]);return vs([s.SpecialExpression,[wr.let,o]],t[2])}function Fs(e){const t=function(e){const t=Li(e.tryPeek()),r=Kt(Ms(e));Ki(e.tryPeek(),"in"),e.advance();const n=e.parseExpression();return vs([s.Binding,[vs([jt,[r,void 0]],t[2]),n]],t[2])}(e),n=[];let o=e.peek();Us(o,["let","when","while"]);const a=[];if("let"===o[1])for(n.push("&let");Bi(o,"let");){const t=Os(e,o),n=a.flatMap(e=>Object.keys(Dt(e[1][0])));if(Object.keys(Dt(t[1][1][1][0])).some(e=>n.includes(e)))throw new r("Duplicate binding",t[1][1][2]);a.push(t[1][1]),o=e.peek(),Us(o,["let","when","while"]),o=e.peek()}let i,c;for(;_i(o,"when")||_i(o,"while");){e.advance(),"when"===o[1]?(n.push("&when"),i=e.parseExpression()):(n.push("&while"),c=e.parseExpression()),o=e.peek();Us(o,n.includes("&when")&&n.includes("&while")?[]:n.includes("&when")?["while"]:["when"]),o=e.peek()}return Us(o,[]),[t,a,i,c]}function Us(e,t){if(!function(e,t){if(Yi(e,",")||ts(e))return!0;for(const r of t){if("let"===r&&Bi(e,"let"))return!0;if(["when","while"].includes(r)&&_i(e,r))return!0}return!1}(e,t)){const n=`${[...t,","].map(e=>`"${e}"`).join(", ")} or ")"`;throw new r(`Expected symbol ${n}`,e[2])}}function Ds(e){const t=Ji(e.tryPeek());e.advance();const r=t[1];return function(e){return e in vi}(r)?vs([s.Number,vi[r]],t[2]):vs([s.ReservedSymbol,t[1]],t[2])}const Ws=/^\$([1-9]\d?)?$/;function Gs(e){const t=e.peek();if(Qi(t)&&Bi(e.peekAhead(1))&&Yi(e.peekAhead(2),"->"))return null;try{const n=function(e){const t=e.peek();if(Bi(t))return[vs([jt,[Ms(e),void 0]],t[2])];es(t),e.advance();let n=!1,o=!1;const a=[];for(;!e.isAtEnd()&&!ts(e.peek())&&!Bi(e.peek(),"let");){if(n)throw new r("Rest argument must be last",e.peekSourceCodeInfo());const t=Ps(e);if(void 0!==t[1][1]&&(o=!0),t[0]===Mt&&(n=!0),o&&!t[1][1])throw new r("Default arguments must be last",e.peekSourceCodeInfo());if(a.push(t),!Yi(e.peek(),",")&&!ts(e.peek())&&!Bi(e.peek(),"let"))throw new r("Expected comma or closing parenthesis",e.peekSourceCodeInfo());Yi(e.peek(),",")&&e.advance()}if(!ts(e.peek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());return e.advance(),a}(e);if(!Yi(e.peek(),"->"))return null;let o;e.advance();let a="";if(_i(e.peek(),"do")){const t=js(e,!0);a=t[1],o=t[0][1][1]}else o=[e.parseExpression()];return vs([s.SpecialExpression,[wr["0_lambda"],[n,o],a]],t[2])}catch{return null}}function Vs(e,t){e.advance();const n=[];for(;!e.isAtEnd()&&!ts(e.tryPeek());){Yi(e.tryPeek(),"...")?(e.advance(),n.push(vs([s.Spread,e.parseExpression()],e.peekSourceCodeInfo()))):n.push(e.parseExpression());const t=e.tryPeek();if(!Yi(t,",")&&!ts(t))throw new r("Expected comma or closing parenthesis",e.tryPeek()?.[2]);Yi(t,",")&&e.advance()}if(!ts(e.tryPeek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());if(e.advance(),!Yt(t))return Jt(t)||_t(t)?qs(t,n,t[2]):vs([s.NormalExpression,[t,n]],t[2]);{const e=t[1];if(e===wr.import){if(1!==n.length)throw new r(`import expects exactly 1 argument, got ${n.length}`,t[2]);const o=n[0];if(!_t(o))throw new r("import expects a module name (symbol), got a non-symbol argument",o[2]??t[2]);const a=o[1];return vs([s.SpecialExpression,[e,a]],t[2])}const o=e;switch(ne(qr.specialExpressions[o].arity,n.length,t[2]),o){case wr["||"]:case wr["&&"]:case wr.recur:case wr.array:case wr.object:case wr["??"]:return vs([s.SpecialExpression,[o,n]],t[2]);case wr["defined?"]:{const[e]=n;return vs([s.SpecialExpression,[o,e]],t[2])}case wr.throw:{const[e]=n;return vs([s.SpecialExpression,[o,e]],t[2])}case wr["0_lambda"]:throw new r(`${o} is not allowed`,t[2]);default:throw new r(`Unknown special expression: ${o}`,t[2])}}}function Bs(e){const t=cs(e.tryPeek());e.advance();const n=[];for(;!e.isAtEnd()&&!ls(e.tryPeek());){if(Yi(e.tryPeek(),"..."))e.advance(),n.push(vs([s.Spread,e.parseExpression()],e.peekSourceCodeInfo()));else{const t=e.tryPeek();if(ms(t)){const r=Es(e,t);n.push(vs([s.String,r[1]],t[2]))}else if(Bi(t)){const r=t[1].startsWith("'")?bs(t[1]):t[1];n.push(vs([s.String,r],t[2])),e.advance()}else{if(!ns(t))throw new r("Expected key to be a symbol or a string",e.peekSourceCodeInfo());e.advance(),n.push(e.parseExpression()),is(e.tryPeek()),e.advance()}Hi(e.tryPeek(),":"),e.advance(),n.push(e.parseExpression())}const t=e.tryPeek();if(!Yi(t,",")&&!ls(t))throw new r("Expected comma or closing brace",e.peekSourceCodeInfo());Yi(t,",")&&e.advance()}var o;return ls(o=e.tryPeek())||ps("RBrace",void 0,o),e.advance(),vs([s.SpecialExpression,[wr.object,n]],t[2])}function Ls(e){let t=function(e){const t=e.peek();if(Qi(t)){e.storePosition();const t=Gs(e);if(t)return t;e.restorePosition(),e.advance();const n=e.parseExpression();if(!ts(e.peek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());return e.advance(),n}if(Yi(t)){const n=t[1];if(jr(n))return e.advance(),vs(void 0!==wr[n]?[s.SpecialBuiltinSymbol,wr[n]]:[s.NormalBuiltinSymbol,Tt[n]],t[2]);if("->"===n)return function(e){const t=e.peek();e.advance();const n=e.getPosition();let o,a="";if(_i(e.peek(),"do")){const t=js(e,!0);a=t[1],o=t[0][1][1]}else o=[e.parseExpression()];const i=e.getPosition()-1;let c=0,l="NOT_SET";for(let o=n;o<=i;o+=1){const n=e.getTokenAt(o);if(Bi(n)){const e=Ws.exec(n[1]);if(e){const n=e[1]??"1";if("1"===n){if(!e[1]&&"WITH_1"===l||e[1]&&"NAKED"===l)throw new r("Please make up your mind, either use $ or $1",t[2]);l=e[1]?"WITH_1":"NAKED"}if(c=Math.max(c,Number(n)),c>20)throw new r("Can't specify more than 20 arguments",t[2])}}}const m=[];for(let e=1;e<=c;e+=1)1===e&&"NAKED"===l?m.push(vs([jt,[[s.UserDefinedSymbol,"$"],void 0]],t[2])):m.push(vs([jt,[[s.UserDefinedSymbol,`$${e}`],void 0]],t[2]));return vs([s.SpecialExpression,[wr["0_lambda"],[m,o],a]],t[2])}(e);throw new r(`Illegal operator: ${n}`,t[2])}if(ss(t))return Bs(e);if(ns(t))return function(e){const t=os(e.tryPeek());e.advance();const n=[];for(;!e.isAtEnd()&&!as(e.tryPeek());){Yi(e.tryPeek(),"...")?(e.advance(),n.push(vs([s.Spread,e.parseExpression()],e.peekSourceCodeInfo()))):n.push(e.parseExpression());const t=e.tryPeek();if(!Yi(t,",")&&!as(t))throw new r("Expected comma or closing parenthesis",e.peekSourceCodeInfo());Yi(t,",")&&e.advance()}return is(e.tryPeek()),e.advance(),vs([s.SpecialExpression,[wr.array,n]],t[2])}(e);const n=t[0];switch(n){case"Number":case"BasePrefixedNumber":return Cs(e);case"string":return Es(e,t);case"Symbol":{e.storePosition();const t=Gs(e);return t||(e.restorePosition(),Ms(e))}case"ReservedSymbol":return Ds(e);case"RegexpShorthand":return function(e){const t=e.peek();e.advance();const r=t[1].lastIndexOf('"'),n=t[1].substring(2,r),o=t[1].substring(r+1),a=vs([s.String,n],t[2]),i=vs([s.String,o],t[2]);return vs([s.NormalExpression,[vs([s.NormalBuiltinSymbol,Tt.regexp],t[2]),[a,i]]],t[2])}(e);default:throw new r(`Unknown token type: ${n}`,t[2])}}(e),n=e.tryPeek();for(;Yi(n,".")||ns(n)||Qi(n);)if("."===n[1]){e.advance();const o=e.tryPeek();if(!Bi(o))throw new r("Expected symbol",e.peekSourceCodeInfo());t=_s(t,vs([s.String,o[1]],o[2]),n[2]),e.advance(),n=e.tryPeek()}else if(ns(n)){e.advance();const o=e.parseExpression();if(!as(e.tryPeek()))throw new r("Expected closing bracket",e.peekSourceCodeInfo());t=_s(t,o,n[2]),e.advance(),n=e.tryPeek()}else Qi(n)&&(t=Vs(e,t),n=e.tryPeek());return t}function _s(e,t,r){return vs([s.NormalExpression,[[s.NormalBuiltinSymbol,Tt.get],[e,t]]],r)}function Ks(e,t=0){const n=e.tryPeek();let o;if(Bi(n))switch(n[1]){case"let":return Os(e,n);case"if":case"unless":o=function(e,t){const r="unless"===t[1];e.advance();const n=e.parseExpression();Ki(e.tryPeek(),"then"),e.advance();const o=zs(e,["else","end"]);let a;return _i(e.tryPeek(),"else")&&(e.advance(),a=zs(e,["end"])),e.advance(),vs(r?[s.SpecialExpression,[wr.unless,[n,o,a]]]:[s.SpecialExpression,[wr.if,[n,o,a]]],t[2])}(e,n);break;case"cond":o=function(e,t){e.advance();const r=[];for(;!e.isAtEnd()&&!_i(e.tryPeek(),"end");){Ki(e.tryPeek(),"case"),e.advance();const t=e.parseExpression();Ki(e.tryPeek(),"then"),e.advance();const n=zs(e,["case","end"]);if(r.push([t,n]),_i(e.tryPeek(),"end"))break}return Ki(e.tryPeek()),e.advance(),vs([s.SpecialExpression,[wr.cond,r]],t[2])}(e,n);break;case"match":o=function(e,t){e.advance();const r=e.parseExpression(),n=[];for(;!e.isAtEnd()&&!_i(e.tryPeek(),"end");){Ki(e.tryPeek(),"case"),e.advance();const t=Ps(e,{allowLiteralPatterns:!0});let r;_i(e.tryPeek(),"when")&&(e.advance(),r=e.parseExpression()),Ki(e.tryPeek(),"then"),e.advance();const o=zs(e,["case","end"]);if(n.push([t,o,r]),_i(e.tryPeek(),"end"))break}return Ki(e.tryPeek(),"end"),e.advance(),vs([s.SpecialExpression,[wr.match,r,n]],t[2])}(e,n);break;case"for":case"doseq":o=function(e,t){const n="doseq"===t[1];e.advance(),es(e.tryPeek()),e.advance();const o=[];for(;!e.isAtEnd()&&!ts(e.tryPeek());){const t=Fs(e),n=o.flatMap(e=>Object.keys(Dt(e[0][1][0]))),a=Dt(t[0][1][0]);if(Object.keys(a).some(e=>n.includes(e)))throw new r("Duplicate binding",t[0][2]);o.push(t),Yi(e.tryPeek(),",")&&e.advance()}rs(e.tryPeek()),e.advance(),Hi(e.tryPeek(),"->"),e.advance();const a=e.parseExpression();return vs(n?[s.SpecialExpression,[wr.doseq,o,a]]:[s.SpecialExpression,[wr.for,o,a]],t[2])}(e,n);break;case"loop":o=function(e,t){e.advance(),es(e.tryPeek()),e.advance();const n=[];let o=e.tryPeek();for(;!e.isAtEnd()&&!ts(o);){const t=Ps(e,{requireDefaultValue:!0,noRest:!0}),r=t[1][1];t[1][1]=void 0,n.push(vs([s.Binding,[t,r]],t[2])),Yi(e.tryPeek(),",")&&e.advance(),o=e.tryPeek()}if(0===n.length)throw new r("Expected binding",e.peekSourceCodeInfo());rs(o),e.advance(),Hi(e.tryPeek(),"->"),e.advance();const a=e.parseExpression();return vs([s.SpecialExpression,[wr.loop,n,a]],t[2])}(e,n);break;case"try":o=function(e,t){e.advance();const r=zs(e,["catch"]);let n;e.advance(),Qi(e.tryPeek())&&(e.advance(),n=Ms(e),rs(e.tryPeek()),e.advance());const o=zs(e,["end"]);return e.advance(),vs([s.SpecialExpression,[wr.try,r,n,o]],t[2])}(e,n)}else _i(n,"do")&&(o=js(e)[0]);o||=Ls(e);let a=e.tryPeek();for(;!As(e);){if(us(a)){const r=a[1],n=Ts(r,a[2]);if(n<=t&&(12!==n||12!==t))break;const i=vs(wr[r]?[s.SpecialBuiltinSymbol,wr[r]]:[s.NormalBuiltinSymbol,Tt[r]],a[2]);e.advance();o=Ns(a,i,o,Ks(e,n),a[2])}else if(Bi(a)){if(!Sr(a[1]))break;const n=3;if(n<=t)break;const i=Ms(e),s=Ks(e,n);if(Yt(i))throw new r("Special expressions are not allowed in binary functional operators",i[2]);o=qs(i,[o,s],a[2])}else{if("?"!==a?.[1])break;{if(1<=t)break;e.advance();const n=Ks(e);if(!Yi(e.tryPeek(),":"))throw new r("Expected :",e.peekSourceCodeInfo());e.advance();const a=Ks(e);o=vs([s.SpecialExpression,[wr.if,[o,n,a]]],o[2])}}a=e.tryPeek()}return o}function Js(e){e.tokens.forEach(e=>{if("Error"===e[0])throw new r(e[3],e[2])});const t=[],n=function(e){const t=new $s(e);return t.parseExpression=(e=0)=>Ks(t,e),t}(e);for(;!n.isAtEnd();)if(t.push(Ks(n,0)),Yi(n.tryPeek(),";"))n.advance();else if(!n.isAtEnd())throw new r("Expected ;",n.peekSourceCodeInfo());return t}class Ys{cache={};firstEntry=void 0;lastEntry=void 0;_size=0;maxSize;constructor(e){if(this.maxSize=null===e?null:ue(e),"number"==typeof this.maxSize&&this.maxSize<1)throw new Error(`1 is the minimum maxSize, got ${d(e)}`)}getContent(){return Object.entries(this.cache).reduce((e,[t,r])=>(e[t]=r.value,e),{})}get size(){return this._size}get(e){return this.cache[e]?.value}clear(){this.cache={},this.firstEntry=void 0,this.lastEntry=void 0,this._size=0}has(e){return!!this.cache[e]}set(e,t){if(this.has(e))throw new Error(`AstCache - key already present: ${e}`);const r={value:t,nextEntry:void 0,key:e};for(this.cache[e]=r,this._size+=1,this.lastEntry&&(this.lastEntry.nextEntry=r),this.lastEntry=r,this.firstEntry||(this.firstEntry=this.lastEntry);null!==this.maxSize&&this.size>this.maxSize;)this.dropFirstEntry()}dropFirstEntry(){const e=this.firstEntry;delete this.cache[e.key],this._size-=1,this.firstEntry=e.nextEntry}}class Hs{astCache;astCacheSize;debug;modules;constructor(e={}){if(this.debug=e.debug??!1,this.astCacheSize=e.astCacheSize??null,this.astCacheSize){this.astCache=new Ys(this.astCacheSize);const t=e.initialCache??{};for(const e of Object.keys(t))this.astCache.set(e,t[e])}else this.astCache=null;const t=e.modules??[];this.modules=new Map(t.map(e=>[e.name,e]))}getRuntimeInfo(){return{astCacheSize:this.astCacheSize,astCache:this.astCache,debug:this.debug}}async={run:async(e,t={})=>{if(ys(e))return this.runBundle(e,t);const r=this.generateAst(e,t);return this.evaluate(r,t)},apply:async(e,t,r={})=>this.apply(e,t,r)};run(e,t={}){if(ys(e))return this.runBundle(e,t);const r=this.generateAst(e,t),n=this.evaluate(r,t);if(n instanceof Promise)throw new TypeError("Unexpected async result in synchronous run(). Use lits.async.run() for async operations.");return n}runBundle(e,t={}){const r=$i(t,this.modules,t.pure),n=r.pure;r.pure=!0;for(const[n,o]of e.fileModules){const e=xi(this.generateAst(o,t),r.create({}));r.registerValueModule(n,e)}r.pure=n;const o=xi(this.generateAst(e.program,t),r);if(o instanceof Promise)throw new TypeError("Unexpected async result in synchronous runBundle(). Use lits.async.run() for async operations.");return o}getUndefinedSymbols(e,t={}){const r="string"==typeof e?this.generateAst(e,t):e,n=$i(t,this.modules);return hi(r,n,qr,wi)}tokenize(e,t={}){const r=function(e,t,r){let n=0;const o={tokens:[],filePath:r,hasDebugData:t};for(;n<e.length;){const a=t?Gi(e,n,r):void 0,i=Vi(e,n),[s,c]=i;n+=s,c&&(a&&(c[2]=a),o.tokens.push(c))}return o}(e,this.debug,t.filePath);return t.minify?gs(r,{removeWhiteSpace:!1}):r}parse(e){const t={body:[],hasDebugData:(e=gs(e,{removeWhiteSpace:!0})).hasDebugData};return t.body=Js(e),t}evaluate(e,t){return xi(e,$i(t,this.modules,t.pure))}transformSymbols(e,t){return function(e,t){return{...e,tokens:e.tokens.map(e=>Bi(e)?[e[0],t(e[1])]:e)}}(e,t)}untokenize(e){return function(e){return e.tokens.reduce((e,t)=>`${e}${t[1]}`,"")}(e)}apply(e,t,r={}){const n="FN_2eb7b316_471c_5bfa_90cb_d3dfd9164a59",o=this.generateApplyFunctionCall(n,t),a=this.generateAst(o,r),i=t.reduce((e,t,r)=>(e[`${n}_${r}`]=t,e),{[n]:e});return r.bindings={...r.bindings,...i},this.evaluate(a,r)}generateApplyFunctionCall(e,t){const r=t.map((t,r)=>`${e}_${r}`).join(", ");return`${e}(${r})`}generateAst(e,t){if(this.astCache){const t=this.astCache.get(e);if(t)return t}const r=this.tokenize(e,{filePath:t.filePath}),n=this.parse(r);return this.astCache?.set(e,n),n}getAutoCompleter(e,t,r={}){return new ds(e,t,this,r)}}const Xs=[Ur,Vr,Jr,Mn,Ln,eo,ga,za,Sa,va,qa,$a,ja,Fa];function Zs(e){return[`number-theory.${e}-seq`,`number-theory.${e}-nth`,`number-theory.${e}-take-while`,`number-theory.${e}?`]}function Qs(e){const t=e.replace(/^/,"");return[`vector.${e}`,`vector.moving-${t}`,`vector.centered-moving-${t}`,`vector.running-${t}`]}function ec(e){return[`vector.moving-${e}`,`vector.centered-moving-${e}`,`vector.running-${e}`]}const tc={collection:["filter","map","reduce","count","get","contains?","assoc","++"],collectionUtils:["collection.filteri","collection.mapi","collection.reducei","collection.reduce-right","collection.reducei-right","collection.reductions","collection.reductionsi","collection.get-in","collection.assoc-in","collection.update","collection.update-in","collection.not-empty","collection.every?","collection.not-every?","collection.any?","collection.not-any?"],array:["range","repeat","flatten","mapcat","moving-fn","running-fn"],sequence:["nth","push","pop","index-of","some","reverse","first","second","last","rest","next","sort","slice","take","take-last","drop","drop-last","take-while","drop-while"],sequenceUtils:["sequence.position","sequence.last-index-of","sequence.unshift","sequence.splice","sequence.sort-by","sequence.distinct","sequence.remove","sequence.remove-at","sequence.split-at","sequence.split-with","sequence.frequencies","sequence.group-by","sequence.partition","sequence.partition-all","sequence.partition-by","sequence.starts-with?","sequence.ends-with?","sequence.interleave","sequence.interpose"],math:["+","-","*","/","mod","%","quot","inc","dec","sqrt","cbrt","^","round","trunc","floor","ceil","min","max","abs","sign"],mathUtils:["math.ln","math.log2","math.log10","math.sin","math.cos","math.tan","math.asin","math.acos","math.atan","math.sinh","math.cosh","math.tanh","math.asinh","math.acosh","math.atanh","math.to-rad","math.to-deg"],functional:["|>","apply","identity","comp","constantly"],functionalUtils:["functional.juxt","functional.complement","functional.every-pred","functional.some-pred","functional.fnull"],meta:["doc","arity"],misc:["!=","==","<",">","<=",">=","not","write!","iso-date->epoch","epoch->iso-date","boolean","compare","identical?","json-parse","json-stringify"],object:["dissoc","keys","vals","entries","find","merge","merge-with","zipmap","select-keys"],predicate:["boolean?","null?","number?","string?","function?","integer?","array?","object?","collection?","sequence?","regexp?","zero?","pos?","neg?","even?","odd?","finite?","negative-infinity?","positive-infinity?","false?","true?","empty?","not-empty?","vector?","grid?","matrix?"],regularExpression:["regexp","re-match","replace","replace-all"],string:["str","number","lower-case","upper-case","trim","split","join","blank?"],stringUtils:["string.string-repeat","string.from-char-code","string.to-char-code","string.trim-left","string.trim-right","string.pad-left","string.pad-right","string.split-lines","string.template","string.encode-base64","string.decode-base64","string.encode-uri-component","string.decode-uri-component","string.capitalize"],bitwise:["<<",">>",">>>","&","|","xor"],bitwiseUtils:["bitwise.bit-not","bitwise.bit-and-not","bitwise.bit-flip","bitwise.bit-clear","bitwise.bit-set","bitwise.bit-test"],assertion:["assert"],assertionUtils:["assertion.assert=","assertion.assert!=","assertion.assert-gt","assertion.assert-lt","assertion.assert-gte","assertion.assert-lte","assertion.assert-true","assertion.assert-false","assertion.assert-truthy","assertion.assert-falsy","assertion.assert-null","assertion.assert-throws","assertion.assert-throws-error","assertion.assert-not-throws","assertion.assert-array","assertion.assert-boolean","assertion.assert-collection","assertion.assert-function","assertion.assert-grid","assertion.assert-integer","assertion.assert-matrix","assertion.assert-number","assertion.assert-object","assertion.assert-regexp","assertion.assert-sequence","assertion.assert-string","assertion.assert-vector"],grid:["grid.cell-every?","grid.some?","grid.every-row?","grid.some-row?","grid.every-col?","grid.some-col?","grid.row","grid.col","grid.shape","grid.fill","grid.generate","grid.reshape","grid.transpose","grid.flip-h","grid.flip-v","grid.rotate","grid.crop","grid.slice-rows","grid.slice-cols","grid.splice-rows","grid.splice-cols","grid.concat-rows","grid.concat-cols","grid.cell-map","grid.cell-mapi","grid.cell-reduce","grid.cell-reducei","grid.push-rows","grid.unshift-rows","grid.pop-row","grid.shift-row","grid.push-cols","grid.unshift-cols","grid.pop-col","grid.shift-col","grid.from-array"],matrix:["matrix.mul","matrix.det","matrix.inv","matrix.adj","matrix.cofactor","matrix.minor","matrix.trace","matrix.symmetric?","matrix.triangular?","matrix.upper-triangular?","matrix.lower-triangular?","matrix.diagonal?","matrix.square?","matrix.orthogonal-matrix?","matrix.identity?","matrix.invertible?","matrix.hilbert","matrix.vandermonde","matrix.band","matrix.banded?","matrix.rank","matrix.frobenius-norm","matrix.one-norm","matrix.inf-norm","matrix.max-norm"],vector:["sum","mean","median","prod"],vectorUtils:["vector.monotonic?","vector.strictly-monotonic?","vector.increasing?","vector.decreasing?","vector.strictly-increasing?","vector.strictly-decreasing?","vector.mode","vector.min-index","vector.max-index","vector.sort-indices","vector.count-values","vector.linspace","vector.cumsum","vector.cumprod","vector.quartiles","vector.percentile","vector.quantile","vector.histogram","vector.ecdf","vector.outliers?","vector.outliers","vector.bincount","vector.winsorize","vector.mse","vector.mae","vector.rmse","vector.smape",...ec("mean"),...ec("median"),...Qs("variance"),...Qs("sample-variance"),...ec("sum"),...ec("prod"),...Qs("stdev"),...Qs("sample-stdev"),...Qs("iqr"),...Qs("span"),...Qs("geometric-mean"),...Qs("harmonic-mean"),...Qs("skewness"),...Qs("sample-skewness"),...Qs("kurtosis"),...Qs("sample-kurtosis"),...Qs("excess-kurtosis"),...Qs("sample-excess-kurtosis"),...Qs("rms"),...Qs("mad"),...Qs("medad"),...Qs("gini-coefficient"),...Qs("entropy"),...Qs("skewness")],linAlg:["linear-algebra.reflect","linear-algebra.refract","linear-algebra.lerp","linear-algebra.rotate2d","linear-algebra.rotate3d","linear-algebra.dot","linear-algebra.cross","linear-algebra.normalize-minmax","linear-algebra.normalize-zscore","linear-algebra.normalize-robust","linear-algebra.normalize-l1","linear-algebra.normalize-l2","linear-algebra.normalize-log","linear-algebra.angle","linear-algebra.projection","linear-algebra.orthogonal?","linear-algebra.parallel?","linear-algebra.collinear?","linear-algebra.cosine-similarity","linear-algebra.euclidean-distance","linear-algebra.euclidean-norm","linear-algebra.manhattan-distance","linear-algebra.manhattan-norm","linear-algebra.hamming-distance","linear-algebra.hamming-norm","linear-algebra.chebyshev-distance","linear-algebra.chebyshev-norm","linear-algebra.minkowski-distance","linear-algebra.minkowski-norm","linear-algebra.cov","linear-algebra.corr","linear-algebra.spearman-corr","linear-algebra.pearson-corr","linear-algebra.kendall-tau","linear-algebra.autocorrelation","linear-algebra.cross-correlation","linear-algebra.rref","linear-algebra.solve","linear-algebra.to-polar","linear-algebra.from-polar"],numberTheory:[...Zs("abundant"),...Zs("arithmetic"),...Zs("bell"),...Zs("catalan"),...Zs("composite"),...Zs("deficient"),...Zs("factorial"),...Zs("fibonacci"),...Zs("geometric"),...Zs("golomb"),...Zs("happy"),...Zs("look-and-say"),...Zs("lucas"),...Zs("lucky"),...Zs("mersenne"),...Zs("padovan"),...Zs("partition"),...Zs("pell"),...Zs("perfect"),...Zs("perfect-cube"),...Zs("perfect-power"),...Zs("perfect-square"),...Zs("polygonal"),...Zs("prime"),...Zs("recaman"),...Zs("sylvester"),...Zs("thue-morse"),...Zs("tribonacci"),"number-theory.collatz-seq","number-theory.juggler-seq","number-theory.bernoulli-seq","number-theory.bernoulli-take-while","number-theory.bernoulli-nth","number-theory.combinations","number-theory.count-combinations","number-theory.derangements","number-theory.count-derangements","number-theory.divisors","number-theory.count-divisors","number-theory.proper-divisors","number-theory.count-proper-divisors","number-theory.prime-factors","number-theory.count-prime-factors","number-theory.distinct-prime-factors","number-theory.count-distinct-prime-factors","number-theory.factorial","number-theory.partitions","number-theory.count-partitions","number-theory.permutations","number-theory.count-permutations","number-theory.power-set","number-theory.count-power-set","number-theory.coprime?","number-theory.divisible-by?","number-theory.gcd","number-theory.lcm","number-theory.multinomial","number-theory.amicable?","number-theory.euler-totient","number-theory.mobius","number-theory.mertens","number-theory.sigma","number-theory.carmichael-lambda","number-theory.cartesian-product","number-theory.perfect-power","number-theory.mod-exp","number-theory.mod-inv","number-theory.extended-gcd","number-theory.chinese-remainder","number-theory.stirling-first","number-theory.stirling-second"],random:["random.random!","random.random-int!","random.random-int-inclusive!","random.random-float!","random.random-boolean!","random.random-item!","random.random-sample!","random.random-sample-unique!","random.shuffle!","random.random-normal!","random.random-exponential!","random.random-binomial!","random.random-poisson!","random.random-gamma!","random.random-pareto!","random.uuid!","random.random-char!","random.random-string!","random.random-id!","random.random-color!"],convert:["convert.angstrom->um","convert.angstrom->mm","convert.angstrom->cm","convert.angstrom->m","convert.angstrom->km","convert.angstrom->in","convert.angstrom->ft","convert.angstrom->yd","convert.angstrom->mi","convert.angstrom->nmi","convert.um->angstrom","convert.um->mm","convert.um->cm","convert.um->m","convert.um->km","convert.um->in","convert.um->ft","convert.um->yd","convert.um->mi","convert.um->nmi","convert.mm->angstrom","convert.mm->um","convert.mm->cm","convert.mm->m","convert.mm->km","convert.mm->in","convert.mm->ft","convert.mm->yd","convert.mm->mi","convert.mm->nmi","convert.cm->angstrom","convert.cm->um","convert.cm->mm","convert.cm->m","convert.cm->km","convert.cm->in","convert.cm->ft","convert.cm->yd","convert.cm->mi","convert.cm->nmi","convert.m->angstrom","convert.m->um","convert.m->mm","convert.m->cm","convert.m->km","convert.m->in","convert.m->ft","convert.m->yd","convert.m->mi","convert.m->nmi","convert.km->angstrom","convert.km->um","convert.km->mm","convert.km->cm","convert.km->m","convert.km->in","convert.km->ft","convert.km->yd","convert.km->mi","convert.km->nmi","convert.in->angstrom","convert.in->um","convert.in->mm","convert.in->cm","convert.in->m","convert.in->km","convert.in->ft","convert.in->yd","convert.in->mi","convert.in->nmi","convert.ft->angstrom","convert.ft->um","convert.ft->mm","convert.ft->cm","convert.ft->m","convert.ft->km","convert.ft->in","convert.ft->yd","convert.ft->mi","convert.ft->nmi","convert.yd->angstrom","convert.yd->um","convert.yd->mm","convert.yd->cm","convert.yd->m","convert.yd->km","convert.yd->in","convert.yd->ft","convert.yd->mi","convert.yd->nmi","convert.mi->angstrom","convert.mi->um","convert.mi->mm","convert.mi->cm","convert.mi->m","convert.mi->km","convert.mi->in","convert.mi->ft","convert.mi->yd","convert.mi->nmi","convert.nmi->angstrom","convert.nmi->um","convert.nmi->mm","convert.nmi->cm","convert.nmi->m","convert.nmi->km","convert.nmi->in","convert.nmi->ft","convert.nmi->yd","convert.nmi->mi","convert.mg->g","convert.mg->kg","convert.mg->t","convert.mg->oz","convert.mg->lb","convert.mg->st","convert.g->mg","convert.g->kg","convert.g->t","convert.g->oz","convert.g->lb","convert.g->st","convert.kg->mg","convert.kg->g","convert.kg->t","convert.kg->oz","convert.kg->lb","convert.kg->st","convert.t->mg","convert.t->g","convert.t->kg","convert.t->oz","convert.t->lb","convert.t->st","convert.oz->mg","convert.oz->g","convert.oz->kg","convert.oz->t","convert.oz->lb","convert.oz->st","convert.lb->mg","convert.lb->g","convert.lb->kg","convert.lb->t","convert.lb->oz","convert.lb->st","convert.st->mg","convert.st->g","convert.st->kg","convert.st->t","convert.st->oz","convert.st->lb","convert.ml->cl","convert.ml->dl","convert.ml->l","convert.ml->tsp","convert.ml->tbsp","convert.ml->fl-oz","convert.ml->cup","convert.ml->pt","convert.ml->qt","convert.ml->gal","convert.cl->ml","convert.cl->dl","convert.cl->l","convert.cl->tsp","convert.cl->tbsp","convert.cl->fl-oz","convert.cl->cup","convert.cl->pt","convert.cl->qt","convert.cl->gal","convert.dl->ml","convert.dl->cl","convert.dl->l","convert.dl->tsp","convert.dl->tbsp","convert.dl->fl-oz","convert.dl->cup","convert.dl->pt","convert.dl->qt","convert.dl->gal","convert.l->ml","convert.l->cl","convert.l->dl","convert.l->tsp","convert.l->tbsp","convert.l->fl-oz","convert.l->cup","convert.l->pt","convert.l->qt","convert.l->gal","convert.tsp->ml","convert.tsp->cl","convert.tsp->dl","convert.tsp->l","convert.tsp->tbsp","convert.tsp->fl-oz","convert.tsp->cup","convert.tsp->pt","convert.tsp->qt","convert.tsp->gal","convert.tbsp->ml","convert.tbsp->cl","convert.tbsp->dl","convert.tbsp->l","convert.tbsp->tsp","convert.tbsp->fl-oz","convert.tbsp->cup","convert.tbsp->pt","convert.tbsp->qt","convert.tbsp->gal","convert.fl-oz->ml","convert.fl-oz->cl","convert.fl-oz->dl","convert.fl-oz->l","convert.fl-oz->tsp","convert.fl-oz->tbsp","convert.fl-oz->cup","convert.fl-oz->pt","convert.fl-oz->qt","convert.fl-oz->gal","convert.cup->ml","convert.cup->cl","convert.cup->dl","convert.cup->l","convert.cup->tsp","convert.cup->tbsp","convert.cup->fl-oz","convert.cup->pt","convert.cup->qt","convert.cup->gal","convert.pt->ml","convert.pt->cl","convert.pt->dl","convert.pt->l","convert.pt->tsp","convert.pt->tbsp","convert.pt->fl-oz","convert.pt->cup","convert.pt->qt","convert.pt->gal","convert.qt->ml","convert.qt->cl","convert.qt->dl","convert.qt->l","convert.qt->tsp","convert.qt->tbsp","convert.qt->fl-oz","convert.qt->cup","convert.qt->pt","convert.qt->gal","convert.gal->ml","convert.gal->cl","convert.gal->dl","convert.gal->l","convert.gal->tsp","convert.gal->tbsp","convert.gal->fl-oz","convert.gal->cup","convert.gal->pt","convert.gal->qt","convert.ms->s","convert.ms->min","convert.ms->h","convert.ms->day","convert.ms->week","convert.s->ms","convert.s->min","convert.s->h","convert.s->day","convert.s->week","convert.min->ms","convert.min->s","convert.min->h","convert.min->day","convert.min->week","convert.h->ms","convert.h->s","convert.h->min","convert.h->day","convert.h->week","convert.day->ms","convert.day->s","convert.day->min","convert.day->h","convert.day->week","convert.week->ms","convert.week->s","convert.week->min","convert.week->h","convert.week->day","convert.mm2->cm2","convert.mm2->m2","convert.mm2->km2","convert.mm2->in2","convert.mm2->ft2","convert.mm2->yd2","convert.mm2->acre","convert.mm2->hectare","convert.cm2->mm2","convert.cm2->m2","convert.cm2->km2","convert.cm2->in2","convert.cm2->ft2","convert.cm2->yd2","convert.cm2->acre","convert.cm2->hectare","convert.m2->mm2","convert.m2->cm2","convert.m2->km2","convert.m2->in2","convert.m2->ft2","convert.m2->yd2","convert.m2->acre","convert.m2->hectare","convert.km2->mm2","convert.km2->cm2","convert.km2->m2","convert.km2->in2","convert.km2->ft2","convert.km2->yd2","convert.km2->acre","convert.km2->hectare","convert.in2->mm2","convert.in2->cm2","convert.in2->m2","convert.in2->km2","convert.in2->ft2","convert.in2->yd2","convert.in2->acre","convert.in2->hectare","convert.ft2->mm2","convert.ft2->cm2","convert.ft2->m2","convert.ft2->km2","convert.ft2->in2","convert.ft2->yd2","convert.ft2->acre","convert.ft2->hectare","convert.yd2->mm2","convert.yd2->cm2","convert.yd2->m2","convert.yd2->km2","convert.yd2->in2","convert.yd2->ft2","convert.yd2->acre","convert.yd2->hectare","convert.acre->mm2","convert.acre->cm2","convert.acre->m2","convert.acre->km2","convert.acre->in2","convert.acre->ft2","convert.acre->yd2","convert.acre->hectare","convert.hectare->mm2","convert.hectare->cm2","convert.hectare->m2","convert.hectare->km2","convert.hectare->in2","convert.hectare->ft2","convert.hectare->yd2","convert.hectare->acre","convert.m/s->km/h","convert.m/s->mph","convert.m/s->kn","convert.m/s->ft/s","convert.km/h->m/s","convert.km/h->mph","convert.km/h->kn","convert.km/h->ft/s","convert.mph->m/s","convert.mph->km/h","convert.mph->kn","convert.mph->ft/s","convert.kn->m/s","convert.kn->km/h","convert.kn->mph","convert.kn->ft/s","convert.ft/s->m/s","convert.ft/s->km/h","convert.ft/s->mph","convert.ft/s->kn","convert.b->kb","convert.b->mb","convert.b->gb","convert.b->tb","convert.b->pb","convert.kb->b","convert.kb->mb","convert.kb->gb","convert.kb->tb","convert.kb->pb","convert.mb->b","convert.mb->kb","convert.mb->gb","convert.mb->tb","convert.mb->pb","convert.gb->b","convert.gb->kb","convert.gb->mb","convert.gb->tb","convert.gb->pb","convert.tb->b","convert.tb->kb","convert.tb->mb","convert.tb->gb","convert.tb->pb","convert.pb->b","convert.pb->kb","convert.pb->mb","convert.pb->gb","convert.pb->tb","convert.pa->kpa","convert.pa->bar","convert.pa->atm","convert.pa->psi","convert.pa->mmhg","convert.kpa->pa","convert.kpa->bar","convert.kpa->atm","convert.kpa->psi","convert.kpa->mmhg","convert.bar->pa","convert.bar->kpa","convert.bar->atm","convert.bar->psi","convert.bar->mmhg","convert.atm->pa","convert.atm->kpa","convert.atm->bar","convert.atm->psi","convert.atm->mmhg","convert.psi->pa","convert.psi->kpa","convert.psi->bar","convert.psi->atm","convert.psi->mmhg","convert.mmhg->pa","convert.mmhg->kpa","convert.mmhg->bar","convert.mmhg->atm","convert.mmhg->psi","convert.j->kj","convert.j->cal","convert.j->kcal","convert.j->wh","convert.j->kwh","convert.j->btu","convert.kj->j","convert.kj->cal","convert.kj->kcal","convert.kj->wh","convert.kj->kwh","convert.kj->btu","convert.cal->j","convert.cal->kj","convert.cal->kcal","convert.cal->wh","convert.cal->kwh","convert.cal->btu","convert.kcal->j","convert.kcal->kj","convert.kcal->cal","convert.kcal->wh","convert.kcal->kwh","convert.kcal->btu","convert.wh->j","convert.wh->kj","convert.wh->cal","convert.wh->kcal","convert.wh->kwh","convert.wh->btu","convert.kwh->j","convert.kwh->kj","convert.kwh->cal","convert.kwh->kcal","convert.kwh->wh","convert.kwh->btu","convert.btu->j","convert.btu->kj","convert.btu->cal","convert.btu->kcal","convert.btu->wh","convert.btu->kwh","convert.w->kw","convert.w->mw","convert.w->hp","convert.kw->w","convert.kw->mw","convert.kw->hp","convert.mw->w","convert.mw->kw","convert.mw->hp","convert.hp->w","convert.hp->kw","convert.hp->mw","convert.hz->khz","convert.hz->mhz","convert.hz->ghz","convert.khz->hz","convert.khz->mhz","convert.khz->ghz","convert.mhz->hz","convert.mhz->khz","convert.mhz->ghz","convert.ghz->hz","convert.ghz->khz","convert.ghz->mhz","convert.deg->rad","convert.deg->grad","convert.deg->turn","convert.rad->deg","convert.rad->grad","convert.rad->turn","convert.grad->deg","convert.grad->rad","convert.grad->turn","convert.turn->deg","convert.turn->rad","convert.turn->grad","convert.c->f","convert.c->k","convert.f->c","convert.f->k","convert.k->c","convert.k->f"],shorthand:["-short-regexp","-short-fn"],datatype:["-type-number","-type-string","-type-object","-type-array","-type-vector","-type-matrix","-type-grid","-type-boolean","-type-function","-type-integer","-type-any","-type-null","-type-collection","-type-sequence","-type-regexp","-type-never"]},rc=[...[...[...tc.collection,...tc.array,...tc.sequence,...tc.math,...tc.functional,...tc.meta,...tc.misc,...tc.object,...tc.predicate,...tc.regularExpression,...tc.string,...tc.bitwise,...tc.vector,...tc.assertion],...[...tc.matrix,...tc.vectorUtils,...tc.linAlg,...tc.grid,...tc.numberTheory,...tc.random,...tc.mathUtils,...tc.functionalUtils,...tc.assertionUtils,...tc.stringUtils,...tc.collectionUtils,...tc.sequenceUtils,...tc.bitwiseUtils,...tc.convert]],...tc.shorthand,...tc.datatype];function nc(e){return rc.includes(e)}export{Hs as Lits,Xs as allBuiltinModules,mi as apiReference,k as asLitsFunction,z as asNativeJsFunction,N as asUserDefinedFunction,q as assertLitsFunction,Ur as assertModule,S as assertNativeJsFunction,$ as assertUserDefinedFunction,ja as bitwiseUtilsModule,Sa as functionalUtilsModule,Vr as gridModule,nc as isApiName,E as isBuiltinFunction,ai as isCustomReference,Rr as isDataType,si as isDatatypeReference,oi as isFunctionReference,rt as isGrid,ys as isLitsBundle,i as isLitsError,w as isLitsFunction,ot as isMatrix,T as isNativeJsFunction,ii as isShorthandReference,A as isUserDefinedFunction,Xe as isVector,Ln as linearAlgebraModule,za as mathUtilsModule,eo as matrixModule,Ar as normalExpressionKeys,ga as numberTheoryModule,Jr as randomModule,Nr as specialExpressionKeys,Mn as vectorModule};
|
|
2
2
|
//# sourceMappingURL=full.esm.js.map
|