@mojir/lits 2.2.3 → 2.3.0

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.
Files changed (65) hide show
  1. package/README.md +1 -8
  2. package/dist/cli/cli.js +1264 -909
  3. package/dist/cli/src/Lits/Lits.d.ts +8 -2
  4. package/dist/cli/src/builtin/bindingNode.d.ts +2 -1
  5. package/dist/cli/src/builtin/interface.d.ts +3 -2
  6. package/dist/cli/src/builtin/modules/number-theory/sequences/index.d.ts +2 -1
  7. package/dist/cli/src/evaluator/functionExecutors.d.ts +2 -1
  8. package/dist/cli/src/evaluator/index.d.ts +3 -2
  9. package/dist/cli/src/evaluator/interface.d.ts +3 -2
  10. package/dist/cli/src/utils/maybePromise.d.ts +54 -0
  11. package/dist/full.esm.js +1 -1
  12. package/dist/full.esm.js.map +1 -1
  13. package/dist/full.js +1 -1
  14. package/dist/full.js.map +1 -1
  15. package/dist/index.esm.js +1 -1
  16. package/dist/index.esm.js.map +1 -1
  17. package/dist/index.js +1 -1
  18. package/dist/index.js.map +1 -1
  19. package/dist/lits.iife.js +1 -1
  20. package/dist/lits.iife.js.map +1 -1
  21. package/dist/modules/assert.esm.js +1 -1
  22. package/dist/modules/assert.esm.js.map +1 -1
  23. package/dist/modules/assert.js +1 -1
  24. package/dist/modules/assert.js.map +1 -1
  25. package/dist/modules/collection.esm.js +1 -1
  26. package/dist/modules/collection.esm.js.map +1 -1
  27. package/dist/modules/collection.js +1 -1
  28. package/dist/modules/collection.js.map +1 -1
  29. package/dist/modules/grid.esm.js +1 -1
  30. package/dist/modules/grid.esm.js.map +1 -1
  31. package/dist/modules/grid.js +1 -1
  32. package/dist/modules/grid.js.map +1 -1
  33. package/dist/modules/number-theory.esm.js +1 -1
  34. package/dist/modules/number-theory.esm.js.map +1 -1
  35. package/dist/modules/number-theory.js +1 -1
  36. package/dist/modules/number-theory.js.map +1 -1
  37. package/dist/modules/sequence.esm.js +1 -1
  38. package/dist/modules/sequence.esm.js.map +1 -1
  39. package/dist/modules/sequence.js +1 -1
  40. package/dist/modules/sequence.js.map +1 -1
  41. package/dist/modules/src/Lits/Lits.d.ts +8 -2
  42. package/dist/modules/src/builtin/bindingNode.d.ts +2 -1
  43. package/dist/modules/src/builtin/interface.d.ts +3 -2
  44. package/dist/modules/src/builtin/modules/number-theory/sequences/index.d.ts +2 -1
  45. package/dist/modules/src/evaluator/functionExecutors.d.ts +2 -1
  46. package/dist/modules/src/evaluator/index.d.ts +3 -2
  47. package/dist/modules/src/evaluator/interface.d.ts +3 -2
  48. package/dist/modules/src/utils/maybePromise.d.ts +54 -0
  49. package/dist/modules/vector.esm.js +1 -1
  50. package/dist/modules/vector.esm.js.map +1 -1
  51. package/dist/modules/vector.js +1 -1
  52. package/dist/modules/vector.js.map +1 -1
  53. package/dist/src/Lits/Lits.d.ts +8 -2
  54. package/dist/src/builtin/bindingNode.d.ts +2 -1
  55. package/dist/src/builtin/interface.d.ts +3 -2
  56. package/dist/src/builtin/modules/number-theory/sequences/index.d.ts +2 -1
  57. package/dist/src/evaluator/functionExecutors.d.ts +2 -1
  58. package/dist/src/evaluator/index.d.ts +3 -2
  59. package/dist/src/evaluator/interface.d.ts +3 -2
  60. package/dist/src/utils/maybePromise.d.ts +54 -0
  61. package/dist/testFramework.esm.js +1 -1
  62. package/dist/testFramework.esm.js.map +1 -1
  63. package/dist/testFramework.js +1 -1
  64. package/dist/testFramework.js.map +1 -1
  65. package/package.json +1 -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 a=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)}`}(a,n)),this.shortMessage=a,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 a extends r{constructor(e,t){super(e,t),Object.setPrototypeOf(this,a.prototype),this.name="AssertionError"}}class o extends r{symbol;constructor(e,t){super(`Undefined symbol '${e}'.`,t),this.symbol=e,Object.setPrototypeOf(this,o.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={}){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 f(e,t,n={}){if(!v(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":"",a=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,a].filter(e=>!!e).join(" ")}(n)}, got ${d(e)}.`,y(e,t))}function b(e,t,r={}){return f(e,t,r),e}function x(e,t,n){return new r(`Expected ${e}, got ${d(t)}.`,y(t,n))}function w(e,t){return q(e,t),e}function q(e,t){if(!function(e){return void 0!==e}(e))throw new r("Unexpected undefined",y(e,t))}function k(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function A(e){return null!==e&&"object"==typeof e&&!!e[u]}function N(e,t){return $(e,t),e}function $(e,t){if(!A(e))throw x("LitsFunction",e,t)}function T(e){return A(e)&&"UserDefined"===e.functionType}function S(e,t){return z(e,t),e}function z(e,t){if(!T(e))throw x("NativeJsFunction",e,t)}function E(e){return A(e)&&"NativeJsFunction"===e.functionType}function j(e,t){return M(e,t),e}function M(e,t){if(!E(e))throw x("NativeJsFunction",e,t)}function R(e){return k(e)&&"Builtin"===e.functionType}function C(e){return void 0!==e}function P(e,t){return I(e,t),e}function I(e,t){if(!C(e))throw x("not undefined",e,t)}function O(e){return Array.isArray(e)||"string"==typeof e}function F(e,t){return U(e,t),e}function U(e,t){if(!O(e))throw x("string or array",e,t)}function D(e){return!(null===e||"object"!=typeof e||Array.isArray(e)||e instanceof RegExp||A(e)||L(e))}function G(e,t){if(!D(e))throw x("object",e,t)}function W(e){return O(e)||D(e)}function V(e,t){return B(e,t),e}function B(e,t){if(!W(e))throw x("string, array or object",e,t)}function L(e){return null!==e&&"object"==typeof e&&!!e[p]}function K(e,t){if(!function(e){return L(e)||"string"==typeof e}(e))throw x("string or RegularExpression",e,t)}function _(e,t){return J(e,t),e}function J(e,t){if(!function(e){return"number"==typeof e||!!W(e)||!!A(e)}(e))throw x("FunctionLike",e,t)}function H(e,t){const{min:r}=e;return!("number"==typeof r&&t<r)}function Y(e){return"number"==typeof e||W(e)?Q(1):e.arity}function X(e,t,n){const{min:a,max:o}=e;if("number"==typeof a&&t<a)throw new r(`Wrong number of arguments, expected at least ${a}, got ${d(t)}.`,n);if("number"==typeof o&&t>o)throw new r(`Wrong number of arguments, expected at most ${o}, got ${d(t)}.`,n)}function Z(e){return!("number"==typeof e.max&&e.max<2)&&!("number"==typeof e.min&&e.min>2)}function Q(e){return{min:e,max:e}}function ee(e,t){return{a:{type:e},b:{type:t}}}const te={"<<":{evaluate:([e,t],r)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0}),e<<t),arity:Q(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ee("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)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0}),e>>t),arity:Q(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ee("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)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0}),e>>>t),arity:Q(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ee("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)=>(f(e,r,{integer:!0}),t.reduce((e,t)=>(f(t,r,{integer:!0}),e&t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...ee("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)=>(f(e,r,{integer:!0}),t.reduce((e,t)=>(f(t,r,{integer:!0}),e|t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...ee("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)=>(f(e,r,{integer:!0}),t.reduce((e,t)=>(f(t,r,{integer:!0}),e^t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...ee("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 re(e,t={}){return"string"==typeof e&&((!t.nonEmpty||0!==e.length)&&(!t.char||1===e.length))}function ne(e,t,r={}){if(!re(e,r))throw x(""+(r.nonEmpty?"non empty string":r.char?"character":"string"),e,t)}function ae(e,t,r={}){return ne(e,t,r),e}function oe(e){return"string"==typeof e||"number"==typeof e}function ie(e,t){return se(e,t),e}function se(e,t){if(!oe(e))throw x("string or number",e,t)}function ce(e,t){return!!W(e)&&("string"==typeof e||Array.isArray(e)?!!v(t,{integer:!0})&&(t>=0&&t<e.length):!!Object.getOwnPropertyDescriptor(e,t))}function le(e,t,n){if(se(e,n),se(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(P(e[n],r),P(t[n],r),r))return!1;return!0}if(L(e)&&L(t))return e.s===t.s&&e.f===t.f;if(k(e)&&k(t)){const n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;for(let a=0;a<n.length;a+=1){const o=ae(n[a],r);if(!me(e[o],t[o],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 D(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 x("array",e,t)}function qe(e,t){if(!function(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e)}(e))throw x("array of strings",e,t)}function ke(e,t){if(!function(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e&&1===e.length)}(e))throw x("array of strings",e,t)}const Ae={filter:{evaluate:([e,t],r,n,{executeFunction:a})=>{if(B(e,r),J(t,r),Array.isArray(e)){return e.filter(e=>a(t,[e],n,r))}return re(e)?e.split("").filter(e=>a(t,[e],n,r)).join(""):Object.entries(e).filter(([,e])=>a(t,[e],n,r)).reduce((e,[t,r])=>(e[t]=r,e),{})},arity:Q(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:a})=>{const o=_(e.at(-1),t);if(D(e[0]))return function({colls:e,contextStack:t,executeFunction:n,fn:a,sourceCodeInfo:o}){G(e[0],o);const i=Object.keys(e[0]),s={};return e.forEach(e=>{G(e,o);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(", ")}`,o);if(!t.every(e=>i.includes(e)))throw new r(`All objects must have the same keys. Expected: ${i.join(", ")}. Found: ${t.join(", ")}`,o);Object.entries(e).forEach(([e,t])=>{s[e]||(s[e]=[]),s[e].push(t)})}),i.reduce((e,r)=>(e[r]=n(a,s[r],t,o),e),{})}({colls:e.slice(0,-1),fn:o,sourceCodeInfo:t,contextStack:n,executeFunction:a});const i=e.slice(0,-1);U(i[0],t);const s="string"==typeof i[0];let c=i[0].length;i.slice(1).forEach(e=>{s?ne(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=l.map(e=>a(o,e,n,t));return s?(m.forEach(e=>ne(e,t)),m.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.map","grid.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,a,{executeFunction:o})=>(B(e,n),J(t,n),I(r,n),"string"==typeof e?(ne(r,n),0===e.length?r:e.split("").reduce((e,r)=>o(t,[e,r],a,n),r)):Array.isArray(e)?0===e.length?r:e.reduce((e,r)=>o(t,[e,r],a,n),r):0===Object.keys(e).length?r:Object.entries(e).reduce((e,[,r])=>o(t,[e,r],a,n),r)),arity:Q(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.reduce","grid.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,a=pe(e[2]);if(se(n,t),null===r)return a;B(r,t);const o=function(e,t){if(D(e)){if("string"==typeof t&&ce(e,t))return pe(e[t])}else if(v(t,{nonNegative:!0,integer:!0})&&t>=0&&t<e.length)return pe(e[t])}(r,n);return void 0===o?a:o},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:(B(e,t),Array.isArray(e)?e.length:Object.keys(e).length),arity:Q(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&&(B(e,r),re(e)?(ne(t,r),e.includes(t)):O(e)?(I(t,r),!!e.find(e=>me(P(e),t,r))):(ne(t,r),t in e)),arity:Q(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)=>(B(e,n),se(t,n),I(r,n),function(e,t,r,n){if(B(e,n),se(t,n),Array.isArray(e)||"string"==typeof e){if(f(t,n,{integer:!0}),f(t,n,{gte:0}),f(t,n,{lte:e.length}),"string"==typeof e)return ne(r,n,{char:!0}),`${e.slice(0,t)}${r}${e.slice(t+1)}`;const a=[...e];return a[t]=r,a}ne(t,n);const a={...e};return a[t]=r,a}(e,t,r,n)),arity:Q(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)=>(v(e[0])||B(e[0],t),Array.isArray(e[0])?e.reduce((e,r)=>(we(r,t),e.concat(r)),[]):oe(e[0])?e.reduce((e,r)=>(se(r,t),`${e}${r}`),""):e.reduce((e,r)=>(G(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 })"]}}},Ne={range:{evaluate:(e,t)=>{const[r,n,a]=e;let o,i,s;f(r,t,{finite:!0}),1===e.length?(o=0,i=r,s=i>=0?1:-1):2===e.length?(f(n,t,{finite:!0}),o=r,i=n,s=i>=o?1:-1):(f(n,t,{finite:!0}),f(a,t,{finite:!0}),o=r,i=n,s=a,f(s,t,i>o?{positive:!0}:i<o?{negative:!0}:{nonZero:!0}));const c=[];for(let e=o;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)=>{f(t,r,{integer:!0,nonNegative:!0});const n=[];for(let r=0;r<t;r+=1)n.push(e);return n},arity:Q(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","vector.ones","vector.zeros","vector.fill","vector.generate","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:b(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:a})=>(we(e,r),J(t,r),e.map(e=>a(t,[e],n,r)).flat(1)),arity:Q(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,a,{executeFunction:o})=>{we(e,n),f(t,n,{integer:!0,lte:e.length}),J(r,n);const i=[];for(let s=0;s<=e.length-t;s++){const c=o(r,[e.slice(s,s+t)],a,n);i.push(c)}return i},arity:Q(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:a})=>{we(e,r),J(t,r);const o=[];for(let i=0;i<e.length;i+=1){const s=e.slice(0,i+1);o.push(a(t,[s],n,r))}return o},arity:Q(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)"]}}},$e={nth:{evaluate:(e,t)=>{const[r,n]=e,a=pe(e[2]);if(f(n,t,{integer:!0}),null===r)return a;if(U(r,t),n>=0&&n<r.length){return pe(r[n])}return a},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;U(e,t);return pe(e[0])},arity:Q(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;U(e,t);return pe(e.at(-1))},arity:Q(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)=>(U(e,t),"string"==typeof e?e.substring(0,e.length-1):e.slice(0,e.length-1)),arity:Q(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","sequence.shift","last"],examples:["pop([1, 2, 3])","pop([])"]}},"index-of":{evaluate:([e,t],r)=>{if(I(t,r),null===e)return null;if(U(e,r),"string"==typeof e){ne(t,r);const n=e.indexOf(t);return-1!==n?n:null}{const n=e.findIndex(e=>me(P(e,r),t),r);return-1!==n?n:null}},arity:Q(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)=>(U(e,r),"string"==typeof e?(ke(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)=>(U(e,t),Array.isArray(e)?e.length<=1?[]:e.slice(1):e.substring(1)),arity:Q(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","sequence.shift"],examples:['rest(["Albert", "Mojir", 160, [1, 2]])','rest(["Albert"])',"rest([])",'rest("Albert")','rest("A",)','rest("")']}},next:{evaluate:([e],t)=>(U(e,t),Array.isArray(e)?e.length<=1?null:e.slice(1):e.length<=1?null:e.substring(1)),arity:Q(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:(U(e,t),Array.isArray(e)?[...e].reverse():e.split("").reverse().join("")),arity:Q(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:(U(e,t),pe(e[1])),arity:Q(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,a]=e;return U(r,t),f(n,t,{integer:!0}),2===e.length?(Array.isArray(r),r.slice(n)):(f(a,t,{integer:!0}),Array.isArray(r),r.slice(n,a))},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:["sequence.take","sequence.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:a})=>(J(t,r),null===e?null:(U(e,r),0===e.length?null:"string"==typeof e?e.split("").find(e=>a(t,[e],n,r))??null:pe(e.find(e=>a(t,[e],n,r))))),arity:Q(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[a]=e,o=1===e.length,i=o?null:e[1];if(U(a,t),"string"==typeof a){const e=a.split("");return o?e.sort((e,r)=>le(e,r,t)):(J(i,t),e.sort((e,a)=>{const o=n(i,[e,a],r,t);return f(o,t,{finite:!0}),o})),e.join("")}const s=[...a];return o?s.sort((e,r)=>(se(e,t),se(r,t),le(e,r,t))):s.sort((e,a)=>{J(i,t);const o=n(i,[e,a],r,t);return f(o,t,{finite:!0}),o}),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)"]}}},Te=new WeakSet,Se=new WeakSet,ze=new WeakSet,Ee=new WeakSet,je=new WeakSet,Me=new WeakSet,Re=new WeakSet;function Ce(e){return Array.isArray(e)?(Te.has(e)||(Pe(e),We(e)||De(e)),e):e}function Pe(e){return!!Array.isArray(e)&&(!!Se.has(e)||!ze.has(e)&&(e.every(e=>v(e))?(Te.add(e),Se.add(e),!0):(ze.add(e),!1)))}function Ie(e,t){if(!Pe(e))throw new r(`Expected a vector, but got ${e}`,t)}function Oe(e,t){if(!function(e){return!!Pe(e)&&2===e.length}(e))throw new r(`Expected a 2d vector, but got ${e}`,t)}function Fe(e,t){if(!function(e){return!!Pe(e)&&3===e.length}(e))throw new r(`Expected a 3d vector, but got ${e}`,t)}function Ue(e,t){if(Ie(e,t),0===e.length)throw new r(`Expected a non empty vector, but got ${e}`,t)}function De(e){if(!Array.isArray(e))return!1;if(Me.has(e))return!0;if(Re.has(e))return!1;if(0===e.length)return Re.add(e),!1;if(!Array.isArray(e[0]))return Re.add(e),!1;const t=e[0].length;for(const r of e.slice(1)){if(!Array.isArray(r))return Re.add(e),!1;if(r.length!==t)return Re.add(e),!1}return Te.add(e),Me.add(e),!0}function Ge(e,t){if(!De(e))throw new r(`Expected a grid, but got ${e}`,t)}function We(e){if(!Array.isArray(e))return!1;if(Ee.has(e))return!0;if(je.has(e))return!1;if(0===e.length)return je.add(e),!1;if(!Array.isArray(e[0])||0===e[0].length)return je.add(e),!1;const t=e[0].length;for(const r of e)if(!Array.isArray(r)||r.length!==t||r.some(e=>!v(e)))return je.add(e),!1;return Te.add(e),Me.add(e),Ee.add(e),!0}function Ve(e,t){if(!We(e))throw new r(`Expected a matrix, but got ${e}`,t)}function Be(e,t){if(!We(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 Le(e,t){let n=!1,a=!1;for(const o of e)if(Pe(o))n=!0;else if(We(o))a=!0;else if(!v(o))throw new r("Invalid parameter type: "+typeof o,t);if(a){if(n)throw new r("Cannot mix vector and matrix types",t);let a=null,o=null;for(const n of e)if(We(n))if(null===a)a=n.length,o=n[0].length;else if(n.length!==a||n[0].length!==o)throw new r("Matrix dimensions do not match",t);return["matrix",e.map(e=>We(e)?e:Array.from({length:a},()=>Array.from({length:o},()=>e)))]}if(n){let n=null;for(const a of e)if(Pe(a))if(null===n)n=a.length;else if(a.length!==n)throw new r("Vector lengths do not match",t);return["vector",e.map(e=>Pe(e)?e:Array.from({length:n},()=>e))]}return["number",e]}function Ke(e){return(t,r)=>{const[n,a]=Le(t,r);return"number"===n?e(a[0]):"vector"===n?a[0].map(t=>e(t)):a[0].map(t=>t.map(t=>e(t)))}}function _e(e){return(t,r)=>{const[n,a]=Le(t,r);return"number"===n?e(a[0],a[1]):"vector"===n?a[0].map((t,r)=>e(t,a[1][r])):a[0].map((t,r)=>t.map((t,n)=>e(t,a[1][r][n])))}}function Je(e,t){return(r,n)=>{if(0===r.length)return e;const[a,o]=Le(r,n);if("number"===a)return o.reduce((e,r)=>t(e,r),e);if("vector"===a){const[e,...r]=o;return r.reduce((e,r)=>e.map((e,n)=>t(e,r[n])),e)}{const[e,...r]=o;return r.reduce((e,r)=>e.map((e,n)=>e.map((e,a)=>t(e,r[n][a]))),e)}}}const He={inc:{evaluate:Ke(e=>e+1),arity:Q(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:Ke(e=>e-1),arity:Q(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:Je(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:Je(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]=Le(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]=Le(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:_e((e,t)=>Math.trunc(e/t)),arity:Q(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:_e((e,t)=>e-t*Math.floor(e/t)),arity:Q(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:_e((e,t)=>e%t),arity:Q(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:Ke(e=>Math.sqrt(e)),arity:Q(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:Ke(e=>Math.cbrt(e)),arity:Q(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:_e((e,t)=>e**t),arity:Q(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,a]=Le([e],r);if("number"===n){if(void 0===t||0===t)return Math.round(a[0]);{f(t,r,{integer:!0,positive:!0});const e=10**t;return Math.round(a[0]*e)/e}}if("vector"===n){const e=a[0];if(void 0===t||0===t)return e.map(e=>Math.round(e));{f(t,r,{integer:!0,positive:!0});const n=10**t;return e.map(e=>Math.round(e*n)/n)}}{const e=a[0];if(void 0===t||0===t)return e.map(e=>e.map(e=>Math.round(e)));{f(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:Ke(e=>Math.trunc(e)),arity:Q(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:Ke(e=>Math.floor(e)),arity:Q(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:Ke(e=>Math.ceil(e)),arity:Q(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&&Pe(e[0])){const r=e[0];return Ue(r,t),r.reduce((e,t)=>Math.min(e,t),1/0)}const[r,...n]=e;return f(r,t),n.reduce((e,r)=>(f(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&&Pe(e[0])){const r=e[0];return Ue(r,t),r.reduce((e,t)=>Math.max(e,t),-1/0)}const[r,...n]=e;return f(r,t),n.reduce((e,r)=>(f(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:Ke(e=>Math.abs(e)),arity:Q(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:Ke(e=>Math.sign(e)),arity:Q(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 Ye([e,...t],r){const n=P(e,r);for(const e of t)if(!me(n,P(e,r),r))return!1;return!0}const Xe={"==":{evaluate:(e,t)=>Ye(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)=>!Ye(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 `(! (== 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=ie(e);for(const e of t){if(le(n,ie(e),r)<=0)return!1;n=ie(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=ie(e);for(const e of t){if(le(n,ie(e),r)>=0)return!1;n=ie(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=ie(e);for(const e of t){if(le(n,ie(e),r)<0)return!1;n=ie(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=ie(e);for(const e of t){if(le(n,ie(e),r)>0)return!1;n=ie(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)"]}},"!":{evaluate:([e])=>!e,arity:Q(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:["!(3)","!(true)",'!("A string")',"!(0)","!(false)","!(null)",'!("")']}},"epoch->iso-date":{evaluate:([e],t)=>(f(e,t),new Date(e).toISOString()),arity:Q(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)=>{ne(e,t);const r=new Date(e).valueOf();return f(r,t,{finite:!0}),r},arity:Q(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?P(e[e.length-1],t):null),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:Q(1),docs:{category:"misc",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Coerces $x to boolean.",seeAlso:["!","boolean?","true?","false?"],examples:["boolean(0)","boolean(1)","boolean(null)",'boolean("Albert")']}},compare:{evaluate:([e,t],r)=>(se(e,r),se(t,r),le(e,t,r)),arity:Q(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)=>(ne(e,t),JSON.parse(e)),arity:Q(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)=>(I(e,r),void 0===t?JSON.stringify(e):(f(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}},import:{evaluate:([e],t,n)=>{ne(e,t);const a=e.indexOf(".");if(-1!==a){const o=e.substring(0,a),i=e.substring(a+1),s=n.getModule(o);if(!s)throw new r(`Unknown module: '${o}'`,t);const c=s.functions[i];if(!c)throw new r(`Function '${i}' not found in module '${o}'`,t);return{[u]:!0,sourceCodeInfo:t,functionType:"Module",moduleName:o,functionName:i,arity:c.arity}}const o=e,i=n.getModule(o);if(!i)throw new r(`Unknown module: '${o}'`,t);const s={};for(const[e,r]of Object.entries(i.functions))s[e]={[u]:!0,sourceCodeInfo:t,functionType:"Module",moduleName:o,functionName:e,arity:r.arity};return s},arity:Q(1),docs:{category:"misc",returns:{type:"any"},args:{path:{type:"string",description:'The module path to import. Can be a module name (e.g., "vector", "grid") or a fully qualified function name (e.g., "vector.mean", "grid.row").'}},variants:[{argumentNames:["path"]}],description:'Imports module functions. Use a module name (e.g., "vector") to import all functions as an object, or a fully qualified name (e.g., "vector.mean") to import a single function directly.',examples:['let v = import("vector"); v.mean([1, 2, 3, 4])','let v-sum = import("vector.sum"); v-sum([1, 2, 3])','let g = import("grid"); g.row([[1, 2], [3, 4]], 0)']}}},Ze={keys:{evaluate:([e],t)=>(G(e,t),Object.keys(e)),arity:Q(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)=>(G(e,t),Object.values(e)),arity:Q(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)=>(G(e,t),Object.entries(e)),arity:Q(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)=>(G(e,r),ne(t,r),ce(e,t)?[t,e[t]]:null),arity:Q(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)=>{G(e,r),ne(t,r);const n={...e};return delete n[t],n},arity:Q(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 G(r,t),n.reduce((e,r)=>(G(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 a=e[0],o=e.at(-1),i=e.slice(1,-1);return G(a,t),J(o,t),i.reduce((e,a)=>(G(a,t),Object.entries(a).forEach(a=>{const i=ae(a[0],t),s=pe(a[1]);ce(e,i)?e[i]=n(o,[e[i],s],r,t):e[i]=s}),e),{...a})},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)=>{qe(e,r),we(t,r);const n=Math.min(e.length,t.length),a={};for(let o=0;o<n;o+=1){a[ae(e[o],r)]=pe(t[o])}return a},arity:Q(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)=>(qe(t,r),G(e,r),t.reduce((t,r)=>(ce(e,r)&&(t[r]=pe(e[r])),t),{})),arity:Q(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"])']}}},Qe={"function?":{evaluate:([e])=>A(e),arity:Q(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:Q(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:Q(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&&v(e,{integer:!0}),arity:Q(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:Q(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:Q(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)=>(f(e,t,{finite:!0}),Math.abs(e)<ve),arity:Q(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)=>(f(e,t,{finite:!0}),e>0),arity:Q(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)=>(f(e,t,{finite:!0}),e<0),arity:Q(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)=>(f(e,t,{finite:!0}),e%2==0),arity:Q(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)=>(f(e,t,{finite:!0}),v(e,{integer:!0})&&e%2!=0),arity:Q(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:Q(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])=>W(e),arity:Q(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])=>O(e),arity:Q(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])=>D(e),arity:Q(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])=>L(e),arity:Q(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","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)=>(f(e,t),Number.isFinite(e)),arity:Q(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)=>(f(e,t),e===Number.POSITIVE_INFINITY),arity:Q(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)=>(f(e,t),e===Number.NEGATIVE_INFINITY),arity:Q(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:Q(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:Q(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||(B(e,t),"string"==typeof e||Array.isArray(e)?0===e.length:0===Object.keys(e).length),arity:Q(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&&(B(e,t),"string"==typeof e||Array.isArray(e)?e.length>0:Object.keys(e).length>0),arity:Q(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])=>Pe(e),arity:Q(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])=>We(e),arity:Q(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])=>De(e),arity:Q(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]])']}}},et={regexp:{evaluate:([e,t],n)=>{ne(e,n);const a=e||"(?:)",o="string"==typeof t?t:"";try{new RegExp(a,o)}catch(e){throw new r(`Invalid regular expression: ${a} ${o}`,n)}return{[p]:!0,sourceCodeInfo:n,s:a,f:o}},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","match","replace","replace-all","regexp?"],hideOperatorForm:!0}},match:{evaluate:([e,t],r)=>{if(function(e,t){if(!L(e))throw x("RegularExpression",e,t)}(t,r),!re(e))return null;const n=new RegExp(t.s,t.f).exec(e);return n?[...n]:null},arity:Q(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 `match`-array is returned, otherwise `null` is returned.",seeAlso:["regexp","replace","replace-all","-short-regexp","regexp?"],examples:['match(" A string", regexp("^\\\\s*(.*)$"))','match(" A string", #"^\\s*(.*)$")','match("My name is Albert", #"albert"i)','match("My name is Ben", #"albert"i)','match(null, #"albert"i)','match(1, #"albert"i)','match({}, #"albert"i)']}},replace:{evaluate:([e,t,r],n)=>{ne(e,n),K(t,n),ne(r,n);const a=L(t)?new RegExp(t.s,`${t.f}`):t;return e.replace(a,r)},arity:Q(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","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)=>{ne(e,n),K(t,n),ne(r,n);const a=L(t)?new RegExp(t.s,`${t.f.includes("g")?t.f:`${t.f}g`}`):t;return e.replaceAll(a,r)},arity:Q(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","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, "-")']}}},tt=/^\s*$/,rt={str:{evaluate:e=>e.reduce((e,t)=>e+(null==t?"":D(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)=>{ne(e,t);const n=Number(e);if(Number.isNaN(n))throw new r(`Could not convert '${e}' to a number.`,t);return n},arity:Q(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)=>(ne(e,t),e.toLowerCase()),arity:Q(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)=>(ne(e,t),e.toUpperCase()),arity:Q(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)=>(ne(e,t),e.trim()),arity:Q(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=>se(e,r)),ne(t,r),e.join(t)),arity:Q(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)=>{ne(e,n),K(t,n),void 0!==r&&f(r,n,{integer:!0,nonNegative:!0});const a="string"==typeof t?t:new RegExp(t.s,t.f);return e.split(a,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||(ne(e,t),tt.test(e)),arity:Q(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?(".")']}}},nt={"|>":{evaluate:([e,t],r,n,{executeFunction:a})=>(J(t,r),a(t,[e],n,r)),arity:Q(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:a})=>{J(e,r);const o=t[t.length-1];we(o,r);return a(e,[...t.slice(0,-1),...o],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:Q(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=>J(e,t)),{[u]:!0,sourceCodeInfo:t,functionType:"Comp",params:e,arity:e.length>0?Y(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:Q(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 at(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:a}){const o=t.map(t=>`${` ${e}(${t.argumentNames.map(e=>{let t="";return r[e].rest&&(t+="..."),t+=e,t}).join(", ")})`} -> ${ot(n)}`),i=a?["","Operator:",` a ${e} b -> ${ot(n)}`]:[];return[...o,...i]}(e).join("\n ")}\n\n Arguments:\n ${function(e){return Object.entries(e.args).map(([e,t])=>`${e}: ${ot(t)}`)}(e).join("\n ")}\n\n Examples:\n${e.examples.map(e=>xe(e,4)).join("\n\n")}`)}function ot(e){const t=e.type,r=(Array.isArray(t)?t:[t]).join(" | ");return e.array||e.rest?`Array<${r}>`:r}function it(e){return{doc:{evaluate:([t],r)=>{if(q(e),J(t,r),!A(t))return"";if("Builtin"===t.functionType){const r=e[t.name];return r?at(r):""}return"UserDefined"===t.functionType||"NativeJsFunction"===t.functionType?t.docString:""},arity:Q(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)=>(J(e,t),A(e)?e.arity:Q(1)),arity:Q(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 st={sum:{evaluate:([e],t)=>(Ie(e,t),e.reduce((e,t)=>e+t,0)),arity:Q(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.sum"],examples:["sum([1, 2, 3, 4, 5])","sum([1, -2, 3])","sum([])"]}},prod:{evaluate:([e],t)=>(Ie(e,t),e.reduce((e,t)=>e*t,1)),arity:Q(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.prod"],examples:["prod([1, 2, 3, 4, 5])","prod([1, -2, 3])","prod([])"]}},mean:{evaluate:([e],t)=>(Ue(e,t),e.reduce((e,t)=>e+t,0)/e.length),arity:Q(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.mean"],examples:["mean([1, 2, 3, 4, 5])","mean([1, -2, 3])"]}},median:{evaluate:([e],t)=>(Ue(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:Q(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.median"],examples:["median([1, 2, 3, 4, 5])","median([1, 2, 3, 4])","median([3, 1, 4, 1, 5])"]}}},ct={};const lt={...te,...Ae,...Ne,...$e,...He,...it(ct),...Xe,...Ze,...Qe,...et,...rt,...nt,...st};Object.entries(lt).forEach(([e,t])=>{t.name=e});const mt={...lt},ut={},pt=[];Object.entries(mt).forEach(([e,t],r)=>{ut[e]=r,pt.push(t)});const gt={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})=>{let n=!0;for(const a of e[1][1])if(n=r(a,t),!n)break;return n},evaluateAsNormalExpression:(e,t)=>{let r=!0;for(const n of e)if(r=P(n,t),!r)break;return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1],t,n,a)},ht={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];for(const[e,a]of n){if(r(e,t))return r(a,t)}return null},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1].flat(),t,n,a)},dt={arity:{},docs:{category:"special-expression",customVariants:["switch value switch-branch switch-branch ... end"],details:[["value","any","The value to test."],["switch-branch","case test then body","A branch of the switch expression."],["test","expression","The condition to test."],["body","expressions","The expressions to evaluate if the test is truthy."]],description:"Used for branching. `switch-branches` are tested sequentially from the top against `value`. If no branch is tested truthy, `null` is returned.",examples:['\nswitch 1\n case 1 then write!("One")\n case 2 then write!("Two")\nend','\nswitch 2\n case 1 then write!("One")\n case 2 then write!("Two")\nend','\nswitch 3\n case 1 then write!("One")\n case 2 then write!("Two")\nend']},evaluate:(e,t,{evaluateNode:r})=>{const[,n,a]=e[1],o=r(n,t);for(const[e,n]of a){if(r(e,t)===o)return r(n,t)}return null},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r([e[1][1],...e[1][2].flat()],t,n,a)};function yt(e){const t=e[0];return s.UserDefinedSymbol===t||s.NormalBuiltinSymbol===t||s.SpecialBuiltinSymbol===t}function vt(e){return s.UserDefinedSymbol===e[0]}function ft(e,t){return function(e,t){if(!vt(e))throw x("UserDefinedSymbolNode",e,t)}(e,t),e}function bt(e){return s.NormalBuiltinSymbol===e[0]}function xt(e){return s.SpecialBuiltinSymbol===e[0]}function wt(e){return!!function(e){return e[0]===s.NormalExpression}(e)&&yt(e[1][0])}function qt(e){return e[0]===s.Spread}const kt={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?(+)"]},At={arity:Q(1),docs:kt,evaluate:(e,t)=>{const r=e[1][1];if(function(e,t){if(!yt(e))throw x("SymbolNode",e,t)}(r),!vt(r))return!0;return null!==t.lookUp(r)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r([e[1][1]],t,n,a)};const Nt=11,$t=12,Tt=13,St=14;function zt(e,t){if(e[0]===Tt)Object.values(e[1][0]).forEach(e=>{e[1][1]&&t(e[1][1]),zt(e,t)});else if(e[0]===St)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]),zt(n,t))}}function Et(e,t,r){const n={};return jt(e,t,r,e[2],n),n}function jt(e,t,n,a,o){if(e[0]===Tt){!function(e,t){if(!k(e))throw new r(`Expected UnknownRecord, got ${d(e)}.`,y(e,t))}(t,a);const i=new Set;let s;if(Object.entries(e[1][0]).forEach(([e,r])=>{if(r[0]===$t)return void(s=r);i.add(e);const c=(void 0!==t[e]?t[e]:r[1][1]&&n(r[1][1]))??null;I(c,a),jt(r,c,n,a,o)}),s){const e=Object.entries(t).filter(([e])=>!i.has(e)).reduce((e,[t,r])=>(e[t]=P(r),e),{});o[s[1][0]]=e}}else if(e[0]===St){let r=null;we(t,a);for(let i=0;i<e[1][0].length;i+=1){const s=e[1][0][i]??null;if(null===s)continue;if(s[0]===$t){r=i;break}const c=(void 0!==t[i]?t[i]:s[1][1]&&n(s[1][1]))??null;I(c,a),jt(s,c,n,a,o)}if(null!==r){const n=t.slice(r),a=e[1][0][r];o[a[1][0]]=n}}else e[0]===$t?o[e[1][0]]=P(t):o[e[1][0][1]]=P(t)}function Mt(e){const t={};return Rt(e,t),t}function Rt(e,t){if(null!==e)if(e[0]===St)for(const r of e[1][0])Rt(r,t);else if(e[0]===Tt)for(const r of Object.values(e[1][0]))Rt(r,t);else if(e[0]===$t){if(t[e[1][0]])throw new r(`Duplicate binding name: ${e[1][0]}`,e[2]);t[e[1][0]]=!0}else{if(t[e[1][0][1]])throw new r(`Duplicate binding name: ${e[1][0]}`,e[2]);t[e[1][0][1]]=!0}}const Ct={arity:{},evaluate:(e,t,{evaluateNode:r})=>{const n=e[1][1],a=n[1][0],o=n[1][1],i=r(o,t),s=Et(a,i,e=>r(e,t));return t.exportValues(s,a[2]),i},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>{const o=e[1][1],i=o[1][0],s=o[1][1],c=r([s],t,n,a);return zt(i,e=>{ye(c,r([e],t,n,a))}),t.addValues(Mt(i),i[2]),c}},Pt={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({});let a=null;for(const t of e[1][1])a=r(t,n);return a},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1],t.create({}),n,a)},It={arity:{},evaluate:(e,t,{builtin:r,getUndefinedSymbols:n,evaluateNode:a})=>{const o=e[1][1],i=e[1][2],s=function(e,t,r,n,a){const o={},i=e[0].reduce((e,t)=>(Object.keys(Mt(t)).forEach(t=>{e[t]={value:null}}),e),{}),s=n(e[1],t.new(i),r,a);s.forEach(e=>{const r=t.getValue(e);C(r)&&(o[e]={value:r})});const c=[e[0],e[1],o];return c}(o,t,r,n,a),c=s[0].filter(e=>e[0]!==$t&&void 0===e[1][1]).length,l={min:c>0?c:void 0,max:s[0].some(e=>e[0]===$t)?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:a})=>function(e,t,r,n,a){const o=new Set,i={self:{value:null}};e[0].forEach(e=>{Object.assign(i,Mt(e)),zt(e,e=>{ye(o,r([e],t,n,a))})});const s=t.create(i),c=r(e[1],s,n,a);return ye(o,c),o}(e[1][1],t,r,n,a)};const Ot={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,a,o]=e[1][1];return r(n,t)?r(a,t):o?r(o,t):null},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1].filter(e=>!!e),t,n,a)},Ft={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,a,o]=e[1][1];return r(n,t)?o?r(o,t):null:r(a,t)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1].filter(e=>!!e),t,n,a)},Ut={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)']},Dt={arity:Q(0),docs:Ut,evaluate:(e,t,{evaluateNode:r})=>{const n=e[1][1],a=n[1][0],o=n[1][1],i=r(o,t),s=Et(a,i,e=>r(e,t));return t.addValues(s,a[2]),i},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>{const o=e[1][1],i=o[1][0],s=o[1][1],c=r([s],t,n,a);return zt(i,e=>{ye(c,r([e],t,n,a))}),t.addValues(Mt(i),i[2]),c}},Gt={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:a})=>{const o=e[1][1],i=o.reduce((e,t)=>{const r=a(t[1][1],n.create(e)),o=Et(t[1][0],r,e=>a(e,n));return Object.entries(o).forEach(([t,r])=>{e[t]={value:r}}),e},{}),s=n.create(i),c=e[1][2];for(;;){let l=null;try{l=a(c,s)}catch(s){if(s instanceof t){const t=s.params;if(t.length!==o.length)throw new r(`recur expected ${o.length} parameters, got ${d(t.length)}`,e[2]);o.forEach((e,r)=>{const o=Et(e[1][0],P(t[r]),e=>a(e,n));for(const[e,t]of Object.entries(o))i[e].value=t});continue}throw s}return l}},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>{const o=e[1][1],i=o.reduce((e,t)=>{const r=Mt(t[1][0]);return Object.keys(r).forEach(t=>{e[t]={value:!0}}),e},{});return de(r(o.map(e=>e[1][1]),t,n,a),r([e[1][2]],t.create(i),n,a))}};function Wt(e,t,r,n){for(const a of e){const[e,o]=a[1],i=Et(e,n(o,r),e=>n(e,r));Object.entries(i).forEach(([e,r])=>{t[e]={value:r}})}}function Vt(e,t,r,n){const a=t[2],[,o,i]=t[1],s=[],c=o.map(()=>0);let l=!1;for(;!l;){const t={},m=r.create(t);let u=!1;e:for(let e=0;e<o.length;e+=1){const[r,i,s,p]=o[e],[g,h]=r[1],d=V(n(h,m),a),y=O(d)?d:Object.entries(d);if(0===y.length){u=!0,l=!0;break}const v=w(c[e],a);if(v>=y.length){if(u=!0,0===e){l=!0;break}c[e]=0,c[e-1]=w(c[e-1],a)+1;break}const f=Et(g,P(y[v],a),e=>n(e,m));if(Object.entries(f).forEach(([e,r])=>{t[e]={value:r}}),i&&Wt(i,t,m,n),s&&!n(s,m)){c[e]=w(c[e],a)+1,u=!0;break e}if(p&&!n(p,m)){c[e]=Number.POSITIVE_INFINITY,u=!0;break e}}if(!u){const t=n(i,m);e&&s.push(t),c.length>0&&(c[c.length-1]+=1)}}return e?s:null}function Bt(e,t,r,n,a){const o=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,a).forEach(e=>o.add(e)),Object.assign(i,Mt(u)),c&&c.forEach(e=>{const[s,c]=e[1];r([c],t.create(i),n,a).forEach(e=>o.add(e)),Object.assign(i,Mt(s))}),l&&r([l],t.create(i),n,a).forEach(e=>o.add(e)),m&&r([m],t.create(i),n,a).forEach(e=>o.add(e))}),r([c],t.create(i),n,a).forEach(e=>o.add(e)),o}const Lt={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 "]},Kt={arity:Q(1),docs:Lt,evaluate:(e,t,r)=>Vt(!0,e,t,r.evaluateNode),getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>Bt(e,t,r,n,a)},_t={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 "]},Jt={arity:Q(1),docs:_t,evaluate:(e,t,r)=>(Vt(!1,e,t,r.evaluateNode),null),getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>Bt(e,t,r,n,a)},Ht={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})=>{let n=!1;for(const a of e[1][1])if(n=r(a,t),n)break;return n},evaluateAsNormalExpression:(e,t)=>{let r=!1;for(const n of e)if(r=P(n,t),r)break;return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1],t,n,a)},Yt={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})=>{for(const n of e[1][1]){if(vt(n)&&null===t.lookUp(n))continue;const e=r(n,t);if(null!==e)return e}return null},evaluateAsNormalExpression:(e,t)=>{for(const r of e){const e=P(r,t);if(null!==e)return e}return null},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1],t,n,a)},Xt={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 !(zero?(n)) then\n recur(n - 1)\n end\nend;\nfoo(3)","\n(n -> do\n write!(n);\n if !(zero?(n)) then\n recur(n - 1)\n end\nend)(3)","\nloop (n = 3) -> do\n write!(n);\n if !(zero?(n)) then\n recur(n - 1)\n end\nend"]},evaluate:(e,r,{evaluateNode:n})=>{const a=e[1][1].map(e=>n(e,r));throw new t(a)},evaluateAsNormalExpression:e=>{throw new t(e)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1],t,n,a)},Zt={arity:Q(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})=>{const a=ae(r(e[1][1],t),e[2],{nonEmpty:!0});throw new n(a,e[2])},evaluateAsNormalExpression:(e,t)=>{const r=ae(e[0],t,{nonEmpty:!0});throw new n(r,void 0)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r([e[1][1]],t,n,a)},Qt={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,a,o]=e[1];try{return r(n,t)}catch(e){const n=a?{[a[1]]:{value:e}}:{};return r(o,t.create(n))}},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>{const[,o,i,s]=e[1],c=r([o],t,n,a),l=i?{[i[1]]:{value:!0}}:{};return de(c,r([s],t.create(l),n,a))}},er={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 a=[];for(const o of e[1][1])if(qt(o)){const e=n(o[1],t);if(!Array.isArray(e))throw new r("Spread value is not an array",o[2]);a.push(...e)}else a.push(n(o,t));return a},evaluateAsNormalExpression:(e,t)=>{const r=[];for(const n of e)r.push(P(n,t));return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1],t,n,a)},tr={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 a={},o=e[1][1];for(let e=0;e<o.length;e+=2){const i=o[e];if(qt(i)){const o=n(i[1],t);if(!k(o))throw new r("Spread value is not an object",i[2]);Object.assign(a,o),e-=1}else{const s=n(i,t),c=o[e+1];if(void 0===c)throw new r("Missing value for key",i[2]);const l=n(c,t);ne(s,i[2]),a[s]=l}}return a},evaluateAsNormalExpression:(e,t)=>{const r={};for(let n=0;n<e.length;n+=2){const a=e[n],o=e[n+1];ne(a,t),r[a]=o??null}return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1],t,n,a)},rr={"??":0,"&&":1,"||":2,array:3,cond:4,"0_def":5,"defined?":6,block:7,doseq:8,"0_lambda":9,for:10,if:11,let:12,loop:13,object:14,recur:15,switch:16,throw:17,try:18,unless:19},nr=[Yt,gt,Ht,er,ht,Ct,At,Pt,Jt,It,Kt,Ot,Dt,Gt,tr,Xt,dt,Zt,Qt,Ft],ar={normalExpressions:mt,specialExpressions:nr,allNormalExpressions:pt},or=Object.keys(mt),ir=Object.keys(rr),sr=["^","*","/","%","+","-","<<",">>",">>>","++","<","<=","≤",">",">=","≥","==","!=","≠","&","xor","|","&&","||","??","|>"],cr=[...sr,"?",":","->","...",".",",","=",":",";"],lr=new Set(["comment","cond","def","defined?","block","doseq","if","let","loop","recur","throw","try","unless","while"]);function mr(e){return!lr.has(e)}const ur=new Set(sr);function pr(e){return ur.has(e)}const gr=new Set(cr);function hr(e){return gr.has(e)}const dr=["number","string","object","array","vector","matrix","grid","boolean","function","integer","any","null","collection","sequence","regexp","never"];function yr(e){return dr.includes(e)}function vr(e){return"args"in e&&"variants"in e}const fr={assert:{category:"assert",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:['let { assert } = import("assert");\ntry assert(0, "Expected a positive value") catch (e) e.message end'],seeAlso:["assert.assert-truthy","assert.assert-true"],hideOperatorForm:!0},"assert!=":{category:"assert",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("assert");\ntry assert!=(0, 0, "Expected different values") catch (e) e.message end','let { assert!= } = import("assert");\ntry assert!=(0, 0) catch (e) e.message end','let { assert!= } = import("assert");\ntry 0 assert!= 0 catch (e) e.message end','let { assert!= } = import("assert");\ntry assert!=(0, 1) catch (e) e.message end'],seeAlso:["assert.assert="],hideOperatorForm:!0},"assert=":{category:"assert",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("assert");\ntry assert=({ "a": 1 }, { "a": 2 }, "Expected equal values") catch (e) e.message end','let { assert= } = import("assert");\ntry assert=({ "a": 1 }, { "a": 2 }) catch (e) e.message end','let { assert= } = import("assert");\ntry assert=({ "a": 1 }, { "a": 1 }) catch (e) e.message end'],seeAlso:["assert.assert!="],hideOperatorForm:!0},"assert-gt":{category:"assert",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("assert");\ntry assert-gt(0, 1, "Expected greater value") catch (e) e.message end','let { assert-gt } = import("assert");\ntry assert-gt(0, 0) catch (e) e.message end','let { assert-gt } = import("assert");\ntry assert-gt(1, 0) catch (e) e.message end'],seeAlso:["assert.assert-lt","assert.assert-gte","assert.assert-lte"],hideOperatorForm:!0},"assert-lt":{category:"assert",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("assert");\ntry assert-lt(1, 0, "Expected smaller value value") catch (e) e.message end','let { assert-lt } = import("assert");\ntry assert-lt(1, 1) catch (e) e.message end','let { assert-lt } = import("assert");\ntry assert-lt(0, 1) catch (e) e.message end'],seeAlso:["assert.assert-gt","assert.assert-lte","assert.assert-gte"],hideOperatorForm:!0},"assert-gte":{category:"assert",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("assert");\ntry assert-gte(0, 1, "Expected greater value") catch (e) e.message end','let { assert-gte } = import("assert");\ntry assert-gte(0, 1) catch (e) e.message end','let { assert-gte } = import("assert");\ntry assert-gte(1, 1) catch (e) e.message end'],seeAlso:["assert.assert-lte","assert.assert-gt","assert.assert-lt"],hideOperatorForm:!0},"assert-lte":{category:"assert",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("assert");\ntry assert-lte(1, 0, "Expected smaller value value") catch (e) e.message end','let { assert-lte } = import("assert");\ntry assert-lte(1, 0) catch (e) e.message end','let { assert-lte } = import("assert");\ntry assert-lte(1, 1) catch (e) e.message end'],seeAlso:["assert.assert-gte","assert.assert-lt","assert.assert-gt"],hideOperatorForm:!0},"assert-true":{category:"assert",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("assert");\ntry assert-true(false, "Expected true") catch (e) e.message end','let { assert-true } = import("assert");\ntry assert-true(false) catch (e) e.message end','let { assert-true } = import("assert");\ntry assert-true(true) catch (e) e.message end'],seeAlso:["assert.assert-false","assert.assert-truthy","assert.assert-falsy","assert.assert","assert.assert-boolean"],hideOperatorForm:!0},"assert-false":{category:"assert",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("assert");\ntry assert-false(true, "Expected false") catch (e) e.message end','let { assert-false } = import("assert");\ntry assert-false(true) catch (e) e.message end','let { assert-false } = import("assert");\ntry assert-false(false) catch (e) e.message end'],seeAlso:["assert.assert-true","assert.assert-falsy","assert.assert-truthy","assert.assert-boolean"],hideOperatorForm:!0},"assert-truthy":{category:"assert",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("assert");\ntry assert-truthy(false, "Expected truthy") catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy(false) catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy(0) catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy(null) catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy("") catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy(true) catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy(1) catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy("x") catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy([]) catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy(nd) catch (e) e.message end'],seeAlso:["assert.assert-falsy","assert.assert-true","assert.assert-false","assert.assert","assert.assert-null"],hideOperatorForm:!0},"assert-falsy":{category:"assert",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("assert");\ntry assert-falsy(true, "Expected falsy") catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy("x") catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy([]) catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy(nd) catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy(1) catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy(false) catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy(0) catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy(null) catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy("") catch (e) e.message end'],seeAlso:["assert.assert-truthy","assert.assert-false","assert.assert-true","assert.assert-null"],hideOperatorForm:!0},"assert-null":{category:"assert",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("assert");\ntry assert-null(null) catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null(true, "Expected null") catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null("x") catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null([]) catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null(nd) catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null(1) catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null(false) catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null(0) catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null("") catch (e) e.message end'],seeAlso:["assert.assert-truthy","assert.assert-falsy"],hideOperatorForm:!0},"assert-throws":{category:"assert",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("assert");\nassert-throws(-> throw("Error"))','let { assert-throws } = import("assert");\ntry assert-throws(-> identity("Error")) catch (e) e.message end'],seeAlso:["assert.assert-throws-error","assert.assert-not-throws"],hideOperatorForm:!0},"assert-throws-error":{category:"assert",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("assert");\ntry assert-throws-error(-> throw("Error"), "Error") catch (e) e.message end','let { assert-throws-error } = import("assert");\ntry assert-throws-error(-> identity("Error"), "Error") catch (e) e.message end'],seeAlso:["assert.assert-throws","assert.assert-not-throws"],hideOperatorForm:!0},"assert-not-throws":{category:"assert",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("assert");\ntry assert-not-throws(-> identity("Error")) catch (e) e.message end','let { assert-not-throws } = import("assert");\ntry assert-not-throws(-> throw("Error")) catch (e) e.message end'],seeAlso:["assert.assert-throws","assert.assert-throws-error"],hideOperatorForm:!0},"assert-array":{category:"assert",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("assert");\ntry assert-array([1, 2, 3]) catch (e) e.message end','let { assert-array } = import("assert");\ntry assert-array("string") catch (e) e.message end','let { assert-array } = import("assert");\ntry assert-array(42, "Expected an array") catch (e) e.message end'],seeAlso:["assert.assert-object","assert.assert-collection","assert.assert-sequence"],hideOperatorForm:!0},"assert-boolean":{category:"assert",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("assert");\ntry assert-boolean(true) catch (e) e.message end','let { assert-boolean } = import("assert");\ntry assert-boolean(false) catch (e) e.message end','let { assert-boolean } = import("assert");\ntry assert-boolean(1, "Expected a boolean") catch (e) e.message end'],seeAlso:["assert.assert-true","assert.assert-false","assert.assert-number","assert.assert-string"],hideOperatorForm:!0},"assert-collection":{category:"assert",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("assert");\ntry assert-collection([1, 2]) catch (e) e.message end','let { assert-collection } = import("assert");\ntry assert-collection({ a: 1 }) catch (e) e.message end','let { assert-collection } = import("assert");\ntry assert-collection("hello") catch (e) e.message end','let { assert-collection } = import("assert");\ntry assert-collection(42, "Expected a collection") catch (e) e.message end'],seeAlso:["assert.assert-sequence","assert.assert-array","assert.assert-object"],hideOperatorForm:!0},"assert-function":{category:"assert",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("assert");\ntry assert-function(-> $ + 1) catch (e) e.message end','let { assert-function } = import("assert");\ntry assert-function(42, "Expected a function") catch (e) e.message end'],seeAlso:["assert.assert-number","assert.assert-string"],hideOperatorForm:!0},"assert-grid":{category:"assert",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("assert");\ntry assert-grid([[1, 2], [3, 4]]) catch (e) e.message end','let { assert-grid } = import("assert");\ntry assert-grid([1, 2], "Expected a grid") catch (e) e.message end'],seeAlso:["assert.assert-matrix","assert.assert-vector"],hideOperatorForm:!0},"assert-integer":{category:"assert",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("assert");\ntry assert-integer(42) catch (e) e.message end','let { assert-integer } = import("assert");\ntry assert-integer(3.14, "Expected an integer") catch (e) e.message end'],seeAlso:["assert.assert-number"],hideOperatorForm:!0},"assert-matrix":{category:"assert",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("assert");\ntry assert-matrix([[1, 2], [3, 4]]) catch (e) e.message end','let { assert-matrix } = import("assert");\ntry assert-matrix([1, 2], "Expected a matrix") catch (e) e.message end'],seeAlso:["assert.assert-vector","assert.assert-grid"],hideOperatorForm:!0},"assert-number":{category:"assert",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("assert");\ntry assert-number(42) catch (e) e.message end','let { assert-number } = import("assert");\ntry assert-number("hello", "Expected a number") catch (e) e.message end'],seeAlso:["assert.assert-integer","assert.assert-boolean","assert.assert-string","assert.assert-function"],hideOperatorForm:!0},"assert-object":{category:"assert",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("assert");\ntry assert-object({ a: 1 }) catch (e) e.message end','let { assert-object } = import("assert");\ntry assert-object([1, 2], "Expected an object") catch (e) e.message end'],seeAlso:["assert.assert-array","assert.assert-collection"],hideOperatorForm:!0},"assert-regexp":{category:"assert",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("assert");\ntry assert-regexp(#"^start") catch (e) e.message end','let { assert-regexp } = import("assert");\ntry assert-regexp("hello", "Expected a regexp") catch (e) e.message end'],seeAlso:["assert.assert-string"],hideOperatorForm:!0},"assert-sequence":{category:"assert",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("assert");\ntry assert-sequence([1, 2]) catch (e) e.message end','let { assert-sequence } = import("assert");\ntry assert-sequence("hello") catch (e) e.message end','let { assert-sequence } = import("assert");\ntry assert-sequence({ a: 1 }, "Expected a sequence") catch (e) e.message end'],seeAlso:["assert.assert-collection","assert.assert-array"],hideOperatorForm:!0},"assert-string":{category:"assert",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("assert");\ntry assert-string("hello") catch (e) e.message end','let { assert-string } = import("assert");\ntry assert-string(42, "Expected a string") catch (e) e.message end'],seeAlso:["assert.assert-number","assert.assert-boolean","assert.assert-regexp","assert.assert-function"],hideOperatorForm:!0},"assert-vector":{category:"assert",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("assert");\ntry assert-vector([1, 2, 3]) catch (e) e.message end','let { assert-vector } = import("assert");\ntry assert-vector(["a", "b"], "Expected a vector") catch (e) e.message end'],seeAlso:["assert.assert-matrix","assert.assert-grid"],hideOperatorForm:!0}},br={assert:{evaluate:(e,t)=>{const r=e[0],n=2===e.length?e[1]:`${r}`;if(ne(n,t),!r)throw new a(n,t);return P(r,t)},arity:{min:1,max:2}},"assert=":{evaluate:([e,t,r],n)=>{if(void 0!==r&&(ne(r,n),r=` ${r}`),r??="",!me(P(e,n),P(t,n),n))throw new a(`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&&(ne(r,n),r=` ${r}`),r??="",me(P(e,n),P(t,n),n))throw new a(`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(se(e,n),se(t,n),void 0!==r&&(ne(r,n),r=` ${r}`),r??="",le(e,t,n)<=0)throw new a(`Expected ${e} to be grater than ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-gte":{evaluate:([e,t,r],n)=>{if(se(e,n),se(t,n),void 0!==r&&(ne(r,n),r=` ${r}`),r??="",le(e,t,n)<0)throw new a(`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(se(e,n),se(t,n),void 0!==r&&(ne(r,n),r=` ${r}`),r??="",le(e,t,n)>=0)throw new a(`Expected ${e} to be less than ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-lte":{evaluate:([e,t,r],n)=>{if(se(e,n),se(t,n),void 0!==r&&(ne(r,n),r=` ${r}`),r??="",le(e,t,n)>0)throw new a(`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&&(ne(t,r),t=` ${t}`),t??="",!0!==e)throw new a(`Expected ${e} to be true.${t}`,r);return null},arity:{min:1,max:2}},"assert-false":{evaluate:([e,t],r)=>{if(void 0!==t&&(ne(t,r),t=` ${t}`),t??="",!1!==e)throw new a(`Expected ${e} to be false.${t}`,r);return null},arity:{min:1,max:2}},"assert-truthy":{evaluate:([e,t],r)=>{if(void 0!==t&&(ne(t,r),t=` ${t}`),t??="",!e)throw new a(`Expected ${e} to be truthy.${t}`,r);return null},arity:{min:1,max:2}},"assert-falsy":{evaluate:([e,t],r)=>{if(void 0!==t&&(ne(t,r),t=` ${t}`),t??="",e)throw new a(`Expected ${e} to be falsy.${t}`,r);return null},arity:{min:1,max:2}},"assert-null":{evaluate:([e,t],r)=>{if(void 0!==t&&(ne(t,r),t=` ${t}`),t??="",null!==e)throw new a(`Expected ${e} to be null.${t}`,r);return null},arity:{min:1,max:2}},"assert-throws":{evaluate:([e,t],r,n,{executeFunction:o})=>{void 0!==t&&(ne(t,r),t=` ${t}`),t??="",J(e,r);try{o(e,[],n,r)}catch{return null}throw new a(`Expected function to throw.${t}`,r)},arity:{min:1,max:2}},"assert-throws-error":{evaluate:([e,t,r],n,o,{executeFunction:i})=>{void 0!==r&&(ne(r,n),r=` ${r}`),r??="",ne(t,n),J(e,n);try{i(e,[],o,n)}catch(e){const o=e.shortMessage;if(o!==t)throw new a(`Expected function to throw "${t}", but thrown "${o}".${r}`,n);return null}throw new a(`Expected function to throw "${t}".${r}`,n)},arity:{min:2,max:3}},"assert-not-throws":{evaluate:([e,t],r,n,{executeFunction:o})=>{void 0!==t&&(ne(t,r),t=` ${t}`),t??="",J(e,r);try{o(e,[],n,r)}catch{throw new a(`Expected function not to throw.${t}`,r)}return null},arity:{min:1,max:2}},"assert-array":{evaluate:([e,t],r)=>{if(void 0!==t&&(ne(t,r),t=` ${t}`),t??="",!Array.isArray(e))throw new a(`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&&(ne(t,r),t=` ${t}`),t??="","boolean"!=typeof e)throw new a(`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&&(ne(t,r),t=` ${t}`),t??="",!W(e))throw new a(`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&&(ne(t,r),t=` ${t}`),t??="",!A(e))throw new a(`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&&(ne(t,r),t=` ${t}`),t??="",!De(e))throw new a(`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&&(ne(t,r),t=` ${t}`),t??="","number"!=typeof e||!v(e,{integer:!0}))throw new a(`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&&(ne(t,r),t=` ${t}`),t??="",!We(e))throw new a(`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&&(ne(t,r),t=` ${t}`),t??="","number"!=typeof e)throw new a(`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&&(ne(t,r),t=` ${t}`),t??="",!D(e))throw new a(`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&&(ne(t,r),t=` ${t}`),t??="",!L(e))throw new a(`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&&(ne(t,r),t=` ${t}`),t??="",!O(e))throw new a(`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&&(ne(t,r),t=` ${t}`),t??="","string"!=typeof e)throw new a(`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&&(ne(t,r),t=` ${t}`),t??="",!Pe(e))throw new a(`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))br[e]&&(br[e].docs=t);const xr={name:"assert",functions:br},wr={"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:['// Using "as" alias because "every?" shadows a builtin function\nlet { every? as grid-every? } = import("grid");\ngrid-every?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], string?)','// Using "as" alias because "every?" shadows a builtin function\nlet { every? as grid-every? } = import("grid");\ngrid-every?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], string?)','// Using "as" alias because "every?" shadows a builtin function\nlet { every? as grid-every? } = import("grid");\ngrid-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.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.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.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","vector.fill"]},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","vector.generate"]},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","grid.reverse-cols"]},"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","grid.reverse-rows"]},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"]},"reverse-rows":{category:"grid",description:"Reverses the order of rows in the grid `g`.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to reverse rows."}},variants:[{argumentNames:["g"]}],examples:['let { reverse-rows } = import("grid");\nreverse-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { reverse-rows } = import("grid");\nreverse-rows([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])','let { reverse-rows } = import("grid");\nreverse-rows([\n [1, 2],\n [3, 4],\n])'],seeAlso:["grid.reverse-cols","grid.flip-v"]},"reverse-cols":{category:"grid",description:"Reverses the order of columns in the grid `g`.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to reverse columns."}},variants:[{argumentNames:["g"]}],examples:['let { reverse-cols } = import("grid");\nreverse-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { reverse-cols } = import("grid");\nreverse-cols([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])','let { reverse-cols } = import("grid");\nreverse-cols([\n [1, 2],\n [3, 4],\n])'],seeAlso:["grid.reverse-rows","grid.flip-h"]},slice:{category:"grid",description:"Slices 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:"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:['// Using "as" alias because "slice" shadows a builtin function\nlet { slice as grid-slice } = import("grid");\ngrid-slice([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [1, 1], [2, 2])','// Using "as" alias because "slice" shadows a builtin function\nlet { slice as grid-slice } = import("grid");\ngrid-slice([\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.slice","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.slice","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"]},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:['// Using "as" alias because "map" shadows a builtin function\nlet { map as grid-map } = import("grid");\ngrid-map([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], str)'],seeAlso:["map","grid.mapi","grid.reduce"]},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:['// Using "as" alias because "mapi" shadows a builtin function\nlet { mapi as grid-mapi } = import("grid");\ngrid-mapi([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $1 ++ "(" ++ $2 ++ ", " ++ $3 ++ ")")'],seeAlso:["grid.map","grid.reducei","map"]},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 { reduce as grid-reduce } = import("grid");\ngrid-reduce([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ++, "")'],seeAlso:["reduce","grid.reducei","grid.map"]},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 { reducei as grid-reducei } = import("grid");\ngrid-reducei([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ++, "")'],seeAlso:["grid.reduce","grid.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 qr(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 kr={"every?":{evaluate:([e,t],r,n,{executeFunction:a})=>{Ge(e,r),J(t,r);for(const o of e)for(const e of o)if(!a(t,[e],n,r))return!1;return!0},arity:Q(2)},"some?":{evaluate:([e,t],r,n,{executeFunction:a})=>{Ge(e,r),J(t,r);for(const o of e)for(const e of o)if(a(t,[e],n,r))return!0;return!1},arity:Q(2)},"every-row?":{evaluate:([e,t],r,n,{executeFunction:a})=>{Ge(e,r),J(t,r);for(const o of e)if(!a(t,[o],n,r))return!1;return!0},arity:Q(2)},"some-row?":{evaluate:([e,t],r,n,{executeFunction:a})=>{Ge(e,r),J(t,r);for(const o of e)if(a(t,[o],n,r))return!0;return!1},arity:Q(2)},"every-col?":{evaluate:([e,t],r,n,{executeFunction:a})=>{Ge(e,r),J(t,r);const o=qr(e);for(const e of o)if(!a(t,[e],n,r))return!1;return!0},arity:Q(2)},"some-col?":{evaluate:([e,t],r,n,{executeFunction:a})=>{Ge(e,r),J(t,r);const o=qr(e);for(const e of o)if(a(t,[e],n,r))return!0;return!1},arity:Q(2)},row:{evaluate:([e,t],r)=>(Ge(e,r),f(t,r,{integer:!0,nonNegative:!0,lt:e.length}),e[t]),arity:Q(2)},col:{evaluate:([e,t],r)=>(Ge(e,r),f(t,r,{integer:!0,nonNegative:!0,lt:e[0].length}),e.map(e=>e[t])),arity:Q(2)},shape:{evaluate:([e],t)=>(Ge(e,t),[e.length,e[0].length]),arity:Q(1)},fill:{evaluate:([e,t,r],n)=>{f(e,n,{integer:!0,positive:!0}),f(t,n,{integer:!0,positive:!0}),I(r,n);const a=[];for(let n=0;n<e;n+=1){const e=[];for(let n=0;n<t;n+=1)e.push(r);a.push(e)}return a},arity:Q(3)},generate:{evaluate:([e,t,r],n,a,{executeFunction:o})=>{f(e,n,{integer:!0,positive:!0}),f(t,n,{integer:!0,positive:!0}),J(r,n);const i=[];for(let s=0;s<e;s+=1){const e=[];for(let i=0;i<t;i+=1){const t=o(r,[s,i],a,n);I(t,n),e.push(t)}i.push(e)}return i},arity:Q(3)},reshape:{evaluate:([e,t],n)=>{Ge(e,n),f(t,n,{integer:!0,positive:!0});const a=e.flat();if(a.length%t!==0)throw new r(`The number of elements in the grid must be divisible by rows, but got ${a.length} and ${t}`,n);const o=a.length/t,i=[];for(let e=0;e<t;e+=1){const t=[];for(let r=0;r<o;r+=1)t.push(a[e*o+r]);i.push(t)}return i},arity:Q(2)},transpose:{evaluate:([e],t)=>(Ge(e,t),qr(e)),arity:Q(1)},"flip-h":{evaluate:([e],t)=>(Ge(e,t),e.map(e=>e.reverse())),arity:Q(1)},"flip-v":{evaluate:([e],t)=>(Ge(e,t),e.reverse()),arity:Q(1)},rotate:{evaluate:([e,t],r)=>{if(Ge(e,r),f(t,r,{integer:!0}),0===(t=(t%4+4)%4)||0===e.length)return e.map(e=>[...e]);const n=e.length,a=e[0].length;let o;switch(t){case 1:o=Array(a).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<a;r++)o[r][n-1-t]=e[t][r];break;case 2:o=Array(n).fill(null).map(()=>Array(a).fill(null));for(let t=0;t<n;t++)for(let r=0;r<a;r++)o[n-1-t][a-1-r]=e[t][r];break;case 3:o=Array(a).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<a;r++)o[a-1-r][t]=e[t][r]}return o},arity:Q(2)},"reverse-rows":{evaluate:([e],t)=>(Ge(e,t),e.reverse()),arity:Q(1)},"reverse-cols":{evaluate:([e],t)=>(Ge(e,t),e.map(e=>e.reverse())),arity:Q(1)},slice:{evaluate:([e,t,n],a)=>{if(Ge(e,a),Ie(t,a),2!==t.length)throw new r(`The start vector must have 2 elements, but got ${t.length}`,a);const[o,i]=t;if(f(o,a,{integer:!0,nonNegative:!0,lt:e.length}),f(i,a,{integer:!0,nonNegative:!0,lt:e[0].length}),n??=[e.length,e[0].length],Ie(n,a),2!==n.length)throw new r(`The end vector must have 2 elements, but got ${n.length}`,a);const[s,c]=n;f(s,a,{gt:o,lte:e.length}),f(c,a,{gt:i,lte:e[0].length});const l=[];for(let t=o;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)=>(Ge(e,n),void 0===r?(f(t,n,{integer:!0,lte:e.length,gte:-e.length}),t<0?e.slice(e.length+t):e.slice(t)):(f(t,n,{integer:!0,nonNegative:!0,lte:e.length}),f(r,n,{integer:!0}),f(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)=>{Ge(e,n);const a=qr(e);return void 0===r?(f(t,n,{integer:!0,lte:a.length,gte:-a.length}),qr(t<0?a.slice(a.length+t):a.slice(t))):(f(t,n,{integer:!0,nonNegative:!0,lte:a.length}),f(r,n,{integer:!0}),f(r=r<0?a.length+r:r,n,{gt:t,lte:a.length}),qr(a.slice(t,r)))},arity:{min:2,max:3}},"splice-rows":{evaluate:([e,t,n,...a],o)=>{Ge(e,o),f(t,o,{integer:!0,nonNegative:!0,lte:e.length}),f(n,o,{integer:!0,nonNegative:!0}),0!==a.length&&(Ge(a,o),a.every(t=>{if(we(t,o),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}`,o);return!0}));const i=[];for(let r=0;r<t;r+=1)i.push(e[r]);a.length>0&&i.push(...a);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,...a],o)=>{Ge(e,o);const i=qr(e);f(t,o,{integer:!0,nonNegative:!0,lte:i.length}),f(n,o,{integer:!0,nonNegative:!0}),0!==a.length&&(Ge(a,o),a.every(e=>{if(we(e,o),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}`,o);return!0}));const s=[];for(let e=0;e<t;e+=1)s.push(i[e]);s.push(...a);for(let e=t+n;e<i.length;e+=1)s.push(i[e]);return qr(s)},arity:{min:3}},"concat-rows":{evaluate:(e,t)=>{we(e,t),e.every(e=>Ge(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 a=[];return e.forEach(e=>{e.forEach(e=>{a.push(e)})}),a},arity:{min:1}},"concat-cols":{evaluate:(e,t)=>{we(e,t),e.every(e=>Ge(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 a=[];for(let t=0;t<n;t+=1){const r=[];e.forEach(e=>{r.push(...e[t])}),a.push(r)}return a},arity:{min:1}},map:{evaluate:(e,t,n,{executeFunction:a})=>{const o=_(e.at(-1),t),i=e.slice(0,-1);Ge(i[0],t);const s=i[0].length,c=i[0][0].length;i.slice(1).forEach(e=>{if(Ge(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)});const l=[];for(let e=0;e<s;e+=1){const r=[];for(let s=0;s<c;s+=1){const c=i.map(t=>t[e][s]);r.push(P(a(o,c,n,t)))}l.push(r)}return l},arity:{min:2}},mapi:{evaluate:([e,t],r,n,{executeFunction:a})=>{Ge(e,r),J(t,r);const o=e.length,i=e[0].length,s=[];for(let c=0;c<o;c+=1){const o=[];for(let s=0;s<i;s+=1)o.push(P(a(t,[e[c][s],c,s],n,r)));s.push(o)}return s},arity:Q(2)},reduce:{evaluate:([e,t,r],n,a,{executeFunction:o})=>{Ge(e,n),J(t,n);let i=P(r);for(const r of e)for(const e of r)i=o(t,[i,e],a,n);return i},arity:Q(3)},reducei:{evaluate:([e,t,r],n,a,{executeFunction:o})=>{Ge(e,n),J(t,n);let i=P(r);for(let r=0;r<e.length;r+=1)for(let s=0;s<e[r].length;s+=1)i=o(t,[i,e[r][s],r,s],a,n);return i},arity:Q(3)},"push-rows":{evaluate:([e,...t],n)=>{if(Ge(e,n),Ge(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(Ge(e,n),Ge(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)=>(Ge(e,t),1===e.length?null:e.slice(0,-1)),arity:Q(1)},"shift-row":{evaluate:([e],t)=>(Ge(e,t),1===e.length?null:e.slice(1)),arity:Q(1)},"push-cols":{evaluate:([e,...t],n)=>{if(Ge(e,n),Ge(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 a=[];for(let r=0;r<e.length;r+=1){const n=[];n.push(...e[r]),t.forEach(e=>{n.push(e[r])}),a.push(n)}return a},arity:{min:2}},"unshift-cols":{evaluate:([e,...t],n)=>{if(Ge(e,n),Ge(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 a=[];for(let r=0;r<e.length;r+=1){const n=[];t.forEach(e=>{n.push(e[r])}),n.push(...e[r]),a.push(n)}return a},arity:{min:2}},"pop-col":{evaluate:([e],t)=>(Ge(e,t),1===e[0].length?null:e.map(e=>e.slice(0,-1))),arity:Q(1)},"shift-col":{evaluate:([e],t)=>(Ge(e,t),1===e[0].length?null:e.map(e=>e.slice(1))),arity:Q(1)},"from-array":{evaluate:([e,t],n)=>{if(we(e,n),f(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 a=0;a<t;a++){const t=a*n,o=t+n;r.push(e.slice(t,o))}return r}(e,t)},arity:Q(2)}};for(const[e,t]of Object.entries(wr))kr[e]&&(kr[e].docs=t);const Ar={name:"grid",functions:kr},Nr={"random!":{category:"random",description:"Returns a random number between 0 and 1.",returns:{type:"number"},args:{},variants:[{argumentNames:[]}],examples:['let { random! } = import("random"); random!()'],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"); random-int!(0, 10)','let { random-int! } = import("random"); random-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"); random-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"); random-float!(0, 10)','let { random-float! } = import("random"); random-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"); random-boolean!()','let { random-boolean! } = import("random"); random-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"); random-item!([1, 2, 3, 4, 5])','let { random-item! } = import("random"); random-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"); random-sample-unique!([1, 2, 3, 4, 5], 3)','let { random-sample-unique! } = import("random"); random-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"); random-sample!([1, 2, 3, 4, 5], 3)','let { random-sample! } = import("random"); random-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"); shuffle!([1, 2, 3, 4, 5])','let { shuffle! } = import("random"); shuffle!(["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"); random-normal!(0, 1)','let { random-normal! } = import("random"); random-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"); random-exponential!(1)','let { random-exponential! } = import("random"); random-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"); random-binomial!(10, 0.5)','let { random-binomial! } = import("random"); random-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"); random-poisson!(1)','let { random-poisson! } = import("random"); random-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"); random-gamma!(2, 2)','let { random-gamma! } = import("random"); random-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"); random-pareto!(1)','let { random-pareto! } = import("random"); random-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"); uuid!()'],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"); random-char!("abcde")','let { random-char! } = import("random"); random-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"); random-string!(10, "abcde")','let { random-string! } = import("random"); random-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"); random-id!(10)','let { random-id! } = import("random"); random-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"); random-color!()']}},$r={"random!":{evaluate:()=>Math.random(),arity:Q(0)},"random-int!":{evaluate:([e,t],r)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0,gt:e}),Math.floor(Math.random()*(t-e))+e),arity:Q(2)},"random-int-inclusive!":{evaluate:([e,t],r)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0,gte:e}),Math.floor(Math.random()*(t-e+1))+e),arity:Q(2)},"random-float!":{evaluate:([e,t],r)=>(f(e,r),f(t,r,{gt:e}),Math.random()*(t-e)+e),arity:Q(2)},"random-boolean!":{evaluate:([e],t)=>{const r=e??.5;return f(r,t,{gte:0,lte:1}),Math.random()<r},arity:{min:0,max:1}},"random-item!":{evaluate:([e],t)=>{we(e,t);return P(e[Math.floor(Math.random()*e.length)])},arity:Q(1)},"random-sample!":{evaluate:([e,t],n)=>{if(we(e,n),f(t,n,{integer:!0,nonNegative:!0}),0===e.length)throw new r("Cannot sample from an empty array.",n);const a=[];for(let r=0;r<t;r++){const t=Math.floor(Math.random()*e.length);a.push(e[t])}return a},arity:Q(2)},"random-sample-unique!":{evaluate:([e,t],n)=>{if(we(e,n),f(t,n,{integer:!0,nonNegative:!0,lte:e.length}),0===e.length)throw new r("Cannot sample from an empty array.",n);const a=[],o=[...e];for(let e=0;e<t;e++){const e=Math.floor(Math.random()*o.length);a.push(o[e]),o.splice(e,1)}return a},arity:Q(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},arity:Q(1)},"random-normal!":{evaluate:([e,t],r)=>{f(e,r),f(t,r,{gt:0});const n=Math.random(),a=Math.random();return Math.sqrt(-2*Math.log(n))*Math.cos(2*Math.PI*a)*t+e},arity:Q(2)},"random-exponential!":{evaluate:([e],t)=>{f(e,t,{gt:0});const r=Math.random();return-Math.log(r)/e},arity:Q(1)},"random-binomial!":{evaluate:([e,t],r)=>{f(e,r,{integer:!0,nonNegative:!0}),f(t,r,{gte:0,lte:1});let n=0;for(let r=0;r<e;r++)Math.random()<t&&n++;return n},arity:Q(2)},"random-poisson!":{evaluate:([e],t)=>{f(e,t,{gt:0});const r=Math.exp(-e);let n=0,a=1;do{n++,a*=Math.random()}while(a>r);return n-1},arity:Q(1)},"random-gamma!":{evaluate:([e,t],r)=>(f(e,r,{gt:0}),f(t,r,{gt:0}),Tr(e,t)),arity:Q(2)},"random-pareto!":{evaluate:([e],t)=>{f(e,t,{gt:0});return(1/Math.random())**(1/e)},arity:Q(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)}),arity:Q(0)},"random-char!":{evaluate:([e],t)=>{if(ne(e,t),0===e.length)throw new r("Character set cannot be empty.",t);return e[Math.floor(Math.random()*e.length)]},arity:Q(1)},"random-string!":{evaluate:([e,t],n)=>{if(f(e,n,{integer:!0,positive:!0}),ne(t,n),0===t.length)throw new r("Character set cannot be empty.",n);let a="";for(let r=0;r<e;r++){a+=t[Math.floor(Math.random()*t.length)]}return a},arity:Q(2)},"random-id!":{evaluate:([e],t)=>{f(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},arity:Q(1)},"random-color!":{evaluate:()=>`#${Math.floor(16777216*Math.random()).toString(16).padStart(6,"0")}`,arity:Q(0)}};function Tr(e,t=1){if(e<1){return Tr(e+1-1/3,t)*Math.random()**(1/e)}const r=e-1/3,n=1/Math.sqrt(9*r);let a,o,i;for(;;){do{a=Sr(),o=1+n*a}while(o<=0);if(o*=o*o,i=Math.random(),i<1-.0331*a*a*a*a)return t*r*o;if(Math.log(i)<.5*a*a+r*(1-o+Math.log(o)))return t*r*o}}function Sr(){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(Nr))$r[e]&&($r[e].docs=t);const zr={name:"random",functions:$r},Er={mean:{category:"vector",description:"Returns the **mean** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **mean** of."}},variants:[{argumentNames:["vector"]}],examples:["mean([1, 2, 3])","mean([1, 2, -3])"],seeAlso:["mean","vector.moving-mean","vector.centered-moving-mean","vector.running-mean","vector.geometric-mean","vector.harmonic-mean","vector.median","vector.mode","vector.sum","vector.rms"]},"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","vector.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:["vector.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","vector.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","vector.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","vector.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"]},median:{category:"vector",description:"Returns the median of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to calculate the median of."}},variants:[{argumentNames:["vector"]}],examples:["median([1, 2, 3])","median([1, 2, -3])","median([1, 2, 3, 4])","median([1, 2, -3, 4])"],seeAlso:["median","vector.moving-median","vector.centered-moving-median","vector.running-median","vector.mean","vector.mode","vector.quartiles","vector.percentile","vector.iqr","vector.medad"]},"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:["vector.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:["vector.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:["vector.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, generate } = import("vector");\niqr(generate(1000, -> 1e6 / ($ + 1) ^ 2))','let { iqr, generate } = import("vector");\nlet { ln } = import("math");\niqr(generate(1000, -> ln($ + 1)))'],seeAlso:["vector.moving-iqr","vector.centered-moving-iqr","vector.running-iqr","vector.quartiles","vector.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"]},sum:{category:"vector",description:"Returns the sum of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to sum."}},variants:[{argumentNames:["vector"]}],examples:["sum([1, 2, 3])","sum([1, 2, -3])"],seeAlso:["sum","vector.moving-sum","vector.centered-moving-sum","vector.running-sum","vector.prod","vector.cumsum","vector.mean"]},"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:["vector.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:["vector.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:["vector.sum","vector.moving-sum","vector.centered-moving-sum","vector.cumsum"]},prod:{category:"vector",description:"Returns the **product** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **product** of."}},variants:[{argumentNames:["vector"]}],examples:["prod([1, 2, 3])","prod([1, 2, -3])"],seeAlso:["prod","vector.moving-prod","vector.centered-moving-prod","vector.running-prod","vector.sum","vector.cumprod"]},"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:["vector.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:["vector.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:["vector.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, generate } = import("vector");\nrms(generate(1000, -> 1e6 / ($ + 1) ^ 2))','let { rms, generate } = import("vector");\nlet { ln } = import("math");\nrms(generate(1000, -> ln($ + 1)))'],seeAlso:["vector.moving-rms","vector.centered-moving-rms","vector.running-rms","vector.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","vector.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:["vector.mean","vector.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","vector.ones","vector.zeros","vector.fill","vector.generate"]},ones:{category:"vector",description:"Generates a vector of ones.",returns:{type:"number",array:!0},args:{length:{type:"integer",description:"The length of the vector."}},variants:[{argumentNames:["length"]}],examples:['let { ones } = import("vector");\nones(5)','let { ones } = import("vector");\nones(10)','let { ones } = import("vector");\nones(0)'],seeAlso:["repeat","vector.zeros","vector.fill","vector.generate","vector.linspace"]},zeros:{category:"vector",description:"Generates a vector of zeros.",returns:{type:"number",array:!0},args:{length:{type:"integer",description:"The length of the vector."}},variants:[{argumentNames:["length"]}],examples:['let { zeros } = import("vector");\nzeros(5)','let { zeros } = import("vector");\nzeros(10)','let { zeros } = import("vector");\nzeros(0)'],seeAlso:["repeat","vector.ones","vector.fill","vector.generate","vector.linspace"]},fill:{category:"vector",description:"Generates a vector filled with a number.",returns:{type:"number",array:!0},args:{length:{type:"integer",description:"The length of the vector."},value:{type:"number",description:"The value to fill the vector with."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["length","value"]}],examples:['let { fill } = import("vector");\nfill(5, PI)','let { fill } = import("vector");\nfill(10, -1)'],seeAlso:["repeat","vector.ones","vector.zeros","vector.generate","vector.linspace","grid.fill"]},generate:{category:"vector",description:"Generates a vector of numbers based on a function.",returns:{type:"number",array:!0},args:{length:{type:"integer",description:"The length of the vector."},func:{type:"function",description:"A function that takes an index and returns a number."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["length","func"]}],examples:['let { generate } = import("vector");\ngenerate(5, -> $ * 2)','let { generate } = import("vector");\ngenerate(10, -> $ + 1)','let { generate } = import("vector");\ngenerate(0, -> $ + 1)'],seeAlso:["repeat","vector.ones","vector.zeros","vector.fill","vector.linspace","grid.generate"]},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","vector.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","vector.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, generate } = import("vector");\nquartiles(generate(1000, -> 1e6 / ($ + 1) ^ 2))','let { quartiles, generate } = import("vector");\nlet { ln } = import("math");\nquartiles(generate(1000, -> ln($ + 1)))'],seeAlso:["vector.percentile","vector.quantile","vector.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","vector.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 jr(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],a=Math.floor(.75*t.length),o=t.length%4==0?(t[a-1]+t[a])/2:t[a],i=o-n,s=n-1.5*i,c=o+1.5*i;return e.filter(e=>e<s||e>c)}function Mr(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 a=Math.floor(n),o=Math.ceil(n),i=n-a;return r[a]*(1-i)+r[o]*i}function Rr(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 a=t.slice(0,Math.floor(t.length/2)),o=t.slice(Math.ceil(t.length/2));let i,s;if(a.length%2==0){const e=a.length/2;i=(a[e-1]+a[e])/2}else i=a[Math.floor(a.length/2)];if(o.length%2==0){const e=o.length/2;s=(o[e-1]+o[e])/2}else s=o[Math.floor(o.length/2)];return[i,n,s]}function Cr(e){if(0===e.length)return 0;return e.reduce((e,t)=>e+t,0)/e.length}const Pr={"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 Ir(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 Or={median:e=>Ir(e)};function Fr(e,t){const r=t??Cr(e);return e.reduce((e,t)=>e+(t-r)**2,0)/e.length}const Ur={variance:e=>Fr(e)},Dr={"sample-variance":e=>function(e){const t=Cr(e);return e.reduce((e,r)=>e+(r-t)**2,0)/(e.length-1)}(e),minLength:2};function Gr(e,t){const r=Fr(e,t);return Math.sqrt(r)}const Wr={stdev:e=>Gr(e)},Vr={"sample-stdev":e=>function(e,t){const r=Fr(e,t);return Math.sqrt(r*(e.length/(e.length-1)))}(e),minLength:2},Br={iqr:e=>{const[t,,r]=Rr(e);return r-t},minLength:4},Lr={span:e=>0===e.length?0:Math.max(...e)-Math.min(...e),minLength:0};const Kr={skewness:e=>function(e){const t=Cr(e),r=Gr(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},_r={"sample-skewness":e=>function(e){const t=e.length,r=e.reduce((e,t)=>e+t,0)/t;let n=0,a=0;for(const t of e){const e=t-r;n+=e*e,a+=e*e*e}const o=n/(t-1),i=Math.sqrt(o);if(0===i)throw new Error("Cannot calculate sample skewness when standard deviation is 0");return t/((t-1)*(t-2))*a/i**3}(e),minLength:3};function Jr(e){const t=Cr(e),r=Gr(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 Hr={kurtosis:e=>Jr(e),minLength:4},Yr={"excess-kurtosis":e=>function(e){return Jr(e)-3}(e),minLength:4},Xr={"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},Zr={"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},Qr={rms:e=>Math.sqrt(e.reduce((e,t)=>e+t**2,0)/e.length)};const en={mad:e=>function(e){const t=Ir(e);return e.reduce((e,r)=>e+Math.abs(r-t),0)/e.length}(e)};function tn(e){const t=Ir(e);return 1.4826*Ir(e.map(e=>Math.abs(e-t)))}const rn={medad:e=>tn(e)},nn={"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},on={};function sn(e){for(const[t,r]of Object.entries(e)){if(on[t])throw new Error(`Duplicate normal expression key found: ${t}`);if("minLength"!==t&&"padding"!==t&&"function"==typeof r){const n=r,a=t.replace(/^/,""),o=`moving-${a}`,i=`centered-moving-${a}`,s=`running-${a}`,c=e.minLength??1;f(c,void 0,{integer:!0,finite:!0,gte:0}),on[t]=cn(n,c),on[o]=ln(n,c),on[i]=mn(n,c,e.padding??null),on[s]=un(n,c)}}}function cn(e,t){return{evaluate:([n],a)=>{if(Ie(n,a),n.length<t)throw new r(`Vector length must be at least ${t}`,a);try{return e(n)}catch(e){throw new r(e,a)}},arity:Q(1)}}function ln(e,t){return{evaluate:([n,a],o)=>{if(Ie(n,o),f(a,o,{integer:!0,finite:!0,gte:t,lte:n.length}),0===n.length)return[];try{if(a>=n.length)return[e(n)];const t=[];for(let r=0;r<n.length-a+1;r+=1)t.push(e(n.slice(r,r+a)));return t}catch(e){throw new r(e,o)}},arity:Q(2)}}function mn(e,t,n){return{evaluate:([a,o,i,s],c)=>{if(Ie(a,c),a.length<t)throw new r(`Vector length must be at least ${t}`,c);if(f(o,c,{integer:!0,finite:!0,gte:t,lte:a.length}),null!==(i=i??n)&&f(i,c,{finite:!0}),null!==(s=s??n)&&f(s,c,{finite:!0}),0===a.length)return[];const l=Math.floor(o/2),m=[...Array(l).fill(i),...a,...Array(l).fill(s)],u="number"==typeof i?0:l,p=a.length-("number"==typeof s?0:o-l-1),g=[...Array(u).fill(null)];try{for(let t=u;t<p;t+=1)g.push(e(m.slice(t,t+o)))}catch(e){throw new r(e,c)}return g.push(...Array(a.length-p).fill(null)),g},arity:{min:2,max:4}}}function un(e,t){return{evaluate:([n],a)=>{if(Ie(n,a),n.length<t)throw new r(`Vector length must be at least ${t}`,a);if(0===n.length)return[];try{const r=Math.max(t-1,0),a=Array(r).fill(null);for(let t=r;t<n.length;t+=1)a.push(e(n.slice(0,t+1)));return a}catch(e){throw new r(e,a)}},arity:Q(1)}}sn({mean:e=>Cr(e)}),sn(Pr),sn({"harmonic-mean":e=>e.length/e.reduce((e,t)=>e+1/t,0)}),sn(Or),sn({sum:e=>e.reduce((e,t)=>e+t,0),minLength:0}),sn({prod:e=>e.reduce((e,t)=>e*t,1),padding:1,minLength:0}),sn(Ur),sn(Dr),sn(Wr),sn(Vr),sn(Br),sn(Lr),sn(Kr),sn(_r),sn(Yr),sn(Hr),sn(Zr),sn(Xr),sn(Qr),sn(en),sn(rn),sn(nn),sn(an);const pn={"monotonic?":{evaluate:([e],t)=>(Ie(e,t),e.every((t,r)=>0===r||t>=e[r-1])||e.every((t,r)=>0===r||t<=e[r-1])),arity:Q(1)},"strictly-monotonic?":{evaluate:([e],t)=>(Ie(e,t),e.every((t,r)=>0===r||t>e[r-1])||e.every((t,r)=>0===r||t<e[r-1])),arity:Q(1)},"increasing?":{evaluate:([e],t)=>(Ie(e,t),e.every((t,r)=>0===r||t>=e[r-1])),arity:Q(1)},"decreasing?":{evaluate:([e],t)=>(Ie(e,t),e.every((t,r)=>0===r||t<=e[r-1])),arity:Q(1)},"strictly-increasing?":{evaluate:([e],t)=>(Ie(e,t),e.every((t,r)=>0===r||t>e[r-1])),arity:Q(1)},"strictly-decreasing?":{evaluate:([e],t)=>(Ie(e,t),e.every((t,r)=>0===r||t<e[r-1])),arity:Q(1)},mode:{evaluate:([e],t)=>(Ue(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,a]of t.entries())a===r&&n.push(e);return n}(e)),arity:Q(1)},"min-index":{evaluate:([e],t)=>(Ue(e,t),e.reduce((t,r,n)=>r<e[t]?n:t,0)),arity:Q(1)},"max-index":{evaluate:([e],t)=>(Ue(e,t),e.reduce((t,r,n)=>r>e[t]?n:t,0)),arity:Q(1)},"sort-indices":{evaluate:([e],t)=>(Ie(e,t),[...e.keys()].sort((t,r)=>e[t]-e[r])),arity:Q(1)},"count-values":{evaluate:([e],t)=>{Ie(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:Q(1)},linspace:{evaluate:([e,t,r],n)=>{if(f(e,n,{finite:!0}),f(t,n,{finite:!0}),f(r,n,{integer:!0,nonNegative:!0}),0===r)return[];if(1===r)return[e];const a=(t-e)/(r-1);return Array.from({length:r},(t,r)=>e+r*a)},arity:Q(3)},ones:{evaluate:([e],t)=>(f(e,t,{integer:!0,nonNegative:!0}),Array.from({length:e},()=>1)),arity:Q(1)},zeros:{evaluate:([e],t)=>(f(e,t,{integer:!0,nonNegative:!0}),Array.from({length:e},()=>0)),arity:Q(1)},fill:{evaluate:([e,t],r)=>(f(e,r,{integer:!0,nonNegative:!0}),Array.from({length:e},()=>t)),arity:Q(2)},generate:{evaluate:([e,t],r,n,{executeFunction:a})=>(f(e,r,{integer:!0,nonNegative:!0}),J(t,r),Array.from({length:e},(e,o)=>{const i=a(t,[o],n,r);return f(i,r,{finite:!0}),i})),arity:Q(2)},cumsum:{evaluate:([e],t)=>(Ie(e,t),e.reduce((e,t)=>{const r=e[e.length-1]??0;return e.push(r+t),e},[])),arity:Q(1)},cumprod:{evaluate:([e],t)=>(Ie(e,t),e.reduce((e,t)=>{const r=e[e.length-1]??1;return e.push(r*t),e},[])),arity:Q(1)},quartiles:{evaluate:([e],t)=>{if(Ie(e,t),e.length<4)throw new r("Quartiles require at least four values",t);return Rr(e)},arity:Q(1)},percentile:{evaluate:([e,t],r)=>(Ue(e,r),f(t,r,{finite:!0,nonNegative:!0,lte:100}),Mr(e,t)),arity:Q(2)},quantile:{evaluate:([e,t],r)=>(Ie(e,r),f(t,r,{finite:!0,nonNegative:!0,lte:1}),Mr(e,100*t)),arity:Q(2)},histogram:{evaluate:([e,t],r)=>(Ie(e,r),f(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 a=(n-r)/t,o=[];for(let e=0;e<t;e++){const i=r+e*a,s=e===t-1?n:r+(e+1)*a;o.push([i,s,0])}for(const i of e)i===n?o[t-1][2]+=1:o[Math.min(Math.floor((i-r)/a),t-1)][2]+=1;return o}(e,t)),arity:Q(2)},ecdf:{evaluate:([e,t],r)=>{Ue(e,r),f(t,r,{finite:!0});const n=[...e].sort((e,t)=>e-t),a=n.findIndex(e=>e>t);return-1===a?1:a/n.length},arity:Q(2)},"outliers?":{evaluate:([e],t)=>(Ie(e,t),function(e){return jr(e).length>0}(e)),arity:Q(1)},outliers:{evaluate:([e],t)=>(Ie(e,t),jr(e)),arity:Q(1)},bincount:{evaluate:(e,t)=>{const n=e[0];Ie(n,t),n.forEach(e=>f(e,t,{finite:!0,integer:!0,nonNegative:!0}));const a=e[1]??0;f(a,t,{integer:!0,nonNegative:!0});const o=e[2]??void 0;if(void 0!==o){if(Ie(o,t),o.length!==n.length)throw new r("Weights vector must be the same length as the input vector",t);o.forEach(e=>f(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),a=Math.max(n+1,t),o=Array.from({length:a},()=>0);for(let t=0;t<e.length;t++){const n=Math.floor(e[t]);n<a&&(o[n]+=r?r[t]:1)}return o}(n,a,o)},arity:{min:1,max:3}},winsorize:{evaluate:([e,t,r],n)=>{if(Ie(e,n),f(t,n,{finite:!0,gte:0,lte:1}),r??=t>.5?1:1-t,f(r,n,{finite:!0,gte:t,lte:1}),0===e.length)return[];const a=[...e].sort((e,t)=>e-t),o=Math.max(0,Math.floor(t*e.length)),i=Math.min(e.length-1,Math.max(0,Math.floor(r*e.length)-1)),s=a[o],c=a[i];return e.map(e=>Math.max(s,Math.min(e,c)))},arity:{min:2,max:3}},mse:{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(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:Q(2)},rmse:{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(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:Q(2)},mae:{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(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:Q(2)},smape:{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>{const a=Math.abs(r-t[n]),o=(Math.abs(r)+Math.abs(t[n]))/2;return e+(0===o?0:a/o)},0)/e.length},arity:Q(2)}};!function(e){for(const[t,r]of Object.entries(e)){if(pn[t])throw new Error(`Duplicate normal expression key found: ${t}`);pn[t]=r}}(on);for(const[e,t]of Object.entries(Er))pn[e]&&(pn[e].docs=t);const gn={name:"vector",functions:pn},hn={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?","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"); solve([[2, 0, 0], [3, 1, 0], [4, 5, 6]], [4, 5, 38])','let { solve } = import("linear-algebra"); solve([[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 dn(e){const t=e.map(e=>[...e]),r=t.length,n=t[0].length;let a=0,o=0;for(let e=0;e<n;e++){let i=-1;for(let n=o;n<r;n++)if(!be(t[n][e])){i=n;break}if(-1===i)continue;a+=1,i!==o&&([t[i],t[o]]=[t[o],t[i]]);const s=t[o][e];for(let r=e;r<n;r++)t[o][r]/=s;for(let a=0;a<r;a++)if(a!==o&&!be(t[a][e])){const r=t[a][e];for(let i=e;i<n;i++)t[a][i]-=r*t[o][i]}if(o++,o===r)break}return[t,a]}function yn(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 a=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],a))return!1}return!0}function vn(e){return e.every(e=>be(e))}function fn(e,t){const r=Cr(e),n=Cr(t);let a=0,o=0,i=0;for(let s=0;s<e.length;s++){const c=e[s]-r,l=t[s]-n;a+=c*l,o+=c*c,i+=l*l}if(0===o||0===i)throw new Error("Cannot calculate Pearson correlation coefficient: one of the vectors has zero variance.");return a/(Math.sqrt(o)*Math.sqrt(i))}function bn(e){const t=[...e.keys()].sort((t,r)=>e[t]-e[r]),r=Array.from({length:e.length}).fill(0);let n=1,a=0;for(;a<t.length;){const o=e[t[a]];let i=a;for(;i<t.length&&e[t[i]]===o;)i++;const s=n+(i-a-1)/2;for(let e=a;e<i;e++)r[t[e]]=s;n+=i-a,a=i}return r}function xn(e,t){const r=Cr(e),n=Cr(t);let a=0;for(let o=0;o<e.length;o++)a+=(e[o]-r)*(t[o]-n);return a/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 qn(e,t){return e.reduce((e,r,n)=>e+r*t[n],0)}function kn(e,t){return e.map((e,r)=>e-t[r])}function An(e,t){return e.map(e=>e*t)}const Nn={rotate2d:{evaluate:([e,t],r)=>{if(Oe(e,r),vn(e))return e;f(t,r,{finite:!0});const n=Math.cos(t),a=Math.sin(t);return[e[0]*n-e[1]*a,e[0]*a+e[1]*n]},arity:Q(2)},rotate3d:{evaluate:([e,t,n],a)=>{if(Fe(e,a),vn(e))return e;if(f(n,a,{finite:!0}),Fe(t,a),vn(t))throw new r("Rotation axis must not be zero",a);const o=Math.cos(n),i=Math.sin(n),[s,c,l]=wn(t,a),m=e[0]*s+e[1]*c+e[2]*l;return[m*s*(1-o)+e[0]*o+(-l*e[1]+c*e[2])*i,m*c*(1-o)+e[1]*o+(l*e[0]-s*e[2])*i,m*l*(1-o)+e[2]*o+(-c*e[0]+s*e[1])*i]},arity:Q(3)},reflect:{evaluate:([e,t],n)=>{if(Ie(e,n),Ie(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);if(vn(t))throw new r("Reflection normal must not be zero",n);if(vn(e))return e;const a=wn(t,n);return kn(e,An(a,2*qn(e,a)))},arity:Q(2)},refract:{evaluate:([e,t,n],a)=>{if(Ie(e,a),Ie(t,a),f(n,a,{finite:!0,positive:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",a);if(vn(t))throw new r("Refraction normal must not be zero",a);if(vn(e))return e;const o=wn(e,a),i=wn(t,a),s=qn(o,i),c=1-n*n*(1-s*s);if(c<0)return e;return kn(An(o,n),An(i,n*s+Math.sqrt(c)))},arity:Q(3)},lerp:{evaluate:([e,t,n],a)=>{if(Ie(e,a),Ie(t,a),f(n,a,{finite:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",a);return e.map((e,r)=>e+(t[r]-e)*n)},arity:Q(3)},dot:{evaluate:([e,t],n)=>{if(Ie(e,n),Ie(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return qn(e,t)},arity:Q(2)},cross:{evaluate:([e,t],n)=>{if(Ie(e,n),Ie(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:Q(2)},"normalize-minmax":{evaluate:([e],t)=>{if(Ie(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:Q(1)},"normalize-robust":{evaluate:([e],t)=>{if(Ie(e,t),0===e.length)return[];const r=Ir(e),n=tn(e);return 0===n?e.map(e=>e-r):e.map(e=>(e-r)/n)},arity:Q(1)},"normalize-zscore":{evaluate:([e],t)=>{Ie(e,t);const r=Cr(e),n=Gr(e);return 0===n?e.map(()=>0):e.map(e=>(e-r)/n)},arity:Q(1)},"normalize-l1":{evaluate:([e],t)=>{if(Ie(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:Q(1)},"normalize-l2":{evaluate:([e],t)=>(Ie(e,t),wn(e,t)),arity:Q(1)},"normalize-log":{evaluate:([e],t)=>{if(Ie(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:Q(1)},angle:{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(t,n),vn(e)||vn(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 a=e.reduce((e,r,n)=>e+r*t[n],0),o=Math.sqrt(e.reduce((e,t)=>e+t*t,0)),i=Math.sqrt(t.reduce((e,t)=>e+t*t,0));return Math.acos(a/(o*i))},arity:Q(2)},projection:{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(t,n),vn(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 a=e.reduce((e,r,n)=>e+r*t[n],0),o=Math.sqrt(t.reduce((e,t)=>e+t*t,0));return t.map(e=>a/o**2*e)},arity:Q(2)},"orthogonal?":{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(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:Q(2)},"parallel?":{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return function(e,t){if(!yn(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:Q(2)},"collinear?":{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return yn(e,t)},arity:Q(2)},"cosine-similarity":{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(t,n),vn(e)||vn(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:Q(2)},"euclidean-distance":{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(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:Q(2)},"euclidean-norm":{evaluate:([e],t)=>(Ue(e,t),function(e){return Math.sqrt(e.reduce((e,t)=>e+t**2,0))}(e)),arity:Q(1)},"manhattan-distance":{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(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:Q(2)},"manhattan-norm":{evaluate:([e],t)=>(Ue(e,t),e.reduce((e,t)=>e+Math.abs(t),0)),arity:Q(1)},"hamming-distance":{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(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:Q(2)},"hamming-norm":{evaluate:([e],t)=>(Ue(e,t),e.reduce((e,t)=>e+(0!==t?1:0),0)),arity:Q(1)},"chebyshev-distance":{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(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:Q(2)},"chebyshev-norm":{evaluate:([e],t)=>(Ue(e,t),Math.max(...e.map(e=>Math.abs(e)))),arity:Q(1)},"minkowski-distance":{evaluate:([e,t,n],a)=>{if(Ue(e,a),Ue(t,a),f(n,a,{finite:!0,positive:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",a);return e.reduce((e,r,a)=>e+Math.abs(r-t[a])**n,0)**(1/n)},arity:Q(3)},"minkowski-norm":{evaluate:([e,t],r)=>(Ue(e,r),f(t,r,{finite:!0,positive:!0}),e.reduce((e,r)=>e+Math.abs(r)**t,0)**(1/t)),arity:Q(2)},cov:{evaluate:([e,t],n)=>{if(Ue(e,n),Ue(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return 1===e.length?0:xn(e,t)},arity:Q(2)},corr:{evaluate:([e,t],n)=>{if(Ie(e,n),Ie(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 a=Cr(e),o=Cr(t);return e.reduce((e,r,n)=>e+(r-a)*(t[n]-o),0)/Math.sqrt(e.reduce((e,t)=>e+(t-a)**2,0)*t.reduce((e,t)=>e+(t-o)**2,0))},arity:Q(2)},"spearman-corr":{evaluate:([e,t],n)=>{if(Ie(e,n),Ie(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 a=bn(e),o=bn(t);try{return fn(a,o)}catch(e){throw new r(e,n)}},arity:Q(2)},"pearson-corr":{evaluate:([e,t],n)=>{if(Ie(e,n),Ie(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:Q(2)},"kendall-tau":{evaluate:([e,t],n)=>{if(Ie(e,n),Ie(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,a=0,o=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?o+=1:p?i+=1:l*m>0?n+=1:a+=1)}const s=n+a+o,c=n+a+i;if(0===s||0===c)throw new Error("Not enough data to calculate Kendall's Tau");return(n-a)/Math.sqrt(s*c)}(e,t)}catch(e){throw new r(e,n)}},arity:Q(2)},autocorrelation:{evaluate:([e,t],n)=>{if(Ie(e,n),e.length<2)throw new r("Vector must have at least 2 elements for autocorrelation",n);if(f(t,n,{integer:!0,lt:e.length,gt:-e.length}),0===t)return 1;const a=Math.abs(t),o=Cr(e);let i=0;const s=e.length;for(let r=0;r<s-a;r++){const n=t<0?r:r+a;i+=(e[t<0?r+a:r]-o)*(e[n]-o)}let c=0;for(let t=0;t<s;t++)c+=(e[t]-o)**2;return 0===c?0:i/c},arity:Q(2)},"cross-correlation":{evaluate:([e,t,n],a)=>{if(Ie(e,a),Ie(t,a),e.length<2)throw new r("Vectors must have at least 2 elements",a);if(e.length!==t.length)throw new r("Vectors must be of the same length",a);if(f(n,a,{integer:!0,lt:e.length,gt:-e.length}),0===n&&e.length===t.length&&e.every((e,r)=>e===t[r]))return 1;const[o,i]=function(e,t,r){const n=Math.abs(r),a=e.length-n;let o=[],i=[];return r>=0?(o=e.slice(0,a),i=t.slice(r,r+a)):(o=e.slice(n),i=t.slice(0,a)),[o,i]}(e,t,n);return function(e,t){const r=Cr(e),n=Cr(t),a=Gr(e,r),o=Gr(t,n);return 0===a||0===o?0===a&&0===o&&r===n?1:0:xn(e,t)/(a*o)}(o,i)},arity:Q(3)},rref:{evaluate:([e],t)=>{Ve(e,t);const[r]=dn(e);return r},arity:Q(1)},solve:{evaluate:([e,t],n)=>{if(Be(e,n),Ie(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]]),[a]=dn(n);for(let e=0;e<r;e+=1)if(be(a[e][e]))return null;const o=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+=a[e][n]*o[n];o[e]=(a[e][r]-t)/a[e][e]}return o}(e,t)},arity:Q(2)},"to-polar":{evaluate:([e],t)=>{if(Oe(e,t),vn(e))return[0,0];return[Math.sqrt(e[0]**2+e[1]**2),Math.atan2(e[1],e[0])]},arity:Q(1)},"from-polar":{evaluate:([e],t)=>{Oe(e,t);const[r,n]=e;return 0===r?[0,0]:[r*Math.cos(n),r*Math.sin(n)]},arity:Q(1)}};for(const[e,t]of Object.entries(hn))Nn[e]&&(Nn[e].docs=t);const $n={name:"linear-algebra",functions:Nn},Tn={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?"]},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.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?":{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? } = import("matrix");\northogonal?([[1, 0], [0, 1]])','let { orthogonal? } = import("matrix");\northogonal?([[1, 0], [0, -1]])','let { orthogonal? } = import("matrix");\northogonal?([[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?"]},"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 Sn(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 a=e;for(let n=e+1;n<t;n+=1)Math.abs(r[n][e])>Math.abs(r[a][e])&&(a=n);if(be(r[a][e]))return 0;a!==e&&([r[e],r[a]]=[r[a],r[e]],n=-n);for(let n=e+1;n<t;n+=1){const a=r[n][e]/r[e][e];for(let o=e;o<t;o++)r[n][o]-=a*r[e][o]}}let a=n;for(let e=0;e<t;e++)a*=r[e][e];return a}function zn(e,t,r){const n=e.length,a=[];for(let o=0;o<n;o++)if(o!==t){const t=[];for(let a=0;a<n;a++)a!==r&&t.push(e[o][a]);a.push(t)}return a}function En(e){const t=e.length,r=[];for(let n=0;n<t;n++){r[n]=[];for(let a=0;a<t;a++){const t=(-1)**(n+a)*Sn(zn(e,a,n));r[n][a]=t}}return r}function jn(e){return e.length===e[0].length}function Mn(e){if(!jn(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 Rn(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,a=t[0].length,o=Array(r).fill(0).map(()=>Array(a).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<a;e++)o[i][e]+=n*t[r][e]}return o}const Cn={mul:{evaluate:([e,t],n)=>{Ve(e,n),Ve(t,n);try{return Rn(e,t)}catch(a){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:Q(2)},det:{evaluate:([e],t)=>(Be(e,t),Sn(e)),arity:Q(1)},inv:{evaluate:([e],t)=>{Be(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=Sn(e);if(be(r))return null;const n=En(e),a=[];for(let e=0;e<t;e++){a[e]=[];for(let o=0;o<t;o++)a[e][o]=n[e][o]/r}return a}(e);if(null===n)throw new r("The matrix must be invertible",t);return n},arity:Q(1)},adj:{evaluate:([e],t)=>(Be(e,t),En(e)),arity:Q(1)},cofactor:{evaluate:([e],t)=>(Be(e,t),function(e){const t=e.length,r=[];for(let n=0;n<t;n++){r[n]=[];for(let a=0;a<t;a++){const t=zn(e,n,a),o=(-1)**(n+a);r[n][a]=o*Sn(t)}}return r}(e)),arity:Q(1)},minor:{evaluate:([e,t,r],n)=>(Ve(e,n),f(t,n,{integer:!0,nonNegative:!0,lte:e.length}),f(r,n,{integer:!0,nonNegative:!0,lte:e[0].length}),zn(e,t,r)),arity:Q(3)},trace:{evaluate:([e],t)=>(Be(e,t),function(e){return e.reduce((e,t,r)=>e+t[r],0)}(e)),arity:Q(1)},"symmetric?":{evaluate:([e],t)=>(Ve(e,t),function(e){const t=e.length;if(!jn(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:Q(1)},"triangular?":{evaluate:([e],t)=>(Ve(e,t),function(e){if(!jn(e))return!1;const t=e.length;let r=!0,n=!0;for(let a=0;a<t;a++)for(let o=0;o<t;o++){if(a>o&&0!==e[a][o]&&(r=!1,!n))return!1;a<o&&0!==e[a][o]&&(n=!1)}return r||n}(e)),arity:Q(1)},"upper-triangular?":{evaluate:([e],t)=>(Ve(e,t),function(e){if(!jn(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:Q(1)},"lower-triangular?":{evaluate:([e],t)=>(Ve(e,t),function(e){if(!jn(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:Q(1)},"diagonal?":{evaluate:([e],t)=>(Ve(e,t),function(e){if(!jn(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:Q(1)},"square?":{evaluate:([e],t)=>(Ve(e,t),jn(e)),arity:Q(1)},"orthogonal?":{evaluate:([e],t)=>(Ve(e,t),function(e){return!!jn(e)&&Mn(Rn(e,qr(e)))}(e)),arity:Q(1)},"identity?":{evaluate:([e],t)=>(Ve(e,t),Mn(e)),arity:Q(1)},"invertible?":{evaluate:([e],t)=>(Ve(e,t),!!function(e){return!!We(e)&&e.length===e[0].length}(e)&&!be(Sn(e))),arity:Q(1)},hilbert:{evaluate:([e],t)=>{f(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:Q(1)},vandermonde:{evaluate:([e],t)=>{Ie(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:Q(1)},band:{evaluate:([e,t,r],n)=>(f(e,n,{integer:!0,positive:!0}),f(t,n,{integer:!0,nonNegative:!0,lt:e}),f(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 a=0;a<e;a++)for(let o=Math.max(0,a-t);o<=Math.min(e-1,a+r);o++)n[a][o]=1;return n}(e,t,r)),arity:Q(3)},"banded?":{evaluate:([e,t,r],n)=>{Ve(e,n);const a=Math.max(e.length,e[0].length);return f(t,n,{integer:!0,nonNegative:!0,lt:a}),f(r,n,{integer:!0,nonNegative:!0,lt:a}),function(e,t,r){const n=e.length,a=e[0].length;for(let o=0;o<n;o++)for(let n=0;n<a;n++)if(0!==e[o][n]&&(o-n>t||n-o>r))return!1;return!0}(e,t,r)},arity:Q(3)},rank:{evaluate:([e],t)=>{Ve(e,t);const[,r]=dn(e);return r},arity:Q(1)},"frobenius-norm":{evaluate:([e],t)=>(Ve(e,t),Math.sqrt(e.reduce((e,t)=>e+t.reduce((e,t)=>e+t*t,0),0))),arity:Q(1)},"one-norm":{evaluate:([e],t)=>(Ve(e,t),function(e){const t=e.length,r=e[0].length;let n=0;for(let a=0;a<r;a+=1){let r=0;for(let n=0;n<t;n+=1)r+=Math.abs(e[n][a]);n=Math.max(n,r)}return n}(e)),arity:Q(1)},"inf-norm":{evaluate:([e],t)=>(Ve(e,t),e.reduce((e,t)=>Math.max(e,t.reduce((e,t)=>e+Math.abs(t),0)),0)),arity:Q(1)},"max-norm":{evaluate:([e],t)=>(Ve(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:Q(1)}};for(const[e,t]of Object.entries(Tn))Cn[e]&&(Cn[e].docs=t);const Pn={name:"matrix",functions:Cn},In={"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 On(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 Fn(e,t){if(1===t)return e.map(e=>[e]);const r=[];for(let n=0;n<=e.length-t;n++){const a=e[n],o=Fn(e.slice(n+1),t-1);for(const e of o)r.push([a,...e])}return r}const Un={combinations:{evaluate:([e,t],r)=>(we(e,r),f(t,r,{integer:!0,nonNegative:!0,lte:e.length}),0===t?[[]]:Fn(e,t)),arity:Q(2)},"count-combinations":{evaluate:([e,t],r)=>(f(e,r,{integer:!0,nonNegative:!0}),f(t,r,{integer:!0,nonNegative:!0,lte:e}),On(e,t)),arity:Q(2)}};const Dn={derangements:{evaluate:([e],t)=>(we(e,t),function(e){const t=e.length,r=[],n=Array.from({length:t},()=>!1),a=Array.from({length:t});return function o(i){if(i!==t)for(let r=0;r<t;r++)n[r]||r===i||(n[r]=!0,a[i]=e[r],o(i+1),n[r]=!1);else r.push([...a])}(0),r}(e)),arity:Q(1)},"count-derangements":{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),function(e){if(1===e)return 0;let t=1,r=0,n=0;for(let a=2;a<=e;a++)n=(a-1)*(t+r),t=r,r=n;return n}(e)),arity:Q(1)}};function Gn(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 Wn(e){return Gn(e).sort((e,t)=>e-t)}function Vn(e){return Wn(e).slice(0,-1)}const Bn={divisors:{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),Wn(e)),arity:Q(1)},"count-divisors":{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),Gn(e).length),arity:Q(1)},"proper-divisors":{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),Vn(e)),arity:Q(1)},"count-proper-divisors":{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),Gn(e).length-1),arity:Q(1)}},Ln=[1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368e3,20922789888e3,355687428096e3,6402373705728e3];function Kn(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 Ln[e];let t=Ln[18];for(let r=19;r<=e;r++)t*=r;return t}const _n={factorial:{evaluate:([e],t)=>(f(e,t,{integer:!0,nonNegative:!0,lte:170}),Kn(e)),arity:Q(1)}},Jn=[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 Hn={partitions:{evaluate:([e],t)=>(f(e,t,{integer:!0,nonNegative:!0}),function(e){if(e<=0)return[[]];if(1===e)return[[1]];const t=[];return function e(r,n,a){if(0!==r)for(let t=Math.min(n,r);t>=1;t--)a.push(t),e(r-t,t,a),a.pop();else t.push([...a])}(e,e,[]),t}(e)),arity:Q(1)},"count-partitions":{evaluate:([e],t)=>{if(f(e,t,{integer:!0,nonNegative:!0}),0===e)return 1;if(e>Jn.length)throw new r(`n is too large. The maximum value is ${Jn.length-1}.`,t);return Jn[e-1]},arity:Q(1)}};function Yn(e){if(0===e.length)return[[]];const t=[];for(let r=0;r<e.length;r++){const n=e[r],a=Yn([...e.slice(0,r),...e.slice(r+1)]);for(const e of a)t.push([n,...e])}return t}const Xn={permutations:{evaluate:([e],t)=>(we(e,t),Yn(e)),arity:Q(1)},"count-permutations":{evaluate:([e,t],r)=>(f(e,r,{integer:!0,nonNegative:!0}),f(t,r,{integer:!0,nonNegative:!0,lte:e}),Kn(e)/Kn(e-t)),arity:Q(2)}};const Zn={"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:Q(1)},"count-power-set":{evaluate:([e],t)=>(f(e,t,{integer:!0,nonNegative:!0}),e>=53?1/0:2**e),arity:Q(1)}};function Qn(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 ea={"prime-factors":{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),Qn(e)),arity:Q(1)},"distinct-prime-factors":{evaluate:([e],t)=>{f(e,t,{finite:!0,integer:!0,positive:!0});const r=Qn(e),n=new Set(r);return Array.from(n)},arity:Q(1)},"count-prime-factors":{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),Qn(e).length),arity:Q(1)},"count-distinct-prime-factors":{evaluate:([e],t)=>{f(e,t,{finite:!0,integer:!0,positive:!0});const r=Qn(e);return new Set(r).size},arity:Q(1)}};function ta(e){return Vn(e).reduce((e,t)=>e+t,0)>e}const ra={"abundant-seq":e=>{const t=[];let r=2;for(;t.length<e;)ta(r)&&t.push(r),r+=1;return t},"abundant?":e=>ta(e),"abundant-take-while":e=>{const t=[];for(let r=2;;r+=1)if(ta(r)){if(!e(r,t.length))break;t.push(r)}return t}};const na={"arithmetic-seq":{evaluate:([e,t,r],n)=>(f(e,n,{finite:!0}),f(t,n,{finite:!0}),f(r,n,{integer:!0,positive:!0}),Array.from({length:r},(r,n)=>e+n*t)),arity:Q(3)},"arithmetic-take-while":{evaluate:([e,t,r],n,a,{executeFunction:o})=>{f(e,n,{finite:!0}),f(t,n,{finite:!0}),J(r,n);const i=[];for(let s=0;;s+=1){const c=e+s*t;if(!o(r,[c,s],a,n))break;i[s]=c}return i},arity:Q(3)},"arithmetic-nth":{evaluate:([e,t,r],n)=>(f(e,n,{finite:!0}),f(t,n,{finite:!0}),f(r,n,{integer:!0,positive:!0}),e+(r-1)*t),arity:Q(3)},"arithmetic?":{evaluate:([e,t,r],n)=>(f(r,n),f(e,n,{finite:!0}),f(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 a=Math.round(n),o=e+t*a;return fe(n,a)&&fe(o,r)}(e,t,r)),arity:Q(3)}};function aa(e){const t=[1];for(let r=1;r<e;r+=1){let e=0;for(let n=0;n<r;n+=1)e+=On(r+1,n)*t[n];t[r]=r>1&&r%2==1?0:-e/(r+1)}return t}const oa={"bernoulli-seq":{evaluate:([e],t)=>(f(e,t,{integer:!0,positive:!0}),aa(e)),arity:Q(1)},"bernoulli-nth":{evaluate:([e],t)=>{f(e,t,{integer:!0,positive:!0});return aa(e)[e-1]},arity:Q(1)},"bernoulli-take-while":{evaluate:([e],t,r,{executeFunction:n})=>{J(e,t);return function(e){const t=[1];let r=1;for(;;){const n=t.length+100;for(;r<n;r++){let n=0;for(let e=0;e<r;e++)n+=On(r+1,e)*t[e];const a=r>1&&r%2==1?0:-n/(r+1);if(!e(a,r))return t;t.push(a)}}}((t,a)=>!!n(e,[t,a],r))},arity:Q(1)}};function ia(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 sa={"prime-seq":e=>{const t=[];let r=2;for(;t.length<e;)ia(r)&&t.push(r),r+=1;return t},"prime?":e=>ia(e),"prime-take-while":e=>{const t=[];for(let r=2;;r+=1)if(ia(r)){if(!e(r,t.length))break;t.push(r)}return t}};function ca(e){return!(e<=1)&&!ia(e)}const la={"composite-seq":e=>{const t=[];let r=2;for(;t.length<e;)ca(r)&&t.push(r),r+=1;return t},"composite?":e=>ca(e),"composite-take-while":e=>{const t=[];for(let r=4;;r+=1)if(ca(r)){if(!e(r,t.length))break;t.push(r)}return t}};function ma(e){return Vn(e).reduce((e,t)=>e+t,0)<e}const ua={"deficient-seq":e=>{const t=[];let r=1;for(;t.length<e;)ma(r)&&t.push(r),r+=1;return t},"deficient?":e=>ma(e),"deficient-take-while":e=>{const t=[];for(let r=1;;r+=1)if(ma(r)){if(!e(r,t.length))break;t.push(r)}return t}};const pa={"geometric-seq":{evaluate:([e,t,r],n)=>(f(e,n,{finite:!0}),f(t,n,{finite:!0}),f(r,n,{integer:!0,positive:!0}),Array.from({length:r},(r,n)=>e*t**n)),arity:Q(3)},"geometric-take-while":{evaluate:([e,t,r],n,a,{executeFunction:o})=>{f(e,n,{finite:!0}),f(t,n,{finite:!0}),J(r,n);const i=[];for(let s=0;;s+=1){const c=e*t**s;if(!o(r,[c,s],a,n))break;i[s]=c}return i},arity:Q(3)},"geometric-nth":{evaluate:([e,t,r],n)=>(f(e,n,{finite:!0}),f(t,n,{finite:!0}),f(r,n,{integer:!0,positive:!0}),e*t**(r-1)),arity:Q(3)},"geometric?":{evaluate:([e,t,r],n)=>(f(r,n),f(e,n,{finite:!0}),f(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)),a=Math.round(n);if(!fe(a,n)||a<0)return!1;const o=a%2==0?Math.sign(e):Math.sign(e)*Math.sign(t);return Math.sign(r)===o}if(t>1&&r<e||t<1&&r>e)return!1;const n=Math.log(r/e)/Math.log(t),a=Math.round(n);return!(!fe(a,n)||a<0)&&fe(e*t**a,r)}(e,t,r)),arity:Q(3)}};const ga={"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){if(!e(1,0))return[];const t=[0,1];for(let r=2;;r++){const n=1+t[r-t[t[r-1]]];if(!e(n,r-1))break;t.push(n)}return t.slice(1)}(e)};function ha(e){let t=0;for(;e>0;){const r=e%10;t+=r*r,e=Math.floor(e/10)}return t}const da={"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=>function(e){if(e<=0)return!1;const t=new Set;for(;1!==e&&!t.has(e);)t.add(e),e=ha(e);return 1===e}(e),"happy-take-while":e=>{const t=[];for(let r=1;;r++){let n=r;const a=new Set;for(;1!==n&&!a.has(n);)a.add(n),n=String(n).split("").reduce((e,t)=>e+Number(t)**2,0);if(1===n){if(!e(r,t.length))break;t.push(r)}}return t}},ya={"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 va(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 fa={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=>{if(!e("1",0))return[];const t=["1"];for(let r=1;;r+=1){const n=t[r-1].replace(/(\d)\1*/g,e=>`${e.length}${e[0]}`);if(!e(n,r))break;t[r]=n}return t},"look-and-say?":e=>function(e){let t="1";if(t===e)return!0;for(;;){if(t=va(t),t===e)return!0;if(t.length>e.length)return!1}}(e)};function ba(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 a=1;if(!e(1,0))return[];let o=1;for(;o<r.length;){const t=r[o];if(!e(t,a))break;n.push(t),a++;const i=t,s=[];for(let e=0;e<r.length;e++)(e+1)%i!==0&&s.push(r[e]);if(r=s,o++,o>=r.length-5){let e=r[r.length-1]+2;for(;r.length<o+1e3;)r.push(e),e+=2}}return n}const xa={"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 a=1;for(;a<t.length&&a<e;){const e=t[a];let r=0;for(let n=0;n<t.length;n++)(n+1)%e!==0&&(t[r++]=t[n]);t.length=r,a<t.length&&a++}return t.slice(0,e)}(e),"lucky?":e=>ba(t=>t<=e).includes(e),"lucky-take-while":e=>ba(e)};const wa={"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],a=t[t.length-2],o=t[t.length-1];for(;o<e;){if(r=n+a,n=a,a=o,o=r,o===e)return!0;if(!Number.isSafeInteger(o))return!1}}return!1}(e),"padovan-take-while":e=>{const t=[];if(!e(1,0))return t;if(t.push(1),!e(1,1))return t;if(t.push(1),!e(1,2))return t;t.push(1);let r=1,n=1,a=1;for(let o=4;;o+=1){const i=r+n;if(r=n,n=a,a=i,!e(a,o))break;t.push(a)}return t}},qa={"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=[];for(let r=1;;r++){const n=r**3;if(!e(n,r))break;t.push(n)}return t}};function ka(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 Aa={"perfect-power-seq":e=>{const t=[];for(let r=1;t.length<e;r++)ka(r)&&t.push(r);return t},"perfect-power?":e=>null!==ka(e),"perfect-power-take-while":e=>{const t=[];for(let r=1;;r++)if(ka(r)){if(!e(r,t.length))break;t.push(r)}return t}},Na={"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=[];for(let r=1;;r++){const n=r**2;if(!e(n,r))break;t.push(n)}return t}},$a={"polygonal-seq":{evaluate:([e,t],r)=>{f(e,r,{integer:!0,gte:3}),f(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:Q(2)},"polygonal-take-while":{evaluate:([e,t],r,n,{executeFunction:a})=>{f(e,r,{integer:!0,gte:3}),J(t,r);const o=[];for(let i=1;;i+=1){if(!a(t,[(i*i*(e-2)-i*(e-4))/2,i],n,r))break;o[i-1]=(i*i*(e-2)-i*(e-4))/2}return o},arity:Q(2)},"polygonal-nth":{evaluate:([e,t],r)=>(f(e,r,{integer:!0,gte:3}),f(t,r,{integer:!0,positive:!0}),(t*t*(e-2)-t*(e-4))/2),arity:Q(2)},"polygonal?":{evaluate:([e,t],r)=>{if(f(t,r,{integer:!0}),f(e,r,{integer:!0,gte:3}),t<=0)return!1;const n=e-2,a=e-4,o=8*n*t+a*a,i=Math.sqrt(o);if(!Number.isInteger(i))return!1;const s=i+a;if(s%(2*n)!=0)return!1;const c=s/(2*n);return Number.isInteger(c)&&c>0},arity:Q(2)}};const Ta={"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=>{if(!e(0,0))return[];const t=[0],r=new Set([0]);for(let n=1;;n++){let a=t[n-1]-n;if((a<=0||r.has(a))&&(a=t[n-1]+n),!e(a,n))break;t.push(a),r.add(a)}return t},"recaman?":()=>!0},Sa={"thue-morse-seq":e=>{const t=[];for(let r=0;r<e;r+=1)t[r]=za(r)%2;return t},"thue-morse-take-while":e=>{const t=[];for(let r=0;;r+=1){const n=za(r)%2;if(!e(n,r))break;t[r]=n}return t},"thue-morse?":e=>1===e||0===e};function za(e){let t=0;for(;e;)t+=1&e,e>>=1;return t}const Ea={};function ja(e){for(const[t,r]of Object.entries(e)){if(Ea[t])throw new Error(`Duplicate normal expression key found: ${t}`);Ea[t]=r}}function Ma(e,t){return{[`${e}-seq`]:Ca(e=>t.slice(0,e),t.length),[`${e}-take-while`]:Pa(e=>{let r=0;for(r=0;!(r>=t.length)&&e(t[r],r);r+=1);return t.slice(0,r)},t.length),[`${e}-nth`]:Ia(()=>t,t.length),[`${e}?`]:Oa(e=>t.includes(e))}}function Ra(e){for(const[t,r]of Object.entries(e)){if(Ea[t])throw new Error(`Duplicate normal expression key found: ${t}`);t.endsWith("seq")?(Ea[t]=Ca(r,e.maxLength),e.noNth||(Ea[t.replace(/seq$/,"nth")]=Ia(r,e.maxLength))):t.endsWith("take-while")?Ea[t]=Pa(r,e.maxLength):t.endsWith("?")&&(e.string?Ea[t]=Fa(r):Ea[t]=Oa(r))}}function Ca(e,t){return{evaluate:(n,a)=>{const o=n[0]??t;f(o,a,{integer:!0,positive:!0,lte:t});const i=e(o,a);if("number"==typeof i[0]&&i.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",a);return i},arity:"number"==typeof t?{max:1}:Q(1)}}function Pa(e,t){return{evaluate:(t,n,a,{executeFunction:o})=>{const i=t[0];J(i,n);const s=e((e,t)=>!!o(i,[e,t],a),n);if("number"==typeof s[0]&&s.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",n);return s},arity:"number"==typeof t?{max:1}:Q(1)}}function Ia(e,t){return{evaluate:(n,a)=>{const o=n[0];f(o,a,{integer:!0,positive:!0,lte:t});const i=e(o,a);if("number"==typeof i[0]&&i.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",a);return i[o-1]},arity:Q(1)}}function Oa(e){return{evaluate:(t,r)=>{const n=t[0];return f(n,r),e(n,r)},arity:Q(1)}}function Fa(e){return{evaluate:(t,r)=>{const n=t[0];return ne(n,r),e(n,r)},arity:Q(1)}}function Ua(e,t){for(;0!==t;){const r=t;t=e%t,e=r}return Math.abs(e)}function Da(e,t){return Math.floor(e*t/Ua(e,t))}function Ga(e){if(1===e)return 1;const t=Qn(e);return new Set(t).size!==t.length?0:t.length%2==0?1:-1}function Wa(e,t){if(0===t)return[e,1,0];const[r,n,a]=Wa(t,e%t);return[r,a,n-Math.floor(e/t)*a]}function Va(e,t){const[r,n]=Wa(e,t);if(1!==r)throw new Error(`Modular inverse does not exist (gcd(${e}, ${t}) = ${r})`);return(n%t+t)%t}Ra(ra),Ra({"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}),Ra(la),Ra(ua),Ra(ga),Ra(da),Ra(ya),Ra(fa),Ra(xa),Ra(wa),Ra(Na),Ra(qa),Ra(Aa),Ra(sa),Ra(Ta),Ra(Sa),ja(Ma("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])),ja(Ma("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])),ja(Ma("factorial",Ln)),ja(Ma("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])),ja(Ma("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])),ja(Ma("mersenne",[3,7,31,127,2047,8191,131071,524287,2147483647])),ja(Ma("partition",Jn)),ja(Ma("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])),ja(Ma("perfect",[6,28,496,8128,33550336,8589869056,137438691328])),ja(Ma("sylvester",[2,6,42,1806,3263442,0x9afa8dc8416])),ja(Ma("bell",[1,2,5,15,52,203,877,4140,21147,115975,678570,4213597,27644437,190899322,1382958545,10480142147,82864869804,682076806159,5832742205057,51724158235372,474869816156751,4506715738447323])),ja(na),ja(oa),ja(pa),ja($a);const Ba={"coprime?":{evaluate:([e,t],r)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0}),1===Ua(e,t)),arity:Q(2)},"divisible-by?":{evaluate:([e,t],r)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0}),0!==t&&e%t===0),arity:Q(2)},gcd:{evaluate:([e,t],r)=>(f(e,r),f(t,r),Ua(e,t)),arity:Q(2)},lcm:{evaluate:([e,t],r)=>(f(e,r),f(t,r),Da(e,t)),arity:Q(2)},multinomial:{evaluate:([...e],t)=>{Ie(e,t);return Kn(e.reduce((e,r)=>(f(r,t,{integer:!0,nonNegative:!0}),e+r),0))/e.reduce((e,t)=>e*Kn(t),1)},arity:{min:1}},"amicable?":{evaluate:([e,t],r)=>{f(e,r,{integer:!0,positive:!0}),f(t,r,{integer:!0,positive:!0});const n=Vn(e).reduce((e,t)=>e+t,0),a=Vn(t).reduce((e,t)=>e+t,0);return n===t&&a===e&&e!==t},arity:Q(2)},"euler-totient":{evaluate:([e],t)=>{f(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:Q(1)},mobius:{evaluate:([e],t)=>{if(f(e,t,{integer:!0,positive:!0}),1===e)return 1;const r=Qn(e);return new Set(r).size!==r.length?0:r.length%2==0?1:-1},arity:Q(1)},mertens:{evaluate:([e],t)=>{if(f(e,t,{integer:!0,positive:!0}),1===e)return 1;let r=0;for(let t=1;t<=e;t++){r+=Ga(t)}return r},arity:Q(1)},sigma:{evaluate:([e],t)=>(f(e,t,{integer:!0,positive:!0}),Wn(e).reduce((e,t)=>e+t,0)),arity:Q(1)},"carmichael-lambda":{evaluate:([e],t)=>{if(f(e,t,{integer:!0,positive:!0}),1===e)return 1;const r=Qn(e),n=new Map;for(const e of r)n.set(e,(n.get(e)||0)+1);const a=[];for(const[e,t]of n.entries())2===e?1===t?a.push(1):2===t?a.push(2):a.push(2**(t-2)):a.push((e-1)*e**(t-1));return a.reduce((e,t)=>Da(e,t),1)},arity:Q(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)=>{f(e,t,{integer:!0,positive:!0});return ka(e)||null},arity:Q(1)},"mod-exp":{evaluate:([e,t,r],n)=>(f(e,n,{finite:!0}),f(t,n,{integer:!0,positive:!0}),f(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:Q(3)},"mod-inv":{evaluate:([e,t],n)=>{f(e,n,{integer:!0,positive:!0}),f(t,n,{integer:!0,positive:!0});try{return Va(e,t)}catch(e){throw new r(e,n)}},arity:Q(2)},"extended-gcd":{evaluate:([e,t],r)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0}),Wa(e,t)),arity:Q(2)},"chinese-remainder":{evaluate:([e,t],n)=>{if(Ie(e,n),Ie(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=Wa(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 a=0;a<e.length;a++){const o=e[a],i=t[a],s=r/i;n=(n+o*s*Va(s,i))%r}return n}(e,t)}catch(e){throw new r(e.message,n)}},arity:Q(2)},"stirling-first":{evaluate:([e,t],r)=>{f(e,r,{integer:!0,positive:!0}),f(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:Q(2)},"stirling-second":{evaluate:([e,t],r)=>{if(f(e,r,{integer:!0,positive:!0}),f(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:Q(2)}};function La(e){for(const[t,r]of Object.entries(e)){if(Ba[t])throw new Error(`Duplicate normal expression key found: ${t}`);Ba[t]=r}}!function(e){for(const[t,r]of Object.entries(e)){if(Ba[t])throw new Error(`Duplicate normal expression key found: ${t}`);Ba[t]=r}}(Ea),La(_n),La(Bn),La(Un),La(Xn),La(Hn),La(ea),La(Dn),La(Zn);for(const[e,t]of Object.entries(In))Ba[e]&&(Ba[e].docs=t);const Ka={name:"number-theory",functions:Ba},_a={"string-repeat":{evaluate:([e,t],r)=>(ne(e,r),f(t,r,{integer:!0,nonNegative:!0}),e.repeat(t)),arity:Q(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"); "*" string-repeat 10','let { string-repeat } = import("string"); string-repeat("*", 10)','let { string-repeat } = import("string"); string-repeat("***", 0)']}},"from-char-code":{evaluate:([e],t)=>{f(e,t,{finite:!0});const n=ue(e);try{return String.fromCodePoint(n)}catch(e){throw new r(e,t)}},arity:Q(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"); from-char-code(65)','let { from-char-code } = import("string"); from-char-code(0)']}},"to-char-code":{evaluate:([e],t)=>(ne(e,t,{nonEmpty:!0}),w(e.codePointAt(0),t)),arity:Q(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"); to-char-code("A")','let { to-char-code } = import("string"); to-char-code("Albert")']}},"trim-left":{evaluate:([e],t)=>(ne(e,t),e.replace(/^\s+/,"")),arity:Q(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"); trim-left(" Albert ")','let { trim-left } = import("string"); trim-left(" ")','let { trim-left } = import("string"); trim-left("")']}},"trim-right":{evaluate:([e],t)=>(ne(e,t),e.replace(/\s+$/,"")),arity:Q(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"); trim-right(" Albert ")','let { trim-right } = import("string"); trim-right(" ")','let { trim-right } = import("string"); trim-right("")']}},"split-lines":{evaluate:([e],t)=>(ne(e,t),e.split(/\r\n|\n|\r/).filter(e=>""!==e)),arity:Q(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"); split-lines("Albert\nMojir\n")','let { split-lines } = import("string"); split-lines("Albert\n\nMojir")','let { split-lines } = import("string"); split-lines("Albert\nMojir\n\n")','let { split-lines } = import("string"); split-lines("")']}},"pad-left":{evaluate:([e,t,r],n)=>(ne(e,n),f(t,n,{integer:!0}),void 0!==r&&ne(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"); "Albert" pad-left 20','let { pad-left } = import("string"); pad-left("Albert", 20)','let { pad-left } = import("string"); pad-left("Albert", 20, "-*-")','let { pad-left } = import("string"); pad-left("Albert", 5)','let { pad-left } = import("string"); pad-left("Albert", -1)']}},"pad-right":{evaluate:([e,t,r],n)=>(ne(e,n),f(t,n,{integer:!0}),void 0!==r&&ne(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"); "Albert" pad-right 20','let { pad-right } = import("string"); pad-right("Albert", 20)','let { pad-right } = import("string"); pad-right("Albert", 20, "-*-")','let { pad-right } = import("string"); pad-right("Albert", 5)','let { pad-right } = import("string"); pad-right("Albert", -1)']}},template:{evaluate:([e,...t],r)=>{ne(e,r),we(t,r);const n=e.split("||||");if(n.length<=1)return Ha(n[0],t,r);{const e=t[0];f(e,r,{integer:!0,nonNegative:!0});const a=[`${e}`,...t.slice(1)];if(2===n.length){return Ha(n[1===e?0:1],a,r)}return Ha(n[Math.min(e,n.length-1)],a,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"); template("Hi, $1 and $2", "Carl", "Larry")','let { template } = import("string"); template("Hi $1, $2, $3, $4, $5, $6, $7, $8 and $9", "A", "B", "C", "D", "E", "F", "G", "H", "I")','let { template } = import("string"); template("$1 book||||$1 books", 0)','let { template } = import("string"); template("$1 book||||$1 books", 1)','let { template } = import("string"); template("$1 book||||$1 books", 2)','let { template } = import("string"); template("No book||||$1 book||||$1 books", 0)','let { template } = import("string"); template("No book||||$1 book||||$1 books", 1)','let { template } = import("string"); template("No book||||$1 book||||$1 books", 10)','let { template } = import("string"); template("No book||||One book||||Two books||||Three books||||$1 books", 0)','let { template } = import("string"); template("No book||||One book||||Two books||||Three books||||$1 books", 1)','let { template } = import("string"); template("No book||||One book||||Two books||||Three books||||$1 books", 2)','let { template } = import("string"); template("No book||||One book||||Two books||||Three books||||$1 books", 3)','let { template } = import("string"); template("No book||||One book||||Two books||||Three books||||$1 books", 4)'],hideOperatorForm:!0}},"encode-base64":{evaluate:([e],t)=>(ne(e,t),btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16))))),arity:Q(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"); encode-base64("Albert")']}},"decode-base64":{evaluate:([e],t)=>{ne(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:Q(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"); decode-base64("QWxiZXJ0IPCfkLs=")']}},"encode-uri-component":{evaluate:([e],t)=>(ne(e,t),encodeURIComponent(e)),arity:Q(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"); encode-uri-component("Hi everyone!?")']}},"decode-uri-component":{evaluate:([e],t)=>{ne(e,t);try{return decodeURIComponent(e)}catch(e){throw new r(e,t)}},arity:Q(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"); decode-uri-component("Hi%20everyone!%3F%20%F0%9F%91%8D")']}},capitalize:{evaluate:([e],t)=>(ne(e,t),e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()),arity:Q(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"); capitalize("albert")','let { capitalize } = import("string"); capitalize("ALBERT")','let { capitalize } = import("string"); capitalize("aLBERT")','let { capitalize } = import("string"); capitalize("")']}}},Ja=/\$\$/g;function Ha(e,t,r){for(let n=0;n<9;n+=1){const a=new RegExp(`(\\$\\$|[^$]|^)\\$${n+1}`,"g");if(a.test(e)){const o=ie(t[n],r);e=e.replace(a,`$1${o}`)}}return e=e.replace(Ja,"$")}const Ya={name:"string",functions:_a};function Xa(e,t){if(D(e)){if("string"==typeof t&&ce(e,t))return pe(e[t])}else if(v(t,{nonNegative:!0,integer:!0})&&t>=0&&t<e.length)return pe(e[t])}function Za(e,t,r,n){if(B(e,n),Array.isArray(e)||"string"==typeof e){if(f(t,n,{integer:!0}),f(t,n,{gte:0}),f(t,n,{lte:e.length}),"string"==typeof e)return ne(r,n,{char:!0}),`${e.slice(0,t)}${r}${e.slice(t+1)}`;const a=[...e];return a[t]=r,a}ne(t,n);const a={...e};return a[t]=r,a}function Qa(e,t,r,n,a,o,i){if(D(e)){ne(t,i);const s={...e};return s[t]=o(r,[s[t],...n],a,i),s}{f(t,i);const s=ue(t);if(f(s,i,{lte:e.length}),Array.isArray(e)){const t=e.map((e,t)=>s===t?o(r,[e,...n],a,i):e);return s===e.length&&(t[s]=o(r,[void 0,...n],a,i)),t}{const t=e.split("").map((e,t)=>s===t?ae(o(r,[e,...n],a,i),i,{char:!0}):e);return s===e.length&&(t[s]=ae(o(r,[void 0,...n],a,i),i,{char:!0})),t.join("")}}}function eo(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 a;return Array.isArray(n)?(f(t,r),a=V(n[t],r)):(G(n,r),ne(t,r),ce(e.coll,t)||(n[t]={}),a=V(n[t],r)),{coll:a,parent:n}},{coll:n,parent:{}})}}const to={"get-in":{evaluate:(e,t)=>{let r=pe(e[0]);const n=e[1]??[],a=pe(e[2]);we(n,t);for(const e of n){if(se(e,t),!W(r))return a;{const t=Xa(r,e);if(void 0===t)return a;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(B(e,n),we(t,n),I(r,n),1===t.length)return se(t[0],n),Za(e,t[0],r,n);const{coll:a,innerCollMeta:o}=eo(e,t,n),i=ie(t[t.length-1],n),s=ie(t[t.length-2],n);return Array.isArray(o.parent)?(f(s,n),o.parent[s]=Za(o.coll,i,r,n)):(ne(s,n),o.parent[s]=Za(o.coll,i,r,n)),a},arity:Q(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],a,o,{executeFunction:i})=>(B(e,a),se(t,a),J(r,a),Qa(e,t,r,n,o,i,a)),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],a,o,{executeFunction:i})=>{if(B(e,a),we(t,a),J(r,a),1===t.length)return se(t[0],a),Qa(e,t[0],r,n,o,i,a);const{coll:s,innerCollMeta:c}=eo(e,t,a),l=ie(t[t.length-1],a),m=ie(t[t.length-2],a);return Array.isArray(c.parent)?(f(m,a),c.parent[m]=Qa(c.coll,l,r,n,o,i,a)):(ne(m,a),c.parent[m]=Qa(c.coll,l,r,n,o,i,a)),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:a})=>{if(B(e,r),J(t,r),Array.isArray(e)){return e.filter((e,o)=>a(t,[e,o],n,r))}return"string"==typeof e?e.split("").filter((e,o)=>a(t,[e,o],n,r)).join(""):Object.entries(e).filter(([e,o])=>a(t,[o,e],n,r)).reduce((e,[t,r])=>(e[t]=r,e),{})},arity:Q(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:a})=>(B(e,r),J(t,r),Array.isArray(e)?e.map((e,o)=>a(t,[e,o],n,r)):"string"==typeof e?e.split("").map((e,o)=>a(t,[e,o],n,r)).join(""):Object.entries(e).reduce((e,[o,i])=>(e[o]=a(t,[i,o],n,r),e),{})),arity:Q(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,a,{executeFunction:o})=>(B(e,n),J(t,n),I(r,n),"string"==typeof e?(ne(r,n),0===e.length?r:e.split("").reduce((e,r,i)=>o(t,[e,r,i],a,n),r)):Array.isArray(e)?0===e.length?r:e.reduce((e,r,i)=>o(t,[e,r,i],a,n),r):0===Object.keys(e).length?r:Object.entries(e).reduce((e,[r,i])=>o(t,[e,i,r],a,n),r)),arity:Q(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,a,{executeFunction:o})=>(B(e,n),J(t,n),I(r,n),"string"==typeof e?0===e.length?r:e.split("").reduceRight((e,r)=>o(t,[e,r],a,n),r):Array.isArray(e)?0===e.length?r:e.reduceRight((e,r)=>o(t,[e,r],a,n),r):0===Object.keys(e).length?r:Object.entries(e).reduceRight((e,[,r])=>o(t,[e,r],a,n),r)),arity:Q(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,a,{executeFunction:o})=>(B(e,n),J(t,n),I(r,n),"string"==typeof e?0===e.length?r:e.split("").reduceRight((e,r,i)=>o(t,[e,r,i],a,n),r):Array.isArray(e)?0===e.length?r:e.reduceRight((e,r,i)=>o(t,[e,r,i],a,n),r):0===Object.keys(e).length?r:Object.entries(e).reduceRight((e,[r,i])=>o(t,[e,i,r],a,n),r)),arity:Q(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,a,{executeFunction:o})=>{if(B(e,n),J(t,n),I(r,n),I(r,n),"string"==typeof e){if(ne(r,n),0===e.length)return[r];const i=[r];return e.split("").reduce((e,r)=>{const s=o(t,[e,r],a,n);return i.push(s),s},r),i}if(Array.isArray(e)){if(0===e.length)return[r];const i=[r];return e.reduce((e,r)=>{const s=o(t,[e,r],a,n);return i.push(s),s},r),i}{if(0===Object.keys(e).length)return[r];const i=[r];return Object.entries(e).reduce((e,[,r])=>{const s=o(t,[e,r],a,n);return i.push(s),s},r),i}},arity:Q(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,a,{executeFunction:o})=>{if(B(e,n),J(t,n),I(r,n),I(r,n),"string"==typeof e){if(ne(r,n),0===e.length)return[r];const i=[r];return e.split("").reduce((e,r,s)=>{const c=o(t,[e,r,s],a,n);return i.push(c),c},r),i}if(Array.isArray(e)){if(0===e.length)return[r];const i=[r];return e.reduce((e,r,s)=>{const c=o(t,[e,r,s],a,n);return i.push(c),c},r),i}{if(0===Object.keys(e).length)return[r];const i=[r];return Object.entries(e).reduce((e,[r,s])=>{const c=o(t,[e,s,r],a,n);return i.push(c),c},r),i}},arity:Q(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:(B(e,t),"string"==typeof e||Array.isArray(e)?e.length>0?e:null:Object.keys(e).length>0?e:null),arity:Q(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:a})=>(B(e,r),J(t,r),Array.isArray(e)?e.every(e=>a(t,[e],n,r)):"string"==typeof e?e.split("").every(e=>a(t,[e],n,r)):Object.entries(e).every(e=>a(t,[e],n,r))),arity:Q(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.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:a})=>(J(t,r),B(e,r),Array.isArray(e)?e.some(e=>a(t,[e],n,r)):"string"==typeof e?e.split("").some(e=>a(t,[e],n,r)):Object.entries(e).some(e=>a(t,[e],n,r))),arity:Q(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:a})=>(J(t,r),B(e,r),Array.isArray(e)?!e.some(e=>a(t,[e],n,r)):"string"==typeof e?!e.split("").some(e=>a(t,[e],n,r)):!Object.entries(e).some(e=>a(t,[e],n,r))),arity:Q(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:a})=>(J(t,r),B(e,r),Array.isArray(e)?!e.every(e=>a(t,[e],n,r)):"string"==typeof e?!e.split("").every(e=>a(t,[e],n,r)):!Object.entries(e).every(e=>a(t,[e],n,r))),arity:Q(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)']}}},ro={name:"collection",functions:to},no={position:{evaluate:([e,t],r,n,{executeFunction:a})=>{if(J(t,r),null===e)return null;if(U(e,r),"string"==typeof e){const o=e.split("").findIndex(e=>a(t,[e],n,r));return-1!==o?o:null}{const o=e.findIndex(e=>a(t,[e],n,r));return-1!==o?o:null}},arity:Q(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(I(t,r),null===e)return null;if(U(e,r),"string"==typeof e){ne(t,r);const n=e.lastIndexOf(t);return-1!==n?n:null}{const n=e.findLastIndex(e=>me(P(e,r),t),r);return-1!==n?n:null}},arity:Q(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)']}},shift:{evaluate:([e],t)=>{if(U(e,t),"string"==typeof e)return e.substring(1);const r=[...e];return r.shift(),r},arity:Q(1),docs:{category:"sequence",returns:{type:["sequence","null"]},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"Returns a copy of $seq with first element removed. If $seq is empty `null` is returned.",seeAlso:["sequence.unshift","pop","rest"],examples:['let su = import("sequence"); su.shift([1, 2, 3])','let su = import("sequence"); su.shift([])']}},splice:{evaluate:(e,t)=>{const[r,n,a,...o]=e;U(r,t),f(n,t,{integer:!0}),f(a,t,{integer:!0,nonNegative:!0});const i=n<0?r.length+n:n;return Array.isArray(r)?[...r.slice(0,i),...o,...r.slice(i+a)]:(o.forEach(e=>ne(e,t)),`${r.substring(0,i)}${o.join("")}${r.substring(i+a)}`)},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[a,o]=e,i=2===e.length;U(a,t),J(o,t);const s=i?null:e[2];if("string"==typeof a){const e=a.split("");return i?e.sort((e,a)=>{const i=n(o,[e],r,t);se(i,t);const s=n(o,[a],r,t);return se(s,t),le(i,s,t)}):(J(s,t),e.sort((e,a)=>{const i=n(o,[e],r,t),c=n(o,[a],r,t),l=n(s,[i,c],r,t);return f(l,t,{finite:!0}),l})),e.join("")}const c=[...a];return i?c.sort((e,a)=>{const i=n(o,[e],r,t);se(i,t);const s=n(o,[a],r,t);return se(s,t),le(i,s,t)}):(J(s,t),c.sort((e,a)=>{const i=n(o,[e],r,t),c=n(o,[a],r,t),l=n(s,[i,c],r,t);return f(l,t,{finite:!0}),l})),c},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)']}},take:{evaluate:([e,t],r)=>{f(t,r),U(e,r);const n=Math.max(Math.ceil(t),0);return e.slice(0,n)},arity:Q(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:["sequence.take-last","sequence.take-while","sequence.drop","slice","sequence.split-at"],examples:['let su = import("sequence"); su.take([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.take([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.take([1, 2, 3, 4, 5], 0)','let su = import("sequence"); su.take("Albert", 2)','let su = import("sequence"); su.take("Albert", 50)']}},"take-last":{evaluate:([e,t],r)=>{U(e,r),f(t,r);const n=Math.max(Math.ceil(t),0),a=e.length-n;return e.slice(a)},arity:Q(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},n:{type:"integer"},seq:{type:"sequence"}},variants:[{argumentNames:["n","seq"]}],description:"Constructs a new array with the $n last elements from $seq.",seeAlso:["sequence.take","sequence.drop-last"],examples:['let su = import("sequence"); su.take-last([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.take-last([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.take-last([1, 2, 3, 4, 5], 0)']}},"take-while":{evaluate:([e,t],r,n,{executeFunction:a})=>{U(e,r),J(t,r);const o=[];for(const i of e){if(!a(t,[i],n,r))break;o.push(i)}return"string"==typeof e?o.join(""):o},arity:Q(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:["sequence.take","sequence.drop-while","sequence.split-with"],examples:['\nlet su = import("sequence");\nsu.take-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)','\nlet su = import("sequence");\nsu.take-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)']}},drop:{evaluate:([e,t],r)=>{f(t,r);const n=Math.max(Math.ceil(t),0);return U(e,r),e.slice(n)},arity:Q(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:["sequence.drop-last","sequence.drop-while","sequence.take","slice","sequence.split-at"],examples:['let su = import("sequence"); su.drop([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.drop([1, 2, 3, 4, 5], 0)','let su = import("sequence"); su.drop("Albert", 2)','let su = import("sequence"); su.drop("Albert", 50)']}},"drop-last":{evaluate:([e,t],r)=>{U(e,r),f(t,r);const n=Math.max(Math.ceil(t),0),a=e.length-n;return e.slice(0,a)},arity:Q(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:["sequence.drop","sequence.take-last"],examples:['let su = import("sequence"); su.drop-last([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.drop-last([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.drop-last([1, 2, 3, 4, 5], 0)']}},"drop-while":{evaluate:([e,t],r,n,{executeFunction:a})=>{if(U(e,r),J(t,r),Array.isArray(e)){const o=e.findIndex(e=>!a(t,[e],n,r));return e.slice(o)}const o=e.split(""),i=o.findIndex(e=>!a(t,[e],n,r));return o.slice(i).join("")},arity:Q(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:["sequence.drop","sequence.take-while","sequence.split-with"],examples:['\nlet su = import("sequence");\nsu.drop-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)','\nlet su = import("sequence");\nsu.drop-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)']}},unshift:{evaluate:([e,...t],r)=>{if(U(e,r),"string"==typeof e)return ke(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","sequence.shift","++"],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(U(e,t),Array.isArray(e)){const r=[];for(const n of e)I(n,t),r.some(e=>me(e,n,t))||r.push(n);return r}return Array.from(new Set(e.split(""))).join("")},arity:Q(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:a})=>(J(t,r),U(e,r),Array.isArray(e)?e.filter(e=>!a(t,[e],n,r)):e.split("").filter(e=>!a(t,[e],n,r)).join("")),arity:Q(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)=>{f(t,r,{integer:!0}),U(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:Q(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)=>{f(t,r,{integer:!0}),U(e,r);const n=t<0?e.length+t:t;return[e.slice(0,n),e.slice(n)]},arity:Q(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","sequence.take","sequence.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:a})=>{J(t,r),U(e,r);const o=Array.isArray(e),i=(o?e:e.split("")).findIndex(e=>!a(t,[e],n,r));return-1===i?[e,o?[]:""]:[e.slice(0,i),e.slice(i)]},arity:Q(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","sequence.take-while","sequence.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)=>{U(e,t);return("string"==typeof e?e.split(""):e).reduce((e,r)=>(ne(r,t),ce(e,r)?e[r]=e[r]+1:e[r]=1,e),{})},arity:Q(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:a})=>{J(t,r),U(e,r);return(Array.isArray(e)?e:e.split("")).reduce((e,o)=>{const i=a(t,[o],n,r);return ne(i,r),ce(e,i)||(e[i]=[]),e[i].push(o),e},{})},arity:Q(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=F(e[0],t),n=ue(b(e[1],t)),a=e.length>=3?ue(b(e[2],t)):n,o=4===e.length?null===e[3]?[]:function(e,t){return we(e,t),e}(e[3],t):void 0;return ao(n,a,r,o,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=F(e[0],t),n=ue(b(e[1],t));return ao(n,3===e.length?ue(b(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:a})=>{J(t,r),U(e,r);const o="string"==typeof e;let i;const s=(o?e.split(""):e).reduce((e,o)=>{const s=a(t,[o],n,r);return s!==i&&(e.push([]),i=s),e[e.length-1].push(o),e},[]);return o?s.map(e=>e.join("")):s},arity:Q(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)=>(U(e,r),"string"==typeof e?(ne(t,r),e.endsWith(t)):me(P(e.at(-1),r),P(t,r),r)),arity:Q(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)=>(U(e,r),"string"==typeof e?(ne(t,r),e.startsWith(t)):me(P(e[0],r),P(t,r),r)),arity:Q(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=>(ne(e,t),e.split(""))):e.map(e=>(we(e,t),e)),a=Math.min(...n.map(e=>e.length)),o=[];for(let e=0;e<a;e+=1)for(const t of n)e<t.length&&o.push(t[e]);return r?o.join(""):o},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(U(e,r),"string"==typeof e)return ne(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:Q(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 ao(e,t,r,n,a){f(t,a,{positive:!0});const o="string"==typeof r,i=[];let s=0;e:for(;s<r.length;){const a=[];for(let o=s;o<s+e;o+=1)if(o>=r.length){const e=o-r.length;if(!n){s+=t;continue e}if(e>=n.length)break;a.push(n[e])}else a.push(r[o]);i.push(a),s+=t}return o?i.map(e=>e.join("")):i}const oo={name:"sequence",functions:no};function io(e){return([t],n)=>{const[a,o]=function(e,t){if(Pe(e))return["vector",e];if(We(e))return["matrix",e];if(!v(e))throw new r("Invalid parameter type: "+typeof e,t);return["number",e]}(t,n);return"number"===a?e(o):"vector"===a?o.map(t=>e(t)):o.map(t=>t.map(t=>e(t)))}}const so={name:"math",functions:{sin:{evaluate:io(e=>Math.sin(e)),arity:Q(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"); sin(0)','let { sin } = import("math"); sin(1)','let { sin } = import("math"); sin(PI)','let { sin } = import("math"); sin(-0.5)','let { sin } = import("math"); sin([1, 2, 3])','let { sin } = import("math"); sin([[1, 2], [3, 4]])']}},asin:{evaluate:io(e=>Math.asin(e)),arity:Q(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"); asin(0)','let { asin } = import("math"); asin(1)','let { asin } = import("math"); asin(-0.5)','let { asin } = import("math"); asin([1, 2, 3])','let { asin } = import("math"); asin([[1, 2], [3, 4]])']}},sinh:{evaluate:io(e=>Math.sinh(e)),arity:Q(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"); sinh(0)','let { sinh } = import("math"); sinh(1)','let { sinh } = import("math"); sinh(-0.5)','let { sinh } = import("math"); sinh([0.1, 0.2, 0.3])','let { sinh } = import("math"); sinh([[0.1, 0.2], [0.3, 0.4]])']}},asinh:{evaluate:io(e=>Math.asinh(e)),arity:Q(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"); asinh(10)','let { asinh } = import("math"); asinh(90)','let { asinh } = import("math"); asinh(50)','let { asinh } = import("math"); asinh([10, 20, 30])','let { asinh } = import("math"); asinh([[10, 20], [30, 40]])']}},cos:{evaluate:io(e=>Math.cos(e)),arity:Q(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"); cos(0)','let { cos } = import("math"); cos(1)','let { cos } = import("math"); cos(PI)','let { cos } = import("math"); cos(-0.5)','let { cos } = import("math"); cos([1, 2, 3])','let { cos } = import("math"); cos([[1, 2], [3, 4]])']}},acos:{evaluate:io(e=>Math.acos(e)),arity:Q(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"); acos(0)','let { acos } = import("math"); acos(1)','let { acos } = import("math"); acos(-0.5)','let { acos } = import("math"); acos([0.1, 0.2, 0.3])','let { acos } = import("math"); acos([[0.1, 0.2], [0.3, 0.4]])']}},cosh:{evaluate:io(e=>Math.cosh(e)),arity:Q(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"); cosh(0)','let { cosh } = import("math"); cosh(1)','let { cosh } = import("math"); cosh(-0.5)','let { cosh } = import("math"); cosh([0.1, 0.2, 0.3])','let { cosh } = import("math"); cosh([[0.1, 0.2], [0.3, 0.4]])']}},acosh:{evaluate:io(e=>Math.acosh(e)),arity:Q(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"); acosh(1)','let { acosh } = import("math"); acosh(2)','let { acosh } = import("math"); acosh(100)','let { acosh } = import("math"); acosh(50)','let { acosh } = import("math"); acosh([1, 2, 3])','let { acosh } = import("math"); acosh([[1, 2], [3, 4]])']}},tan:{evaluate:io(e=>Math.tan(e)),arity:Q(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"); tan(0)','let { tan } = import("math"); tan(1)','let { tan } = import("math"); tan(PI)','let { tan } = import("math"); tan(-0.5)','let { tan } = import("math"); tan([1, 2, 3])','let { tan } = import("math"); tan([[1, 2], [3, 4]])']}},atan:{evaluate:io(e=>Math.atan(e)),arity:Q(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"); atan(0)','let { atan } = import("math"); atan(1)','let { atan } = import("math"); atan(-0.5)','let { atan } = import("math"); atan([0.1, 0.2, 0.3])','let { atan } = import("math"); atan([[0.1, 0.2], [0.3, 0.4]])']}},tanh:{evaluate:io(e=>Math.tanh(e)),arity:Q(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"); tanh(0)','let { tanh } = import("math"); tanh(1)','let { tanh } = import("math"); tanh(-0.5)','let { tanh } = import("math"); tanh(50)']}},atanh:{evaluate:io(e=>Math.atanh(e)),arity:Q(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"); atanh(0)','let { atanh } = import("math"); atanh(0.9)','let { atanh } = import("math"); atanh(-0.5)','let { atanh } = import("math"); atanh([0.1, 0.2, 0.3])','let { atanh } = import("math"); atanh([[0.1, 0.2], [0.3, 0.4]])']}},ln:{evaluate:io(e=>Math.log(e)),arity:Q(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"); ln(0.01)','let { ln } = import("math"); ln(2.5)','let { ln } = import("math"); ln(E)','let { ln } = import("math"); ln([1, 2, 3])','let { ln } = import("math"); ln([[1, 2], [3, 4]])']}},log2:{evaluate:io(e=>Math.log2(e)),arity:Q(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"); log2(0.01)','let { log2 } = import("math"); log2(2 ^ 12)','let { log2 } = import("math"); log2(2.5)','let { log2 } = import("math"); log2([1, 2, 3])','let { log2 } = import("math"); log2([[1, 2], [3, 4]])']}},log10:{evaluate:io(e=>Math.log10(e)),arity:Q(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"); log10(0.01)','let { log10 } = import("math"); log10(10 ^ 12)','let { log10 } = import("math"); log10(2.5)','let { log10 } = import("math"); log10([1, 2, 3])','let { log10 } = import("math"); log10([[1, 2], [3, 4]])']}},"to-rad":{evaluate:io(e=>e*Math.PI/180),arity:Q(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"); to-rad(0)','let { to-rad } = import("math"); to-rad(90)','let { to-rad } = import("math"); to-rad(180)','let { to-rad } = import("math"); to-rad(360)','let { to-rad } = import("math"); to-rad([0, 90, 180])','let { to-rad } = import("math"); to-rad([[0, 90], [180, 360]])']}},"to-deg":{evaluate:io(e=>180*e/Math.PI),arity:Q(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"); to-deg(0)','let { to-deg } = import("math"); to-deg(PI)','let { to-deg } = import("math"); to-deg(PI / 2)','let { to-deg } = import("math"); to-deg(3 * PI / 2)','let { to-deg } = import("math"); to-deg([0, PI, PI / 2])','let { to-deg } = import("math"); to-deg([[0, PI], [PI / 2, 3 * PI / 2]])']}}}},co={name:"functional",functions:{juxt:{evaluate:(e,t)=>{e.forEach(e=>J(e,t));const n=function(e){return e.reduce((e,t)=>{if(null===e)return null;const r="number"==typeof t||W(t)?Q(1):t.arity,{min:n,max:a}=r,{min:o,max:i}=e,s="number"==typeof n&&"number"==typeof o?Math.max(n,o):"number"==typeof n?n:"number"==typeof o?o:void 0,c="number"==typeof a&&"number"==typeof i?Math.min(a,i):"number"==typeof a?a:"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=_(e,t);return{[u]:!0,sourceCodeInfo:t,functionType:"Complement",function:r,arity:Y(r)}},arity:Q(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=_(e,r);return{[u]:!0,sourceCodeInfo:r,functionType:"Fnull",function:n,params:t,arity:Y(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 lo(e,t){return{a:{type:e},b:{type:t}}}const mo={name:"bitwise",functions:{"bit-not":{evaluate:([e],t)=>(f(e,t,{integer:!0}),~e),arity:Q(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)=>(f(e,r,{integer:!0}),t.reduce((e,t)=>(f(t,r,{integer:!0}),e&~t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...lo("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)=>{f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0});return e^1<<t},arity:Q(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...lo("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)=>{f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0});return e|1<<t},arity:Q(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...lo("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)=>{f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0});return e&~(1<<t)},arity:Q(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...lo("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)=>{f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0});return!!(e&1<<t)},arity:Q(2),docs:{category:"bitwise",returns:{type:"boolean"},args:{...lo("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)']}}}},uo={"-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']}},po={"-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","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 go(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 ho(e,t){const r={};for(const[n,a]of Object.entries(t)){const t=a.docs;if(!t)throw new Error(`Missing docs for ${e}.${n}`);const o=`${e}.${n}`;r[o]={title:o,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 yo=go(te),vo=go(Ne),fo=go(Ae),bo=go(nt),xo=go(He),wo=go(it({})),qo=go(Xe),ko=go(Ze),Ao=go(Qe),No=go(et),$o=go($e),To=go(rt),So=go(st);const zo=function(){const e={};for(const[t,r]of Object.entries(rr)){const n=nr[r],a=n?.docs;a&&(vr(a)?e[t]={title:t,category:a.category,description:a.description,returns:a.returns,args:a.args,variants:a.variants,examples:a.examples,...a.seeAlso?{seeAlso:a.seeAlso}:{},...a.hideOperatorForm?{noOperatorDocumentation:!0}:{}}:e[t]={title:t,category:a.category,description:a.description,customVariants:a.customVariants,...a.details?{details:a.details}:{},...a.returns?{returns:a.returns}:{},examples:a.examples,...a.seeAlso?{seeAlso:a.seeAlso}:{}})}return e}();function Eo(e){return"returns"in e&&"args"in e&&"variants"in e}function jo(e){return"customVariants"in e}function Mo(e){return"shorthand"in e}function Ro(e){return"datatype"in e}const Co={...yo,...fo,...vo,...$o,...xo,...bo,...wo,...qo,...ko,...Ao,...No,...To,...So},Po={...ho(xr.name,xr.functions),...ho(Ar.name,Ar.functions),...ho(zr.name,zr.functions),...ho(gn.name,gn.functions),...ho($n.name,$n.functions),...ho(Pn.name,Pn.functions),...ho(Ka.name,Ka.functions),...ho(Ya.name,Ya.functions),...ho(ro.name,ro.functions),...ho(oo.name,oo.functions),...ho(so.name,so.functions),...ho(co.name,co.functions),...ho(mo.name,mo.functions)};Object.entries(Co).forEach(([e,t])=>{if(!mt[e])throw new Error(`Missing normal expression ${e} in normalExpressions`);const r=mt[e].arity;!t.noOperatorDocumentation&&Z(r)&&(t._isOperator=!0,hr(e)&&(t._prefereOperator=!0))}),Object.entries(zo).forEach(([e,t])=>{if(Eo(t)){const r=nr[rr[e]]?.arity;r&&Z(r)&&(t._isOperator=!0)}});const Io=Fo({...{...Co,...zo},...po,...uo}),Oo=Fo({...Io,...Po});function Fo(e){return Object.fromEntries(Object.entries(e).sort(([e,t],[r,n])=>{const a="special-expression"===t.category?"":t.category,o="special-expression"===n.category?"":n.category;return a!==o?a.localeCompare(o):e.localeCompare(r)}))}var Uo;Object.values(Oo).forEach(e=>{e.title=e.title.replace(/"/g,"&quot;")}),Uo=Co,Object.assign(ct,Uo);const Do=(e,t,r,n)=>{const a=Array.isArray(e)?e:[[s.SpecialExpression,[rr.block,e.body]]],o=new Set;for(const e of a)Go(e,t,r,n)?.forEach(e=>o.add(e));return o};function Go(e,t,n,a){const o=e[0];switch(o){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,o=new Set;if(wt(r)){const[,[e]]=r;if(vt(e)){null===t.lookUp(e)&&o.add(e[1])}}else{const[,[e]]=r;Go(e,t,n,a)?.forEach(e=>o.add(e))}for(const e of r[1][1])Go(e,t,n,a)?.forEach(e=>o.add(e));return o}case s.SpecialExpression:{const r=e,o=r[1][0];return(0,n.specialExpressions[o].getUndefinedSymbols)(r,t,{getUndefinedSymbols:Do,builtin:n,evaluateNode:a})}case s.Spread:return Go(e[1],t,n,a);default:throw new r(`Unhandled node type: ${o}`,e[2])}}const Wo=(1+Math.sqrt(5))/2,Vo={E:Math.E,"-E":-Math.E,"ε":Math.E,"-ε":-Math.E,PI:Math.PI,"-PI":-Math.PI,"π":Math.PI,"-π":-Math.PI,PHI:Wo,"-PHI":-Wo,"φ":Wo,"-φ":-Wo,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},Bo={true:!0,false:!1,null:null,do:null,else:null,case:null,each:null,in:null,when:null,while:null,catch:null,function:null,export:null,as:null,then:null,end:null,_:null,...Vo};const Lo={NativeJsFunction:(e,t,n)=>{try{return pe(e.nativeFn.fn(...t))}catch(e){const t="string"==typeof e?e:k(e)&&"string"==typeof e.message?e.message:"<no message>";throw new r(`Native function threw: "${t}"`,n)}},UserDefined:(e,n,a,o,{evaluateNode:i})=>{for(;;){if(!H(e.arity,n.length))throw new r(`Expected ${e.arity} arguments, got ${n.length}.`,a);const s=e.evaluatedfunction,c=s[0],l=c.filter(e=>e[0]!==$t).length,m=o.create(e.evaluatedfunction[2]),u={self:{value:e}},p=[];for(let e=0;e<n.length;e+=1)if(e<l){const t=pe(n[e]),r=Et(c[e],t,e=>i(e,m.create(u)));Object.entries(r).forEach(([e,t])=>{u[e]={value:t}})}else p.push(pe(n[e]));for(let e=n.length;e<l;e++){const t=c[e],r=Et(t,i(t[1][1],o.create(u)),e=>i(e,o.create(u)));Object.entries(r).forEach(([e,t])=>{u[e]={value:t}})}const g=c.find(e=>e[0]===$t);if(void 0!==g){const e=Et(g,p,e=>i(e,o.create(u)));Object.entries(e).forEach(([e,t])=>{u[e]={value:t}})}try{let e=null;const t=m.create(u);for(const r of s[1])e=i(r,t);return e}catch(e){if(e instanceof t){n=e.params;continue}throw e}}},Partial:(e,t,n,a,{executeFunction:o})=>{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 o(e.function,i,a,n)},Comp:(e,t,n,a,{executeFunction:o})=>{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 P(t[0],n)}return P(i.reduceRight((e,t)=>[o(_(t,n),e,a,n)],t)[0],n)},Constantly:e=>e.value,Juxt:(e,t,r,n,{executeFunction:a})=>e.params.map(e=>a(_(e,r),t,n,r)),Complement:(e,t,r,n,{executeFunction:a})=>!a(e.function,t,n,r),EveryPred:(e,t,r,n,{executeFunction:a})=>{for(const o of e.params)for(const e of t){if(!a(_(o,r),[e],n,r))return!1}return!0},SomePred:(e,t,r,n,{executeFunction:a})=>{for(const o of e.params)for(const e of t){if(a(_(o,r),[e],n,r))return!0}return!1},Fnull:(e,t,r,n,{executeFunction:a})=>{const o=t.map((t,r)=>null===t?pe(e.params[r]):t);return a(_(e.function,r),o,n,r)},Builtin:(e,t,r,n,{executeFunction:a})=>w(pt[e.normalBuiltinSymbolType],r).evaluate(t,r,n,{executeFunction:a}),SpecialBuiltin:(e,t,n,a,{executeFunction:o})=>{const i=w(nr[e.specialBuiltinSymbolType],n);if(i.evaluateAsNormalExpression)return i.evaluateAsNormalExpression(t,n,a,{executeFunction:o});throw new r(`Special builtin function ${e.specialBuiltinSymbolType} is not supported as normal expression.`,n)},Module:(e,t,n,a,{executeFunction:o})=>{const i=a.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);return X(s.arity,t.length,n),s.evaluate(t,n,a,{executeFunction:o})}};function Ko(e,t){let r=null;for(const n of e.body)r=_o(n,t);return r}function _o(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 w(Bo[t],e[2])}(e);case s.NormalExpression:{const n=function(e,t){const n=e[2],a=e[1][1],i=[],c=[];if(a.forEach((e,n)=>{if(qt(e)){const n=_o(e[1],t);if(!Array.isArray(n))throw new r(`Spread operator requires an array, got ${d(e)}`,e[2]);i.push(...n)}else e[0]===s.ReservedSymbol&&"_"===e[1]?c.push(n):i.push(_o(e,t))}),wt(e)){const r=e[1][0];if(c.length>0){const e=_o(r,t);return{[u]:!0,function:_(e,n),functionType:"Partial",params:i,placeholders:c,sourceCodeInfo:n,arity:Q(c.length)}}if(bt(r)){const n=r[1];return ar.allNormalExpressions[n].evaluate(i,e[2],t,{executeFunction:Jo})}{const a=t.getValue(r[1]);if(void 0!==a)return Jo(_(a,n),i,t,n);throw new o(r[1],e[2])}}{const r=_(_o(e[1][0],t),n);if(c.length>0){return{[u]:!0,function:r,functionType:"Partial",params:i,placeholders:c,sourceCodeInfo:n,arity:Q(c.length)}}return Jo(r,i,t,n)}}(e,t);if("number"==typeof n&&Number.isNaN(n))throw new r("Number is NaN",e[2]);return Ce(n)}case s.SpecialExpression:return Ce(function(e,t){const r=e[1][0],n=w(ar.specialExpressions[r],e[2]);return(0,n.evaluate)(e,t,{evaluateNode:_o,builtin:ar,getUndefinedSymbols:Do})}(e,t));default:throw new r(`${l(e[0])}-node cannot be evaluated`,e[2])}}function Jo(e,t,n,a){if(A(e))return Lo[e.functionType](e,t,a,n,{evaluateNode:_o,executeFunction:Jo});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 a=t[0];return f(a,n,{integer:!0,nonNegative:!0}),pe(e[a])}(e,t,a);if(D(e))return function(e,t,n){if(1!==t.length)throw new r("Object as function requires one string parameter.",n);const a=t[0];return ne(a,n),pe(e[a])}(e,t,a);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 a=pe(t[0]);if(D(a))return pe(a[e]);if(v(a,{integer:!0}))return pe(e[a]);throw new r(`string as function expects Obj or integer parameter, got ${d(a)}`,n)}(e,t,a);if(v(e))return function(e,t,n){if(f(e,n,{integer:!0}),1!==t.length)throw new r("Number as function requires one Arr parameter.",n);const a=t[0];return U(a,n),pe(a[e])}(e,t,a);throw new r("Unexpected function type",a)}class Ho{contexts;globalContext;values;nativeJsFunctions;modules;constructor({contexts:e,values:t,nativeJsFunctions:r,modules:n}){this.globalContext=w(e[0]),this.contexts=e,this.values=t,this.nativeJsFunctions=r,this.modules=n??new Map}getModule(e){return this.modules.get(e)}create(e){const t=this.globalContext,r=new Ho({contexts:[e,...this.contexts],values:this.values,nativeJsFunctions:this.nativeJsFunctions,modules:this.modules});return r.globalContext=t,r}new(e){return new Ho({contexts:[{},e],modules:this.modules})}exportValues(e,t){for(const[n,a]of Object.entries(e)){if(this.globalContext[n])throw new r(`Cannot redefine exported value "${n}"`,t);const e=Yo(n);if(e)throw new r(`Cannot shadow ${e}`,t);this.globalContext[n]={value:a}}this.contexts[0]!==this.globalContext&&this.addValues(e,t)}addValues(e,t){const n=this.contexts[0];for(const[a,o]of Object.entries(e)){if(n[a])throw new r(`Cannot redefine value "${a}"`,t);const e=Yo(a);if(e)throw new r(`Cannot shadow ${e}`,t);n[a]={value:pe(o)}}}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(xt(e)){const t=e[1];switch(t){case rr["&&"]:case rr["||"]:case rr.array:case rr.object:case rr["defined?"]:case rr.recur:case rr.throw:case rr["??"]:{const r=w(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(bt(e)){const t=e[1],r=pt[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(k(n=t)&&void 0!==n.value)return t.value;var n;throw new o(e[1],e[2])}}function Yo(e){return ir.includes(e)?`special expression "${e}"`:or.includes(e)?`builtin function "${e}"`:"self"===e?`builtin value "${e}"`:null}function Xo(e={},t){const n=e.globalContext??{},a=e.contexts?[n,...e.contexts]:[n],o=new Ho({contexts:a,values:e.values,modules:t,nativeJsFunctions:e.jsFunctions&&Object.entries(e.jsFunctions).reduce((e,[t,n])=>{const a=t.split("."),o=a.pop();if(/^[A-Z]/.test(o))throw new r(`Invalid identifier "${t}" in jsFunctions, function name must not start with an uppercase letter`,void 0);let i=e;for(const e of a){if(0===e.length)throw new r(`Invalid empty identifier "${t}" in jsFunctions`,void 0);if(!/^[A-Z]/.test(e))throw new r(`Invalid identifier "${t}" in jsFunctions, module name must start with an uppercase letter`,void 0);i[e]||(i[e]={}),i=i[e]}!function(e){if(!function(e){return"object"==typeof e&&null!==e&&"fn"in e&&"function"==typeof e.fn}(e))throw new TypeError("Expected a NativeJsFunction")}(n);const s={functionType:"NativeJsFunction",nativeFn:n,name:o,[u]:!0,arity:n.arity??{},docString:n.docString??""};return i===e&&function(e){const t=Yo(e);if(t)throw new r(`Cannot shadow ${t}`,void 0)}(o),i[o]=s,e},{})});return e.globalModuleScope?o:o.create({})}const Zo=["(",")","[","]","{","}","'",'"',"`",",",".",";"," ","\n","\r","\t"],Qo=["0","1","2","3","4","5","6","7","8","9",...Zo],ei=new Set(Zo),ti=new Set(Qo),ri=/\s/,ni=[0],ai=(e,t)=>{if('"'!==e[t])return ni;let r='"',n=1,a=e[t+n],o=!1;for(;a&&('"'!==a||o);)n+=1,o?(o=!1,r+=a):("\\"===a&&(o=!0),r+=a),a=e[t+n];return a?(r+='"',[n+1,["string",r]]):[n,["Error",r,void 0,`Unclosed string at position ${t}`]]};function oi(e,t,r,n){return t===r.slice(n,n+t.length)?[t.length,[e,t]]:ni}const ii=/\d/,si=/[0-7]/,ci=/[0-9a-f]/i,li=/[01]/,mi=/[\s)\]}(,;]/,ui=(e,t)=>{let r=e[t];if("'"===r){let n=1,a=e[t+n],o=!1;for(;"'"!==a||o;){if(void 0===a)return[n,["Error",r,void 0,`Unclosed quoted symbol at position ${t}`]];n+=1,o?(o=!1,r+=a):("\\"===a&&(o=!0),r+=a),a=e[t+n]}return r+="'",[n+1,["Symbol",r]]}if(!ti.has(r)){const n=t;let a=e[t+=1];for(;a&&!ei.has(a);)r+=a,a=e[t+=1];return r.endsWith(":")?[t-n-1,["Symbol",r.slice(0,-1)]]:[t-n,["Symbol",r]]}return ni},pi=[(e,t)=>{let r=e[t];if(!r||!ri.test(r))return ni;let n=r;for(r=e[t+=1];r&&ri.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 ni},(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 ni},(e,t)=>{const r=ui(e,t);if(0===r[0]||!r[1])return ni;let n=r[1][1];n=n.startsWith("'")?n.slice(1,n.length-1):n;return void 0===Bo[n]?ni:[r[0],["ReservedSymbol",n]]},(e,t)=>oi("LParen","(",e,t),(e,t)=>oi("RParen",")",e,t),(e,t)=>oi("LBracket","[",e,t),(e,t)=>oi("RBracket","]",e,t),(e,t)=>oi("LBrace","{",e,t),(e,t)=>oi("RBrace","}",e,t),(e,t)=>{if('"'!==e[t]||'"'!==e[t+1]||'"'!==e[t+2])return ni;let r='"""',n=3,a=e[t+n],o=e.slice(t+n,t+n+3),i=!1;for(;a&&('"""'!==o||i);)n+=1,i?(i=!1,r+=a):("\\"===a&&(i=!0),r+=a),a=e[t+n],o=e.slice(t+n,t+n+3);return a?(r+='"""',[n+3,["DocString",r]]):[n,["Error",r,void 0,`Unclosed doc string at position ${t}`]]},ai,(e,t)=>{if("#"!==e[t])return ni;const[r,n]=ai(e,t+1);if(!n)return ni;if("Error"===n[0]){return[r+1,["Error",`#${n[1]}`,void 0,`Unclosed regexp at position ${t}`]]}t+=r+1;let a=r+1,o="";for(;"g"===e[t]||"i"===e[t];)if(o+=e[t],a+=1,t+=1,o.includes(e[t]))return[a,["Error",`#${n[1]}${o}`,void 0,`Duplicated regexp option "${e[t]}"`]];return[a,["RegexpShorthand",`#${n[1]}${o}`]]},(e,t)=>{if("0"!==e[t])return ni;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 ni;let a;for(a=t+2;a<e.length;a+=1){const t=e[a];if("binary"===n&&!li.test(t))break;if("octal"===n&&!si.test(t))break;if("hex"===n&&!ci.test(t))break}const o=a-t;if(o<=2)return ni;const i=e[a];return i&&!mi.test(i)?ni:[o,["BasePrefixedNumber",e.substring(t,a)]]},(e,t)=>{let r;const n="-"===e[t],a="+"===e[t],o=n||a?t+1:t;let i=!1,s=!1;for(r=o;r<e.length;r+=1){const n=e[r];if("_"===n){if(!ii.test(e[r-1])||!ii.test(e[r+1]))return r===o?ni:[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]]}else if("."===n){if(r===o)return ni;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===o)return ni;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||a)&&r===o)return ni;const c=r-t;if(0===c)return ni;const l=e[r];return l&&":"!==l&&!mi.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&&hr(r))return[3,["Operator",r]];const n=e.slice(t,t+2);if(t+1<e.length&&hr(n))return[2,["Operator",n]];const a=e[t]??"";return hr(a)?[1,["Operator",a]]:ni},ui];function gi(e,t,r){const n=e.substring(0,t+1).split(/\r\n|\r|\n/),a=n[n.length-1],o=function(e,t){return e.split(/\r\n|\r|\n/)[t]}(e,n.length-1);return{code:o,position:{line:n.length,column:a.length},filePath:r}}function hi(e,t){const r=t;if(0===t){const[n,a]=((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 ni})(e,t);if(t+=n,n>0)return[t-r,a]}for(const n of pi){const[a,o]=n(e,t);if(t+=a,0!==a)return[t-r,o]}return[1,["Error",e[r],void 0,"Unrecognized character"]]}function di(e,t){return"Symbol"===e?.[0]&&(!t||e[1]===t)}function yi(e,t){return function(e,t){di(e,t)||Pi("Symbol",void 0,e)}(e,t),e}function vi(e,t){return"ReservedSymbol"===e?.[0]&&(!t||e[1]===t)}function fi(e,t){vi(e,t)||Pi("ReservedSymbol",t,e)}function bi(e,t){return fi(e,t),e}function xi(e,t){return"Operator"===e?.[0]&&(!t||e[1]===t)}function wi(e,t){xi(e,t)||Pi("Operator",t,e)}function qi(e){return"LParen"===e?.[0]}function ki(e){qi(e)||Pi("LParen",void 0,e)}function Ai(e){return"RParen"===e?.[0]}function Ni(e){Ai(e)||Pi("RParen",void 0,e)}function $i(e){return"LBracket"===e?.[0]}function Ti(e){return function(e){$i(e)||Pi("LBracket",void 0,e)}(e),e}function Si(e){return"RBracket"===e?.[0]}function zi(e){Si(e)||Pi("RBracket",void 0,e)}function Ei(e){return"LBrace"===e?.[0]}function ji(e){return function(e){Ei(e)||Pi("LBrace",void 0,e)}(e),e}function Mi(e){return"RBrace"===e?.[0]}function Ri(e){return"string"===e?.[0]}function Ci(e){return"Operator"===e?.[0]&&pr(e[1])}function Pi(e,t,n){const a=n?`${n[0]} '${n[1]}'`:"end of input";throw new r(`Unexpected token: ${a}, expected ${e}${t?` '${t}'`:""}`,n?.[2])}function Ii(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 Oi=new Set([...or,...ir,...Object.keys(Bo)]);class Fi{originalProgram;originalPosition;prefixProgram="";suffixProgram="";searchString="";suggestions=[];suggestionIndex=null;constructor(e,t,r,n){this.originalProgram=e,this.originalPosition=t;const a=this.originalProgram.slice(0,this.originalPosition),o=r.tokenize(a).tokens.at(-1);o&&"Error"!==o[0]&&(this.searchString=o[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_def","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 a=this.generateWithPredicate(e,e=>!t.has(e)&&e.includes(this.searchString));a.forEach(e=>t.add(e));const o=this.generateWithPredicate(e,e=>!t.has(e)&&e.includes(this.searchString.toLowerCase()));return o.forEach(e=>t.add(e)),[...r,...n,...a,...o]}generateWithPredicate(e,t){const r=new Set;return Oi.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.jsFunctions??{}).filter(t).forEach(e=>r.add(e)),Object.keys(e.values??{}).filter(t).forEach(e=>r.add(e)),[...r].sort((e,t)=>e.localeCompare(t))}}class Ui{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 Di(e,t){return t&&(e[2]=t),e}function Gi(e,t){return void 0!==rr[e]&&"fn"!==e&&"def"!==e&&"defn"!==e?Di([s.SpecialBuiltinSymbol,rr[e]],t):void 0!==ut[e]?Di([s.NormalBuiltinSymbol,ut[e]],t):Di([s.UserDefinedSymbol,e],t)}function Wi(e){return e.substring(1,e.length-1).replace(/(\\{2})|(\\')|\\(.)/g,(e,t,r,n)=>t?"\\":r?"'":`\\${n}`)}const Vi=Object.entries(ut).reduce((e,[t,r])=>(e[r]=t,e),[]),Bi=Object.entries(rr).reduce((e,[t,r])=>(e[r]=t,e),[]);function Li(e){return vt(e)?e[1]:bt(e)?Vi[e[1]]:Bi[e[1]]}function Ki(e,t,r){const n=Di([s.NormalExpression,[e,t]],r);return bt(e)&&X(pt[e[1]].arity,n[1][1].length,r),n}function _i(e){if(e.isAtEnd())return!0;const t=e.tryPeek();return xi(t)?[";",",",":"].includes(t[1]):!!vi(t)&&["else","when","while","case","catch","let","then","end","do"].includes(t[1])}function Ji(e,t,n,a,o){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"&":case"xor":case"|":case"|>":return Ki(t,[n,a],o);case"&&":case"||":case"??":return Di([s.SpecialExpression,[rr[i],[n,a]]],o);default:throw new r(`Unknown binary operator: ${i}`,o)}}function Hi(e){const t=e.peek();if(e.advance(),!di(t))throw new r(`Expected symbol token, got ${t[0]}`,t[2]);return"'"===t[1][0]?Gi(Wi(t[1]),t[2]):Gi(t[1],t[2])}function Yi(e,{requireDefaultValue:t,noRest:n}={}){const a=e.tryPeek();if(di(a)){const n=Hi(e);if(!vt(n))throw new r("Expected user defined symbol",a[2]);const o=Xi(e);if(t&&!o)throw new r("Expected assignment",e.peekSourceCodeInfo());return Di([Nt,[n,o]],a[2])}if(xi(a,"...")){if(n)throw new r("Rest element not allowed",a[2]);e.advance();const t=ft(Hi(e));if(xi(e.tryPeek(),"="))throw new r("Rest argument can not have default value",e.peekSourceCodeInfo());return Di([$t,[t[1],void 0]],a[2])}if($i(a)){e.advance();const n=[];let o=e.peek(),i=!1;for(;!Si(o);){if(i)throw new r("Rest argument must be last",o[2]);if(xi(o,",")){n.push(null),e.advance(),o=e.peek();continue}const t=Yi(e);t[0]===$t&&(i=!0),n.push(t),o=e.peek(),Si(o)||(wi(o,","),e.advance()),o=e.peek()}e.advance();const s=Xi(e);if(t&&!s)throw new r("Expected assignment",e.peekSourceCodeInfo());return Di([St,[n,s]],a[2])}if(Ei(a)){e.advance();const n={};let o=e.peek(),i=!1;for(;!Mi(o);){if(i)throw new r("Rest argument must be last",o[2]);xi(o,"...")&&(i=!0,e.advance());const t=Hi(e),s=Li(t);if(o=e.peek(),vi(o,"as")){if(i)throw new r("Rest argument can not have alias",o[2]);e.advance();const t=ft(Hi(e));if(n[t[1]])throw new r(`Duplicate binding name: ${t}`,o[2]);n[s]=Di([Nt,[t,Xi(e)]],a[2])}else if(Mi(o)||xi(o,",")||xi(o,"=")){const s=ft(t,t[2]);if(n[s[1]])throw new r(`Duplicate binding name: ${s}`,o[2]);if(i&&xi(e.tryPeek(),"="))throw new r("Rest argument can not have default value",e.peekSourceCodeInfo());n[s[1]]=Di(i?[$t,[s[1],Xi(e)]]:[Nt,[s,Xi(e)]],a[2])}else if(xi(o,":")){if(e.advance(),o=e.peek(),!Ei(o)&&!$i(o))throw new r("Expected object or array",o[2]);n[s]=Yi(e)}Mi(e.peek())||(wi(e.peek(),","),e.advance()),o=e.peek()}e.advance(),o=e.peek();const s=Xi(e);if(t&&!s)throw new r("Expected assignment",o[2]);return Di([Tt,[n,s]],a[2])}throw new r("Expected symbol",e.peekSourceCodeInfo())}function Xi(e){if(xi(e.tryPeek(),"="))return e.advance(),e.parseExpression()}function Zi(e,t){e.advance();const r=Yi(e,{requireDefaultValue:!0,noRest:!0}),n=r[1][1];r[1][1]=void 0;const a=Di([s.Binding,[r,n]],t[2]);return Di([s.SpecialExpression,[rr.let,a]],t[2])}function Qi(e,t){const n=[];for(;!e.isAtEnd()&&!es(e,t);)xi(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]:Di([s.SpecialExpression,[rr.block,n]],e.peekSourceCodeInfo())}function es(e,t){for(const r of t)if(vi(e.tryPeek(),r))return!0;return!1}function ts(e){const t=function(e){const t=yi(e.tryPeek()),r=ft(Hi(e));fi(e.tryPeek(),"in"),e.advance();const n=e.parseExpression();return Di([s.Binding,[Di([Nt,[r,void 0]],t[2]),n]],t[2])}(e),n=[];let a=e.peek();rs(a,["let","when","while"]);const o=[];if("let"===a[1])for(n.push("&let");di(a,"let");){const t=Zi(e,a),n=o.flatMap(e=>Object.keys(Mt(e[1][0])));if(Object.keys(Mt(t[1][1][1][0])).some(e=>n.includes(e)))throw new r("Duplicate binding",t[1][1][2]);o.push(t[1][1]),a=e.peek(),rs(a,["let","when","while"]),a=e.peek()}let i,c;for(;vi(a,"when")||vi(a,"while");){e.advance(),"when"===a[1]?(n.push("&when"),i=e.parseExpression()):(n.push("&while"),c=e.parseExpression()),a=e.peek();rs(a,n.includes("&when")&&n.includes("&while")?[]:n.includes("&when")?["while"]:["when"]),a=e.peek()}return rs(a,[]),[t,o,i,c]}function rs(e,t){if(!function(e,t){if(xi(e,",")||Ai(e))return!0;for(const r of t){if("let"===r&&di(e,"let"))return!0;if(["when","while"].includes(r)&&vi(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 ns(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,a,o,i,s,c)=>t?"\\":n?"\n":a?"\t":o?"\r":i?"\b":s?"\f":r?'"':c);return Di([s.String,r],t[2])}function as(e,t=!1){const n=bi(e.tryPeek(),"do");e.advance();let a="";t&&function(e){return"DocString"===e?.[0]}(e.tryPeek())&&(a=function(e){const t=e.peek(),r=t[2]?["string",t[1].slice(2,-2),t[2]]:["string",t[1].slice(2,-2)],n=ns(e,r);return xe(n[1])}(e));const o=[];for(;!e.isAtEnd()&&!vi(e.tryPeek(),"end");)if(o.push(e.parseExpression()),xi(e.tryPeek(),";"))e.advance();else if(!vi(e.tryPeek(),"end"))throw new r("Expected end",e.peekSourceCodeInfo());return fi(e.tryPeek(),"end"),e.advance(),[Di([s.SpecialExpression,[rr.block,o]],n[2]),a]}function os(e){const t=bi(e.tryPeek());e.advance();const r=t[1];return function(e){return e in Vo}(r)?Di([s.Number,Vo[r]],t[2]):Di([s.ReservedSymbol,t[1]],t[2])}const is=/^\$([1-9]\d?)?$/;function ss(e){const t=e.peek();if(qi(t)&&di(e.peekAhead(1))&&xi(e.peekAhead(2),"->"))return null;try{const n=function(e){const t=e.peek();if(di(t))return[Di([Nt,[Hi(e),void 0]],t[2])];ki(t),e.advance();let n=!1,a=!1;const o=[];for(;!e.isAtEnd()&&!Ai(e.peek())&&!di(e.peek(),"let");){if(n)throw new r("Rest argument must be last",e.peekSourceCodeInfo());const t=Yi(e);if(void 0!==t[1][1]&&(a=!0),t[0]===$t&&(n=!0),a&&!t[1][1])throw new r("Default arguments must be last",e.peekSourceCodeInfo());if(o.push(t),!xi(e.peek(),",")&&!Ai(e.peek())&&!di(e.peek(),"let"))throw new r("Expected comma or closing parenthesis",e.peekSourceCodeInfo());xi(e.peek(),",")&&e.advance()}if(!Ai(e.peek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());return e.advance(),o}(e);if(!xi(e.peek(),"->"))return null;let a;e.advance();let o="";if(vi(e.peek(),"do")){const t=as(e,!0);o=t[1],a=t[0][1][1]}else a=[e.parseExpression()];return Di([s.SpecialExpression,[rr["0_lambda"],[n,a],o]],t[2])}catch{return null}}function cs(e,t){e.advance();const n=[];for(;!e.isAtEnd()&&!Ai(e.tryPeek());){xi(e.tryPeek(),"...")?(e.advance(),n.push(Di([s.Spread,e.parseExpression()],e.peekSourceCodeInfo()))):n.push(e.parseExpression());const t=e.tryPeek();if(!xi(t,",")&&!Ai(t))throw new r("Expected comma or closing parenthesis",e.tryPeek()?.[2]);xi(t,",")&&e.advance()}if(!Ai(e.tryPeek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());if(e.advance(),!xt(t))return bt(t)||vt(t)?Ki(t,n,t[2]):Di([s.NormalExpression,[t,n]],t[2]);{const e=t[1];switch(X(ar.specialExpressions[e].arity,n.length,t[2]),e){case rr["||"]:case rr["&&"]:case rr.recur:case rr.array:case rr.object:case rr["??"]:return Di([s.SpecialExpression,[e,n]],t[2]);case rr["defined?"]:{const[r]=n;return Di([s.SpecialExpression,[e,r]],t[2])}case rr.throw:{const[r]=n;return Di([s.SpecialExpression,[e,r]],t[2])}case rr["0_lambda"]:case rr["0_def"]:throw new r(`${e} is not allowed`,t[2]);default:throw new r(`Unknown special expression: ${e}`,t[2])}}}function ls(e){const t=ji(e.tryPeek());e.advance();const n=[];for(;!e.isAtEnd()&&!Mi(e.tryPeek());){if(xi(e.tryPeek(),"..."))e.advance(),n.push(Di([s.Spread,e.parseExpression()],e.peekSourceCodeInfo()));else{const t=e.tryPeek();if(Ri(t)){const r=ns(e,t);n.push(Di([s.String,r[1]],t[2]))}else if(di(t)){const r=t[1].startsWith("'")?Wi(t[1]):t[1];n.push(Di([s.String,r],t[2])),e.advance()}else{if(!$i(t))throw new r("Expected key to be a symbol or a string",e.peekSourceCodeInfo());e.advance(),n.push(e.parseExpression()),zi(e.tryPeek()),e.advance()}wi(e.tryPeek(),":"),e.advance(),n.push(e.parseExpression())}const t=e.tryPeek();if(!xi(t,",")&&!Mi(t))throw new r("Expected comma or closing brace",e.peekSourceCodeInfo());xi(t,",")&&e.advance()}var a;return Mi(a=e.tryPeek())||Pi("RBrace",void 0,a),e.advance(),Di([s.SpecialExpression,[rr.object,n]],t[2])}function ms(e){let t=function(e){const t=e.peek();if(qi(t)){e.storePosition();const t=ss(e);if(t)return t;e.restorePosition(),e.advance();const n=e.parseExpression();if(!Ai(e.peek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());return e.advance(),n}if(xi(t)){const n=t[1];if(pr(n))return e.advance(),Di(void 0!==rr[n]?[s.SpecialBuiltinSymbol,rr[n]]:[s.NormalBuiltinSymbol,ut[n]],t[2]);if("->"===n)return function(e){const t=e.peek();e.advance();const n=e.getPosition();let a,o="";if(vi(e.peek(),"do")){const t=as(e,!0);o=t[1],a=t[0][1][1]}else a=[e.parseExpression()];const i=e.getPosition()-1;let c=0,l="NOT_SET";for(let a=n;a<=i;a+=1){const n=e.getTokenAt(a);if(di(n)){const e=is.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(Di([Nt,[[s.UserDefinedSymbol,"$"],void 0]],t[2])):m.push(Di([Nt,[[s.UserDefinedSymbol,`$${e}`],void 0]],t[2]));return Di([s.SpecialExpression,[rr["0_lambda"],[m,a],o]],t[2])}(e);throw new r(`Illegal operator: ${n}`,t[2])}if(Ei(t))return ls(e);if($i(t))return function(e){const t=Ti(e.tryPeek());e.advance();const n=[];for(;!e.isAtEnd()&&!Si(e.tryPeek());){xi(e.tryPeek(),"...")?(e.advance(),n.push(Di([s.Spread,e.parseExpression()],e.peekSourceCodeInfo()))):n.push(e.parseExpression());const t=e.tryPeek();if(!xi(t,",")&&!Si(t))throw new r("Expected comma or closing parenthesis",e.peekSourceCodeInfo());xi(t,",")&&e.advance()}return zi(e.tryPeek()),e.advance(),Di([s.SpecialExpression,[rr.array,n]],t[2])}(e);const n=t[0];switch(n){case"Number":case"BasePrefixedNumber":return function(e){const t=e.peek();e.advance();const r=t[1],n="-"===r[0],a=(n?r.substring(1):r).replace(/_/g,"");return Di([s.Number,n?-Number(a):Number(a)],t[2])}(e);case"string":return ns(e,t);case"Symbol":{e.storePosition();const t=ss(e);return t||(e.restorePosition(),Hi(e))}case"ReservedSymbol":return os(e);case"RegexpShorthand":return function(e){const t=e.peek();e.advance();const r=t[1].lastIndexOf('"'),n=t[1].substring(2,r),a=t[1].substring(r+1),o=Di([s.String,n],t[2]),i=Di([s.String,a],t[2]);return Di([s.NormalExpression,[Di([s.NormalBuiltinSymbol,ut.regexp],t[2]),[o,i]]],t[2])}(e);default:throw new r(`Unknown token type: ${n}`,t[2])}}(e),n=e.tryPeek();for(;xi(n,".")||$i(n)||qi(n);)if("."===n[1]){e.advance();const a=e.tryPeek();if(!di(a))throw new r("Expected symbol",e.peekSourceCodeInfo());t=us(t,Di([s.String,a[1]],a[2]),n[2]),e.advance(),n=e.tryPeek()}else if($i(n)){e.advance();const a=e.parseExpression();if(!Si(e.tryPeek()))throw new r("Expected closing bracket",e.peekSourceCodeInfo());t=us(t,a,n[2]),e.advance(),n=e.tryPeek()}else qi(n)&&(t=cs(e,t),n=e.tryPeek());return t}function us(e,t,r){return Di([s.NormalExpression,[[s.NormalBuiltinSymbol,ut.get],[e,t]]],r)}function ps(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"!=":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 gs(e,t=0,n=!1){const a=e.tryPeek();let o;if(di(a))switch(a[1]){case"let":return Zi(e,a);case"if":case"unless":o=function(e,t){const r="unless"===t[1];e.advance();const n=e.parseExpression();fi(e.tryPeek(),"then"),e.advance();const a=Qi(e,["else","end"]);let o;return vi(e.tryPeek(),"else")&&(e.advance(),o=Qi(e,["end"])),e.advance(),Di(r?[s.SpecialExpression,[rr.unless,[n,a,o]]]:[s.SpecialExpression,[rr.if,[n,a,o]]],t[2])}(e,a);break;case"cond":o=function(e,t){e.advance();const r=[];for(;!e.isAtEnd()&&!vi(e.tryPeek(),"end");){fi(e.tryPeek(),"case"),e.advance();const t=e.parseExpression();fi(e.tryPeek(),"then"),e.advance();const n=Qi(e,["case","end"]);if(r.push([t,n]),vi(e.tryPeek(),"end"))break}return fi(e.tryPeek()),e.advance(),Di([s.SpecialExpression,[rr.cond,r]],t[2])}(e,a);break;case"switch":o=function(e,t){e.advance();const r=e.parseExpression(),n=[];for(;!e.isAtEnd()&&!vi(e.tryPeek(),"end");){fi(e.tryPeek(),"case"),e.advance();const t=e.parseExpression();fi(e.tryPeek(),"then"),e.advance();const r=Qi(e,["case","end"]);if(n.push([t,r]),vi(e.tryPeek(),"end"))break}return fi(e.tryPeek(),"end"),e.advance(),Di([s.SpecialExpression,[rr.switch,r,n]],t[2])}(e,a);break;case"for":case"doseq":o=function(e,t){const n="doseq"===t[1];e.advance(),ki(e.tryPeek()),e.advance();const a=[];for(;!e.isAtEnd()&&!Ai(e.tryPeek());){const t=ts(e),n=a.flatMap(e=>Object.keys(Mt(e[0][1][0]))),o=Mt(t[0][1][0]);if(Object.keys(o).some(e=>n.includes(e)))throw new r("Duplicate binding",t[0][2]);a.push(t),xi(e.tryPeek(),",")&&e.advance()}Ni(e.tryPeek()),e.advance(),wi(e.tryPeek(),"->"),e.advance();const o=e.parseExpression();return Di(n?[s.SpecialExpression,[rr.doseq,a,o]]:[s.SpecialExpression,[rr.for,a,o]],t[2])}(e,a);break;case"loop":o=function(e,t){e.advance(),ki(e.tryPeek()),e.advance();const n=[];let a=e.tryPeek();for(;!e.isAtEnd()&&!Ai(a);){const t=Yi(e,{requireDefaultValue:!0,noRest:!0}),r=t[1][1];t[1][1]=void 0,n.push(Di([s.Binding,[t,r]],t[2])),xi(e.tryPeek(),",")&&e.advance(),a=e.tryPeek()}if(0===n.length)throw new r("Expected binding",e.peekSourceCodeInfo());Ni(a),e.advance(),wi(e.tryPeek(),"->"),e.advance();const o=e.parseExpression();return Di([s.SpecialExpression,[rr.loop,n,o]],t[2])}(e,a);break;case"try":o=function(e,t){e.advance();const r=Qi(e,["catch"]);let n;e.advance(),qi(e.tryPeek())&&(e.advance(),n=Hi(e),Ni(e.tryPeek()),e.advance());const a=Qi(e,["end"]);return e.advance(),Di([s.SpecialExpression,[rr.try,r,n,a]],t[2])}(e,a)}else if(vi(a,"do"))o=as(e)[0];else if(vi(a,"export")){if(!n)throw new r("export is only allowed in module scope",a[2]);return function(e,t){e.advance();const n=e.tryPeek();if(di(n,"let")){const r=Zi(e,yi(n));return Di([s.SpecialExpression,[rr["0_def"],r[1][1]]],t[2])}throw new r("Expected let",e.peekSourceCodeInfo())}(e,a)}o||=ms(e);let i=e.tryPeek();for(;!_i(e);){if(Ci(i)){const r=i[1],n=ps(r,i[2]);if(n<=t&&(12!==n||12!==t))break;const a=Di(rr[r]?[s.SpecialBuiltinSymbol,rr[r]]:[s.NormalBuiltinSymbol,ut[r]],i[2]);e.advance();o=Ji(i,a,o,gs(e,n),i[2])}else if(di(i)){if(!mr(i[1]))break;const n=3;if(n<=t)break;const a=Hi(e),s=gs(e,n);if(xt(a))throw new r("Special expressions are not allowed in binary functional operators",a[2]);o=Ki(a,[o,s],i[2])}else{if("?"!==i?.[1])break;{if(1<=t)break;e.advance();const n=gs(e);if(!xi(e.tryPeek(),":"))throw new r("Expected :",e.peekSourceCodeInfo());e.advance();const a=gs(e);o=Di([s.SpecialExpression,[rr.if,[o,n,a]]],o[2])}}i=e.tryPeek()}return o}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 ds{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}}run(e,t={}){const r=this.generateAst(e,t);return this.evaluate(r,t)}context(e,t={}){const r="string"==typeof e?this.generateAst(e,t):e,n=Xo(t,this.modules);return Ko(r,n),n.globalContext}getUndefinedSymbols(e,t={}){const r="string"==typeof e?this.generateAst(e,t):e,n=Xo(t,this.modules);return Do(r,n,ar,_o)}tokenize(e,t={}){const r=function(e,t,r){let n=0;const a={tokens:[],filePath:r,hasDebugData:t};for(;n<e.length;){const o=t?gi(e,n,r):void 0,i=hi(e,n),[s,c]=i;n+=s,c&&(o&&(c[2]=o),a.tokens.push(c))}return a}(e,this.debug,t.filePath);return t.minify?Ii(r,{removeWhiteSpace:!1}):r}parse(e){const t={body:[],hasDebugData:(e=Ii(e,{removeWhiteSpace:!0})).hasDebugData};return t.body=function(e){e.tokens.forEach(e=>{if("Error"===e[0])throw new r(e[3],e[2])});const t=[],n=new Ui(e);for(n.parseExpression=(e=0,t=!1)=>gs(n,e,t);!n.isAtEnd();)if(t.push(gs(n,0,!0)),xi(n.tryPeek(),";"))n.advance();else if(!n.isAtEnd())throw new r("Expected ;",n.peekSourceCodeInfo());return t}(e),t}evaluate(e,t){return Ko(e,Xo(t,this.modules))}transformSymbols(e,t){return function(e,t){return{...e,tokens:e.tokens.map(e=>di(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",a=this.generateApplyFunctionCall(n,t),o=this.generateAst(a,r),i=t.reduce((e,t,r)=>(e[`${n}_${r}`]=t,e),{[n]:e});return r.values={...r.values,...i},this.evaluate(o,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 Fi(e,t,this,r)}}const ys=[xr,Ar,zr,gn,$n,Pn,Ka,so,co,Ya,ro,oo,mo];function vs(e){return[`number-theory.${e}-seq`,`number-theory.${e}-nth`,`number-theory.${e}-take-while`,`number-theory.${e}?`]}function fs(e){const t=e.replace(/^/,"");return[`vector.${e}`,`vector.moving-${t}`,`vector.centered-moving-${t}`,`vector.running-${t}`]}const bs={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"],sequenceUtils:["sequence.position","sequence.last-index-of","sequence.shift","sequence.unshift","sequence.splice","sequence.sort-by","sequence.take","sequence.take-last","sequence.take-while","sequence.drop","sequence.drop-last","sequence.drop-while","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:["≠","==","<",">","<=",">=","!","write!","iso-date->epoch","epoch->iso-date","boolean","compare","identical?","import","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","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"],assert:["assert.assert","assert.assert=","assert.assert!=","assert.assert-gt","assert.assert-lt","assert.assert-gte","assert.assert-lte","assert.assert-true","assert.assert-false","assert.assert-truthy","assert.assert-falsy","assert.assert-null","assert.assert-throws","assert.assert-throws-error","assert.assert-not-throws","assert.assert-array","assert.assert-boolean","assert.assert-collection","assert.assert-function","assert.assert-grid","assert.assert-integer","assert.assert-matrix","assert.assert-number","assert.assert-object","assert.assert-regexp","assert.assert-sequence","assert.assert-string","assert.assert-vector"],grid:["grid.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.reverse-rows","grid.reverse-cols","grid.slice","grid.slice-rows","grid.slice-cols","grid.splice-rows","grid.splice-cols","grid.concat-rows","grid.concat-cols","grid.map","grid.mapi","grid.reduce","grid.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.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.median","vector.mode","vector.min-index","vector.max-index","vector.sort-indices","vector.count-values","vector.linspace","vector.ones","vector.zeros","vector.fill","vector.generate","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",...fs("mean"),...fs("median"),...fs("variance"),...fs("sample-variance"),...fs("sum"),...fs("prod"),...fs("stdev"),...fs("sample-stdev"),...fs("iqr"),...fs("span"),...fs("geometric-mean"),...fs("harmonic-mean"),...fs("skewness"),...fs("sample-skewness"),...fs("kurtosis"),...fs("sample-kurtosis"),...fs("excess-kurtosis"),...fs("sample-excess-kurtosis"),...fs("rms"),...fs("mad"),...fs("medad"),...fs("gini-coefficient"),...fs("entropy"),...fs("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:[...vs("abundant"),...vs("arithmetic"),...vs("bell"),...vs("catalan"),...vs("composite"),...vs("deficient"),...vs("factorial"),...vs("fibonacci"),...vs("geometric"),...vs("golomb"),...vs("happy"),...vs("look-and-say"),...vs("lucas"),...vs("lucky"),...vs("mersenne"),...vs("padovan"),...vs("partition"),...vs("pell"),...vs("perfect"),...vs("perfect-cube"),...vs("perfect-power"),...vs("perfect-square"),...vs("polygonal"),...vs("prime"),...vs("recaman"),...vs("sylvester"),...vs("thue-morse"),...vs("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!"],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"]},xs=[...[...[...bs.collection,...bs.array,...bs.sequence,...bs.math,...bs.functional,...bs.meta,...bs.misc,...bs.object,...bs.predicate,...bs.regularExpression,...bs.string,...bs.bitwise,...bs.vector],...[...bs.matrix,...bs.vectorUtils,...bs.linAlg,...bs.grid,...bs.numberTheory,...bs.random,...bs.mathUtils,...bs.functionalUtils,...bs.assert,...bs.stringUtils,...bs.collectionUtils,...bs.sequenceUtils,...bs.bitwiseUtils]],...bs.shorthand,...bs.datatype];function ws(e){return xs.includes(e)}export{ds as Lits,ys as allBuiltinModules,Io as apiReference,N as asLitsFunction,j as asNativeJsFunction,S as asUserDefinedFunction,$ as assertLitsFunction,xr as assertModule,M as assertNativeJsFunction,z as assertUserDefinedFunction,mo as bitwiseUtilsModule,co as functionalUtilsModule,Ar as gridModule,ws as isApiName,R as isBuiltinFunction,jo as isCustomReference,yr as isDataType,Ro as isDatatypeReference,Eo as isFunctionReference,De as isGrid,i as isLitsError,A as isLitsFunction,We as isMatrix,E as isNativeJsFunction,Mo as isShorthandReference,T as isUserDefinedFunction,Pe as isVector,$n as linearAlgebraModule,so as mathUtilsModule,Pn as matrixModule,or as normalExpressionKeys,Ka as numberTheoryModule,zr as randomModule,ir as specialExpressionKeys,gn 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 a=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)}`}(a,n)),this.shortMessage=a,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 a extends r{constructor(e,t){super(e,t),Object.setPrototypeOf(this,a.prototype),this.name="AssertionError"}}class o extends r{symbol;constructor(e,t){super(`Undefined symbol '${e}'.`,t),this.symbol=e,Object.setPrototypeOf(this,o.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={}){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 f(e,t,n={}){if(!v(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":"",a=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,a].filter(e=>!!e).join(" ")}(n)}, got ${d(e)}.`,y(e,t))}function b(e,t,r={}){return f(e,t,r),e}function x(e,t,n){return new r(`Expected ${e}, got ${d(t)}.`,y(t,n))}function w(e,t){return q(e,t),e}function q(e,t){if(!function(e){return void 0!==e}(e))throw new r("Unexpected undefined",y(e,t))}function k(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function A(e){return null!==e&&"object"==typeof e&&!!e[u]}function N(e,t){return $(e,t),e}function $(e,t){if(!A(e))throw x("LitsFunction",e,t)}function T(e){return A(e)&&"UserDefined"===e.functionType}function S(e,t){return z(e,t),e}function z(e,t){if(!T(e))throw x("NativeJsFunction",e,t)}function E(e){return A(e)&&"NativeJsFunction"===e.functionType}function j(e,t){return M(e,t),e}function M(e,t){if(!E(e))throw x("NativeJsFunction",e,t)}function C(e){return k(e)&&"Builtin"===e.functionType}function R(e){return void 0!==e}function P(e,t){return I(e,t),e}function I(e,t){if(!R(e))throw x("not undefined",e,t)}function O(e){return Array.isArray(e)||"string"==typeof e}function F(e,t){return U(e,t),e}function U(e,t){if(!O(e))throw x("string or array",e,t)}function D(e){return!(null===e||"object"!=typeof e||Array.isArray(e)||e instanceof RegExp||A(e)||L(e))}function G(e,t){if(!D(e))throw x("object",e,t)}function W(e){return O(e)||D(e)}function V(e,t){return B(e,t),e}function B(e,t){if(!W(e))throw x("string, array or object",e,t)}function L(e){return null!==e&&"object"==typeof e&&!!e[p]}function _(e,t){if(!function(e){return L(e)||"string"==typeof e}(e))throw x("string or RegularExpression",e,t)}function K(e,t){return J(e,t),e}function J(e,t){if(!function(e){return"number"==typeof e||!!W(e)||!!A(e)}(e))throw x("FunctionLike",e,t)}function Y(e){return"number"==typeof e||W(e)?Z(1):e.arity}function H(e,t,n){const{min:a,max:o}=e;if("number"==typeof a&&t<a)throw new r(`Wrong number of arguments, expected at least ${a}, got ${d(t)}.`,n);if("number"==typeof o&&t>o)throw new r(`Wrong number of arguments, expected at most ${o}, got ${d(t)}.`,n)}function X(e){return!("number"==typeof e.max&&e.max<2)&&!("number"==typeof e.min&&e.min>2)}function Z(e){return{min:e,max:e}}function Q(e,t){return{a:{type:e},b:{type:t}}}const ee={"<<":{evaluate:([e,t],r)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0}),e<<t),arity:Z(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...Q("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)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0}),e>>t),arity:Z(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...Q("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)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0}),e>>>t),arity:Z(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...Q("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)=>(f(e,r,{integer:!0}),t.reduce((e,t)=>(f(t,r,{integer:!0}),e&t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...Q("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)=>(f(e,r,{integer:!0}),t.reduce((e,t)=>(f(t,r,{integer:!0}),e|t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...Q("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)=>(f(e,r,{integer:!0}),t.reduce((e,t)=>(f(t,r,{integer:!0}),e^t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...Q("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 te(e,t={}){return"string"==typeof e&&((!t.nonEmpty||0!==e.length)&&(!t.char||1===e.length))}function re(e,t,r={}){if(!te(e,r))throw x(""+(r.nonEmpty?"non empty string":r.char?"character":"string"),e,t)}function ne(e,t,r={}){return re(e,t,r),e}function ae(e){return"string"==typeof e||"number"==typeof e}function oe(e,t){return ie(e,t),e}function ie(e,t){if(!ae(e))throw x("string or number",e,t)}function se(e,t){return!!W(e)&&("string"==typeof e||Array.isArray(e)?!!v(t,{integer:!0})&&(t>=0&&t<e.length):!!Object.getOwnPropertyDescriptor(e,t))}function ce(e,t,n){if(ie(e,n),ie(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 le(e,t,r){if(e===t)return!0;if("number"==typeof e&&"number"==typeof t)return ve(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(!le(P(e[n],r),P(t[n],r),r))return!1;return!0}if(L(e)&&L(t))return e.s===t.s&&e.f===t.f;if(k(e)&&k(t)){const n=Object.keys(e),a=Object.keys(t);if(n.length!==a.length)return!1;for(let a=0;a<n.length;a+=1){const o=ne(n[a],r);if(!le(e[o],t[o],r))return!1}return!0}return!1}function me(e){return Math.max(0,Math.ceil(e))}function ue(e){return e??null}function pe(e){return D(e)?Object.entries(e).reduce((e,t)=>{const[r,n]=t;return e[r]=pe(n),e},{}):Array.isArray(e)?e.map(e=>pe(e)):e}function ge(e){return pe(e)}function he(...e){const t=new Set;for(const r of e)r.forEach(e=>t.add(e));return t}function de(e,t){t.forEach(t=>e.add(t))}const ye=1e-10;function ve(e,t,r=ye){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 fe(e){return Math.abs(e)<ye}function be(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 xe(e,t){if(!Array.isArray(e))throw x("array",e,t)}function we(e,t){if(!function(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e)}(e))throw x("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 x("array of strings",e,t)}function ke(e,t){return e instanceof Promise?e.then(t):t(e)}function Ae(e,t){const r=[];for(let n=0;n<e.length;n++){const a=t(e[n],n);if(a instanceof Promise)return Ne(a,r,e,t,n);r.push(a)}return r}async function Ne(e,t,r,n,a){t.push(await e);for(let e=a+1;e<r.length;e++)t.push(await n(r[e],e));return t}function $e(e,t,r){let n=r;for(let r=0;r<e.length;r++){const a=t(n,e[r],r);if(a instanceof Promise)return Te(a,e,t,r);n=a}return n}async function Te(e,t,r,n){let a=await e;for(let e=n+1;e<t.length;e++)a=await r(a,t[e],e);return a}function Se(e,t){for(let r=0;r<e.length;r++){const n=t(e[r],r);if(n instanceof Promise)return ze(n,e,t,r)}}async function ze(e,t,r,n){await e;for(let e=n+1;e<t.length;e++)await r(t[e],e)}function Ee(e,t){try{const r=e();return r instanceof Promise?r.catch(t):r}catch(e){return t(e)}}function je(e,t){for(let r=0;r<e.length;r++){const n=t(e[r],r);if(n instanceof Promise)return Me(n,e,t,r);if(n)return!0}return!1}async function Me(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 Ce(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 Pe(e,t){const r=[];for(let n=0;n<e.length;n++){const a=t(e[n],n);if(a instanceof Promise)return Ie(a,r,e,t,n);a&&r.push(e[n])}return r}async function Ie(e,t,r,n,a){await e&&t.push(r[a]);for(let e=a+1;e<r.length;e++)await n(r[e],e)&&t.push(r[e]);return t}function Oe(e,t){for(let r=0;r<e.length;r++){const n=t(e[r],r);if(n instanceof Promise)return Fe(n,e,t,r);if(n)return r}return-1}async function Fe(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 Ue={filter:{evaluate:([e,t],r,n,{executeFunction:a})=>{if(B(e,r),J(t,r),Array.isArray(e))return $e(e,(e,o)=>ke(a(t,[o],n,r),t=>(t&&e.push(o),e)),[]);if(te(e)){return ke($e(e.split(""),(e,o)=>ke(a(t,[o],n,r),t=>(t&&e.push(o),e)),[]),e=>e.join(""))}return $e(Object.entries(e),(e,[o,i])=>ke(a(t,[i],n,r),t=>(t&&(e[o]=i),e)),{})},arity:Z(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:a})=>{const o=K(e.at(-1),t);if(D(e[0]))return function({colls:e,contextStack:t,executeFunction:n,fn:a,sourceCodeInfo:o}){G(e[0],o);const i=Object.keys(e[0]),s={};return e.forEach(e=>{G(e,o);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(", ")}`,o);if(!t.every(e=>i.includes(e)))throw new r(`All objects must have the same keys. Expected: ${i.join(", ")}. Found: ${t.join(", ")}`,o);Object.entries(e).forEach(([e,t])=>{s[e]||(s[e]=[]),s[e].push(t)})}),$e(i,(e,r)=>ke(n(a,s[r],t,o),t=>(e[r]=t,e)),{})}({colls:e.slice(0,-1),fn:o,sourceCodeInfo:t,contextStack:n,executeFunction:a});const i=e.slice(0,-1);U(i[0],t);const s="string"==typeof i[0];let c=i[0].length;i.slice(1).forEach(e=>{s?re(e,t):xe(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=Ae(l,e=>a(o,e,n,t));return s?ke(m,e=>(e.forEach(e=>re(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.map","grid.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,a,{executeFunction:o})=>(B(e,n),J(t,n),I(r,n),"string"==typeof e?(re(r,n),0===e.length?r:$e(e.split(""),(e,r)=>o(t,[e,r],a,n),r)):Array.isArray(e)?0===e.length?r:$e(e,(e,r)=>o(t,[e,r],a,n),r):0===Object.keys(e).length?r:$e(Object.entries(e),(e,[,r])=>o(t,[e,r],a,n),r)),arity:Z(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.reduce","grid.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,a=ue(e[2]);if(ie(n,t),null===r)return a;B(r,t);const o=function(e,t){if(D(e)){if("string"==typeof t&&se(e,t))return ue(e[t])}else if(v(t,{nonNegative:!0,integer:!0})&&t>=0&&t<e.length)return ue(e[t])}(r,n);return void 0===o?a:o},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:(B(e,t),Array.isArray(e)?e.length:Object.keys(e).length),arity:Z(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&&(B(e,r),te(e)?(re(t,r),e.includes(t)):O(e)?(I(t,r),!!e.find(e=>le(P(e),t,r))):(re(t,r),t in e)),arity:Z(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)=>(B(e,n),ie(t,n),I(r,n),function(e,t,r,n){if(B(e,n),ie(t,n),Array.isArray(e)||"string"==typeof e){if(f(t,n,{integer:!0}),f(t,n,{gte:0}),f(t,n,{lte:e.length}),"string"==typeof e)return re(r,n,{char:!0}),`${e.slice(0,t)}${r}${e.slice(t+1)}`;const a=[...e];return a[t]=r,a}re(t,n);const a={...e};return a[t]=r,a}(e,t,r,n)),arity:Z(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)=>(v(e[0])||B(e[0],t),Array.isArray(e[0])?e.reduce((e,r)=>(xe(r,t),e.concat(r)),[]):ae(e[0])?e.reduce((e,r)=>(ie(r,t),`${e}${r}`),""):e.reduce((e,r)=>(G(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 })"]}}},De={range:{evaluate:(e,t)=>{const[r,n,a]=e;let o,i,s;f(r,t,{finite:!0}),1===e.length?(o=0,i=r,s=i>=0?1:-1):2===e.length?(f(n,t,{finite:!0}),o=r,i=n,s=i>=o?1:-1):(f(n,t,{finite:!0}),f(a,t,{finite:!0}),o=r,i=n,s=a,f(s,t,i>o?{positive:!0}:i<o?{negative:!0}:{nonZero:!0}));const c=[];for(let e=o;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)=>{f(t,r,{integer:!0,nonNegative:!0});const n=[];for(let r=0;r<t;r+=1)n.push(e);return n},arity:Z(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","vector.ones","vector.zeros","vector.fill","vector.generate","string.string-repeat"],examples:["repeat(10, 3)","repeat(10, 0)",'"Albert" repeat 5']}},flatten:{evaluate:([e,t],r)=>{xe(e,r);const n=void 0===t||t===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:b(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:a})=>(xe(e,r),J(t,r),ke(Ae(e,e=>a(t,[e],n,r)),e=>e.flat(1))),arity:Z(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,a,{executeFunction:o})=>{xe(e,n),f(t,n,{integer:!0,lte:e.length}),J(r,n);const i=[];for(let r=0;r<=e.length-t;r++)i.push(e.slice(r,r+t));return Ae(i,e=>o(r,[e],a,n))},arity:Z(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:a})=>{xe(e,r),J(t,r);const o=[];for(let t=0;t<e.length;t+=1)o.push(e.slice(0,t+1));return Ae(o,e=>a(t,[e],n,r))},arity:Z(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,a=ue(e[2]);if(f(n,t,{integer:!0}),null===r)return a;if(U(r,t),n>=0&&n<r.length){return ue(r[n])}return a},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;U(e,t);return ue(e[0])},arity:Z(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;U(e,t);return ue(e.at(-1))},arity:Z(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)=>(U(e,t),"string"==typeof e?e.substring(0,e.length-1):e.slice(0,e.length-1)),arity:Z(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","sequence.shift","last"],examples:["pop([1, 2, 3])","pop([])"]}},"index-of":{evaluate:([e,t],r)=>{if(I(t,r),null===e)return null;if(U(e,r),"string"==typeof e){re(t,r);const n=e.indexOf(t);return-1!==n?n:null}{const n=e.findIndex(e=>le(P(e,r),t),r);return-1!==n?n:null}},arity:Z(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)=>(U(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)=>(U(e,t),Array.isArray(e)?e.length<=1?[]:e.slice(1):e.substring(1)),arity:Z(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","sequence.shift"],examples:['rest(["Albert", "Mojir", 160, [1, 2]])','rest(["Albert"])',"rest([])",'rest("Albert")','rest("A",)','rest("")']}},next:{evaluate:([e],t)=>(U(e,t),Array.isArray(e)?e.length<=1?null:e.slice(1):e.length<=1?null:e.substring(1)),arity:Z(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:(U(e,t),Array.isArray(e)?[...e].reverse():e.split("").reverse().join("")),arity:Z(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:(U(e,t),ue(e[1])),arity:Z(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,a]=e;return U(r,t),f(n,t,{integer:!0}),2===e.length?(Array.isArray(r),r.slice(n)):(f(a,t,{integer:!0}),Array.isArray(r),r.slice(n,a))},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:["sequence.take","sequence.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:a})=>{if(J(t,r),null===e)return null;if(U(e,r),0===e.length)return null;return $e("string"==typeof e?e.split(""):e,(e,o)=>null!==e?e:ke(a(t,[o],n,r),e=>e?ue(o):null),null)},arity:Z(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[a]=e,o=1===e.length,i=o?null:e[1];if(U(a,t),"string"==typeof a){const e=a.split("");return o?e.sort((e,r)=>ce(e,r,t)):(J(i,t),e.sort((e,a)=>{const o=n(i,[e,a],r,t);if(o instanceof Promise)throw new TypeError("Async functions cannot be used as sort comparators");return f(o,t,{finite:!0}),o})),e.join("")}const s=[...a];return o?s.sort((e,r)=>(ie(e,t),ie(r,t),ce(e,r,t))):s.sort((e,a)=>{J(i,t);const o=n(i,[e,a],r,t);if(o instanceof Promise)throw new TypeError("Async functions cannot be used as sort comparators");return f(o,t,{finite:!0}),o}),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)"]}}},We=new WeakSet,Ve=new WeakSet,Be=new WeakSet,Le=new WeakSet,_e=new WeakSet,Ke=new WeakSet,Je=new WeakSet;function Ye(e){return Array.isArray(e)?(We.has(e)||(He(e),nt(e)||tt(e)),e):e}function He(e){return!!Array.isArray(e)&&(!!Ve.has(e)||!Be.has(e)&&(e.every(e=>v(e))?(We.add(e),Ve.add(e),!0):(Be.add(e),!1)))}function Xe(e,t){if(!He(e))throw new r(`Expected a vector, but got ${e}`,t)}function Ze(e,t){if(!function(e){return!!He(e)&&2===e.length}(e))throw new r(`Expected a 2d vector, but got ${e}`,t)}function Qe(e,t){if(!function(e){return!!He(e)&&3===e.length}(e))throw new r(`Expected a 3d vector, but got ${e}`,t)}function et(e,t){if(Xe(e,t),0===e.length)throw new r(`Expected a non empty vector, but got ${e}`,t)}function tt(e){if(!Array.isArray(e))return!1;if(Ke.has(e))return!0;if(Je.has(e))return!1;if(0===e.length)return Je.add(e),!1;if(!Array.isArray(e[0]))return Je.add(e),!1;const t=e[0].length;for(const r of e.slice(1)){if(!Array.isArray(r))return Je.add(e),!1;if(r.length!==t)return Je.add(e),!1}return We.add(e),Ke.add(e),!0}function rt(e,t){if(!tt(e))throw new r(`Expected a grid, but got ${e}`,t)}function nt(e){if(!Array.isArray(e))return!1;if(Le.has(e))return!0;if(_e.has(e))return!1;if(0===e.length)return _e.add(e),!1;if(!Array.isArray(e[0])||0===e[0].length)return _e.add(e),!1;const t=e[0].length;for(const r of e)if(!Array.isArray(r)||r.length!==t||r.some(e=>!v(e)))return _e.add(e),!1;return We.add(e),Ke.add(e),Le.add(e),!0}function at(e,t){if(!nt(e))throw new r(`Expected a matrix, but got ${e}`,t)}function ot(e,t){if(!nt(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 it(e,t){let n=!1,a=!1;for(const o of e)if(He(o))n=!0;else if(nt(o))a=!0;else if(!v(o))throw new r("Invalid parameter type: "+typeof o,t);if(a){if(n)throw new r("Cannot mix vector and matrix types",t);let a=null,o=null;for(const n of e)if(nt(n))if(null===a)a=n.length,o=n[0].length;else if(n.length!==a||n[0].length!==o)throw new r("Matrix dimensions do not match",t);return["matrix",e.map(e=>nt(e)?e:Array.from({length:a},()=>Array.from({length:o},()=>e)))]}if(n){let n=null;for(const a of e)if(He(a))if(null===n)n=a.length;else if(a.length!==n)throw new r("Vector lengths do not match",t);return["vector",e.map(e=>He(e)?e:Array.from({length:n},()=>e))]}return["number",e]}function st(e){return(t,r)=>{const[n,a]=it(t,r);return"number"===n?e(a[0]):"vector"===n?a[0].map(t=>e(t)):a[0].map(t=>t.map(t=>e(t)))}}function ct(e){return(t,r)=>{const[n,a]=it(t,r);return"number"===n?e(a[0],a[1]):"vector"===n?a[0].map((t,r)=>e(t,a[1][r])):a[0].map((t,r)=>t.map((t,n)=>e(t,a[1][r][n])))}}function lt(e,t){return(r,n)=>{if(0===r.length)return e;const[a,o]=it(r,n);if("number"===a)return o.reduce((e,r)=>t(e,r),e);if("vector"===a){const[e,...r]=o;return r.reduce((e,r)=>e.map((e,n)=>t(e,r[n])),e)}{const[e,...r]=o;return r.reduce((e,r)=>e.map((e,n)=>e.map((e,a)=>t(e,r[n][a]))),e)}}}const mt={inc:{evaluate:st(e=>e+1),arity:Z(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:st(e=>e-1),arity:Z(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:lt(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:lt(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]=it(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]=it(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:ct((e,t)=>Math.trunc(e/t)),arity:Z(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:ct((e,t)=>e-t*Math.floor(e/t)),arity:Z(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:ct((e,t)=>e%t),arity:Z(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:st(e=>Math.sqrt(e)),arity:Z(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:st(e=>Math.cbrt(e)),arity:Z(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:ct((e,t)=>e**t),arity:Z(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,a]=it([e],r);if("number"===n){if(void 0===t||0===t)return Math.round(a[0]);{f(t,r,{integer:!0,positive:!0});const e=10**t;return Math.round(a[0]*e)/e}}if("vector"===n){const e=a[0];if(void 0===t||0===t)return e.map(e=>Math.round(e));{f(t,r,{integer:!0,positive:!0});const n=10**t;return e.map(e=>Math.round(e*n)/n)}}{const e=a[0];if(void 0===t||0===t)return e.map(e=>e.map(e=>Math.round(e)));{f(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:st(e=>Math.trunc(e)),arity:Z(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:st(e=>Math.floor(e)),arity:Z(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:st(e=>Math.ceil(e)),arity:Z(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&&He(e[0])){const r=e[0];return et(r,t),r.reduce((e,t)=>Math.min(e,t),1/0)}const[r,...n]=e;return f(r,t),n.reduce((e,r)=>(f(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&&He(e[0])){const r=e[0];return et(r,t),r.reduce((e,t)=>Math.max(e,t),-1/0)}const[r,...n]=e;return f(r,t),n.reduce((e,r)=>(f(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:st(e=>Math.abs(e)),arity:Z(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:st(e=>Math.sign(e)),arity:Z(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 ut([e,...t],r){const n=P(e,r);for(const e of t)if(!le(n,P(e,r),r))return!1;return!0}const pt={"==":{evaluate:(e,t)=>ut(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)=>!ut(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 `(! (== 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=oe(e);for(const e of t){if(ce(n,oe(e),r)<=0)return!1;n=oe(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=oe(e);for(const e of t){if(ce(n,oe(e),r)>=0)return!1;n=oe(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=oe(e);for(const e of t){if(ce(n,oe(e),r)<0)return!1;n=oe(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=oe(e);for(const e of t){if(ce(n,oe(e),r)>0)return!1;n=oe(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)"]}},"!":{evaluate:([e])=>!e,arity:Z(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:["!(3)","!(true)",'!("A string")',"!(0)","!(false)","!(null)",'!("")']}},"epoch->iso-date":{evaluate:([e],t)=>(f(e,t),new Date(e).toISOString()),arity:Z(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)=>{re(e,t);const r=new Date(e).valueOf();return f(r,t,{finite:!0}),r},arity:Z(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?P(e[e.length-1],t):null),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:Z(1),docs:{category:"misc",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Coerces $x to boolean.",seeAlso:["!","boolean?","true?","false?"],examples:["boolean(0)","boolean(1)","boolean(null)",'boolean("Albert")']}},compare:{evaluate:([e,t],r)=>(ie(e,r),ie(t,r),ce(e,t,r)),arity:Z(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)=>(re(e,t),JSON.parse(e)),arity:Z(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)=>(I(e,r),void 0===t?JSON.stringify(e):(f(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}},import:{evaluate:([e],t,n)=>{re(e,t);const a=e.indexOf(".");if(-1!==a){const o=e.substring(0,a),i=e.substring(a+1),s=n.getModule(o);if(!s)throw new r(`Unknown module: '${o}'`,t);const c=s.functions[i];if(!c)throw new r(`Function '${i}' not found in module '${o}'`,t);return{[u]:!0,sourceCodeInfo:t,functionType:"Module",moduleName:o,functionName:i,arity:c.arity}}const o=e,i=n.getModule(o);if(!i)throw new r(`Unknown module: '${o}'`,t);const s={};for(const[e,r]of Object.entries(i.functions))s[e]={[u]:!0,sourceCodeInfo:t,functionType:"Module",moduleName:o,functionName:e,arity:r.arity};return s},arity:Z(1),docs:{category:"misc",returns:{type:"any"},args:{path:{type:"string",description:'The module path to import. Can be a module name (e.g., "vector", "grid") or a fully qualified function name (e.g., "vector.mean", "grid.row").'}},variants:[{argumentNames:["path"]}],description:'Imports module functions. Use a module name (e.g., "vector") to import all functions as an object, or a fully qualified name (e.g., "vector.mean") to import a single function directly.',examples:['let v = import("vector"); v.mean([1, 2, 3, 4])','let v-sum = import("vector.sum"); v-sum([1, 2, 3])','let g = import("grid"); g.row([[1, 2], [3, 4]], 0)']}}},gt={keys:{evaluate:([e],t)=>(G(e,t),Object.keys(e)),arity:Z(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)=>(G(e,t),Object.values(e)),arity:Z(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)=>(G(e,t),Object.entries(e)),arity:Z(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)=>(G(e,r),re(t,r),se(e,t)?[t,e[t]]:null),arity:Z(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)=>{G(e,r),re(t,r);const n={...e};return delete n[t],n},arity:Z(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 G(r,t),n.reduce((e,r)=>(G(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 a=e[0],o=e.at(-1),i=e.slice(1,-1);return G(a,t),J(o,t),$e(i,(e,a)=>{G(a,t);return ke($e(Object.entries(a),(e,a)=>{const i=ne(a[0],t),s=ue(a[1]);return se(e,i)?ke(n(o,[e[i],s],r,t),t=>(e[i]=t,e)):(e[i]=s,e)},e),e=>e)},{...a})},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)=>{we(e,r),xe(t,r);const n=Math.min(e.length,t.length),a={};for(let o=0;o<n;o+=1){a[ne(e[o],r)]=ue(t[o])}return a},arity:Z(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)=>(we(t,r),G(e,r),t.reduce((t,r)=>(se(e,r)&&(t[r]=ue(e[r])),t),{})),arity:Z(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"])']}}},ht={"function?":{evaluate:([e])=>A(e),arity:Z(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:Z(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:Z(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&&v(e,{integer:!0}),arity:Z(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:Z(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:Z(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)=>(f(e,t,{finite:!0}),Math.abs(e)<ye),arity:Z(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)=>(f(e,t,{finite:!0}),e>0),arity:Z(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)=>(f(e,t,{finite:!0}),e<0),arity:Z(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)=>(f(e,t,{finite:!0}),e%2==0),arity:Z(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)=>(f(e,t,{finite:!0}),v(e,{integer:!0})&&e%2!=0),arity:Z(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:Z(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])=>W(e),arity:Z(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])=>O(e),arity:Z(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])=>D(e),arity:Z(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])=>L(e),arity:Z(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","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)=>(f(e,t),Number.isFinite(e)),arity:Z(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)=>(f(e,t),e===Number.POSITIVE_INFINITY),arity:Z(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)=>(f(e,t),e===Number.NEGATIVE_INFINITY),arity:Z(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:Z(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:Z(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||(B(e,t),"string"==typeof e||Array.isArray(e)?0===e.length:0===Object.keys(e).length),arity:Z(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&&(B(e,t),"string"==typeof e||Array.isArray(e)?e.length>0:Object.keys(e).length>0),arity:Z(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])=>He(e),arity:Z(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])=>nt(e),arity:Z(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])=>tt(e),arity:Z(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]])']}}},dt={regexp:{evaluate:([e,t],n)=>{re(e,n);const a=e||"(?:)",o="string"==typeof t?t:"";try{new RegExp(a,o)}catch(e){throw new r(`Invalid regular expression: ${a} ${o}`,n)}return{[p]:!0,sourceCodeInfo:n,s:a,f:o}},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","match","replace","replace-all","regexp?"],hideOperatorForm:!0}},match:{evaluate:([e,t],r)=>{if(function(e,t){if(!L(e))throw x("RegularExpression",e,t)}(t,r),!te(e))return null;const n=new RegExp(t.s,t.f).exec(e);return n?[...n]:null},arity:Z(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 `match`-array is returned, otherwise `null` is returned.",seeAlso:["regexp","replace","replace-all","-short-regexp","regexp?"],examples:['match(" A string", regexp("^\\\\s*(.*)$"))','match(" A string", #"^\\s*(.*)$")','match("My name is Albert", #"albert"i)','match("My name is Ben", #"albert"i)','match(null, #"albert"i)','match(1, #"albert"i)','match({}, #"albert"i)']}},replace:{evaluate:([e,t,r],n)=>{re(e,n),_(t,n),re(r,n);const a=L(t)?new RegExp(t.s,`${t.f}`):t;return e.replace(a,r)},arity:Z(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","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)=>{re(e,n),_(t,n),re(r,n);const a=L(t)?new RegExp(t.s,`${t.f.includes("g")?t.f:`${t.f}g`}`):t;return e.replaceAll(a,r)},arity:Z(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","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, "-")']}}},yt=/^\s*$/,vt={str:{evaluate:e=>e.reduce((e,t)=>e+(null==t?"":D(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)=>{re(e,t);const n=Number(e);if(Number.isNaN(n))throw new r(`Could not convert '${e}' to a number.`,t);return n},arity:Z(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)=>(re(e,t),e.toLowerCase()),arity:Z(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)=>(re(e,t),e.toUpperCase()),arity:Z(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)=>(re(e,t),e.trim()),arity:Z(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)=>(xe(e,r),e.forEach(e=>ie(e,r)),re(t,r),e.join(t)),arity:Z(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)=>{re(e,n),_(t,n),void 0!==r&&f(r,n,{integer:!0,nonNegative:!0});const a="string"==typeof t?t:new RegExp(t.s,t.f);return e.split(a,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||(re(e,t),yt.test(e)),arity:Z(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?(".")']}}},ft={"|>":{evaluate:([e,t],r,n,{executeFunction:a})=>(J(t,r),a(t,[e],n,r)),arity:Z(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:a})=>{J(e,r);const o=t[t.length-1];xe(o,r);return a(e,[...t.slice(0,-1),...o],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])=>ue(e),arity:Z(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=>J(e,t)),{[u]:!0,sourceCodeInfo:t,functionType:"Comp",params:e,arity:e.length>0?Y(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:ue(e),arity:{}}),arity:Z(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 bt(e){return be(`\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:a}){const o=t.map(t=>`${` ${e}(${t.argumentNames.map(e=>{let t="";return r[e].rest&&(t+="..."),t+=e,t}).join(", ")})`} -> ${xt(n)}`),i=a?["","Operator:",` a ${e} b -> ${xt(n)}`]:[];return[...o,...i]}(e).join("\n ")}\n\n Arguments:\n ${function(e){return Object.entries(e.args).map(([e,t])=>`${e}: ${xt(t)}`)}(e).join("\n ")}\n\n Examples:\n${e.examples.map(e=>be(e,4)).join("\n\n")}`)}function xt(e){const t=e.type,r=(Array.isArray(t)?t:[t]).join(" | ");return e.array||e.rest?`Array<${r}>`:r}function wt(e){return{doc:{evaluate:([t],r)=>{if(q(e),J(t,r),!A(t))return"";if("Builtin"===t.functionType){const r=e[t.name];return r?bt(r):""}return"UserDefined"===t.functionType||"NativeJsFunction"===t.functionType?t.docString:""},arity:Z(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)=>(J(e,t),A(e)?e.arity:Z(1)),arity:Z(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)=>(Xe(e,t),e.reduce((e,t)=>e+t,0)),arity:Z(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.sum"],examples:["sum([1, 2, 3, 4, 5])","sum([1, -2, 3])","sum([])"]}},prod:{evaluate:([e],t)=>(Xe(e,t),e.reduce((e,t)=>e*t,1)),arity:Z(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.prod"],examples:["prod([1, 2, 3, 4, 5])","prod([1, -2, 3])","prod([])"]}},mean:{evaluate:([e],t)=>(et(e,t),e.reduce((e,t)=>e+t,0)/e.length),arity:Z(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.mean"],examples:["mean([1, 2, 3, 4, 5])","mean([1, -2, 3])"]}},median:{evaluate:([e],t)=>(et(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:Z(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.median"],examples:["median([1, 2, 3, 4, 5])","median([1, 2, 3, 4])","median([3, 1, 4, 1, 5])"]}}},kt={};const At={...ee,...Ue,...De,...Ge,...mt,...wt(kt),...pt,...gt,...ht,...dt,...vt,...ft,...qt};Object.entries(At).forEach(([e,t])=>{t.name=e});const Nt={...At},$t={},Tt=[];Object.entries(Nt).forEach(([e,t],r)=>{$t[e]=r,Tt.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})=>$e(e[1][1],(e,n)=>e?r(n,t):e,!0),evaluateAsNormalExpression:(e,t)=>{let r=!0;for(const n of e)if(r=P(n,t),!r)break;return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1],t,n,a)},zt={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(a){if(a>=n.length)return null;const[o,i]=n[a];return ke(r(o,t),n=>n?r(i,t):e(a+1))}(0)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1].flat(),t,n,a)},Et={arity:{},docs:{category:"special-expression",customVariants:["switch value switch-branch switch-branch ... end"],details:[["value","any","The value to test."],["switch-branch","case test then body","A branch of the switch expression."],["test","expression","The condition to test."],["body","expressions","The expressions to evaluate if the test is truthy."]],description:"Used for branching. `switch-branches` are tested sequentially from the top against `value`. If no branch is tested truthy, `null` is returned.",examples:['\nswitch 1\n case 1 then write!("One")\n case 2 then write!("Two")\nend','\nswitch 2\n case 1 then write!("One")\n case 2 then write!("Two")\nend','\nswitch 3\n case 1 then write!("One")\n case 2 then write!("Two")\nend']},evaluate:(e,t,{evaluateNode:r})=>{const[,n,a]=e[1];return ke(r(n,t),e=>function n(o){if(o>=a.length)return null;const[i,s]=a[o];return ke(r(i,t),a=>a===e?r(s,t):n(o+1))}(0))},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r([e[1][1],...e[1][2].flat()],t,n,a)};function jt(e){const t=e[0];return s.UserDefinedSymbol===t||s.NormalBuiltinSymbol===t||s.SpecialBuiltinSymbol===t}function Mt(e){return s.UserDefinedSymbol===e[0]}function Ct(e,t){return function(e,t){if(!Mt(e))throw x("UserDefinedSymbolNode",e,t)}(e,t),e}function Rt(e){return s.NormalBuiltinSymbol===e[0]}function Pt(e){return s.SpecialBuiltinSymbol===e[0]}function It(e){return!!function(e){return e[0]===s.NormalExpression}(e)&&jt(e[1][0])}function Ot(e){return e[0]===s.Spread}const Ft={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?(+)"]},Ut={arity:Z(1),docs:Ft,evaluate:(e,t)=>{const r=e[1][1];if(function(e,t){if(!jt(e))throw x("SymbolNode",e,t)}(r),!Mt(r))return!0;return null!==t.lookUp(r)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r([e[1][1]],t,n,a)};const Dt=11,Gt=12,Wt=13,Vt=14;function Bt(e,t){if(e[0]===Wt)Object.values(e[1][0]).forEach(e=>{e[1][1]&&t(e[1][1]),Bt(e,t)});else if(e[0]===Vt)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]),Bt(n,t))}}function Lt(e,t,r){const n=e[2],a={};return ke(_t(e,t,r,n,a),()=>a)}function _t(e,t,n,a,o){if(e[0]===Wt){!function(e,t){if(!k(e))throw new r(`Expected UnknownRecord, got ${d(e)}.`,y(e,t))}(t,a);const i=new Set;let s;return ke(Se(Object.entries(e[1][0]),([e,r])=>{if(r[0]===Gt)return void(s=r);i.add(e);const c=t[e];return ke(void 0!==c?c:r[1][1]?n(r[1][1]):null,e=>{const t=e??null;return I(t,a),_t(r,t,n,a,o)})}),()=>{if(s){const e=Object.entries(t).filter(([e])=>!i.has(e)).reduce((e,[t,r])=>(e[t]=P(r),e),{});o[s[1][0]]=e}})}if(e[0]===Vt){let r=null;xe(t,a);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]===Gt){r=t;break}i.push({element:n,index:t})}}return ke(Se(i,({element:e,index:r})=>{const i=t[r];return ke(void 0!==i?i:e[1][1]?n(e[1][1]):null,t=>{const r=t??null;return I(r,a),_t(e,r,n,a,o)})}),()=>{if(null!==r){const n=t.slice(r),a=e[1][0][r];o[a[1][0]]=n}})}e[0]===Gt?o[e[1][0]]=P(t):o[e[1][0][1]]=P(t)}function Kt(e){const t={};return Jt(e,t),t}function Jt(e,t){if(null!==e)if(e[0]===Vt)for(const r of e[1][0])Jt(r,t);else if(e[0]===Wt)for(const r of Object.values(e[1][0]))Jt(r,t);else if(e[0]===Gt){if(t[e[1][0]])throw new r(`Duplicate binding name: ${e[1][0]}`,e[2]);t[e[1][0]]=!0}else{if(t[e[1][0][1]])throw new r(`Duplicate binding name: ${e[1][0]}`,e[2]);t[e[1][0][1]]=!0}}const Yt={arity:{},evaluate:(e,t,{evaluateNode:r})=>{const n=e[1][1],a=n[1][0],o=n[1][1];return ke(r(o,t),e=>ke(Lt(a,e,e=>r(e,t)),r=>(t.exportValues(r,a[2]),e)))},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>{const o=e[1][1],i=o[1][0],s=o[1][1],c=r([s],t,n,a);return Bt(i,e=>{de(c,r([e],t,n,a))}),t.addValues(Kt(i),i[2]),c}},Ht={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 $e(e[1][1],(e,t)=>r(t,n),null)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1],t.create({}),n,a)},Xt={arity:{},evaluate:(e,t,{builtin:r,getUndefinedSymbols:n,evaluateNode:a})=>{const o=e[1][1],i=e[1][2],s=function(e,t,r,n,a){const o={},i=e[0].reduce((e,t)=>(Object.keys(Kt(t)).forEach(t=>{e[t]={value:null}}),e),{}),s=n(e[1],t.new(i),r,a);s.forEach(e=>{const r=t.getValue(e);R(r)&&(o[e]={value:r})});const c=[e[0],e[1],o];return c}(o,t,r,n,a),c=s[0].filter(e=>e[0]!==Gt&&void 0===e[1][1]).length,l={min:c>0?c:void 0,max:s[0].some(e=>e[0]===Gt)?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:a})=>function(e,t,r,n,a){const o=new Set,i={self:{value:null}};e[0].forEach(e=>{Object.assign(i,Kt(e)),Bt(e,e=>{de(o,r([e],t,n,a))})});const s=t.create(i),c=r(e[1],s,n,a);return de(o,c),o}(e[1][1],t,r,n,a)};const Zt={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,a,o]=e[1][1];return ke(r(n,t),e=>e?r(a,t):o?r(o,t):null)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1].filter(e=>!!e),t,n,a)},Qt={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,a,o]=e[1][1];return ke(r(n,t),e=>e?o?r(o,t):null:r(a,t))},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1].filter(e=>!!e),t,n,a)},er={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)']},tr={arity:Z(0),docs:er,evaluate:(e,t,{evaluateNode:r})=>{const n=e[1][1],a=n[1][0],o=n[1][1];return ke(r(o,t),e=>ke(Lt(a,e,e=>r(e,t)),r=>(t.addValues(r,a[2]),e)))},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>{const o=e[1][1],i=o[1][0],s=o[1][1],c=r([s],t,n,a);return Bt(i,e=>{de(c,r([e],t,n,a))}),t.addValues(Kt(i),i[2]),c}},rr={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:a})=>{const o=e[1][1],i=$e(o,(e,t)=>ke(a(t[1][1],n.create(e)),r=>ke(Lt(t[1][0],r,e=>a(e,n)),t=>(Object.entries(t).forEach(([t,r])=>{e[t]={value:r}}),e))),{});return ke(i,i=>{const s=n.create(i),c=e[1][2];function l(t){if(t.length!==o.length)throw new r(`recur expected ${o.length} parameters, got ${d(t.length)}`,e[2]);return ke(Se(o,(e,r)=>ke(Lt(e[1][0],P(t[r]),e=>a(e,n)),e=>{for(const[t,r]of Object.entries(e))i[t].value=r})),()=>m())}function m(){return Ee(()=>a(c,s),e=>{if(e instanceof t)return l(e.params);throw e})}for(;;)try{const e=a(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!==o.length)throw new r(`recur expected ${o.length} parameters, got ${d(t.length)}`,e[2]);for(let e=0;e<o.length;e+=1){const r=Lt(o[e][1][0],P(t[e]),e=>a(e,n));if(r instanceof Promise)return r.then(r=>{for(const[e,t]of Object.entries(r))i[e].value=t;return ke(Se(o.slice(e+1),(r,o)=>ke(Lt(r[1][0],P(t[e+1+o]),e=>a(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:a})=>{const o=e[1][1],i=o.reduce((e,t)=>{const r=Kt(t[1][0]);return Object.keys(r).forEach(t=>{e[t]={value:!0}}),e},{});return he(r(o.map(e=>e[1][1]),t,n,a),r([e[1][2]],t.create(i),n,a))}};function nr(e,t,r,n){const a=t[2],[,o,i]=t[1],s=[],c=o.map(()=>0);return function t(){const l={},m=r.create(l);return ke(function e(t){if(t>=o.length)return"continue";const[r,i,s,u]=o[t],[p,g]=r[1];return ke(n(g,m),r=>{const o=V(r,a),g=O(o)?o:Object.entries(o);if(0===g.length)return"abort";const h=w(c[t],a);if(h>=g.length)return 0===t?"abort":(c[t]=0,c[t-1]=w(c[t-1],a)+1,"skip");const d=P(g[h],a);return ke(Lt(p,d,e=>n(e,m)),r=>(Object.entries(r).forEach(([e,t])=>{l[e]={value:t}}),ke(i.length>0?function(e,t,r,n){let a;for(const o of e)a=ke(a,()=>{const[e,a]=o[1];return ke(n(a,r),a=>ke(Lt(e,a,e=>n(e,r)),e=>{Object.entries(e).forEach(([e,r])=>{t[e]={value:r}})}))});return a}(i,l,m,n):void 0,()=>s?ke(n(s,m),r=>r?u?ke(n(u,m),r=>r?e(t+1):(c[t]=Number.POSITIVE_INFINITY,"skip")):e(t+1):(c[t]=w(c[t],a)+1,"skip")):u?ke(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():ke(n(i,m),r=>(e&&s.push(r),c.length>0&&(c[c.length-1]+=1),t())))}()}function ar(e,t,r,n,a){const o=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,a).forEach(e=>o.add(e)),Object.assign(i,Kt(u)),c&&c.forEach(e=>{const[s,c]=e[1];r([c],t.create(i),n,a).forEach(e=>o.add(e)),Object.assign(i,Kt(s))}),l&&r([l],t.create(i),n,a).forEach(e=>o.add(e)),m&&r([m],t.create(i),n,a).forEach(e=>o.add(e))}),r([c],t.create(i),n,a).forEach(e=>o.add(e)),o}const or={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 "]},ir={arity:Z(1),docs:or,evaluate:(e,t,r)=>nr(!0,e,t,r.evaluateNode),getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>ar(e,t,r,n,a)},sr={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 "]},cr={arity:Z(1),docs:sr,evaluate:(e,t,r)=>ke(nr(!1,e,t,r.evaluateNode),()=>null),getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>ar(e,t,r,n,a)},lr={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})=>$e(e[1][1],(e,n)=>e||r(n,t),!1),evaluateAsNormalExpression:(e,t)=>{let r=!1;for(const n of e)if(r=P(n,t),r)break;return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1],t,n,a)},mr={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 ke($e(e[1][1],(e,a)=>e!==n?e:Mt(a)&&null===t.lookUp(a)?n:ke(r(a,t),e=>null!==e?e:n),n),e=>e===n?null:e)},evaluateAsNormalExpression:(e,t)=>{for(const r of e){const e=P(r,t);if(null!==e)return e}return null},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1],t,n,a)},ur={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 !(zero?(n)) then\n recur(n - 1)\n end\nend;\nfoo(3)","\n(n -> do\n write!(n);\n if !(zero?(n)) then\n recur(n - 1)\n end\nend)(3)","\nloop (n = 3) -> do\n write!(n);\n if !(zero?(n)) then\n recur(n - 1)\n end\nend"]},evaluate:(e,r,{evaluateNode:n})=>ke(Ae(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:a})=>r(e[1][1],t,n,a)},pr={arity:Z(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})=>ke(r(e[1][1],t),t=>{const r=ne(t,e[2],{nonEmpty:!0});throw new n(r,e[2])}),evaluateAsNormalExpression:(e,t)=>{const r=ne(e[0],t,{nonEmpty:!0});throw new n(r,void 0)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r([e[1][1]],t,n,a)},gr={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,a,o]=e[1];return Ee(()=>r(n,t),e=>{const n=a?{[a[1]]:{value:e}}:{};return r(o,t.create(n))})},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>{const[,o,i,s]=e[1],c=r([o],t,n,a),l=i?{[i[1]]:{value:!0}}:{};return he(c,r([s],t.create(l),n,a))}},hr={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 a=[];return ke(Se(e[1][1],e=>Ot(e)?ke(n(e[1],t),t=>{if(!Array.isArray(t))throw new r("Spread value is not an array",e[2]);a.push(...t)}):ke(n(e,t),e=>{a.push(e)})),()=>a)},evaluateAsNormalExpression:(e,t)=>{const r=[];for(const n of e)r.push(P(n,t));return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1],t,n,a)},dr={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 a={},o=e[1][1];return function e(i){if(i>=o.length)return a;const s=o[i];if(Ot(s))return ke(n(s[1],t),t=>{if(!k(t))throw new r("Spread value is not an object",s[2]);return Object.assign(a,t),e(i+1)});{const c=o[i+1];if(void 0===c)throw new r("Missing value for key",s[2]);return ke(n(s,t),r=>ke(n(c,t),t=>(re(r,s[2]),a[r]=t,e(i+2))))}}(0)},evaluateAsNormalExpression:(e,t)=>{const r={};for(let n=0;n<e.length;n+=2){const a=e[n],o=e[n+1];re(a,t),r[a]=o??null}return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:a})=>r(e[1][1],t,n,a)},yr={"??":0,"&&":1,"||":2,array:3,cond:4,"0_def":5,"defined?":6,block:7,doseq:8,"0_lambda":9,for:10,if:11,let:12,loop:13,object:14,recur:15,switch:16,throw:17,try:18,unless:19},vr=[mr,St,lr,hr,zt,Yt,Ut,Ht,cr,Xt,ir,Zt,tr,rr,dr,ur,Et,pr,gr,Qt],fr={normalExpressions:Nt,specialExpressions:vr,allNormalExpressions:Tt},br=Object.keys(Nt),xr=Object.keys(yr),wr=["^","*","/","%","+","-","<<",">>",">>>","++","<","<=","≤",">",">=","≥","==","!=","≠","&","xor","|","&&","||","??","|>"],qr=[...wr,"?",":","->","...",".",",","=",":",";"],kr=new Set(["comment","cond","def","defined?","block","doseq","if","let","loop","recur","throw","try","unless","while"]);function Ar(e){return!kr.has(e)}const Nr=new Set(wr);function $r(e){return Nr.has(e)}const Tr=new Set(qr);function Sr(e){return Tr.has(e)}const zr=["number","string","object","array","vector","matrix","grid","boolean","function","integer","any","null","collection","sequence","regexp","never"];function Er(e){return zr.includes(e)}function jr(e){return"args"in e&&"variants"in e}const Mr={assert:{category:"assert",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:['let { assert } = import("assert");\ntry assert(0, "Expected a positive value") catch (e) e.message end'],seeAlso:["assert.assert-truthy","assert.assert-true"],hideOperatorForm:!0},"assert!=":{category:"assert",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("assert");\ntry assert!=(0, 0, "Expected different values") catch (e) e.message end','let { assert!= } = import("assert");\ntry assert!=(0, 0) catch (e) e.message end','let { assert!= } = import("assert");\ntry 0 assert!= 0 catch (e) e.message end','let { assert!= } = import("assert");\ntry assert!=(0, 1) catch (e) e.message end'],seeAlso:["assert.assert="],hideOperatorForm:!0},"assert=":{category:"assert",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("assert");\ntry assert=({ "a": 1 }, { "a": 2 }, "Expected equal values") catch (e) e.message end','let { assert= } = import("assert");\ntry assert=({ "a": 1 }, { "a": 2 }) catch (e) e.message end','let { assert= } = import("assert");\ntry assert=({ "a": 1 }, { "a": 1 }) catch (e) e.message end'],seeAlso:["assert.assert!="],hideOperatorForm:!0},"assert-gt":{category:"assert",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("assert");\ntry assert-gt(0, 1, "Expected greater value") catch (e) e.message end','let { assert-gt } = import("assert");\ntry assert-gt(0, 0) catch (e) e.message end','let { assert-gt } = import("assert");\ntry assert-gt(1, 0) catch (e) e.message end'],seeAlso:["assert.assert-lt","assert.assert-gte","assert.assert-lte"],hideOperatorForm:!0},"assert-lt":{category:"assert",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("assert");\ntry assert-lt(1, 0, "Expected smaller value value") catch (e) e.message end','let { assert-lt } = import("assert");\ntry assert-lt(1, 1) catch (e) e.message end','let { assert-lt } = import("assert");\ntry assert-lt(0, 1) catch (e) e.message end'],seeAlso:["assert.assert-gt","assert.assert-lte","assert.assert-gte"],hideOperatorForm:!0},"assert-gte":{category:"assert",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("assert");\ntry assert-gte(0, 1, "Expected greater value") catch (e) e.message end','let { assert-gte } = import("assert");\ntry assert-gte(0, 1) catch (e) e.message end','let { assert-gte } = import("assert");\ntry assert-gte(1, 1) catch (e) e.message end'],seeAlso:["assert.assert-lte","assert.assert-gt","assert.assert-lt"],hideOperatorForm:!0},"assert-lte":{category:"assert",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("assert");\ntry assert-lte(1, 0, "Expected smaller value value") catch (e) e.message end','let { assert-lte } = import("assert");\ntry assert-lte(1, 0) catch (e) e.message end','let { assert-lte } = import("assert");\ntry assert-lte(1, 1) catch (e) e.message end'],seeAlso:["assert.assert-gte","assert.assert-lt","assert.assert-gt"],hideOperatorForm:!0},"assert-true":{category:"assert",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("assert");\ntry assert-true(false, "Expected true") catch (e) e.message end','let { assert-true } = import("assert");\ntry assert-true(false) catch (e) e.message end','let { assert-true } = import("assert");\ntry assert-true(true) catch (e) e.message end'],seeAlso:["assert.assert-false","assert.assert-truthy","assert.assert-falsy","assert.assert","assert.assert-boolean"],hideOperatorForm:!0},"assert-false":{category:"assert",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("assert");\ntry assert-false(true, "Expected false") catch (e) e.message end','let { assert-false } = import("assert");\ntry assert-false(true) catch (e) e.message end','let { assert-false } = import("assert");\ntry assert-false(false) catch (e) e.message end'],seeAlso:["assert.assert-true","assert.assert-falsy","assert.assert-truthy","assert.assert-boolean"],hideOperatorForm:!0},"assert-truthy":{category:"assert",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("assert");\ntry assert-truthy(false, "Expected truthy") catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy(false) catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy(0) catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy(null) catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy("") catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy(true) catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy(1) catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy("x") catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy([]) catch (e) e.message end','let { assert-truthy } = import("assert");\ntry assert-truthy(nd) catch (e) e.message end'],seeAlso:["assert.assert-falsy","assert.assert-true","assert.assert-false","assert.assert","assert.assert-null"],hideOperatorForm:!0},"assert-falsy":{category:"assert",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("assert");\ntry assert-falsy(true, "Expected falsy") catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy("x") catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy([]) catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy(nd) catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy(1) catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy(false) catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy(0) catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy(null) catch (e) e.message end','let { assert-falsy } = import("assert");\ntry assert-falsy("") catch (e) e.message end'],seeAlso:["assert.assert-truthy","assert.assert-false","assert.assert-true","assert.assert-null"],hideOperatorForm:!0},"assert-null":{category:"assert",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("assert");\ntry assert-null(null) catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null(true, "Expected null") catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null("x") catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null([]) catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null(nd) catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null(1) catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null(false) catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null(0) catch (e) e.message end','let { assert-null } = import("assert");\ntry assert-null("") catch (e) e.message end'],seeAlso:["assert.assert-truthy","assert.assert-falsy"],hideOperatorForm:!0},"assert-throws":{category:"assert",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("assert");\nassert-throws(-> throw("Error"))','let { assert-throws } = import("assert");\ntry assert-throws(-> identity("Error")) catch (e) e.message end'],seeAlso:["assert.assert-throws-error","assert.assert-not-throws"],hideOperatorForm:!0},"assert-throws-error":{category:"assert",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("assert");\ntry assert-throws-error(-> throw("Error"), "Error") catch (e) e.message end','let { assert-throws-error } = import("assert");\ntry assert-throws-error(-> identity("Error"), "Error") catch (e) e.message end'],seeAlso:["assert.assert-throws","assert.assert-not-throws"],hideOperatorForm:!0},"assert-not-throws":{category:"assert",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("assert");\ntry assert-not-throws(-> identity("Error")) catch (e) e.message end','let { assert-not-throws } = import("assert");\ntry assert-not-throws(-> throw("Error")) catch (e) e.message end'],seeAlso:["assert.assert-throws","assert.assert-throws-error"],hideOperatorForm:!0},"assert-array":{category:"assert",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("assert");\ntry assert-array([1, 2, 3]) catch (e) e.message end','let { assert-array } = import("assert");\ntry assert-array("string") catch (e) e.message end','let { assert-array } = import("assert");\ntry assert-array(42, "Expected an array") catch (e) e.message end'],seeAlso:["assert.assert-object","assert.assert-collection","assert.assert-sequence"],hideOperatorForm:!0},"assert-boolean":{category:"assert",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("assert");\ntry assert-boolean(true) catch (e) e.message end','let { assert-boolean } = import("assert");\ntry assert-boolean(false) catch (e) e.message end','let { assert-boolean } = import("assert");\ntry assert-boolean(1, "Expected a boolean") catch (e) e.message end'],seeAlso:["assert.assert-true","assert.assert-false","assert.assert-number","assert.assert-string"],hideOperatorForm:!0},"assert-collection":{category:"assert",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("assert");\ntry assert-collection([1, 2]) catch (e) e.message end','let { assert-collection } = import("assert");\ntry assert-collection({ a: 1 }) catch (e) e.message end','let { assert-collection } = import("assert");\ntry assert-collection("hello") catch (e) e.message end','let { assert-collection } = import("assert");\ntry assert-collection(42, "Expected a collection") catch (e) e.message end'],seeAlso:["assert.assert-sequence","assert.assert-array","assert.assert-object"],hideOperatorForm:!0},"assert-function":{category:"assert",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("assert");\ntry assert-function(-> $ + 1) catch (e) e.message end','let { assert-function } = import("assert");\ntry assert-function(42, "Expected a function") catch (e) e.message end'],seeAlso:["assert.assert-number","assert.assert-string"],hideOperatorForm:!0},"assert-grid":{category:"assert",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("assert");\ntry assert-grid([[1, 2], [3, 4]]) catch (e) e.message end','let { assert-grid } = import("assert");\ntry assert-grid([1, 2], "Expected a grid") catch (e) e.message end'],seeAlso:["assert.assert-matrix","assert.assert-vector"],hideOperatorForm:!0},"assert-integer":{category:"assert",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("assert");\ntry assert-integer(42) catch (e) e.message end','let { assert-integer } = import("assert");\ntry assert-integer(3.14, "Expected an integer") catch (e) e.message end'],seeAlso:["assert.assert-number"],hideOperatorForm:!0},"assert-matrix":{category:"assert",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("assert");\ntry assert-matrix([[1, 2], [3, 4]]) catch (e) e.message end','let { assert-matrix } = import("assert");\ntry assert-matrix([1, 2], "Expected a matrix") catch (e) e.message end'],seeAlso:["assert.assert-vector","assert.assert-grid"],hideOperatorForm:!0},"assert-number":{category:"assert",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("assert");\ntry assert-number(42) catch (e) e.message end','let { assert-number } = import("assert");\ntry assert-number("hello", "Expected a number") catch (e) e.message end'],seeAlso:["assert.assert-integer","assert.assert-boolean","assert.assert-string","assert.assert-function"],hideOperatorForm:!0},"assert-object":{category:"assert",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("assert");\ntry assert-object({ a: 1 }) catch (e) e.message end','let { assert-object } = import("assert");\ntry assert-object([1, 2], "Expected an object") catch (e) e.message end'],seeAlso:["assert.assert-array","assert.assert-collection"],hideOperatorForm:!0},"assert-regexp":{category:"assert",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("assert");\ntry assert-regexp(#"^start") catch (e) e.message end','let { assert-regexp } = import("assert");\ntry assert-regexp("hello", "Expected a regexp") catch (e) e.message end'],seeAlso:["assert.assert-string"],hideOperatorForm:!0},"assert-sequence":{category:"assert",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("assert");\ntry assert-sequence([1, 2]) catch (e) e.message end','let { assert-sequence } = import("assert");\ntry assert-sequence("hello") catch (e) e.message end','let { assert-sequence } = import("assert");\ntry assert-sequence({ a: 1 }, "Expected a sequence") catch (e) e.message end'],seeAlso:["assert.assert-collection","assert.assert-array"],hideOperatorForm:!0},"assert-string":{category:"assert",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("assert");\ntry assert-string("hello") catch (e) e.message end','let { assert-string } = import("assert");\ntry assert-string(42, "Expected a string") catch (e) e.message end'],seeAlso:["assert.assert-number","assert.assert-boolean","assert.assert-regexp","assert.assert-function"],hideOperatorForm:!0},"assert-vector":{category:"assert",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("assert");\ntry assert-vector([1, 2, 3]) catch (e) e.message end','let { assert-vector } = import("assert");\ntry assert-vector(["a", "b"], "Expected a vector") catch (e) e.message end'],seeAlso:["assert.assert-matrix","assert.assert-grid"],hideOperatorForm:!0}},Cr={assert:{evaluate:(e,t)=>{const r=e[0],n=2===e.length?e[1]:`${r}`;if(re(n,t),!r)throw new a(n,t);return P(r,t)},arity:{min:1,max:2}},"assert=":{evaluate:([e,t,r],n)=>{if(void 0!==r&&(re(r,n),r=` ${r}`),r??="",!le(P(e,n),P(t,n),n))throw new a(`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&&(re(r,n),r=` ${r}`),r??="",le(P(e,n),P(t,n),n))throw new a(`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(ie(e,n),ie(t,n),void 0!==r&&(re(r,n),r=` ${r}`),r??="",ce(e,t,n)<=0)throw new a(`Expected ${e} to be grater than ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-gte":{evaluate:([e,t,r],n)=>{if(ie(e,n),ie(t,n),void 0!==r&&(re(r,n),r=` ${r}`),r??="",ce(e,t,n)<0)throw new a(`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(ie(e,n),ie(t,n),void 0!==r&&(re(r,n),r=` ${r}`),r??="",ce(e,t,n)>=0)throw new a(`Expected ${e} to be less than ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-lte":{evaluate:([e,t,r],n)=>{if(ie(e,n),ie(t,n),void 0!==r&&(re(r,n),r=` ${r}`),r??="",ce(e,t,n)>0)throw new a(`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&&(re(t,r),t=` ${t}`),t??="",!0!==e)throw new a(`Expected ${e} to be true.${t}`,r);return null},arity:{min:1,max:2}},"assert-false":{evaluate:([e,t],r)=>{if(void 0!==t&&(re(t,r),t=` ${t}`),t??="",!1!==e)throw new a(`Expected ${e} to be false.${t}`,r);return null},arity:{min:1,max:2}},"assert-truthy":{evaluate:([e,t],r)=>{if(void 0!==t&&(re(t,r),t=` ${t}`),t??="",!e)throw new a(`Expected ${e} to be truthy.${t}`,r);return null},arity:{min:1,max:2}},"assert-falsy":{evaluate:([e,t],r)=>{if(void 0!==t&&(re(t,r),t=` ${t}`),t??="",e)throw new a(`Expected ${e} to be falsy.${t}`,r);return null},arity:{min:1,max:2}},"assert-null":{evaluate:([e,t],r)=>{if(void 0!==t&&(re(t,r),t=` ${t}`),t??="",null!==e)throw new a(`Expected ${e} to be null.${t}`,r);return null},arity:{min:1,max:2}},"assert-throws":{evaluate:([e,t],r,n,{executeFunction:o})=>(void 0!==t&&(re(t,r),t=` ${t}`),t??="",J(e,r),Ee(()=>ke(o(e,[],n,r),()=>{throw new a(`Expected function to throw.${t}`,r)}),()=>null)),arity:{min:1,max:2}},"assert-throws-error":{evaluate:([e,t,r],n,o,{executeFunction:i})=>(void 0!==r&&(re(r,n),r=` ${r}`),r??="",re(t,n),J(e,n),Ee(()=>ke(i(e,[],o,n),()=>{throw new a(`Expected function to throw "${t}".${r}`,n)}),e=>{const o=e.shortMessage;if(o!==t)throw new a(`Expected function to throw "${t}", but thrown "${o}".${r}`,n);return null})),arity:{min:2,max:3}},"assert-not-throws":{evaluate:([e,t],r,n,{executeFunction:o})=>(void 0!==t&&(re(t,r),t=` ${t}`),t??="",J(e,r),Ee(()=>ke(o(e,[],n,r),()=>null),()=>{throw new a(`Expected function not to throw.${t}`,r)})),arity:{min:1,max:2}},"assert-array":{evaluate:([e,t],r)=>{if(void 0!==t&&(re(t,r),t=` ${t}`),t??="",!Array.isArray(e))throw new a(`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&&(re(t,r),t=` ${t}`),t??="","boolean"!=typeof e)throw new a(`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&&(re(t,r),t=` ${t}`),t??="",!W(e))throw new a(`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&&(re(t,r),t=` ${t}`),t??="",!A(e))throw new a(`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&&(re(t,r),t=` ${t}`),t??="",!tt(e))throw new a(`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&&(re(t,r),t=` ${t}`),t??="","number"!=typeof e||!v(e,{integer:!0}))throw new a(`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&&(re(t,r),t=` ${t}`),t??="",!nt(e))throw new a(`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&&(re(t,r),t=` ${t}`),t??="","number"!=typeof e)throw new a(`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&&(re(t,r),t=` ${t}`),t??="",!D(e))throw new a(`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&&(re(t,r),t=` ${t}`),t??="",!L(e))throw new a(`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&&(re(t,r),t=` ${t}`),t??="",!O(e))throw new a(`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&&(re(t,r),t=` ${t}`),t??="","string"!=typeof e)throw new a(`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&&(re(t,r),t=` ${t}`),t??="",!He(e))throw new a(`Expected ${JSON.stringify(e)} to be a vector.${t}`,r);return null},arity:{min:1,max:2}}};for(const[e,t]of Object.entries(Mr))Cr[e]&&(Cr[e].docs=t);const Rr={name:"assert",functions:Cr},Pr={"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:['// Using "as" alias because "every?" shadows a builtin function\nlet { every? as grid-every? } = import("grid");\ngrid-every?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], string?)','// Using "as" alias because "every?" shadows a builtin function\nlet { every? as grid-every? } = import("grid");\ngrid-every?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], string?)','// Using "as" alias because "every?" shadows a builtin function\nlet { every? as grid-every? } = import("grid");\ngrid-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.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.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.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","vector.fill"]},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","vector.generate"]},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","grid.reverse-cols"]},"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","grid.reverse-rows"]},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"]},"reverse-rows":{category:"grid",description:"Reverses the order of rows in the grid `g`.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to reverse rows."}},variants:[{argumentNames:["g"]}],examples:['let { reverse-rows } = import("grid");\nreverse-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { reverse-rows } = import("grid");\nreverse-rows([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])','let { reverse-rows } = import("grid");\nreverse-rows([\n [1, 2],\n [3, 4],\n])'],seeAlso:["grid.reverse-cols","grid.flip-v"]},"reverse-cols":{category:"grid",description:"Reverses the order of columns in the grid `g`.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to reverse columns."}},variants:[{argumentNames:["g"]}],examples:['let { reverse-cols } = import("grid");\nreverse-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { reverse-cols } = import("grid");\nreverse-cols([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])','let { reverse-cols } = import("grid");\nreverse-cols([\n [1, 2],\n [3, 4],\n])'],seeAlso:["grid.reverse-rows","grid.flip-h"]},slice:{category:"grid",description:"Slices 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:"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:['// Using "as" alias because "slice" shadows a builtin function\nlet { slice as grid-slice } = import("grid");\ngrid-slice([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [1, 1], [2, 2])','// Using "as" alias because "slice" shadows a builtin function\nlet { slice as grid-slice } = import("grid");\ngrid-slice([\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.slice","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.slice","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"]},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:['// Using "as" alias because "map" shadows a builtin function\nlet { map as grid-map } = import("grid");\ngrid-map([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], str)'],seeAlso:["map","grid.mapi","grid.reduce"]},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:['// Using "as" alias because "mapi" shadows a builtin function\nlet { mapi as grid-mapi } = import("grid");\ngrid-mapi([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $1 ++ "(" ++ $2 ++ ", " ++ $3 ++ ")")'],seeAlso:["grid.map","grid.reducei","map"]},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 { reduce as grid-reduce } = import("grid");\ngrid-reduce([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ++, "")'],seeAlso:["reduce","grid.reducei","grid.map"]},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 { reducei as grid-reducei } = import("grid");\ngrid-reducei([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ++, "")'],seeAlso:["grid.reduce","grid.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 Ir(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 Or={"every?":{evaluate:([e,t],r,n,{executeFunction:a})=>{rt(e,r),J(t,r);const o=[];for(const t of e)for(const e of t)o.push(e);return Ce(o,e=>a(t,[e],n,r))},arity:Z(2)},"some?":{evaluate:([e,t],r,n,{executeFunction:a})=>{rt(e,r),J(t,r);const o=[];for(const t of e)for(const e of t)o.push(e);return je(o,e=>a(t,[e],n,r))},arity:Z(2)},"every-row?":{evaluate:([e,t],r,n,{executeFunction:a})=>(rt(e,r),J(t,r),Ce(Array.from(e),e=>a(t,[e],n,r))),arity:Z(2)},"some-row?":{evaluate:([e,t],r,n,{executeFunction:a})=>(rt(e,r),J(t,r),je(Array.from(e),e=>a(t,[e],n,r))),arity:Z(2)},"every-col?":{evaluate:([e,t],r,n,{executeFunction:a})=>{rt(e,r),J(t,r);const o=Ir(e);return Ce(Array.from(o),e=>a(t,[e],n,r))},arity:Z(2)},"some-col?":{evaluate:([e,t],r,n,{executeFunction:a})=>{rt(e,r),J(t,r);const o=Ir(e);return je(Array.from(o),e=>a(t,[e],n,r))},arity:Z(2)},row:{evaluate:([e,t],r)=>(rt(e,r),f(t,r,{integer:!0,nonNegative:!0,lt:e.length}),e[t]),arity:Z(2)},col:{evaluate:([e,t],r)=>(rt(e,r),f(t,r,{integer:!0,nonNegative:!0,lt:e[0].length}),e.map(e=>e[t])),arity:Z(2)},shape:{evaluate:([e],t)=>(rt(e,t),[e.length,e[0].length]),arity:Z(1)},fill:{evaluate:([e,t,r],n)=>{f(e,n,{integer:!0,positive:!0}),f(t,n,{integer:!0,positive:!0}),I(r,n);const a=[];for(let n=0;n<e;n+=1){const e=[];for(let n=0;n<t;n+=1)e.push(r);a.push(e)}return a},arity:Z(3)},generate:{evaluate:([e,t,r],n,a,{executeFunction:o})=>(f(e,n,{integer:!0,positive:!0}),f(t,n,{integer:!0,positive:!0}),J(r,n),Ae(Array.from({length:e}),(e,i)=>Ae(Array.from({length:t}),(e,t)=>ke(o(r,[i,t],a,n),e=>(I(e,n),e))))),arity:Z(3)},reshape:{evaluate:([e,t],n)=>{rt(e,n),f(t,n,{integer:!0,positive:!0});const a=e.flat();if(a.length%t!==0)throw new r(`The number of elements in the grid must be divisible by rows, but got ${a.length} and ${t}`,n);const o=a.length/t,i=[];for(let e=0;e<t;e+=1){const t=[];for(let r=0;r<o;r+=1)t.push(a[e*o+r]);i.push(t)}return i},arity:Z(2)},transpose:{evaluate:([e],t)=>(rt(e,t),Ir(e)),arity:Z(1)},"flip-h":{evaluate:([e],t)=>(rt(e,t),e.map(e=>e.reverse())),arity:Z(1)},"flip-v":{evaluate:([e],t)=>(rt(e,t),e.reverse()),arity:Z(1)},rotate:{evaluate:([e,t],r)=>{if(rt(e,r),f(t,r,{integer:!0}),0===(t=(t%4+4)%4)||0===e.length)return e.map(e=>[...e]);const n=e.length,a=e[0].length;let o;switch(t){case 1:o=Array(a).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<a;r++)o[r][n-1-t]=e[t][r];break;case 2:o=Array(n).fill(null).map(()=>Array(a).fill(null));for(let t=0;t<n;t++)for(let r=0;r<a;r++)o[n-1-t][a-1-r]=e[t][r];break;case 3:o=Array(a).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<a;r++)o[a-1-r][t]=e[t][r]}return o},arity:Z(2)},"reverse-rows":{evaluate:([e],t)=>(rt(e,t),e.reverse()),arity:Z(1)},"reverse-cols":{evaluate:([e],t)=>(rt(e,t),e.map(e=>e.reverse())),arity:Z(1)},slice:{evaluate:([e,t,n],a)=>{if(rt(e,a),Xe(t,a),2!==t.length)throw new r(`The start vector must have 2 elements, but got ${t.length}`,a);const[o,i]=t;if(f(o,a,{integer:!0,nonNegative:!0,lt:e.length}),f(i,a,{integer:!0,nonNegative:!0,lt:e[0].length}),n??=[e.length,e[0].length],Xe(n,a),2!==n.length)throw new r(`The end vector must have 2 elements, but got ${n.length}`,a);const[s,c]=n;f(s,a,{gt:o,lte:e.length}),f(c,a,{gt:i,lte:e[0].length});const l=[];for(let t=o;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)=>(rt(e,n),void 0===r?(f(t,n,{integer:!0,lte:e.length,gte:-e.length}),t<0?e.slice(e.length+t):e.slice(t)):(f(t,n,{integer:!0,nonNegative:!0,lte:e.length}),f(r,n,{integer:!0}),f(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)=>{rt(e,n);const a=Ir(e);return void 0===r?(f(t,n,{integer:!0,lte:a.length,gte:-a.length}),Ir(t<0?a.slice(a.length+t):a.slice(t))):(f(t,n,{integer:!0,nonNegative:!0,lte:a.length}),f(r,n,{integer:!0}),f(r=r<0?a.length+r:r,n,{gt:t,lte:a.length}),Ir(a.slice(t,r)))},arity:{min:2,max:3}},"splice-rows":{evaluate:([e,t,n,...a],o)=>{rt(e,o),f(t,o,{integer:!0,nonNegative:!0,lte:e.length}),f(n,o,{integer:!0,nonNegative:!0}),0!==a.length&&(rt(a,o),a.every(t=>{if(xe(t,o),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}`,o);return!0}));const i=[];for(let r=0;r<t;r+=1)i.push(e[r]);a.length>0&&i.push(...a);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,...a],o)=>{rt(e,o);const i=Ir(e);f(t,o,{integer:!0,nonNegative:!0,lte:i.length}),f(n,o,{integer:!0,nonNegative:!0}),0!==a.length&&(rt(a,o),a.every(e=>{if(xe(e,o),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}`,o);return!0}));const s=[];for(let e=0;e<t;e+=1)s.push(i[e]);s.push(...a);for(let e=t+n;e<i.length;e+=1)s.push(i[e]);return Ir(s)},arity:{min:3}},"concat-rows":{evaluate:(e,t)=>{xe(e,t),e.every(e=>rt(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 a=[];return e.forEach(e=>{e.forEach(e=>{a.push(e)})}),a},arity:{min:1}},"concat-cols":{evaluate:(e,t)=>{xe(e,t),e.every(e=>rt(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 a=[];for(let t=0;t<n;t+=1){const r=[];e.forEach(e=>{r.push(...e[t])}),a.push(r)}return a},arity:{min:1}},map:{evaluate:(e,t,n,{executeFunction:a})=>{const o=K(e.at(-1),t),i=e.slice(0,-1);rt(i[0],t);const s=i[0].length,c=i[0][0].length;return i.slice(1).forEach(e=>{if(rt(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)}),Ae(Array.from({length:s}),(e,r)=>Ae(Array.from({length:c}),(e,s)=>{const c=i.map(e=>e[r][s]);return ke(a(o,c,n,t),e=>P(e))}))},arity:{min:2}},mapi:{evaluate:([e,t],r,n,{executeFunction:a})=>{rt(e,r),J(t,r);const o=e.length,i=e[0].length;return Ae(Array.from({length:o}),(o,s)=>Ae(Array.from({length:i}),(o,i)=>ke(a(t,[e[s][i],s,i],n,r),e=>P(e))))},arity:Z(2)},reduce:{evaluate:([e,t,r],n,a,{executeFunction:o})=>{rt(e,n),J(t,n);const i=[];for(const t of e)for(const e of t)i.push(e);return $e(i,(e,r)=>o(t,[e,r],a,n),P(r))},arity:Z(3)},reducei:{evaluate:([e,t,r],n,a,{executeFunction:o})=>{rt(e,n),J(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 $e(i,(e,{cell:r,i:i,j:s})=>o(t,[e,r,i,s],a,n),P(r))},arity:Z(3)},"push-rows":{evaluate:([e,...t],n)=>{if(rt(e,n),rt(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(rt(e,n),rt(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)=>(rt(e,t),1===e.length?null:e.slice(0,-1)),arity:Z(1)},"shift-row":{evaluate:([e],t)=>(rt(e,t),1===e.length?null:e.slice(1)),arity:Z(1)},"push-cols":{evaluate:([e,...t],n)=>{if(rt(e,n),rt(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 a=[];for(let r=0;r<e.length;r+=1){const n=[];n.push(...e[r]),t.forEach(e=>{n.push(e[r])}),a.push(n)}return a},arity:{min:2}},"unshift-cols":{evaluate:([e,...t],n)=>{if(rt(e,n),rt(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 a=[];for(let r=0;r<e.length;r+=1){const n=[];t.forEach(e=>{n.push(e[r])}),n.push(...e[r]),a.push(n)}return a},arity:{min:2}},"pop-col":{evaluate:([e],t)=>(rt(e,t),1===e[0].length?null:e.map(e=>e.slice(0,-1))),arity:Z(1)},"shift-col":{evaluate:([e],t)=>(rt(e,t),1===e[0].length?null:e.map(e=>e.slice(1))),arity:Z(1)},"from-array":{evaluate:([e,t],n)=>{if(xe(e,n),f(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 a=0;a<t;a++){const t=a*n,o=t+n;r.push(e.slice(t,o))}return r}(e,t)},arity:Z(2)}};for(const[e,t]of Object.entries(Pr))Or[e]&&(Or[e].docs=t);const Fr={name:"grid",functions:Or},Ur={"random!":{category:"random",description:"Returns a random number between 0 and 1.",returns:{type:"number"},args:{},variants:[{argumentNames:[]}],examples:['let { random! } = import("random"); random!()'],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"); random-int!(0, 10)','let { random-int! } = import("random"); random-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"); random-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"); random-float!(0, 10)','let { random-float! } = import("random"); random-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"); random-boolean!()','let { random-boolean! } = import("random"); random-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"); random-item!([1, 2, 3, 4, 5])','let { random-item! } = import("random"); random-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"); random-sample-unique!([1, 2, 3, 4, 5], 3)','let { random-sample-unique! } = import("random"); random-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"); random-sample!([1, 2, 3, 4, 5], 3)','let { random-sample! } = import("random"); random-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"); shuffle!([1, 2, 3, 4, 5])','let { shuffle! } = import("random"); shuffle!(["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"); random-normal!(0, 1)','let { random-normal! } = import("random"); random-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"); random-exponential!(1)','let { random-exponential! } = import("random"); random-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"); random-binomial!(10, 0.5)','let { random-binomial! } = import("random"); random-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"); random-poisson!(1)','let { random-poisson! } = import("random"); random-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"); random-gamma!(2, 2)','let { random-gamma! } = import("random"); random-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"); random-pareto!(1)','let { random-pareto! } = import("random"); random-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"); uuid!()'],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"); random-char!("abcde")','let { random-char! } = import("random"); random-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"); random-string!(10, "abcde")','let { random-string! } = import("random"); random-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"); random-id!(10)','let { random-id! } = import("random"); random-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"); random-color!()']}},Dr={"random!":{evaluate:()=>Math.random(),arity:Z(0)},"random-int!":{evaluate:([e,t],r)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0,gt:e}),Math.floor(Math.random()*(t-e))+e),arity:Z(2)},"random-int-inclusive!":{evaluate:([e,t],r)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0,gte:e}),Math.floor(Math.random()*(t-e+1))+e),arity:Z(2)},"random-float!":{evaluate:([e,t],r)=>(f(e,r),f(t,r,{gt:e}),Math.random()*(t-e)+e),arity:Z(2)},"random-boolean!":{evaluate:([e],t)=>{const r=e??.5;return f(r,t,{gte:0,lte:1}),Math.random()<r},arity:{min:0,max:1}},"random-item!":{evaluate:([e],t)=>{xe(e,t);return P(e[Math.floor(Math.random()*e.length)])},arity:Z(1)},"random-sample!":{evaluate:([e,t],n)=>{if(xe(e,n),f(t,n,{integer:!0,nonNegative:!0}),0===e.length)throw new r("Cannot sample from an empty array.",n);const a=[];for(let r=0;r<t;r++){const t=Math.floor(Math.random()*e.length);a.push(e[t])}return a},arity:Z(2)},"random-sample-unique!":{evaluate:([e,t],n)=>{if(xe(e,n),f(t,n,{integer:!0,nonNegative:!0,lte:e.length}),0===e.length)throw new r("Cannot sample from an empty array.",n);const a=[],o=[...e];for(let e=0;e<t;e++){const e=Math.floor(Math.random()*o.length);a.push(o[e]),o.splice(e,1)}return a},arity:Z(2)},"shuffle!":{evaluate:([e],t)=>{xe(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},arity:Z(1)},"random-normal!":{evaluate:([e,t],r)=>{f(e,r),f(t,r,{gt:0});const n=Math.random(),a=Math.random();return Math.sqrt(-2*Math.log(n))*Math.cos(2*Math.PI*a)*t+e},arity:Z(2)},"random-exponential!":{evaluate:([e],t)=>{f(e,t,{gt:0});const r=Math.random();return-Math.log(r)/e},arity:Z(1)},"random-binomial!":{evaluate:([e,t],r)=>{f(e,r,{integer:!0,nonNegative:!0}),f(t,r,{gte:0,lte:1});let n=0;for(let r=0;r<e;r++)Math.random()<t&&n++;return n},arity:Z(2)},"random-poisson!":{evaluate:([e],t)=>{f(e,t,{gt:0});const r=Math.exp(-e);let n=0,a=1;do{n++,a*=Math.random()}while(a>r);return n-1},arity:Z(1)},"random-gamma!":{evaluate:([e,t],r)=>(f(e,r,{gt:0}),f(t,r,{gt:0}),Gr(e,t)),arity:Z(2)},"random-pareto!":{evaluate:([e],t)=>{f(e,t,{gt:0});return(1/Math.random())**(1/e)},arity:Z(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)}),arity:Z(0)},"random-char!":{evaluate:([e],t)=>{if(re(e,t),0===e.length)throw new r("Character set cannot be empty.",t);return e[Math.floor(Math.random()*e.length)]},arity:Z(1)},"random-string!":{evaluate:([e,t],n)=>{if(f(e,n,{integer:!0,positive:!0}),re(t,n),0===t.length)throw new r("Character set cannot be empty.",n);let a="";for(let r=0;r<e;r++){a+=t[Math.floor(Math.random()*t.length)]}return a},arity:Z(2)},"random-id!":{evaluate:([e],t)=>{f(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},arity:Z(1)},"random-color!":{evaluate:()=>`#${Math.floor(16777216*Math.random()).toString(16).padStart(6,"0")}`,arity:Z(0)}};function Gr(e,t=1){if(e<1){return Gr(e+1-1/3,t)*Math.random()**(1/e)}const r=e-1/3,n=1/Math.sqrt(9*r);let a,o,i;for(;;){do{a=Wr(),o=1+n*a}while(o<=0);if(o*=o*o,i=Math.random(),i<1-.0331*a*a*a*a)return t*r*o;if(Math.log(i)<.5*a*a+r*(1-o+Math.log(o)))return t*r*o}}function Wr(){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(Ur))Dr[e]&&(Dr[e].docs=t);const Vr={name:"random",functions:Dr},Br={mean:{category:"vector",description:"Returns the **mean** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **mean** of."}},variants:[{argumentNames:["vector"]}],examples:["mean([1, 2, 3])","mean([1, 2, -3])"],seeAlso:["mean","vector.moving-mean","vector.centered-moving-mean","vector.running-mean","vector.geometric-mean","vector.harmonic-mean","vector.median","vector.mode","vector.sum","vector.rms"]},"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","vector.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:["vector.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","vector.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","vector.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","vector.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"]},median:{category:"vector",description:"Returns the median of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to calculate the median of."}},variants:[{argumentNames:["vector"]}],examples:["median([1, 2, 3])","median([1, 2, -3])","median([1, 2, 3, 4])","median([1, 2, -3, 4])"],seeAlso:["median","vector.moving-median","vector.centered-moving-median","vector.running-median","vector.mean","vector.mode","vector.quartiles","vector.percentile","vector.iqr","vector.medad"]},"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:["vector.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:["vector.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:["vector.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, generate } = import("vector");\niqr(generate(1000, -> 1e6 / ($ + 1) ^ 2))','let { iqr, generate } = import("vector");\nlet { ln } = import("math");\niqr(generate(1000, -> ln($ + 1)))'],seeAlso:["vector.moving-iqr","vector.centered-moving-iqr","vector.running-iqr","vector.quartiles","vector.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"]},sum:{category:"vector",description:"Returns the sum of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to sum."}},variants:[{argumentNames:["vector"]}],examples:["sum([1, 2, 3])","sum([1, 2, -3])"],seeAlso:["sum","vector.moving-sum","vector.centered-moving-sum","vector.running-sum","vector.prod","vector.cumsum","vector.mean"]},"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:["vector.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:["vector.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:["vector.sum","vector.moving-sum","vector.centered-moving-sum","vector.cumsum"]},prod:{category:"vector",description:"Returns the **product** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **product** of."}},variants:[{argumentNames:["vector"]}],examples:["prod([1, 2, 3])","prod([1, 2, -3])"],seeAlso:["prod","vector.moving-prod","vector.centered-moving-prod","vector.running-prod","vector.sum","vector.cumprod"]},"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:["vector.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:["vector.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:["vector.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, generate } = import("vector");\nrms(generate(1000, -> 1e6 / ($ + 1) ^ 2))','let { rms, generate } = import("vector");\nlet { ln } = import("math");\nrms(generate(1000, -> ln($ + 1)))'],seeAlso:["vector.moving-rms","vector.centered-moving-rms","vector.running-rms","vector.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","vector.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:["vector.mean","vector.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","vector.ones","vector.zeros","vector.fill","vector.generate"]},ones:{category:"vector",description:"Generates a vector of ones.",returns:{type:"number",array:!0},args:{length:{type:"integer",description:"The length of the vector."}},variants:[{argumentNames:["length"]}],examples:['let { ones } = import("vector");\nones(5)','let { ones } = import("vector");\nones(10)','let { ones } = import("vector");\nones(0)'],seeAlso:["repeat","vector.zeros","vector.fill","vector.generate","vector.linspace"]},zeros:{category:"vector",description:"Generates a vector of zeros.",returns:{type:"number",array:!0},args:{length:{type:"integer",description:"The length of the vector."}},variants:[{argumentNames:["length"]}],examples:['let { zeros } = import("vector");\nzeros(5)','let { zeros } = import("vector");\nzeros(10)','let { zeros } = import("vector");\nzeros(0)'],seeAlso:["repeat","vector.ones","vector.fill","vector.generate","vector.linspace"]},fill:{category:"vector",description:"Generates a vector filled with a number.",returns:{type:"number",array:!0},args:{length:{type:"integer",description:"The length of the vector."},value:{type:"number",description:"The value to fill the vector with."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["length","value"]}],examples:['let { fill } = import("vector");\nfill(5, PI)','let { fill } = import("vector");\nfill(10, -1)'],seeAlso:["repeat","vector.ones","vector.zeros","vector.generate","vector.linspace","grid.fill"]},generate:{category:"vector",description:"Generates a vector of numbers based on a function.",returns:{type:"number",array:!0},args:{length:{type:"integer",description:"The length of the vector."},func:{type:"function",description:"A function that takes an index and returns a number."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["length","func"]}],examples:['let { generate } = import("vector");\ngenerate(5, -> $ * 2)','let { generate } = import("vector");\ngenerate(10, -> $ + 1)','let { generate } = import("vector");\ngenerate(0, -> $ + 1)'],seeAlso:["repeat","vector.ones","vector.zeros","vector.fill","vector.linspace","grid.generate"]},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","vector.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","vector.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, generate } = import("vector");\nquartiles(generate(1000, -> 1e6 / ($ + 1) ^ 2))','let { quartiles, generate } = import("vector");\nlet { ln } = import("math");\nquartiles(generate(1000, -> ln($ + 1)))'],seeAlso:["vector.percentile","vector.quantile","vector.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","vector.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 Lr(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],a=Math.floor(.75*t.length),o=t.length%4==0?(t[a-1]+t[a])/2:t[a],i=o-n,s=n-1.5*i,c=o+1.5*i;return e.filter(e=>e<s||e>c)}function _r(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 a=Math.floor(n),o=Math.ceil(n),i=n-a;return r[a]*(1-i)+r[o]*i}function Kr(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 a=t.slice(0,Math.floor(t.length/2)),o=t.slice(Math.ceil(t.length/2));let i,s;if(a.length%2==0){const e=a.length/2;i=(a[e-1]+a[e])/2}else i=a[Math.floor(a.length/2)];if(o.length%2==0){const e=o.length/2;s=(o[e-1]+o[e])/2}else s=o[Math.floor(o.length/2)];return[i,n,s]}function Jr(e){if(0===e.length)return 0;return e.reduce((e,t)=>e+t,0)/e.length}const Yr={"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 Hr(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 Xr={median:e=>Hr(e)};function Zr(e,t){const r=t??Jr(e);return e.reduce((e,t)=>e+(t-r)**2,0)/e.length}const Qr={variance:e=>Zr(e)},en={"sample-variance":e=>function(e){const t=Jr(e);return e.reduce((e,r)=>e+(r-t)**2,0)/(e.length-1)}(e),minLength:2};function tn(e,t){const r=Zr(e,t);return Math.sqrt(r)}const rn={stdev:e=>tn(e)},nn={"sample-stdev":e=>function(e,t){const r=Zr(e,t);return Math.sqrt(r*(e.length/(e.length-1)))}(e),minLength:2},an={iqr:e=>{const[t,,r]=Kr(e);return r-t},minLength:4},on={span:e=>0===e.length?0:Math.max(...e)-Math.min(...e),minLength:0};const sn={skewness:e=>function(e){const t=Jr(e),r=tn(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},cn={"sample-skewness":e=>function(e){const t=e.length,r=e.reduce((e,t)=>e+t,0)/t;let n=0,a=0;for(const t of e){const e=t-r;n+=e*e,a+=e*e*e}const o=n/(t-1),i=Math.sqrt(o);if(0===i)throw new Error("Cannot calculate sample skewness when standard deviation is 0");return t/((t-1)*(t-2))*a/i**3}(e),minLength:3};function ln(e){const t=Jr(e),r=tn(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 mn={kurtosis:e=>ln(e),minLength:4},un={"excess-kurtosis":e=>function(e){return ln(e)-3}(e),minLength:4},pn={"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},gn={"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},hn={rms:e=>Math.sqrt(e.reduce((e,t)=>e+t**2,0)/e.length)};const dn={mad:e=>function(e){const t=Hr(e);return e.reduce((e,r)=>e+Math.abs(r-t),0)/e.length}(e)};function yn(e){const t=Hr(e);return 1.4826*Hr(e.map(e=>Math.abs(e-t)))}const vn={medad:e=>yn(e)},fn={"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 bn={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},xn={};function wn(e){for(const[t,r]of Object.entries(e)){if(xn[t])throw new Error(`Duplicate normal expression key found: ${t}`);if("minLength"!==t&&"padding"!==t&&"function"==typeof r){const n=r,a=t.replace(/^/,""),o=`moving-${a}`,i=`centered-moving-${a}`,s=`running-${a}`,c=e.minLength??1;f(c,void 0,{integer:!0,finite:!0,gte:0}),xn[t]=qn(n,c),xn[o]=kn(n,c),xn[i]=An(n,c,e.padding??null),xn[s]=Nn(n,c)}}}function qn(e,t){return{evaluate:([n],a)=>{if(Xe(n,a),n.length<t)throw new r(`Vector length must be at least ${t}`,a);try{return e(n)}catch(e){throw new r(e,a)}},arity:Z(1)}}function kn(e,t){return{evaluate:([n,a],o)=>{if(Xe(n,o),f(a,o,{integer:!0,finite:!0,gte:t,lte:n.length}),0===n.length)return[];try{if(a>=n.length)return[e(n)];const t=[];for(let r=0;r<n.length-a+1;r+=1)t.push(e(n.slice(r,r+a)));return t}catch(e){throw new r(e,o)}},arity:Z(2)}}function An(e,t,n){return{evaluate:([a,o,i,s],c)=>{if(Xe(a,c),a.length<t)throw new r(`Vector length must be at least ${t}`,c);if(f(o,c,{integer:!0,finite:!0,gte:t,lte:a.length}),null!==(i=i??n)&&f(i,c,{finite:!0}),null!==(s=s??n)&&f(s,c,{finite:!0}),0===a.length)return[];const l=Math.floor(o/2),m=[...Array(l).fill(i),...a,...Array(l).fill(s)],u="number"==typeof i?0:l,p=a.length-("number"==typeof s?0:o-l-1),g=[...Array(u).fill(null)];try{for(let t=u;t<p;t+=1)g.push(e(m.slice(t,t+o)))}catch(e){throw new r(e,c)}return g.push(...Array(a.length-p).fill(null)),g},arity:{min:2,max:4}}}function Nn(e,t){return{evaluate:([n],a)=>{if(Xe(n,a),n.length<t)throw new r(`Vector length must be at least ${t}`,a);if(0===n.length)return[];try{const r=Math.max(t-1,0),a=Array(r).fill(null);for(let t=r;t<n.length;t+=1)a.push(e(n.slice(0,t+1)));return a}catch(e){throw new r(e,a)}},arity:Z(1)}}wn({mean:e=>Jr(e)}),wn(Yr),wn({"harmonic-mean":e=>e.length/e.reduce((e,t)=>e+1/t,0)}),wn(Xr),wn({sum:e=>e.reduce((e,t)=>e+t,0),minLength:0}),wn({prod:e=>e.reduce((e,t)=>e*t,1),padding:1,minLength:0}),wn(Qr),wn(en),wn(rn),wn(nn),wn(an),wn(on),wn(sn),wn(cn),wn(un),wn(mn),wn(gn),wn(pn),wn(hn),wn(dn),wn(vn),wn(fn),wn(bn);const $n={"monotonic?":{evaluate:([e],t)=>(Xe(e,t),e.every((t,r)=>0===r||t>=e[r-1])||e.every((t,r)=>0===r||t<=e[r-1])),arity:Z(1)},"strictly-monotonic?":{evaluate:([e],t)=>(Xe(e,t),e.every((t,r)=>0===r||t>e[r-1])||e.every((t,r)=>0===r||t<e[r-1])),arity:Z(1)},"increasing?":{evaluate:([e],t)=>(Xe(e,t),e.every((t,r)=>0===r||t>=e[r-1])),arity:Z(1)},"decreasing?":{evaluate:([e],t)=>(Xe(e,t),e.every((t,r)=>0===r||t<=e[r-1])),arity:Z(1)},"strictly-increasing?":{evaluate:([e],t)=>(Xe(e,t),e.every((t,r)=>0===r||t>e[r-1])),arity:Z(1)},"strictly-decreasing?":{evaluate:([e],t)=>(Xe(e,t),e.every((t,r)=>0===r||t<e[r-1])),arity:Z(1)},mode:{evaluate:([e],t)=>(et(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,a]of t.entries())a===r&&n.push(e);return n}(e)),arity:Z(1)},"min-index":{evaluate:([e],t)=>(et(e,t),e.reduce((t,r,n)=>r<e[t]?n:t,0)),arity:Z(1)},"max-index":{evaluate:([e],t)=>(et(e,t),e.reduce((t,r,n)=>r>e[t]?n:t,0)),arity:Z(1)},"sort-indices":{evaluate:([e],t)=>(Xe(e,t),[...e.keys()].sort((t,r)=>e[t]-e[r])),arity:Z(1)},"count-values":{evaluate:([e],t)=>{Xe(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:Z(1)},linspace:{evaluate:([e,t,r],n)=>{if(f(e,n,{finite:!0}),f(t,n,{finite:!0}),f(r,n,{integer:!0,nonNegative:!0}),0===r)return[];if(1===r)return[e];const a=(t-e)/(r-1);return Array.from({length:r},(t,r)=>e+r*a)},arity:Z(3)},ones:{evaluate:([e],t)=>(f(e,t,{integer:!0,nonNegative:!0}),Array.from({length:e},()=>1)),arity:Z(1)},zeros:{evaluate:([e],t)=>(f(e,t,{integer:!0,nonNegative:!0}),Array.from({length:e},()=>0)),arity:Z(1)},fill:{evaluate:([e,t],r)=>(f(e,r,{integer:!0,nonNegative:!0}),Array.from({length:e},()=>t)),arity:Z(2)},generate:{evaluate:([e,t],r,n,{executeFunction:a})=>(f(e,r,{integer:!0,nonNegative:!0}),J(t,r),Ae(Array.from({length:e}),(e,o)=>ke(a(t,[o],n,r),e=>(f(e,r,{finite:!0}),e)))),arity:Z(2)},cumsum:{evaluate:([e],t)=>(Xe(e,t),e.reduce((e,t)=>{const r=e[e.length-1]??0;return e.push(r+t),e},[])),arity:Z(1)},cumprod:{evaluate:([e],t)=>(Xe(e,t),e.reduce((e,t)=>{const r=e[e.length-1]??1;return e.push(r*t),e},[])),arity:Z(1)},quartiles:{evaluate:([e],t)=>{if(Xe(e,t),e.length<4)throw new r("Quartiles require at least four values",t);return Kr(e)},arity:Z(1)},percentile:{evaluate:([e,t],r)=>(et(e,r),f(t,r,{finite:!0,nonNegative:!0,lte:100}),_r(e,t)),arity:Z(2)},quantile:{evaluate:([e,t],r)=>(Xe(e,r),f(t,r,{finite:!0,nonNegative:!0,lte:1}),_r(e,100*t)),arity:Z(2)},histogram:{evaluate:([e,t],r)=>(Xe(e,r),f(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 a=(n-r)/t,o=[];for(let e=0;e<t;e++){const i=r+e*a,s=e===t-1?n:r+(e+1)*a;o.push([i,s,0])}for(const i of e)i===n?o[t-1][2]+=1:o[Math.min(Math.floor((i-r)/a),t-1)][2]+=1;return o}(e,t)),arity:Z(2)},ecdf:{evaluate:([e,t],r)=>{et(e,r),f(t,r,{finite:!0});const n=[...e].sort((e,t)=>e-t),a=n.findIndex(e=>e>t);return-1===a?1:a/n.length},arity:Z(2)},"outliers?":{evaluate:([e],t)=>(Xe(e,t),function(e){return Lr(e).length>0}(e)),arity:Z(1)},outliers:{evaluate:([e],t)=>(Xe(e,t),Lr(e)),arity:Z(1)},bincount:{evaluate:(e,t)=>{const n=e[0];Xe(n,t),n.forEach(e=>f(e,t,{finite:!0,integer:!0,nonNegative:!0}));const a=e[1]??0;f(a,t,{integer:!0,nonNegative:!0});const o=e[2]??void 0;if(void 0!==o){if(Xe(o,t),o.length!==n.length)throw new r("Weights vector must be the same length as the input vector",t);o.forEach(e=>f(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),a=Math.max(n+1,t),o=Array.from({length:a},()=>0);for(let t=0;t<e.length;t++){const n=Math.floor(e[t]);n<a&&(o[n]+=r?r[t]:1)}return o}(n,a,o)},arity:{min:1,max:3}},winsorize:{evaluate:([e,t,r],n)=>{if(Xe(e,n),f(t,n,{finite:!0,gte:0,lte:1}),r??=t>.5?1:1-t,f(r,n,{finite:!0,gte:t,lte:1}),0===e.length)return[];const a=[...e].sort((e,t)=>e-t),o=Math.max(0,Math.floor(t*e.length)),i=Math.min(e.length-1,Math.max(0,Math.floor(r*e.length)-1)),s=a[o],c=a[i];return e.map(e=>Math.max(s,Math.min(e,c)))},arity:{min:2,max:3}},mse:{evaluate:([e,t],n)=>{if(et(e,n),et(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:Z(2)},rmse:{evaluate:([e,t],n)=>{if(et(e,n),et(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:Z(2)},mae:{evaluate:([e,t],n)=>{if(et(e,n),et(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:Z(2)},smape:{evaluate:([e,t],n)=>{if(et(e,n),et(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>{const a=Math.abs(r-t[n]),o=(Math.abs(r)+Math.abs(t[n]))/2;return e+(0===o?0:a/o)},0)/e.length},arity:Z(2)}};!function(e){for(const[t,r]of Object.entries(e)){if($n[t])throw new Error(`Duplicate normal expression key found: ${t}`);$n[t]=r}}(xn);for(const[e,t]of Object.entries(Br))$n[e]&&($n[e].docs=t);const Tn={name:"vector",functions:$n},Sn={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?","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"); solve([[2, 0, 0], [3, 1, 0], [4, 5, 6]], [4, 5, 38])','let { solve } = import("linear-algebra"); solve([[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 zn(e){const t=e.map(e=>[...e]),r=t.length,n=t[0].length;let a=0,o=0;for(let e=0;e<n;e++){let i=-1;for(let n=o;n<r;n++)if(!fe(t[n][e])){i=n;break}if(-1===i)continue;a+=1,i!==o&&([t[i],t[o]]=[t[o],t[i]]);const s=t[o][e];for(let r=e;r<n;r++)t[o][r]/=s;for(let a=0;a<r;a++)if(a!==o&&!fe(t[a][e])){const r=t[a][e];for(let i=e;i<n;i++)t[a][i]-=r*t[o][i]}if(o++,o===r)break}return[t,a]}function En(e,t){const r=e=>e.every(e=>fe(e));if(r(e)||r(t))return!0;let n=0;for(;n<e.length&&fe(e[n]);)n++;const a=t[n]/e[n];for(let r=0;r<e.length;r++)if(!fe(e[r])||!fe(t[r])){if(fe(e[r]))return!1;if(!ve(t[r]/e[r],a))return!1}return!0}function jn(e){return e.every(e=>fe(e))}function Mn(e,t){const r=Jr(e),n=Jr(t);let a=0,o=0,i=0;for(let s=0;s<e.length;s++){const c=e[s]-r,l=t[s]-n;a+=c*l,o+=c*c,i+=l*l}if(0===o||0===i)throw new Error("Cannot calculate Pearson correlation coefficient: one of the vectors has zero variance.");return a/(Math.sqrt(o)*Math.sqrt(i))}function Cn(e){const t=[...e.keys()].sort((t,r)=>e[t]-e[r]),r=Array.from({length:e.length}).fill(0);let n=1,a=0;for(;a<t.length;){const o=e[t[a]];let i=a;for(;i<t.length&&e[t[i]]===o;)i++;const s=n+(i-a-1)/2;for(let e=a;e<i;e++)r[t[e]]=s;n+=i-a,a=i}return r}function Rn(e,t){const r=Jr(e),n=Jr(t);let a=0;for(let o=0;o<e.length;o++)a+=(e[o]-r)*(t[o]-n);return a/e.length}function Pn(e,t){if(0===e.length)return e;const n=Math.sqrt(e.reduce((e,t)=>e+t**2,0));if(fe(n))throw new r("The vector must not be zero",t);return e.map(e=>e/n)}function In(e,t){return e.reduce((e,r,n)=>e+r*t[n],0)}function On(e,t){return e.map((e,r)=>e-t[r])}function Fn(e,t){return e.map(e=>e*t)}const Un={rotate2d:{evaluate:([e,t],r)=>{if(Ze(e,r),jn(e))return e;f(t,r,{finite:!0});const n=Math.cos(t),a=Math.sin(t);return[e[0]*n-e[1]*a,e[0]*a+e[1]*n]},arity:Z(2)},rotate3d:{evaluate:([e,t,n],a)=>{if(Qe(e,a),jn(e))return e;if(f(n,a,{finite:!0}),Qe(t,a),jn(t))throw new r("Rotation axis must not be zero",a);const o=Math.cos(n),i=Math.sin(n),[s,c,l]=Pn(t,a),m=e[0]*s+e[1]*c+e[2]*l;return[m*s*(1-o)+e[0]*o+(-l*e[1]+c*e[2])*i,m*c*(1-o)+e[1]*o+(l*e[0]-s*e[2])*i,m*l*(1-o)+e[2]*o+(-c*e[0]+s*e[1])*i]},arity:Z(3)},reflect:{evaluate:([e,t],n)=>{if(Xe(e,n),Xe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);if(jn(t))throw new r("Reflection normal must not be zero",n);if(jn(e))return e;const a=Pn(t,n);return On(e,Fn(a,2*In(e,a)))},arity:Z(2)},refract:{evaluate:([e,t,n],a)=>{if(Xe(e,a),Xe(t,a),f(n,a,{finite:!0,positive:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",a);if(jn(t))throw new r("Refraction normal must not be zero",a);if(jn(e))return e;const o=Pn(e,a),i=Pn(t,a),s=In(o,i),c=1-n*n*(1-s*s);if(c<0)return e;return On(Fn(o,n),Fn(i,n*s+Math.sqrt(c)))},arity:Z(3)},lerp:{evaluate:([e,t,n],a)=>{if(Xe(e,a),Xe(t,a),f(n,a,{finite:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",a);return e.map((e,r)=>e+(t[r]-e)*n)},arity:Z(3)},dot:{evaluate:([e,t],n)=>{if(Xe(e,n),Xe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return In(e,t)},arity:Z(2)},cross:{evaluate:([e,t],n)=>{if(Xe(e,n),Xe(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:Z(2)},"normalize-minmax":{evaluate:([e],t)=>{if(Xe(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:Z(1)},"normalize-robust":{evaluate:([e],t)=>{if(Xe(e,t),0===e.length)return[];const r=Hr(e),n=yn(e);return 0===n?e.map(e=>e-r):e.map(e=>(e-r)/n)},arity:Z(1)},"normalize-zscore":{evaluate:([e],t)=>{Xe(e,t);const r=Jr(e),n=tn(e);return 0===n?e.map(()=>0):e.map(e=>(e-r)/n)},arity:Z(1)},"normalize-l1":{evaluate:([e],t)=>{if(Xe(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:Z(1)},"normalize-l2":{evaluate:([e],t)=>(Xe(e,t),Pn(e,t)),arity:Z(1)},"normalize-log":{evaluate:([e],t)=>{if(Xe(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:Z(1)},angle:{evaluate:([e,t],n)=>{if(et(e,n),et(t,n),jn(e)||jn(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 a=e.reduce((e,r,n)=>e+r*t[n],0),o=Math.sqrt(e.reduce((e,t)=>e+t*t,0)),i=Math.sqrt(t.reduce((e,t)=>e+t*t,0));return Math.acos(a/(o*i))},arity:Z(2)},projection:{evaluate:([e,t],n)=>{if(et(e,n),et(t,n),jn(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 a=e.reduce((e,r,n)=>e+r*t[n],0),o=Math.sqrt(t.reduce((e,t)=>e+t*t,0));return t.map(e=>a/o**2*e)},arity:Z(2)},"orthogonal?":{evaluate:([e,t],n)=>{if(et(e,n),et(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:Z(2)},"parallel?":{evaluate:([e,t],n)=>{if(et(e,n),et(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return function(e,t){if(!En(e,t))return!1;for(let r=0;r<e.length;r++)if(!fe(e[r])&&!fe(t[r]))return Math.sign(e[r])===Math.sign(t[r]);return!0}(e,t)},arity:Z(2)},"collinear?":{evaluate:([e,t],n)=>{if(et(e,n),et(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return En(e,t)},arity:Z(2)},"cosine-similarity":{evaluate:([e,t],n)=>{if(et(e,n),et(t,n),jn(e)||jn(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:Z(2)},"euclidean-distance":{evaluate:([e,t],n)=>{if(et(e,n),et(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:Z(2)},"euclidean-norm":{evaluate:([e],t)=>(et(e,t),function(e){return Math.sqrt(e.reduce((e,t)=>e+t**2,0))}(e)),arity:Z(1)},"manhattan-distance":{evaluate:([e,t],n)=>{if(et(e,n),et(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:Z(2)},"manhattan-norm":{evaluate:([e],t)=>(et(e,t),e.reduce((e,t)=>e+Math.abs(t),0)),arity:Z(1)},"hamming-distance":{evaluate:([e,t],n)=>{if(et(e,n),et(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:Z(2)},"hamming-norm":{evaluate:([e],t)=>(et(e,t),e.reduce((e,t)=>e+(0!==t?1:0),0)),arity:Z(1)},"chebyshev-distance":{evaluate:([e,t],n)=>{if(et(e,n),et(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:Z(2)},"chebyshev-norm":{evaluate:([e],t)=>(et(e,t),Math.max(...e.map(e=>Math.abs(e)))),arity:Z(1)},"minkowski-distance":{evaluate:([e,t,n],a)=>{if(et(e,a),et(t,a),f(n,a,{finite:!0,positive:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",a);return e.reduce((e,r,a)=>e+Math.abs(r-t[a])**n,0)**(1/n)},arity:Z(3)},"minkowski-norm":{evaluate:([e,t],r)=>(et(e,r),f(t,r,{finite:!0,positive:!0}),e.reduce((e,r)=>e+Math.abs(r)**t,0)**(1/t)),arity:Z(2)},cov:{evaluate:([e,t],n)=>{if(et(e,n),et(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return 1===e.length?0:Rn(e,t)},arity:Z(2)},corr:{evaluate:([e,t],n)=>{if(Xe(e,n),Xe(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 a=Jr(e),o=Jr(t);return e.reduce((e,r,n)=>e+(r-a)*(t[n]-o),0)/Math.sqrt(e.reduce((e,t)=>e+(t-a)**2,0)*t.reduce((e,t)=>e+(t-o)**2,0))},arity:Z(2)},"spearman-corr":{evaluate:([e,t],n)=>{if(Xe(e,n),Xe(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 a=Cn(e),o=Cn(t);try{return Mn(a,o)}catch(e){throw new r(e,n)}},arity:Z(2)},"pearson-corr":{evaluate:([e,t],n)=>{if(Xe(e,n),Xe(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 Mn(e,t)}catch(e){throw new r(e,n)}},arity:Z(2)},"kendall-tau":{evaluate:([e,t],n)=>{if(Xe(e,n),Xe(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,a=0,o=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?o+=1:p?i+=1:l*m>0?n+=1:a+=1)}const s=n+a+o,c=n+a+i;if(0===s||0===c)throw new Error("Not enough data to calculate Kendall's Tau");return(n-a)/Math.sqrt(s*c)}(e,t)}catch(e){throw new r(e,n)}},arity:Z(2)},autocorrelation:{evaluate:([e,t],n)=>{if(Xe(e,n),e.length<2)throw new r("Vector must have at least 2 elements for autocorrelation",n);if(f(t,n,{integer:!0,lt:e.length,gt:-e.length}),0===t)return 1;const a=Math.abs(t),o=Jr(e);let i=0;const s=e.length;for(let r=0;r<s-a;r++){const n=t<0?r:r+a;i+=(e[t<0?r+a:r]-o)*(e[n]-o)}let c=0;for(let t=0;t<s;t++)c+=(e[t]-o)**2;return 0===c?0:i/c},arity:Z(2)},"cross-correlation":{evaluate:([e,t,n],a)=>{if(Xe(e,a),Xe(t,a),e.length<2)throw new r("Vectors must have at least 2 elements",a);if(e.length!==t.length)throw new r("Vectors must be of the same length",a);if(f(n,a,{integer:!0,lt:e.length,gt:-e.length}),0===n&&e.length===t.length&&e.every((e,r)=>e===t[r]))return 1;const[o,i]=function(e,t,r){const n=Math.abs(r),a=e.length-n;let o=[],i=[];return r>=0?(o=e.slice(0,a),i=t.slice(r,r+a)):(o=e.slice(n),i=t.slice(0,a)),[o,i]}(e,t,n);return function(e,t){const r=Jr(e),n=Jr(t),a=tn(e,r),o=tn(t,n);return 0===a||0===o?0===a&&0===o&&r===n?1:0:Rn(e,t)/(a*o)}(o,i)},arity:Z(3)},rref:{evaluate:([e],t)=>{at(e,t);const[r]=zn(e);return r},arity:Z(1)},solve:{evaluate:([e,t],n)=>{if(ot(e,n),Xe(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]]),[a]=zn(n);for(let e=0;e<r;e+=1)if(fe(a[e][e]))return null;const o=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+=a[e][n]*o[n];o[e]=(a[e][r]-t)/a[e][e]}return o}(e,t)},arity:Z(2)},"to-polar":{evaluate:([e],t)=>{if(Ze(e,t),jn(e))return[0,0];return[Math.sqrt(e[0]**2+e[1]**2),Math.atan2(e[1],e[0])]},arity:Z(1)},"from-polar":{evaluate:([e],t)=>{Ze(e,t);const[r,n]=e;return 0===r?[0,0]:[r*Math.cos(n),r*Math.sin(n)]},arity:Z(1)}};for(const[e,t]of Object.entries(Sn))Un[e]&&(Un[e].docs=t);const Dn={name:"linear-algebra",functions:Un},Gn={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?"]},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.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?":{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? } = import("matrix");\northogonal?([[1, 0], [0, 1]])','let { orthogonal? } = import("matrix");\northogonal?([[1, 0], [0, -1]])','let { orthogonal? } = import("matrix");\northogonal?([[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?"]},"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 Wn(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 a=e;for(let n=e+1;n<t;n+=1)Math.abs(r[n][e])>Math.abs(r[a][e])&&(a=n);if(fe(r[a][e]))return 0;a!==e&&([r[e],r[a]]=[r[a],r[e]],n=-n);for(let n=e+1;n<t;n+=1){const a=r[n][e]/r[e][e];for(let o=e;o<t;o++)r[n][o]-=a*r[e][o]}}let a=n;for(let e=0;e<t;e++)a*=r[e][e];return a}function Vn(e,t,r){const n=e.length,a=[];for(let o=0;o<n;o++)if(o!==t){const t=[];for(let a=0;a<n;a++)a!==r&&t.push(e[o][a]);a.push(t)}return a}function Bn(e){const t=e.length,r=[];for(let n=0;n<t;n++){r[n]=[];for(let a=0;a<t;a++){const t=(-1)**(n+a)*Wn(Vn(e,a,n));r[n][a]=t}}return r}function Ln(e){return e.length===e[0].length}function _n(e){if(!Ln(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(!ve(e[r][n],1))return!1}else if(!fe(e[r][n]))return!1;return!0}function Kn(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,a=t[0].length,o=Array(r).fill(0).map(()=>Array(a).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<a;e++)o[i][e]+=n*t[r][e]}return o}const Jn={mul:{evaluate:([e,t],n)=>{at(e,n),at(t,n);try{return Kn(e,t)}catch(a){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:Z(2)},det:{evaluate:([e],t)=>(ot(e,t),Wn(e)),arity:Z(1)},inv:{evaluate:([e],t)=>{ot(e,t);const n=function(e){const t=e.length;if(1===t){const t=e[0][0];return fe(t)?null:[[1/t]]}const r=Wn(e);if(fe(r))return null;const n=Bn(e),a=[];for(let e=0;e<t;e++){a[e]=[];for(let o=0;o<t;o++)a[e][o]=n[e][o]/r}return a}(e);if(null===n)throw new r("The matrix must be invertible",t);return n},arity:Z(1)},adj:{evaluate:([e],t)=>(ot(e,t),Bn(e)),arity:Z(1)},cofactor:{evaluate:([e],t)=>(ot(e,t),function(e){const t=e.length,r=[];for(let n=0;n<t;n++){r[n]=[];for(let a=0;a<t;a++){const t=Vn(e,n,a),o=(-1)**(n+a);r[n][a]=o*Wn(t)}}return r}(e)),arity:Z(1)},minor:{evaluate:([e,t,r],n)=>(at(e,n),f(t,n,{integer:!0,nonNegative:!0,lte:e.length}),f(r,n,{integer:!0,nonNegative:!0,lte:e[0].length}),Vn(e,t,r)),arity:Z(3)},trace:{evaluate:([e],t)=>(ot(e,t),function(e){return e.reduce((e,t,r)=>e+t[r],0)}(e)),arity:Z(1)},"symmetric?":{evaluate:([e],t)=>(at(e,t),function(e){const t=e.length;if(!Ln(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:Z(1)},"triangular?":{evaluate:([e],t)=>(at(e,t),function(e){if(!Ln(e))return!1;const t=e.length;let r=!0,n=!0;for(let a=0;a<t;a++)for(let o=0;o<t;o++){if(a>o&&0!==e[a][o]&&(r=!1,!n))return!1;a<o&&0!==e[a][o]&&(n=!1)}return r||n}(e)),arity:Z(1)},"upper-triangular?":{evaluate:([e],t)=>(at(e,t),function(e){if(!Ln(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:Z(1)},"lower-triangular?":{evaluate:([e],t)=>(at(e,t),function(e){if(!Ln(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:Z(1)},"diagonal?":{evaluate:([e],t)=>(at(e,t),function(e){if(!Ln(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:Z(1)},"square?":{evaluate:([e],t)=>(at(e,t),Ln(e)),arity:Z(1)},"orthogonal?":{evaluate:([e],t)=>(at(e,t),function(e){return!!Ln(e)&&_n(Kn(e,Ir(e)))}(e)),arity:Z(1)},"identity?":{evaluate:([e],t)=>(at(e,t),_n(e)),arity:Z(1)},"invertible?":{evaluate:([e],t)=>(at(e,t),!!function(e){return!!nt(e)&&e.length===e[0].length}(e)&&!fe(Wn(e))),arity:Z(1)},hilbert:{evaluate:([e],t)=>{f(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:Z(1)},vandermonde:{evaluate:([e],t)=>{Xe(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:Z(1)},band:{evaluate:([e,t,r],n)=>(f(e,n,{integer:!0,positive:!0}),f(t,n,{integer:!0,nonNegative:!0,lt:e}),f(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 a=0;a<e;a++)for(let o=Math.max(0,a-t);o<=Math.min(e-1,a+r);o++)n[a][o]=1;return n}(e,t,r)),arity:Z(3)},"banded?":{evaluate:([e,t,r],n)=>{at(e,n);const a=Math.max(e.length,e[0].length);return f(t,n,{integer:!0,nonNegative:!0,lt:a}),f(r,n,{integer:!0,nonNegative:!0,lt:a}),function(e,t,r){const n=e.length,a=e[0].length;for(let o=0;o<n;o++)for(let n=0;n<a;n++)if(0!==e[o][n]&&(o-n>t||n-o>r))return!1;return!0}(e,t,r)},arity:Z(3)},rank:{evaluate:([e],t)=>{at(e,t);const[,r]=zn(e);return r},arity:Z(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:Z(1)},"one-norm":{evaluate:([e],t)=>(at(e,t),function(e){const t=e.length,r=e[0].length;let n=0;for(let a=0;a<r;a+=1){let r=0;for(let n=0;n<t;n+=1)r+=Math.abs(e[n][a]);n=Math.max(n,r)}return n}(e)),arity:Z(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:Z(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:Z(1)}};for(const[e,t]of Object.entries(Gn))Jn[e]&&(Jn[e].docs=t);const Yn={name:"matrix",functions:Jn},Hn={"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 Xn(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 Zn(e,t){if(1===t)return e.map(e=>[e]);const r=[];for(let n=0;n<=e.length-t;n++){const a=e[n],o=Zn(e.slice(n+1),t-1);for(const e of o)r.push([a,...e])}return r}const Qn={combinations:{evaluate:([e,t],r)=>(xe(e,r),f(t,r,{integer:!0,nonNegative:!0,lte:e.length}),0===t?[[]]:Zn(e,t)),arity:Z(2)},"count-combinations":{evaluate:([e,t],r)=>(f(e,r,{integer:!0,nonNegative:!0}),f(t,r,{integer:!0,nonNegative:!0,lte:e}),Xn(e,t)),arity:Z(2)}};const ea={derangements:{evaluate:([e],t)=>(xe(e,t),function(e){const t=e.length,r=[],n=Array.from({length:t},()=>!1),a=Array.from({length:t});return function o(i){if(i!==t)for(let r=0;r<t;r++)n[r]||r===i||(n[r]=!0,a[i]=e[r],o(i+1),n[r]=!1);else r.push([...a])}(0),r}(e)),arity:Z(1)},"count-derangements":{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),function(e){if(1===e)return 0;let t=1,r=0,n=0;for(let a=2;a<=e;a++)n=(a-1)*(t+r),t=r,r=n;return n}(e)),arity:Z(1)}};function ta(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 ra(e){return ta(e).sort((e,t)=>e-t)}function na(e){return ra(e).slice(0,-1)}const aa={divisors:{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),ra(e)),arity:Z(1)},"count-divisors":{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),ta(e).length),arity:Z(1)},"proper-divisors":{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),na(e)),arity:Z(1)},"count-proper-divisors":{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),ta(e).length-1),arity:Z(1)}},oa=[1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368e3,20922789888e3,355687428096e3,6402373705728e3];function ia(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 oa[e];let t=oa[18];for(let r=19;r<=e;r++)t*=r;return t}const sa={factorial:{evaluate:([e],t)=>(f(e,t,{integer:!0,nonNegative:!0,lte:170}),ia(e)),arity:Z(1)}},ca=[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 la={partitions:{evaluate:([e],t)=>(f(e,t,{integer:!0,nonNegative:!0}),function(e){if(e<=0)return[[]];if(1===e)return[[1]];const t=[];return function e(r,n,a){if(0!==r)for(let t=Math.min(n,r);t>=1;t--)a.push(t),e(r-t,t,a),a.pop();else t.push([...a])}(e,e,[]),t}(e)),arity:Z(1)},"count-partitions":{evaluate:([e],t)=>{if(f(e,t,{integer:!0,nonNegative:!0}),0===e)return 1;if(e>ca.length)throw new r(`n is too large. The maximum value is ${ca.length-1}.`,t);return ca[e-1]},arity:Z(1)}};function ma(e){if(0===e.length)return[[]];const t=[];for(let r=0;r<e.length;r++){const n=e[r],a=ma([...e.slice(0,r),...e.slice(r+1)]);for(const e of a)t.push([n,...e])}return t}const ua={permutations:{evaluate:([e],t)=>(xe(e,t),ma(e)),arity:Z(1)},"count-permutations":{evaluate:([e,t],r)=>(f(e,r,{integer:!0,nonNegative:!0}),f(t,r,{integer:!0,nonNegative:!0,lte:e}),ia(e)/ia(e-t)),arity:Z(2)}};const pa={"power-set":{evaluate:([e],t)=>(xe(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:Z(1)},"count-power-set":{evaluate:([e],t)=>(f(e,t,{integer:!0,nonNegative:!0}),e>=53?1/0:2**e),arity:Z(1)}};function ga(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 ha={"prime-factors":{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),ga(e)),arity:Z(1)},"distinct-prime-factors":{evaluate:([e],t)=>{f(e,t,{finite:!0,integer:!0,positive:!0});const r=ga(e),n=new Set(r);return Array.from(n)},arity:Z(1)},"count-prime-factors":{evaluate:([e],t)=>(f(e,t,{finite:!0,integer:!0,positive:!0}),ga(e).length),arity:Z(1)},"count-distinct-prime-factors":{evaluate:([e],t)=>{f(e,t,{finite:!0,integer:!0,positive:!0});const r=ga(e);return new Set(r).size},arity:Z(1)}};function da(e){return na(e).reduce((e,t)=>e+t,0)>e}const ya={"abundant-seq":e=>{const t=[];let r=2;for(;t.length<e;)da(r)&&t.push(r),r+=1;return t},"abundant?":e=>da(e),"abundant-take-while":e=>{const t=[];return function r(n){return da(n)?ke(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(2)}};const va={"arithmetic-seq":{evaluate:([e,t,r],n)=>(f(e,n,{finite:!0}),f(t,n,{finite:!0}),f(r,n,{integer:!0,positive:!0}),Array.from({length:r},(r,n)=>e+n*t)),arity:Z(3)},"arithmetic-take-while":{evaluate:([e,t,r],n,a,{executeFunction:o})=>{f(e,n,{finite:!0}),f(t,n,{finite:!0}),J(r,n);const i=e,s=t,c=r,l=[];return function e(t){const r=i+t*s;return ke(o(c,[r,t],a,n),n=>n?(l.push(r),e(t+1)):l)}(0)},arity:Z(3)},"arithmetic-nth":{evaluate:([e,t,r],n)=>(f(e,n,{finite:!0}),f(t,n,{finite:!0}),f(r,n,{integer:!0,positive:!0}),e+(r-1)*t),arity:Z(3)},"arithmetic?":{evaluate:([e,t,r],n)=>(f(r,n),f(e,n,{finite:!0}),f(t,n,{finite:!0}),function(e,t,r){if(0===t)return ve(r,e);const n=(r-e)/t;if(n<0)return!1;const a=Math.round(n),o=e+t*a;return ve(n,a)&&ve(o,r)}(e,t,r)),arity:Z(3)}};function fa(e){const t=[1];for(let r=1;r<e;r+=1){let e=0;for(let n=0;n<r;n+=1)e+=Xn(r+1,n)*t[n];t[r]=r>1&&r%2==1?0:-e/(r+1)}return t}const ba={"bernoulli-seq":{evaluate:([e],t)=>(f(e,t,{integer:!0,positive:!0}),fa(e)),arity:Z(1)},"bernoulli-nth":{evaluate:([e],t)=>{f(e,t,{integer:!0,positive:!0});return fa(e)[e-1]},arity:Z(1)},"bernoulli-take-while":{evaluate:([e],t,r,{executeFunction:n})=>{J(e,t);const a=e;return function(e){const t=[1];return function r(n){let a=0;for(let e=0;e<n;e++)a+=Xn(n+1,e)*t[e];const o=n>1&&n%2==1?0:-a/(n+1);return ke(e(o,n),e=>e?(t.push(o),r(n+1)):t)}(1)}((e,t)=>ke(n(a,[e,t],r),e=>!!e))},arity:Z(1)}};function xa(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 wa={"prime-seq":e=>{const t=[];let r=2;for(;t.length<e;)xa(r)&&t.push(r),r+=1;return t},"prime?":e=>xa(e),"prime-take-while":e=>{const t=[];return function r(n){return xa(n)?ke(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(2)}};function qa(e){return!(e<=1)&&!xa(e)}const ka={"composite-seq":e=>{const t=[];let r=2;for(;t.length<e;)qa(r)&&t.push(r),r+=1;return t},"composite?":e=>qa(e),"composite-take-while":e=>{const t=[];return function r(n){return qa(n)?ke(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(4)}};function Aa(e){return na(e).reduce((e,t)=>e+t,0)<e}const Na={"deficient-seq":e=>{const t=[];let r=1;for(;t.length<e;)Aa(r)&&t.push(r),r+=1;return t},"deficient?":e=>Aa(e),"deficient-take-while":e=>{const t=[];return function r(n){return Aa(n)?ke(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(1)}};const $a={"geometric-seq":{evaluate:([e,t,r],n)=>(f(e,n,{finite:!0}),f(t,n,{finite:!0}),f(r,n,{integer:!0,positive:!0}),Array.from({length:r},(r,n)=>e*t**n)),arity:Z(3)},"geometric-take-while":{evaluate:([e,t,r],n,a,{executeFunction:o})=>{f(e,n,{finite:!0}),f(t,n,{finite:!0}),J(r,n);const i=e,s=t,c=r,l=[];return function e(t){const r=i*s**t;return ke(o(c,[r,t],a,n),n=>n?(l.push(r),e(t+1)):l)}(0)},arity:Z(3)},"geometric-nth":{evaluate:([e,t,r],n)=>(f(e,n,{finite:!0}),f(t,n,{finite:!0}),f(r,n,{integer:!0,positive:!0}),e*t**(r-1)),arity:Z(3)},"geometric?":{evaluate:([e,t,r],n)=>(f(r,n),f(e,n,{finite:!0}),f(t,n,{finite:!0}),function(e,t,r){if(ve(e,0))return ve(r,0);if(ve(t,1))return ve(r,e);if(ve(t,0))return ve(r,0)||ve(r,e);if(ve(r,e))return!0;if(ve(t,-1))return ve(r,e)||ve(r,-e);if(t<0){const n=Math.log(Math.abs(r/e))/Math.log(Math.abs(t)),a=Math.round(n);if(!ve(a,n)||a<0)return!1;const o=a%2==0?Math.sign(e):Math.sign(e)*Math.sign(t);return Math.sign(r)===o}if(t>1&&r<e||t<1&&r>e)return!1;const n=Math.log(r/e)/Math.log(t),a=Math.round(n);return!(!ve(a,n)||a<0)&&ve(e*t**a,r)}(e,t,r)),arity:Z(3)}};const Ta={"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 ke(e(1,0),r=>r?function r(n){const a=1+t[n-t[t[n-1]]];return ke(e(a,n-1),e=>e?(t.push(a),r(n+1)):t.slice(1))}(2):[])}(e)};function Sa(e){if(e<=0)return!1;const t=new Set;for(;1!==e&&!t.has(e);)t.add(e),e=za(e);return 1===e}function za(e){let t=0;for(;e>0;){const r=e%10;t+=r*r,e=Math.floor(e/10)}return t}const Ea={"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=>Sa(e),"happy-take-while":e=>{const t=[];return function r(n){return Sa(n)?ke(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(1)}},ja={"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 Ma(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 Ca={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 ke(e("1",0),r=>{if(!r)return t;return t.push("1"),function r(n){const a=t[n-1].replace(/(\d)\1*/g,e=>`${e.length}${e[0]}`);return ke(e(a,n),e=>e?(t.push(a),r(n+1)):t)}(1)})},"look-and-say?":e=>function(e){let t="1";if(t===e)return!0;for(;;){if(t=Ma(t),t===e)return!0;if(t.length>e.length)return!1}}(e)};function Ra(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 a=1;return ke(e(1,0),t=>{if(!t)return[];let o=1;return function t(){const i=r[o];return ke(e(i,a),e=>{if(!e)return n;n.push(i),a++;const s=i,c=[];for(let e=0;e<r.length;e++)(e+1)%s!==0&&c.push(r[e]);if(r=c,o++,o>=r.length-5){let e=r[r.length-1]+2;for(;r.length<o+1e3;)r.push(e),e+=2}return t()})}()})}const Pa={"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 a=1;for(;a<t.length&&a<e;){const e=t[a];let r=0;for(let n=0;n<t.length;n++)(n+1)%e!==0&&(t[r++]=t[n]);t.length=r,a<t.length&&a++}return t.slice(0,e)}(e),"lucky?":e=>Ra(t=>t<=e).includes(e),"lucky-take-while":e=>Ra(e)};const Ia={"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],a=t[t.length-2],o=t[t.length-1];for(;o<e;){if(r=n+a,n=a,a=o,o=r,o===e)return!0;if(!Number.isSafeInteger(o))return!1}}return!1}(e),"padovan-take-while":e=>{const t=[];return ke(e(1,0),r=>r?(t.push(1),ke(e(1,1),r=>r?(t.push(1),ke(e(1,2),r=>{if(!r)return t;t.push(1);let n=1,a=1,o=1;return function r(i){const s=n+a;return n=a,a=o,o=s,ke(e(o,i),e=>e?(t.push(o),r(i+1)):t)}(4)})):t)):t)}},Oa={"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 a=n**3;return ke(e(a,n),e=>e?(t.push(a),r(n+1)):t)}(1)}};function Fa(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(ve(n**r,e))return[n,r]}return null}const Ua={"perfect-power-seq":e=>{const t=[];for(let r=1;t.length<e;r++)Fa(r)&&t.push(r);return t},"perfect-power?":e=>null!==Fa(e),"perfect-power-take-while":e=>{const t=[];return function r(n){return Fa(n)?ke(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(1)}},Da={"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 a=n**2;return ke(e(a,n),e=>e?(t.push(a),r(n+1)):t)}(1)}},Ga={"polygonal-seq":{evaluate:([e,t],r)=>{f(e,r,{integer:!0,gte:3}),f(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:Z(2)},"polygonal-take-while":{evaluate:([e,t],r,n,{executeFunction:a})=>{f(e,r,{integer:!0,gte:3}),J(t,r);const o=e,i=t,s=[];return function e(t){const c=(t*t*(o-2)-t*(o-4))/2;return ke(a(i,[c,t],n,r),r=>r?(s.push(c),e(t+1)):s)}(1)},arity:Z(2)},"polygonal-nth":{evaluate:([e,t],r)=>(f(e,r,{integer:!0,gte:3}),f(t,r,{integer:!0,positive:!0}),(t*t*(e-2)-t*(e-4))/2),arity:Z(2)},"polygonal?":{evaluate:([e,t],r)=>{if(f(t,r,{integer:!0}),f(e,r,{integer:!0,gte:3}),t<=0)return!1;const n=e-2,a=e-4,o=8*n*t+a*a,i=Math.sqrt(o);if(!Number.isInteger(i))return!1;const s=i+a;if(s%(2*n)!=0)return!1;const c=s/(2*n);return Number.isInteger(c)&&c>0},arity:Z(2)}};const Wa={"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 ke(e(0,0),n=>{if(!n)return t;return t.push(0),function n(a){let o=t[a-1]-a;return(o<=0||r.has(o))&&(o=t[a-1]+a),ke(e(o,a),e=>e?(t.push(o),r.add(o),n(a+1)):t)}(1)})},"recaman?":()=>!0},Va={"thue-morse-seq":e=>{const t=[];for(let r=0;r<e;r+=1)t[r]=Ba(r)%2;return t},"thue-morse-take-while":e=>{const t=[];return function r(n){const a=Ba(n)%2;return ke(e(a,n),e=>e?(t.push(a),r(n+1)):t)}(0)},"thue-morse?":e=>1===e||0===e};function Ba(e){let t=0;for(;e;)t+=1&e,e>>=1;return t}const La={};function _a(e){for(const[t,r]of Object.entries(e)){if(La[t])throw new Error(`Duplicate normal expression key found: ${t}`);La[t]=r}}function Ka(e,t){return{[`${e}-seq`]:Ya(e=>t.slice(0,e),t.length),[`${e}-take-while`]:Ha(e=>function r(n){return n>=t.length?t.slice(0,n):ke(e(t[n],n),e=>e?r(n+1):t.slice(0,n))}(0),t.length),[`${e}-nth`]:Xa(()=>t,t.length),[`${e}?`]:Za(e=>t.includes(e))}}function Ja(e){for(const[t,r]of Object.entries(e)){if(La[t])throw new Error(`Duplicate normal expression key found: ${t}`);t.endsWith("seq")?(La[t]=Ya(r,e.maxLength),e.noNth||(La[t.replace(/seq$/,"nth")]=Xa(r,e.maxLength))):t.endsWith("take-while")?La[t]=Ha(r,e.maxLength):t.endsWith("?")&&(e.string?La[t]=Qa(r):La[t]=Za(r))}}function Ya(e,t){return{evaluate:(n,a)=>{const o=n[0]??t;f(o,a,{integer:!0,positive:!0,lte:t});const i=e(o,a);if("number"==typeof i[0]&&i.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",a);return i},arity:"number"==typeof t?{max:1}:Z(1)}}function Ha(e,t){return{evaluate:(t,n,a,{executeFunction:o})=>{const i=t[0];J(i,n);const s=e((e,t)=>ke(o(i,[e,t],a),e=>!!e),n);return ke(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}:Z(1)}}function Xa(e,t){return{evaluate:(n,a)=>{const o=n[0];f(o,a,{integer:!0,positive:!0,lte:t});const i=e(o,a);if("number"==typeof i[0]&&i.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",a);return i[o-1]},arity:Z(1)}}function Za(e){return{evaluate:(t,r)=>{const n=t[0];return f(n,r),e(n,r)},arity:Z(1)}}function Qa(e){return{evaluate:(t,r)=>{const n=t[0];return re(n,r),e(n,r)},arity:Z(1)}}function eo(e,t){for(;0!==t;){const r=t;t=e%t,e=r}return Math.abs(e)}function to(e,t){return Math.floor(e*t/eo(e,t))}function ro(e){if(1===e)return 1;const t=ga(e);return new Set(t).size!==t.length?0:t.length%2==0?1:-1}function no(e,t){if(0===t)return[e,1,0];const[r,n,a]=no(t,e%t);return[r,a,n-Math.floor(e/t)*a]}function ao(e,t){const[r,n]=no(e,t);if(1!==r)throw new Error(`Modular inverse does not exist (gcd(${e}, ${t}) = ${r})`);return(n%t+t)%t}Ja(ya),Ja({"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}),Ja(ka),Ja(Na),Ja(Ta),Ja(Ea),Ja(ja),Ja(Ca),Ja(Pa),Ja(Ia),Ja(Da),Ja(Oa),Ja(Ua),Ja(wa),Ja(Wa),Ja(Va),_a(Ka("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])),_a(Ka("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])),_a(Ka("factorial",oa)),_a(Ka("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])),_a(Ka("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])),_a(Ka("mersenne",[3,7,31,127,2047,8191,131071,524287,2147483647])),_a(Ka("partition",ca)),_a(Ka("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])),_a(Ka("perfect",[6,28,496,8128,33550336,8589869056,137438691328])),_a(Ka("sylvester",[2,6,42,1806,3263442,0x9afa8dc8416])),_a(Ka("bell",[1,2,5,15,52,203,877,4140,21147,115975,678570,4213597,27644437,190899322,1382958545,10480142147,82864869804,682076806159,5832742205057,51724158235372,474869816156751,4506715738447323])),_a(va),_a(ba),_a($a),_a(Ga);const oo={"coprime?":{evaluate:([e,t],r)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0}),1===eo(e,t)),arity:Z(2)},"divisible-by?":{evaluate:([e,t],r)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0}),0!==t&&e%t===0),arity:Z(2)},gcd:{evaluate:([e,t],r)=>(f(e,r),f(t,r),eo(e,t)),arity:Z(2)},lcm:{evaluate:([e,t],r)=>(f(e,r),f(t,r),to(e,t)),arity:Z(2)},multinomial:{evaluate:([...e],t)=>{Xe(e,t);return ia(e.reduce((e,r)=>(f(r,t,{integer:!0,nonNegative:!0}),e+r),0))/e.reduce((e,t)=>e*ia(t),1)},arity:{min:1}},"amicable?":{evaluate:([e,t],r)=>{f(e,r,{integer:!0,positive:!0}),f(t,r,{integer:!0,positive:!0});const n=na(e).reduce((e,t)=>e+t,0),a=na(t).reduce((e,t)=>e+t,0);return n===t&&a===e&&e!==t},arity:Z(2)},"euler-totient":{evaluate:([e],t)=>{f(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:Z(1)},mobius:{evaluate:([e],t)=>{if(f(e,t,{integer:!0,positive:!0}),1===e)return 1;const r=ga(e);return new Set(r).size!==r.length?0:r.length%2==0?1:-1},arity:Z(1)},mertens:{evaluate:([e],t)=>{if(f(e,t,{integer:!0,positive:!0}),1===e)return 1;let r=0;for(let t=1;t<=e;t++){r+=ro(t)}return r},arity:Z(1)},sigma:{evaluate:([e],t)=>(f(e,t,{integer:!0,positive:!0}),ra(e).reduce((e,t)=>e+t,0)),arity:Z(1)},"carmichael-lambda":{evaluate:([e],t)=>{if(f(e,t,{integer:!0,positive:!0}),1===e)return 1;const r=ga(e),n=new Map;for(const e of r)n.set(e,(n.get(e)||0)+1);const a=[];for(const[e,t]of n.entries())2===e?1===t?a.push(1):2===t?a.push(2):a.push(2**(t-2)):a.push((e-1)*e**(t-1));return a.reduce((e,t)=>to(e,t),1)},arity:Z(1)},"cartesian-product":{evaluate:(e,t)=>{e.forEach(e=>{xe(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)=>{f(e,t,{integer:!0,positive:!0});return Fa(e)||null},arity:Z(1)},"mod-exp":{evaluate:([e,t,r],n)=>(f(e,n,{finite:!0}),f(t,n,{integer:!0,positive:!0}),f(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:Z(3)},"mod-inv":{evaluate:([e,t],n)=>{f(e,n,{integer:!0,positive:!0}),f(t,n,{integer:!0,positive:!0});try{return ao(e,t)}catch(e){throw new r(e,n)}},arity:Z(2)},"extended-gcd":{evaluate:([e,t],r)=>(f(e,r,{integer:!0}),f(t,r,{integer:!0}),no(e,t)),arity:Z(2)},"chinese-remainder":{evaluate:([e,t],n)=>{if(Xe(e,n),Xe(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=no(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 a=0;a<e.length;a++){const o=e[a],i=t[a],s=r/i;n=(n+o*s*ao(s,i))%r}return n}(e,t)}catch(e){throw new r(e.message,n)}},arity:Z(2)},"stirling-first":{evaluate:([e,t],r)=>{f(e,r,{integer:!0,positive:!0}),f(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:Z(2)},"stirling-second":{evaluate:([e,t],r)=>{if(f(e,r,{integer:!0,positive:!0}),f(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:Z(2)}};function io(e){for(const[t,r]of Object.entries(e)){if(oo[t])throw new Error(`Duplicate normal expression key found: ${t}`);oo[t]=r}}!function(e){for(const[t,r]of Object.entries(e)){if(oo[t])throw new Error(`Duplicate normal expression key found: ${t}`);oo[t]=r}}(La),io(sa),io(aa),io(Qn),io(ua),io(la),io(ha),io(ea),io(pa);for(const[e,t]of Object.entries(Hn))oo[e]&&(oo[e].docs=t);const so={name:"number-theory",functions:oo},co={"string-repeat":{evaluate:([e,t],r)=>(re(e,r),f(t,r,{integer:!0,nonNegative:!0}),e.repeat(t)),arity:Z(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"); "*" string-repeat 10','let { string-repeat } = import("string"); string-repeat("*", 10)','let { string-repeat } = import("string"); string-repeat("***", 0)']}},"from-char-code":{evaluate:([e],t)=>{f(e,t,{finite:!0});const n=me(e);try{return String.fromCodePoint(n)}catch(e){throw new r(e,t)}},arity:Z(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"); from-char-code(65)','let { from-char-code } = import("string"); from-char-code(0)']}},"to-char-code":{evaluate:([e],t)=>(re(e,t,{nonEmpty:!0}),w(e.codePointAt(0),t)),arity:Z(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"); to-char-code("A")','let { to-char-code } = import("string"); to-char-code("Albert")']}},"trim-left":{evaluate:([e],t)=>(re(e,t),e.replace(/^\s+/,"")),arity:Z(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"); trim-left(" Albert ")','let { trim-left } = import("string"); trim-left(" ")','let { trim-left } = import("string"); trim-left("")']}},"trim-right":{evaluate:([e],t)=>(re(e,t),e.replace(/\s+$/,"")),arity:Z(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"); trim-right(" Albert ")','let { trim-right } = import("string"); trim-right(" ")','let { trim-right } = import("string"); trim-right("")']}},"split-lines":{evaluate:([e],t)=>(re(e,t),e.split(/\r\n|\n|\r/).filter(e=>""!==e)),arity:Z(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"); split-lines("Albert\nMojir\n")','let { split-lines } = import("string"); split-lines("Albert\n\nMojir")','let { split-lines } = import("string"); split-lines("Albert\nMojir\n\n")','let { split-lines } = import("string"); split-lines("")']}},"pad-left":{evaluate:([e,t,r],n)=>(re(e,n),f(t,n,{integer:!0}),void 0!==r&&re(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"); "Albert" pad-left 20','let { pad-left } = import("string"); pad-left("Albert", 20)','let { pad-left } = import("string"); pad-left("Albert", 20, "-*-")','let { pad-left } = import("string"); pad-left("Albert", 5)','let { pad-left } = import("string"); pad-left("Albert", -1)']}},"pad-right":{evaluate:([e,t,r],n)=>(re(e,n),f(t,n,{integer:!0}),void 0!==r&&re(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"); "Albert" pad-right 20','let { pad-right } = import("string"); pad-right("Albert", 20)','let { pad-right } = import("string"); pad-right("Albert", 20, "-*-")','let { pad-right } = import("string"); pad-right("Albert", 5)','let { pad-right } = import("string"); pad-right("Albert", -1)']}},template:{evaluate:([e,...t],r)=>{re(e,r),xe(t,r);const n=e.split("||||");if(n.length<=1)return mo(n[0],t,r);{const e=t[0];f(e,r,{integer:!0,nonNegative:!0});const a=[`${e}`,...t.slice(1)];if(2===n.length){return mo(n[1===e?0:1],a,r)}return mo(n[Math.min(e,n.length-1)],a,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"); template("Hi, $1 and $2", "Carl", "Larry")','let { template } = import("string"); template("Hi $1, $2, $3, $4, $5, $6, $7, $8 and $9", "A", "B", "C", "D", "E", "F", "G", "H", "I")','let { template } = import("string"); template("$1 book||||$1 books", 0)','let { template } = import("string"); template("$1 book||||$1 books", 1)','let { template } = import("string"); template("$1 book||||$1 books", 2)','let { template } = import("string"); template("No book||||$1 book||||$1 books", 0)','let { template } = import("string"); template("No book||||$1 book||||$1 books", 1)','let { template } = import("string"); template("No book||||$1 book||||$1 books", 10)','let { template } = import("string"); template("No book||||One book||||Two books||||Three books||||$1 books", 0)','let { template } = import("string"); template("No book||||One book||||Two books||||Three books||||$1 books", 1)','let { template } = import("string"); template("No book||||One book||||Two books||||Three books||||$1 books", 2)','let { template } = import("string"); template("No book||||One book||||Two books||||Three books||||$1 books", 3)','let { template } = import("string"); template("No book||||One book||||Two books||||Three books||||$1 books", 4)'],hideOperatorForm:!0}},"encode-base64":{evaluate:([e],t)=>(re(e,t),btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16))))),arity:Z(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"); encode-base64("Albert")']}},"decode-base64":{evaluate:([e],t)=>{re(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:Z(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"); decode-base64("QWxiZXJ0IPCfkLs=")']}},"encode-uri-component":{evaluate:([e],t)=>(re(e,t),encodeURIComponent(e)),arity:Z(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"); encode-uri-component("Hi everyone!?")']}},"decode-uri-component":{evaluate:([e],t)=>{re(e,t);try{return decodeURIComponent(e)}catch(e){throw new r(e,t)}},arity:Z(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"); decode-uri-component("Hi%20everyone!%3F%20%F0%9F%91%8D")']}},capitalize:{evaluate:([e],t)=>(re(e,t),e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()),arity:Z(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"); capitalize("albert")','let { capitalize } = import("string"); capitalize("ALBERT")','let { capitalize } = import("string"); capitalize("aLBERT")','let { capitalize } = import("string"); capitalize("")']}}},lo=/\$\$/g;function mo(e,t,r){for(let n=0;n<9;n+=1){const a=new RegExp(`(\\$\\$|[^$]|^)\\$${n+1}`,"g");if(a.test(e)){const o=oe(t[n],r);e=e.replace(a,`$1${o}`)}}return e=e.replace(lo,"$")}const uo={name:"string",functions:co};function po(e,t){if(D(e)){if("string"==typeof t&&se(e,t))return ue(e[t])}else if(v(t,{nonNegative:!0,integer:!0})&&t>=0&&t<e.length)return ue(e[t])}function go(e,t,r,n){if(B(e,n),Array.isArray(e)||"string"==typeof e){if(f(t,n,{integer:!0}),f(t,n,{gte:0}),f(t,n,{lte:e.length}),"string"==typeof e)return re(r,n,{char:!0}),`${e.slice(0,t)}${r}${e.slice(t+1)}`;const a=[...e];return a[t]=r,a}re(t,n);const a={...e};return a[t]=r,a}function ho(e,t,r,n,a,o,i){if(D(e)){re(t,i);const s={...e};return ke(o(r,[s[t],...n],a,i),e=>(s[t]=e,s))}{f(t,i);const s=me(t);if(f(s,i,{lte:e.length}),Array.isArray(e))return ke(Ae(Array.from({length:e.length+(s===e.length?1:0)}),(t,c)=>s===c?o(r,[e[c],...n],a,i):e[c]),e=>e);{const t=e.split("");return ke(Ae(Array.from({length:t.length+(s===t.length?1:0)}),(e,c)=>s===c?ke(o(r,[t[c],...n],a,i),e=>ne(e,i,{char:!0})):t[c]),e=>e.join(""))}}}function yo(e,t,r){const n=ge(e);return{coll:n,innerCollMeta:t.slice(0,t.length-1).reduce((e,t)=>{const n=e.coll;let a;return Array.isArray(n)?(f(t,r),a=V(n[t],r)):(G(n,r),re(t,r),se(e.coll,t)||(n[t]={}),a=V(n[t],r)),{coll:a,parent:n}},{coll:n,parent:{}})}}const vo={"get-in":{evaluate:(e,t)=>{let r=ue(e[0]);const n=e[1]??[],a=ue(e[2]);xe(n,t);for(const e of n){if(ie(e,t),!W(r))return a;{const t=po(r,e);if(void 0===t)return a;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(B(e,n),xe(t,n),I(r,n),1===t.length)return ie(t[0],n),go(e,t[0],r,n);const{coll:a,innerCollMeta:o}=yo(e,t,n),i=oe(t[t.length-1],n),s=oe(t[t.length-2],n);return Array.isArray(o.parent)?(f(s,n),o.parent[s]=go(o.coll,i,r,n)):(re(s,n),o.parent[s]=go(o.coll,i,r,n)),a},arity:Z(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],a,o,{executeFunction:i})=>(B(e,a),ie(t,a),J(r,a),ho(e,t,r,n,o,i,a)),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],a,o,{executeFunction:i})=>{if(B(e,a),xe(t,a),J(r,a),1===t.length)return ie(t[0],a),ho(e,t[0],r,n,o,i,a);const{coll:s,innerCollMeta:c}=yo(e,t,a),l=oe(t[t.length-1],a),m=oe(t[t.length-2],a);return Array.isArray(c.parent)?(f(m,a),ke(ho(c.coll,l,r,n,o,i,a),e=>(c.parent[m]=e,s))):(re(m,a),ke(ho(c.coll,l,r,n,o,i,a),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:a})=>(B(e,r),J(t,r),Array.isArray(e)?Pe(e,(e,o)=>a(t,[e,o],n,r)):"string"==typeof e?ke(Pe(e.split(""),(e,o)=>a(t,[e,o],n,r)),e=>e.join("")):ke(Pe(Object.entries(e),([e,o])=>a(t,[o,e],n,r)),e=>e.reduce((e,[t,r])=>(e[t]=r,e),{}))),arity:Z(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:a})=>{if(B(e,r),J(t,r),Array.isArray(e))return Ae(e,(e,o)=>a(t,[e,o],n,r));if("string"==typeof e)return ke(Ae(e.split(""),(e,o)=>a(t,[e,o],n,r)),e=>e.join(""));return $e(Object.entries(e),(e,[o,i])=>ke(a(t,[i,o],n,r),t=>(e[o]=t,e)),{})},arity:Z(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,a,{executeFunction:o})=>(B(e,n),J(t,n),I(r,n),"string"==typeof e?(re(r,n),0===e.length?r:$e(e.split("").map((e,t)=>({elem:e,index:t})),(e,{elem:r,index:i})=>o(t,[e,r,i],a,n),r)):Array.isArray(e)?0===e.length?r:$e(e.map((e,t)=>({elem:e,index:t})),(e,{elem:r,index:i})=>o(t,[e,r,i],a,n),r):0===Object.keys(e).length?r:$e(Object.entries(e),(e,[r,i])=>o(t,[e,i,r],a,n),r)),arity:Z(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,a,{executeFunction:o})=>(B(e,n),J(t,n),I(r,n),"string"==typeof e?0===e.length?r:$e(Array.from(e.split("")).reverse(),(e,r)=>o(t,[e,r],a,n),r):Array.isArray(e)?0===e.length?r:$e(Array.from(e).reverse(),(e,r)=>o(t,[e,r],a,n),r):0===Object.keys(e).length?r:$e(Object.entries(e).reverse(),(e,[,r])=>o(t,[e,r],a,n),r)),arity:Z(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,a,{executeFunction:o})=>(B(e,n),J(t,n),I(r,n),"string"==typeof e?0===e.length?r:$e(Array.from(e.split("")).reverse().map((e,t,r)=>({elem:e,index:r.length-1-t})),(e,{elem:r,index:i})=>o(t,[e,r,i],a,n),r):Array.isArray(e)?0===e.length?r:$e(Array.from(e).reverse().map((e,t,r)=>({elem:e,index:r.length-1-t})),(e,{elem:r,index:i})=>o(t,[e,r,i],a,n),r):0===Object.keys(e).length?r:$e(Object.entries(e).reverse(),(e,[r,i])=>o(t,[e,i,r],a,n),r)),arity:Z(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,a,{executeFunction:o})=>{B(e,n),J(t,n),I(r,n),I(r,n);const i="string"==typeof e?(re(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 ke($e(i,(e,r)=>ke(o(t,[e,r],a,n),e=>(s.push(e),e)),r),()=>s)},arity:Z(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,a,{executeFunction:o})=>{B(e,n),J(t,n),I(r,n),I(r,n);const i=(e,t)=>({elem:e,key:t}),s="string"==typeof e?(re(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 ke($e(s,(e,{elem:r,key:i})=>ke(o(t,[e,r,i],a,n),e=>(c.push(e),e)),r),()=>c)},arity:Z(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:(B(e,t),"string"==typeof e||Array.isArray(e)?e.length>0?e:null:Object.keys(e).length>0?e:null),arity:Z(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:a})=>{B(e,r),J(t,r);return Ce(Array.isArray(e)?e:"string"==typeof e?e.split(""):Object.entries(e),e=>a(t,[e],n,r))},arity:Z(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.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:a})=>{J(t,r),B(e,r);return je(Array.isArray(e)?e:"string"==typeof e?e.split(""):Object.entries(e),e=>a(t,[e],n,r))},arity:Z(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:a})=>{J(t,r),B(e,r);return ke(je(Array.isArray(e)?e:"string"==typeof e?e.split(""):Object.entries(e),e=>a(t,[e],n,r)),e=>!e)},arity:Z(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:a})=>{J(t,r),B(e,r);return ke(Ce(Array.isArray(e)?e:"string"==typeof e?e.split(""):Object.entries(e),e=>a(t,[e],n,r)),e=>!e)},arity:Z(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)']}}},fo={name:"collection",functions:vo},bo={position:{evaluate:([e,t],r,n,{executeFunction:a})=>{if(J(t,r),null===e)return null;U(e,r);return ke(Oe("string"==typeof e?e.split(""):e,e=>a(t,[e],n,r)),e=>-1!==e?e:null)},arity:Z(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(I(t,r),null===e)return null;if(U(e,r),"string"==typeof e){re(t,r);const n=e.lastIndexOf(t);return-1!==n?n:null}{const n=e.findLastIndex(e=>le(P(e,r),t),r);return-1!==n?n:null}},arity:Z(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)']}},shift:{evaluate:([e],t)=>{if(U(e,t),"string"==typeof e)return e.substring(1);const r=[...e];return r.shift(),r},arity:Z(1),docs:{category:"sequence",returns:{type:["sequence","null"]},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"Returns a copy of $seq with first element removed. If $seq is empty `null` is returned.",seeAlso:["sequence.unshift","pop","rest"],examples:['let su = import("sequence"); su.shift([1, 2, 3])','let su = import("sequence"); su.shift([])']}},splice:{evaluate:(e,t)=>{const[r,n,a,...o]=e;U(r,t),f(n,t,{integer:!0}),f(a,t,{integer:!0,nonNegative:!0});const i=n<0?r.length+n:n;return Array.isArray(r)?[...r.slice(0,i),...o,...r.slice(i+a)]:(o.forEach(e=>re(e,t)),`${r.substring(0,i)}${o.join("")}${r.substring(i+a)}`)},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[a,o]=e,i=2===e.length;U(a,t),J(o,t);const s=i?null:e[2],c="string"==typeof a,l=c?a.split(""):[...a];return ke(Ae(l,e=>n(o,[e],r,t)),e=>{if(i){const r=l.map((t,r)=>({elem:t,key:e[r]}));r.sort((e,r)=>(ie(e.key,t),ie(r.key,t),ce(e.key,r.key,t)));const n=r.map(e=>e.elem);return c?n.join(""):n}{J(s,t);const a=l.map((t,r)=>({elem:t,key:e[r]}));a.sort((e,a)=>{const o=n(s,[e.key,a.key],r,t);if(o instanceof Promise)throw new TypeError("Async functions cannot be used as sort-by comparators");return f(o,t,{finite:!0}),o});const o=a.map(e=>e.elem);return c?o.join(""):o}})},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)']}},take:{evaluate:([e,t],r)=>{f(t,r),U(e,r);const n=Math.max(Math.ceil(t),0);return e.slice(0,n)},arity:Z(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:["sequence.take-last","sequence.take-while","sequence.drop","slice","sequence.split-at"],examples:['let su = import("sequence"); su.take([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.take([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.take([1, 2, 3, 4, 5], 0)','let su = import("sequence"); su.take("Albert", 2)','let su = import("sequence"); su.take("Albert", 50)']}},"take-last":{evaluate:([e,t],r)=>{U(e,r),f(t,r);const n=Math.max(Math.ceil(t),0),a=e.length-n;return e.slice(a)},arity:Z(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},n:{type:"integer"},seq:{type:"sequence"}},variants:[{argumentNames:["n","seq"]}],description:"Constructs a new array with the $n last elements from $seq.",seeAlso:["sequence.take","sequence.drop-last"],examples:['let su = import("sequence"); su.take-last([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.take-last([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.take-last([1, 2, 3, 4, 5], 0)']}},"take-while":{evaluate:([e,t],r,n,{executeFunction:a})=>{U(e,r),J(t,r);const o="string"==typeof e?e.split(""):Array.from(e);return ke(Oe(o,e=>ke(a(t,[e],n,r),e=>!e)),t=>{const r=-1===t?o:o.slice(0,t);return"string"==typeof e?r.join(""):r})},arity:Z(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:["sequence.take","sequence.drop-while","sequence.split-with"],examples:['\nlet su = import("sequence");\nsu.take-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)','\nlet su = import("sequence");\nsu.take-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)']}},drop:{evaluate:([e,t],r)=>{f(t,r);const n=Math.max(Math.ceil(t),0);return U(e,r),e.slice(n)},arity:Z(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:["sequence.drop-last","sequence.drop-while","sequence.take","slice","sequence.split-at"],examples:['let su = import("sequence"); su.drop([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.drop([1, 2, 3, 4, 5], 0)','let su = import("sequence"); su.drop("Albert", 2)','let su = import("sequence"); su.drop("Albert", 50)']}},"drop-last":{evaluate:([e,t],r)=>{U(e,r),f(t,r);const n=Math.max(Math.ceil(t),0),a=e.length-n;return e.slice(0,a)},arity:Z(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:["sequence.drop","sequence.take-last"],examples:['let su = import("sequence"); su.drop-last([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.drop-last([1, 2, 3, 4, 5], 3)','let su = import("sequence"); su.drop-last([1, 2, 3, 4, 5], 0)']}},"drop-while":{evaluate:([e,t],r,n,{executeFunction:a})=>{U(e,r),J(t,r);const o=Array.isArray(e)?e:e.split("");return ke(Oe(o,e=>ke(a(t,[e],n,r),e=>!e)),t=>-1===t?"string"==typeof e?"":[]:"string"==typeof e?o.slice(t).join(""):e.slice(t))},arity:Z(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:["sequence.drop","sequence.take-while","sequence.split-with"],examples:['\nlet su = import("sequence");\nsu.drop-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)','\nlet su = import("sequence");\nsu.drop-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)']}},unshift:{evaluate:([e,...t],r)=>{if(U(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","sequence.shift","++"],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(U(e,t),Array.isArray(e)){const r=[];for(const n of e)I(n,t),r.some(e=>le(e,n,t))||r.push(n);return r}return Array.from(new Set(e.split(""))).join("")},arity:Z(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:a})=>{J(t,r),U(e,r);return ke(Pe(Array.isArray(e)?e:e.split(""),e=>ke(a(t,[e],n,r),e=>!e)),t=>"string"==typeof e?t.join(""):t)},arity:Z(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)=>{f(t,r,{integer:!0}),U(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:Z(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)=>{f(t,r,{integer:!0}),U(e,r);const n=t<0?e.length+t:t;return[e.slice(0,n),e.slice(n)]},arity:Z(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","sequence.take","sequence.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:a})=>{J(t,r),U(e,r);const o=Array.isArray(e);return ke(Oe(o?e:e.split(""),e=>ke(a(t,[e],n,r),e=>!e)),t=>-1===t?[e,o?[]:""]:[e.slice(0,t),e.slice(t)])},arity:Z(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","sequence.take-while","sequence.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)=>{U(e,t);return("string"==typeof e?e.split(""):e).reduce((e,r)=>(re(r,t),se(e,r)?e[r]=e[r]+1:e[r]=1,e),{})},arity:Z(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:a})=>{J(t,r),U(e,r);return $e(Array.isArray(e)?e:e.split(""),(e,o)=>ke(a(t,[o],n,r),t=>(re(t,r),se(e,t)||(e[t]=[]),e[t].push(o),e)),{})},arity:Z(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=F(e[0],t),n=me(b(e[1],t)),a=e.length>=3?me(b(e[2],t)):n,o=4===e.length?null===e[3]?[]:function(e,t){return xe(e,t),e}(e[3],t):void 0;return xo(n,a,r,o,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=F(e[0],t),n=me(b(e[1],t));return xo(n,3===e.length?me(b(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:a})=>{J(t,r),U(e,r);const o="string"==typeof e;return ke($e(o?e.split(""):e,(e,o)=>ke(a(t,[o],n,r),t=>(t!==e.oldValue&&(e.result.push([]),e.oldValue=t),e.result[e.result.length-1].push(o),e)),{result:[],oldValue:void 0}),({result:e})=>o?e.map(e=>e.join("")):e)},arity:Z(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)=>(U(e,r),"string"==typeof e?(re(t,r),e.endsWith(t)):le(P(e.at(-1),r),P(t,r),r)),arity:Z(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)=>(U(e,r),"string"==typeof e?(re(t,r),e.startsWith(t)):le(P(e[0],r),P(t,r),r)),arity:Z(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=>(re(e,t),e.split(""))):e.map(e=>(xe(e,t),e)),a=Math.min(...n.map(e=>e.length)),o=[];for(let e=0;e<a;e+=1)for(const t of n)e<t.length&&o.push(t[e]);return r?o.join(""):o},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(U(e,r),"string"==typeof e)return re(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:Z(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 xo(e,t,r,n,a){f(t,a,{positive:!0});const o="string"==typeof r,i=[];let s=0;e:for(;s<r.length;){const a=[];for(let o=s;o<s+e;o+=1)if(o>=r.length){const e=o-r.length;if(!n){s+=t;continue e}if(e>=n.length)break;a.push(n[e])}else a.push(r[o]);i.push(a),s+=t}return o?i.map(e=>e.join("")):i}const wo={name:"sequence",functions:bo};function qo(e){return([t],n)=>{const[a,o]=function(e,t){if(He(e))return["vector",e];if(nt(e))return["matrix",e];if(!v(e))throw new r("Invalid parameter type: "+typeof e,t);return["number",e]}(t,n);return"number"===a?e(o):"vector"===a?o.map(t=>e(t)):o.map(t=>t.map(t=>e(t)))}}const ko={name:"math",functions:{sin:{evaluate:qo(e=>Math.sin(e)),arity:Z(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"); sin(0)','let { sin } = import("math"); sin(1)','let { sin } = import("math"); sin(PI)','let { sin } = import("math"); sin(-0.5)','let { sin } = import("math"); sin([1, 2, 3])','let { sin } = import("math"); sin([[1, 2], [3, 4]])']}},asin:{evaluate:qo(e=>Math.asin(e)),arity:Z(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"); asin(0)','let { asin } = import("math"); asin(1)','let { asin } = import("math"); asin(-0.5)','let { asin } = import("math"); asin([1, 2, 3])','let { asin } = import("math"); asin([[1, 2], [3, 4]])']}},sinh:{evaluate:qo(e=>Math.sinh(e)),arity:Z(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"); sinh(0)','let { sinh } = import("math"); sinh(1)','let { sinh } = import("math"); sinh(-0.5)','let { sinh } = import("math"); sinh([0.1, 0.2, 0.3])','let { sinh } = import("math"); sinh([[0.1, 0.2], [0.3, 0.4]])']}},asinh:{evaluate:qo(e=>Math.asinh(e)),arity:Z(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"); asinh(10)','let { asinh } = import("math"); asinh(90)','let { asinh } = import("math"); asinh(50)','let { asinh } = import("math"); asinh([10, 20, 30])','let { asinh } = import("math"); asinh([[10, 20], [30, 40]])']}},cos:{evaluate:qo(e=>Math.cos(e)),arity:Z(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"); cos(0)','let { cos } = import("math"); cos(1)','let { cos } = import("math"); cos(PI)','let { cos } = import("math"); cos(-0.5)','let { cos } = import("math"); cos([1, 2, 3])','let { cos } = import("math"); cos([[1, 2], [3, 4]])']}},acos:{evaluate:qo(e=>Math.acos(e)),arity:Z(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"); acos(0)','let { acos } = import("math"); acos(1)','let { acos } = import("math"); acos(-0.5)','let { acos } = import("math"); acos([0.1, 0.2, 0.3])','let { acos } = import("math"); acos([[0.1, 0.2], [0.3, 0.4]])']}},cosh:{evaluate:qo(e=>Math.cosh(e)),arity:Z(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"); cosh(0)','let { cosh } = import("math"); cosh(1)','let { cosh } = import("math"); cosh(-0.5)','let { cosh } = import("math"); cosh([0.1, 0.2, 0.3])','let { cosh } = import("math"); cosh([[0.1, 0.2], [0.3, 0.4]])']}},acosh:{evaluate:qo(e=>Math.acosh(e)),arity:Z(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"); acosh(1)','let { acosh } = import("math"); acosh(2)','let { acosh } = import("math"); acosh(100)','let { acosh } = import("math"); acosh(50)','let { acosh } = import("math"); acosh([1, 2, 3])','let { acosh } = import("math"); acosh([[1, 2], [3, 4]])']}},tan:{evaluate:qo(e=>Math.tan(e)),arity:Z(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"); tan(0)','let { tan } = import("math"); tan(1)','let { tan } = import("math"); tan(PI)','let { tan } = import("math"); tan(-0.5)','let { tan } = import("math"); tan([1, 2, 3])','let { tan } = import("math"); tan([[1, 2], [3, 4]])']}},atan:{evaluate:qo(e=>Math.atan(e)),arity:Z(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"); atan(0)','let { atan } = import("math"); atan(1)','let { atan } = import("math"); atan(-0.5)','let { atan } = import("math"); atan([0.1, 0.2, 0.3])','let { atan } = import("math"); atan([[0.1, 0.2], [0.3, 0.4]])']}},tanh:{evaluate:qo(e=>Math.tanh(e)),arity:Z(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"); tanh(0)','let { tanh } = import("math"); tanh(1)','let { tanh } = import("math"); tanh(-0.5)','let { tanh } = import("math"); tanh(50)']}},atanh:{evaluate:qo(e=>Math.atanh(e)),arity:Z(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"); atanh(0)','let { atanh } = import("math"); atanh(0.9)','let { atanh } = import("math"); atanh(-0.5)','let { atanh } = import("math"); atanh([0.1, 0.2, 0.3])','let { atanh } = import("math"); atanh([[0.1, 0.2], [0.3, 0.4]])']}},ln:{evaluate:qo(e=>Math.log(e)),arity:Z(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"); ln(0.01)','let { ln } = import("math"); ln(2.5)','let { ln } = import("math"); ln(E)','let { ln } = import("math"); ln([1, 2, 3])','let { ln } = import("math"); ln([[1, 2], [3, 4]])']}},log2:{evaluate:qo(e=>Math.log2(e)),arity:Z(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"); log2(0.01)','let { log2 } = import("math"); log2(2 ^ 12)','let { log2 } = import("math"); log2(2.5)','let { log2 } = import("math"); log2([1, 2, 3])','let { log2 } = import("math"); log2([[1, 2], [3, 4]])']}},log10:{evaluate:qo(e=>Math.log10(e)),arity:Z(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"); log10(0.01)','let { log10 } = import("math"); log10(10 ^ 12)','let { log10 } = import("math"); log10(2.5)','let { log10 } = import("math"); log10([1, 2, 3])','let { log10 } = import("math"); log10([[1, 2], [3, 4]])']}},"to-rad":{evaluate:qo(e=>e*Math.PI/180),arity:Z(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"); to-rad(0)','let { to-rad } = import("math"); to-rad(90)','let { to-rad } = import("math"); to-rad(180)','let { to-rad } = import("math"); to-rad(360)','let { to-rad } = import("math"); to-rad([0, 90, 180])','let { to-rad } = import("math"); to-rad([[0, 90], [180, 360]])']}},"to-deg":{evaluate:qo(e=>180*e/Math.PI),arity:Z(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"); to-deg(0)','let { to-deg } = import("math"); to-deg(PI)','let { to-deg } = import("math"); to-deg(PI / 2)','let { to-deg } = import("math"); to-deg(3 * PI / 2)','let { to-deg } = import("math"); to-deg([0, PI, PI / 2])','let { to-deg } = import("math"); to-deg([[0, PI], [PI / 2, 3 * PI / 2]])']}}}},Ao={name:"functional",functions:{juxt:{evaluate:(e,t)=>{e.forEach(e=>J(e,t));const n=function(e){return e.reduce((e,t)=>{if(null===e)return null;const r="number"==typeof t||W(t)?Z(1):t.arity,{min:n,max:a}=r,{min:o,max:i}=e,s="number"==typeof n&&"number"==typeof o?Math.max(n,o):"number"==typeof n?n:"number"==typeof o?o:void 0,c="number"==typeof a&&"number"==typeof i?Math.min(a,i):"number"==typeof a?a:"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=K(e,t);return{[u]:!0,sourceCodeInfo:t,functionType:"Complement",function:r,arity:Y(r)}},arity:Z(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=K(e,r);return{[u]:!0,sourceCodeInfo:r,functionType:"Fnull",function:n,params:t,arity:Y(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 No(e,t){return{a:{type:e},b:{type:t}}}const $o={name:"bitwise",functions:{"bit-not":{evaluate:([e],t)=>(f(e,t,{integer:!0}),~e),arity:Z(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)=>(f(e,r,{integer:!0}),t.reduce((e,t)=>(f(t,r,{integer:!0}),e&~t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...No("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)=>{f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0});return e^1<<t},arity:Z(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...No("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)=>{f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0});return e|1<<t},arity:Z(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...No("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)=>{f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0});return e&~(1<<t)},arity:Z(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...No("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)=>{f(e,r,{integer:!0}),f(t,r,{integer:!0,nonNegative:!0});return!!(e&1<<t)},arity:Z(2),docs:{category:"bitwise",returns:{type:"boolean"},args:{...No("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)']}}}},To={"-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']}},So={"-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","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 zo(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 Eo(e,t){const r={};for(const[n,a]of Object.entries(t)){const t=a.docs;if(!t)throw new Error(`Missing docs for ${e}.${n}`);const o=`${e}.${n}`;r[o]={title:o,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 jo=zo(ee),Mo=zo(De),Co=zo(Ue),Ro=zo(ft),Po=zo(mt),Io=zo(wt({})),Oo=zo(pt),Fo=zo(gt),Uo=zo(ht),Do=zo(dt),Go=zo(Ge),Wo=zo(vt),Vo=zo(qt);const Bo=function(){const e={};for(const[t,r]of Object.entries(yr)){const n=vr[r],a=n?.docs;a&&(jr(a)?e[t]={title:t,category:a.category,description:a.description,returns:a.returns,args:a.args,variants:a.variants,examples:a.examples,...a.seeAlso?{seeAlso:a.seeAlso}:{},...a.hideOperatorForm?{noOperatorDocumentation:!0}:{}}:e[t]={title:t,category:a.category,description:a.description,customVariants:a.customVariants,...a.details?{details:a.details}:{},...a.returns?{returns:a.returns}:{},examples:a.examples,...a.seeAlso?{seeAlso:a.seeAlso}:{}})}return e}();function Lo(e){return"returns"in e&&"args"in e&&"variants"in e}function _o(e){return"customVariants"in e}function Ko(e){return"shorthand"in e}function Jo(e){return"datatype"in e}const Yo={...jo,...Co,...Mo,...Go,...Po,...Ro,...Io,...Oo,...Fo,...Uo,...Do,...Wo,...Vo},Ho={...Eo(Rr.name,Rr.functions),...Eo(Fr.name,Fr.functions),...Eo(Vr.name,Vr.functions),...Eo(Tn.name,Tn.functions),...Eo(Dn.name,Dn.functions),...Eo(Yn.name,Yn.functions),...Eo(so.name,so.functions),...Eo(uo.name,uo.functions),...Eo(fo.name,fo.functions),...Eo(wo.name,wo.functions),...Eo(ko.name,ko.functions),...Eo(Ao.name,Ao.functions),...Eo($o.name,$o.functions)};Object.entries(Yo).forEach(([e,t])=>{if(!Nt[e])throw new Error(`Missing normal expression ${e} in normalExpressions`);const r=Nt[e].arity;!t.noOperatorDocumentation&&X(r)&&(t._isOperator=!0,Sr(e)&&(t._prefereOperator=!0))}),Object.entries(Bo).forEach(([e,t])=>{if(Lo(t)){const r=vr[yr[e]]?.arity;r&&X(r)&&(t._isOperator=!0)}});const Xo=Qo({...{...Yo,...Bo},...So,...To}),Zo=Qo({...Xo,...Ho});function Qo(e){return Object.fromEntries(Object.entries(e).sort(([e,t],[r,n])=>{const a="special-expression"===t.category?"":t.category,o="special-expression"===n.category?"":n.category;return a!==o?a.localeCompare(o):e.localeCompare(r)}))}var ei;Object.values(Zo).forEach(e=>{e.title=e.title.replace(/"/g,"&quot;")}),ei=Yo,Object.assign(kt,ei);const ti=(e,t,r,n)=>{const a=Array.isArray(e)?e:[[s.SpecialExpression,[yr.block,e.body]]],o=new Set;for(const e of a)ri(e,t,r,n)?.forEach(e=>o.add(e));return o};function ri(e,t,n,a){const o=e[0];switch(o){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,o=new Set;if(It(r)){const[,[e]]=r;if(Mt(e)){null===t.lookUp(e)&&o.add(e[1])}}else{const[,[e]]=r;ri(e,t,n,a)?.forEach(e=>o.add(e))}for(const e of r[1][1])ri(e,t,n,a)?.forEach(e=>o.add(e));return o}case s.SpecialExpression:{const r=e,o=r[1][0];return(0,n.specialExpressions[o].getUndefinedSymbols)(r,t,{getUndefinedSymbols:ti,builtin:n,evaluateNode:a})}case s.Spread:return ri(e[1],t,n,a);default:throw new r(`Unhandled node type: ${o}`,e[2])}}const ni=(1+Math.sqrt(5))/2,ai={E:Math.E,"-E":-Math.E,"ε":Math.E,"-ε":-Math.E,PI:Math.PI,"-PI":-Math.PI,"π":Math.PI,"-π":-Math.PI,PHI:ni,"-PHI":-ni,"φ":ni,"-φ":-ni,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},oi={true:!0,false:!1,null:null,do:null,else:null,case:null,each:null,in:null,when:null,while:null,catch:null,function:null,export:null,as:null,then:null,end:null,_:null,...ai};const ii={NativeJsFunction:(e,t,n)=>{try{const a=e.nativeFn.fn(...t);return a instanceof Promise?a.then(e=>ue(e),e=>{const t="string"==typeof e?e:k(e)&&"string"==typeof e.message?e.message:"<no message>";throw new r(`Native function threw: "${t}"`,n)}):ue(a)}catch(e){const t="string"==typeof e?e:k(e)&&"string"==typeof e.message?e.message:"<no message>";throw new r(`Native function threw: "${t}"`,n)}},UserDefined:(e,n,a,o,{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}.`,a);const c=e.evaluatedfunction,l=c[0],m=l.filter(e=>e[0]!==Gt).length,u=o.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=ke(h,()=>{const e=ue(n[t]);return ke(Lt(l[t],e,e=>i(e,u.create(p))),e=>{Object.entries(e).forEach(([e,t])=>{p[e]={value:t}})})})}else g.push(ue(n[e]));for(let e=n.length;e<m;e++){const t=e;d=ke(d,()=>{const e=l[t];return ke(i(e[1][1],o.create(p)),t=>ke(Lt(e,t,e=>i(e,o.create(p))),e=>{Object.entries(e).forEach(([e,t])=>{p[e]={value:t}})}))})}return ke(h,()=>ke(d,()=>{const e=l.find(e=>e[0]===Gt),r=void 0!==e?ke(Lt(e,g,e=>i(e,o.create(p))),e=>{Object.entries(e).forEach(([e,t])=>{p[e]={value:t}})}):void 0;return ke(r,()=>{const e=u.create(p),r=$e(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,a,{executeFunction:o})=>{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 o(e.function,i,a,n)},Comp:(e,t,n,a,{executeFunction:o})=>{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 P(t[0],n)}let s=t;for(let e=i.length-1;e>=0;e--){const t=i[e];s=ke(s,e=>ke(o(K(t,n),e,a,n),e=>[e]))}return ke(s,e=>P(e[0],n))},Constantly:e=>e.value,Juxt:(e,t,r,n,{executeFunction:a})=>Ae(e.params,e=>a(K(e,r),t,n,r)),Complement:(e,t,r,n,{executeFunction:a})=>ke(a(e.function,t,n,r),e=>!e),EveryPred:(e,t,r,n,{executeFunction:a})=>{const o=[];for(const i of e.params)for(const e of t)o.push(()=>a(K(i,r),[e],n,r));return $e(o,(e,t)=>!!e&&ke(t(),e=>!!e),!0)},SomePred:(e,t,r,n,{executeFunction:a})=>{const o=[];for(const i of e.params)for(const e of t)o.push(()=>a(K(i,r),[e],n,r));return $e(o,(e,t)=>!!e||ke(t(),e=>!!e),!1)},Fnull:(e,t,r,n,{executeFunction:a})=>{const o=t.map((t,r)=>null===t?ue(e.params[r]):t);return a(K(e.function,r),o,n,r)},Builtin:(e,t,r,n,{executeFunction:a})=>w(Tt[e.normalBuiltinSymbolType],r).evaluate(t,r,n,{executeFunction:a}),SpecialBuiltin:(e,t,n,a,{executeFunction:o})=>{const i=w(vr[e.specialBuiltinSymbolType],n);if(i.evaluateAsNormalExpression)return i.evaluateAsNormalExpression(t,n,a,{executeFunction:o});throw new r(`Special builtin function ${e.specialBuiltinSymbolType} is not supported as normal expression.`,n)},Module:(e,t,n,a,{executeFunction:o})=>{const i=a.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);return H(s.arity,t.length,n),s.evaluate(t,n,a,{executeFunction:o})}};function si(e,t){return $e(e.body,(e,r)=>ci(r,t),null)}function ci(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 w(oi[t],e[2])}(e);case s.NormalExpression:{const n=function(e,t){const n=e[2];return ke(function(e,t){const n=[],a=[],o=Se(e,(e,o)=>Ot(e)?ke(ci(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]?ke(ci(e,t),e=>{n.push(e)}):void a.push(o));return ke(o,()=>({params:n,placeholders:a}))}(e[1][1],t),({params:r,placeholders:a})=>{if(It(e)){const i=e[1][0];if(a.length>0){return ke(ci(i,t),e=>({[u]:!0,function:K(e,n),functionType:"Partial",params:r,placeholders:a,sourceCodeInfo:n,arity:Z(a.length)}))}if(Rt(i)){const n=i[1];return fr.allNormalExpressions[n].evaluate(r,e[2],t,{executeFunction:li})}{const a=t.getValue(i[1]);if(void 0!==a)return li(K(a,n),r,t,n);throw new o(i[1],e[2])}}return ke(ci(e[1][0],t),e=>{const o=K(e,n);if(a.length>0){return{[u]:!0,function:o,functionType:"Partial",params:r,placeholders:a,sourceCodeInfo:n,arity:Z(a.length)}}return li(o,r,t,n)})})}(e,t);return ke(n,t=>{if("number"==typeof t&&Number.isNaN(t))throw new r("Number is NaN",e[2]);return Ye(t)})}case s.SpecialExpression:return ke(function(e,t){const r=e[1][0],n=w(fr.specialExpressions[r],e[2]);return(0,n.evaluate)(e,t,{evaluateNode:ci,builtin:fr,getUndefinedSymbols:ti})}(e,t),e=>Ye(e));default:throw new r(`${l(e[0])}-node cannot be evaluated`,e[2])}}function li(e,t,n,a){if(A(e))return ii[e.functionType](e,t,a,n,{evaluateNode:ci,executeFunction:li});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 a=t[0];return f(a,n,{integer:!0,nonNegative:!0}),ue(e[a])}(e,t,a);if(D(e))return function(e,t,n){if(1!==t.length)throw new r("Object as function requires one string parameter.",n);const a=t[0];return re(a,n),ue(e[a])}(e,t,a);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 a=ue(t[0]);if(D(a))return ue(a[e]);if(v(a,{integer:!0}))return ue(e[a]);throw new r(`string as function expects Obj or integer parameter, got ${d(a)}`,n)}(e,t,a);if(v(e))return function(e,t,n){if(f(e,n,{integer:!0}),1!==t.length)throw new r("Number as function requires one Arr parameter.",n);const a=t[0];return U(a,n),ue(a[e])}(e,t,a);throw new r("Unexpected function type",a)}class mi{contexts;globalContext;values;nativeJsFunctions;modules;constructor({contexts:e,values:t,nativeJsFunctions:r,modules:n}){this.globalContext=w(e[0]),this.contexts=e,this.values=t,this.nativeJsFunctions=r,this.modules=n??new Map}getModule(e){return this.modules.get(e)}create(e){const t=this.globalContext,r=new mi({contexts:[e,...this.contexts],values:this.values,nativeJsFunctions:this.nativeJsFunctions,modules:this.modules});return r.globalContext=t,r}new(e){return new mi({contexts:[{},e],modules:this.modules})}exportValues(e,t){for(const[n,a]of Object.entries(e)){if(this.globalContext[n])throw new r(`Cannot redefine exported value "${n}"`,t);const e=ui(n);if(e)throw new r(`Cannot shadow ${e}`,t);this.globalContext[n]={value:a}}this.contexts[0]!==this.globalContext&&this.addValues(e,t)}addValues(e,t){const n=this.contexts[0];for(const[a,o]of Object.entries(e)){if(n[a])throw new r(`Cannot redefine value "${a}"`,t);const e=ui(a);if(e)throw new r(`Cannot shadow ${e}`,t);n[a]={value:ue(o)}}}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:ue(r)};const n=this.nativeJsFunctions?.[t];return n?{value:n}:null}evaluateSymbol(e){if(Pt(e)){const t=e[1];switch(t){case yr["&&"]:case yr["||"]:case yr.array:case yr.object:case yr["defined?"]:case yr.recur:case yr.throw:case yr["??"]:{const r=w(fr.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(Rt(e)){const t=e[1],r=Tt[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(k(n=t)&&void 0!==n.value)return t.value;var n;throw new o(e[1],e[2])}}function ui(e){return xr.includes(e)?`special expression "${e}"`:br.includes(e)?`builtin function "${e}"`:"self"===e?`builtin value "${e}"`:null}function pi(e={},t){const n=e.globalContext??{},a=e.contexts?[n,...e.contexts]:[n],o=new mi({contexts:a,values:e.values,modules:t,nativeJsFunctions:e.jsFunctions&&Object.entries(e.jsFunctions).reduce((e,[t,n])=>{const a=t.split("."),o=a.pop();if(/^[A-Z]/.test(o))throw new r(`Invalid identifier "${t}" in jsFunctions, function name must not start with an uppercase letter`,void 0);let i=e;for(const e of a){if(0===e.length)throw new r(`Invalid empty identifier "${t}" in jsFunctions`,void 0);if(!/^[A-Z]/.test(e))throw new r(`Invalid identifier "${t}" in jsFunctions, module name must start with an uppercase letter`,void 0);i[e]||(i[e]={}),i=i[e]}!function(e){if(!function(e){return"object"==typeof e&&null!==e&&"fn"in e&&"function"==typeof e.fn}(e))throw new TypeError("Expected a NativeJsFunction")}(n);const s={functionType:"NativeJsFunction",nativeFn:n,name:o,[u]:!0,arity:n.arity??{},docString:n.docString??""};return i===e&&function(e){const t=ui(e);if(t)throw new r(`Cannot shadow ${t}`,void 0)}(o),i[o]=s,e},{})});return e.globalModuleScope?o:o.create({})}const gi=["(",")","[","]","{","}","'",'"',"`",",",".",";"," ","\n","\r","\t"],hi=["0","1","2","3","4","5","6","7","8","9",...gi],di=new Set(gi),yi=new Set(hi),vi=/\s/,fi=[0],bi=(e,t)=>{if('"'!==e[t])return fi;let r='"',n=1,a=e[t+n],o=!1;for(;a&&('"'!==a||o);)n+=1,o?(o=!1,r+=a):("\\"===a&&(o=!0),r+=a),a=e[t+n];return a?(r+='"',[n+1,["string",r]]):[n,["Error",r,void 0,`Unclosed string at position ${t}`]]};function xi(e,t,r,n){return t===r.slice(n,n+t.length)?[t.length,[e,t]]:fi}const wi=/\d/,qi=/[0-7]/,ki=/[0-9a-f]/i,Ai=/[01]/,Ni=/[\s)\]}(,;]/,$i=(e,t)=>{let r=e[t];if("'"===r){let n=1,a=e[t+n],o=!1;for(;"'"!==a||o;){if(void 0===a)return[n,["Error",r,void 0,`Unclosed quoted symbol at position ${t}`]];n+=1,o?(o=!1,r+=a):("\\"===a&&(o=!0),r+=a),a=e[t+n]}return r+="'",[n+1,["Symbol",r]]}if(!yi.has(r)){const n=t;let a=e[t+=1];for(;a&&!di.has(a);)r+=a,a=e[t+=1];return r.endsWith(":")?[t-n-1,["Symbol",r.slice(0,-1)]]:[t-n,["Symbol",r]]}return fi},Ti=[(e,t)=>{let r=e[t];if(!r||!vi.test(r))return fi;let n=r;for(r=e[t+=1];r&&vi.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 fi},(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 fi},(e,t)=>{const r=$i(e,t);if(0===r[0]||!r[1])return fi;let n=r[1][1];n=n.startsWith("'")?n.slice(1,n.length-1):n;return void 0===oi[n]?fi:[r[0],["ReservedSymbol",n]]},(e,t)=>xi("LParen","(",e,t),(e,t)=>xi("RParen",")",e,t),(e,t)=>xi("LBracket","[",e,t),(e,t)=>xi("RBracket","]",e,t),(e,t)=>xi("LBrace","{",e,t),(e,t)=>xi("RBrace","}",e,t),(e,t)=>{if('"'!==e[t]||'"'!==e[t+1]||'"'!==e[t+2])return fi;let r='"""',n=3,a=e[t+n],o=e.slice(t+n,t+n+3),i=!1;for(;a&&('"""'!==o||i);)n+=1,i?(i=!1,r+=a):("\\"===a&&(i=!0),r+=a),a=e[t+n],o=e.slice(t+n,t+n+3);return a?(r+='"""',[n+3,["DocString",r]]):[n,["Error",r,void 0,`Unclosed doc string at position ${t}`]]},bi,(e,t)=>{if("#"!==e[t])return fi;const[r,n]=bi(e,t+1);if(!n)return fi;if("Error"===n[0]){return[r+1,["Error",`#${n[1]}`,void 0,`Unclosed regexp at position ${t}`]]}t+=r+1;let a=r+1,o="";for(;"g"===e[t]||"i"===e[t];)if(o+=e[t],a+=1,t+=1,o.includes(e[t]))return[a,["Error",`#${n[1]}${o}`,void 0,`Duplicated regexp option "${e[t]}"`]];return[a,["RegexpShorthand",`#${n[1]}${o}`]]},(e,t)=>{if("0"!==e[t])return fi;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 fi;let a;for(a=t+2;a<e.length;a+=1){const t=e[a];if("binary"===n&&!Ai.test(t))break;if("octal"===n&&!qi.test(t))break;if("hex"===n&&!ki.test(t))break}const o=a-t;if(o<=2)return fi;const i=e[a];return i&&!Ni.test(i)?fi:[o,["BasePrefixedNumber",e.substring(t,a)]]},(e,t)=>{let r;const n="-"===e[t],a="+"===e[t],o=n||a?t+1:t;let i=!1,s=!1;for(r=o;r<e.length;r+=1){const n=e[r];if("_"===n){if(!wi.test(e[r-1])||!wi.test(e[r+1]))return r===o?fi:[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]]}else if("."===n){if(r===o)return fi;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===o)return fi;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(!wi.test(n))break}if((n||a)&&r===o)return fi;const c=r-t;if(0===c)return fi;const l=e[r];return l&&":"!==l&&!Ni.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&&Sr(r))return[3,["Operator",r]];const n=e.slice(t,t+2);if(t+1<e.length&&Sr(n))return[2,["Operator",n]];const a=e[t]??"";return Sr(a)?[1,["Operator",a]]:fi},$i];function Si(e,t,r){const n=e.substring(0,t+1).split(/\r\n|\r|\n/),a=n[n.length-1],o=function(e,t){return e.split(/\r\n|\r|\n/)[t]}(e,n.length-1);return{code:o,position:{line:n.length,column:a.length},filePath:r}}function zi(e,t){const r=t;if(0===t){const[n,a]=((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 fi})(e,t);if(t+=n,n>0)return[t-r,a]}for(const n of Ti){const[a,o]=n(e,t);if(t+=a,0!==a)return[t-r,o]}return[1,["Error",e[r],void 0,"Unrecognized character"]]}function Ei(e,t){return"Symbol"===e?.[0]&&(!t||e[1]===t)}function ji(e,t){return function(e,t){Ei(e,t)||Hi("Symbol",void 0,e)}(e,t),e}function Mi(e,t){return"ReservedSymbol"===e?.[0]&&(!t||e[1]===t)}function Ci(e,t){Mi(e,t)||Hi("ReservedSymbol",t,e)}function Ri(e,t){return Ci(e,t),e}function Pi(e,t){return"Operator"===e?.[0]&&(!t||e[1]===t)}function Ii(e,t){Pi(e,t)||Hi("Operator",t,e)}function Oi(e){return"LParen"===e?.[0]}function Fi(e){Oi(e)||Hi("LParen",void 0,e)}function Ui(e){return"RParen"===e?.[0]}function Di(e){Ui(e)||Hi("RParen",void 0,e)}function Gi(e){return"LBracket"===e?.[0]}function Wi(e){return function(e){Gi(e)||Hi("LBracket",void 0,e)}(e),e}function Vi(e){return"RBracket"===e?.[0]}function Bi(e){Vi(e)||Hi("RBracket",void 0,e)}function Li(e){return"LBrace"===e?.[0]}function _i(e){return function(e){Li(e)||Hi("LBrace",void 0,e)}(e),e}function Ki(e){return"RBrace"===e?.[0]}function Ji(e){return"string"===e?.[0]}function Yi(e){return"Operator"===e?.[0]&&$r(e[1])}function Hi(e,t,n){const a=n?`${n[0]} '${n[1]}'`:"end of input";throw new r(`Unexpected token: ${a}, expected ${e}${t?` '${t}'`:""}`,n?.[2])}function Xi(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 Zi=new Set([...br,...xr,...Object.keys(oi)]);class Qi{originalProgram;originalPosition;prefixProgram="";suffixProgram="";searchString="";suggestions=[];suggestionIndex=null;constructor(e,t,r,n){this.originalProgram=e,this.originalPosition=t;const a=this.originalProgram.slice(0,this.originalPosition),o=r.tokenize(a).tokens.at(-1);o&&"Error"!==o[0]&&(this.searchString=o[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_def","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 a=this.generateWithPredicate(e,e=>!t.has(e)&&e.includes(this.searchString));a.forEach(e=>t.add(e));const o=this.generateWithPredicate(e,e=>!t.has(e)&&e.includes(this.searchString.toLowerCase()));return o.forEach(e=>t.add(e)),[...r,...n,...a,...o]}generateWithPredicate(e,t){const r=new Set;return Zi.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.jsFunctions??{}).filter(t).forEach(e=>r.add(e)),Object.keys(e.values??{}).filter(t).forEach(e=>r.add(e)),[...r].sort((e,t)=>e.localeCompare(t))}}class es{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){return t&&(e[2]=t),e}function rs(e,t){return void 0!==yr[e]&&"fn"!==e&&"def"!==e&&"defn"!==e?ts([s.SpecialBuiltinSymbol,yr[e]],t):void 0!==$t[e]?ts([s.NormalBuiltinSymbol,$t[e]],t):ts([s.UserDefinedSymbol,e],t)}function ns(e){return e.substring(1,e.length-1).replace(/(\\{2})|(\\')|\\(.)/g,(e,t,r,n)=>t?"\\":r?"'":`\\${n}`)}const as=Object.entries($t).reduce((e,[t,r])=>(e[r]=t,e),[]),os=Object.entries(yr).reduce((e,[t,r])=>(e[r]=t,e),[]);function is(e){return Mt(e)?e[1]:Rt(e)?as[e[1]]:os[e[1]]}function ss(e,t,r){const n=ts([s.NormalExpression,[e,t]],r);return Rt(e)&&H(Tt[e[1]].arity,n[1][1].length,r),n}function cs(e){if(e.isAtEnd())return!0;const t=e.tryPeek();return Pi(t)?[";",",",":"].includes(t[1]):!!Mi(t)&&["else","when","while","case","catch","let","then","end","do"].includes(t[1])}function ls(e,t,n,a,o){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"&":case"xor":case"|":case"|>":return ss(t,[n,a],o);case"&&":case"||":case"??":return ts([s.SpecialExpression,[yr[i],[n,a]]],o);default:throw new r(`Unknown binary operator: ${i}`,o)}}function ms(e){const t=e.peek();if(e.advance(),!Ei(t))throw new r(`Expected symbol token, got ${t[0]}`,t[2]);return"'"===t[1][0]?rs(ns(t[1]),t[2]):rs(t[1],t[2])}function us(e,{requireDefaultValue:t,noRest:n}={}){const a=e.tryPeek();if(Ei(a)){const n=ms(e);if(!Mt(n))throw new r("Expected user defined symbol",a[2]);const o=ps(e);if(t&&!o)throw new r("Expected assignment",e.peekSourceCodeInfo());return ts([Dt,[n,o]],a[2])}if(Pi(a,"...")){if(n)throw new r("Rest element not allowed",a[2]);e.advance();const t=Ct(ms(e));if(Pi(e.tryPeek(),"="))throw new r("Rest argument can not have default value",e.peekSourceCodeInfo());return ts([Gt,[t[1],void 0]],a[2])}if(Gi(a)){e.advance();const n=[];let o=e.peek(),i=!1;for(;!Vi(o);){if(i)throw new r("Rest argument must be last",o[2]);if(Pi(o,",")){n.push(null),e.advance(),o=e.peek();continue}const t=us(e);t[0]===Gt&&(i=!0),n.push(t),o=e.peek(),Vi(o)||(Ii(o,","),e.advance()),o=e.peek()}e.advance();const s=ps(e);if(t&&!s)throw new r("Expected assignment",e.peekSourceCodeInfo());return ts([Vt,[n,s]],a[2])}if(Li(a)){e.advance();const n={};let o=e.peek(),i=!1;for(;!Ki(o);){if(i)throw new r("Rest argument must be last",o[2]);Pi(o,"...")&&(i=!0,e.advance());const t=ms(e),s=is(t);if(o=e.peek(),Mi(o,"as")){if(i)throw new r("Rest argument can not have alias",o[2]);e.advance();const t=Ct(ms(e));if(n[t[1]])throw new r(`Duplicate binding name: ${t}`,o[2]);n[s]=ts([Dt,[t,ps(e)]],a[2])}else if(Ki(o)||Pi(o,",")||Pi(o,"=")){const s=Ct(t,t[2]);if(n[s[1]])throw new r(`Duplicate binding name: ${s}`,o[2]);if(i&&Pi(e.tryPeek(),"="))throw new r("Rest argument can not have default value",e.peekSourceCodeInfo());n[s[1]]=ts(i?[Gt,[s[1],ps(e)]]:[Dt,[s,ps(e)]],a[2])}else if(Pi(o,":")){if(e.advance(),o=e.peek(),!Li(o)&&!Gi(o))throw new r("Expected object or array",o[2]);n[s]=us(e)}Ki(e.peek())||(Ii(e.peek(),","),e.advance()),o=e.peek()}e.advance(),o=e.peek();const s=ps(e);if(t&&!s)throw new r("Expected assignment",o[2]);return ts([Wt,[n,s]],a[2])}throw new r("Expected symbol",e.peekSourceCodeInfo())}function ps(e){if(Pi(e.tryPeek(),"="))return e.advance(),e.parseExpression()}function gs(e,t){e.advance();const r=us(e,{requireDefaultValue:!0,noRest:!0}),n=r[1][1];r[1][1]=void 0;const a=ts([s.Binding,[r,n]],t[2]);return ts([s.SpecialExpression,[yr.let,a]],t[2])}function hs(e,t){const n=[];for(;!e.isAtEnd()&&!ds(e,t);)Pi(e.tryPeek(),";")?e.advance():n.push(e.parseExpression());if(function(e,t){if(!ds(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]:ts([s.SpecialExpression,[yr.block,n]],e.peekSourceCodeInfo())}function ds(e,t){for(const r of t)if(Mi(e.tryPeek(),r))return!0;return!1}function ys(e){const t=function(e){const t=ji(e.tryPeek()),r=Ct(ms(e));Ci(e.tryPeek(),"in"),e.advance();const n=e.parseExpression();return ts([s.Binding,[ts([Dt,[r,void 0]],t[2]),n]],t[2])}(e),n=[];let a=e.peek();vs(a,["let","when","while"]);const o=[];if("let"===a[1])for(n.push("&let");Ei(a,"let");){const t=gs(e,a),n=o.flatMap(e=>Object.keys(Kt(e[1][0])));if(Object.keys(Kt(t[1][1][1][0])).some(e=>n.includes(e)))throw new r("Duplicate binding",t[1][1][2]);o.push(t[1][1]),a=e.peek(),vs(a,["let","when","while"]),a=e.peek()}let i,c;for(;Mi(a,"when")||Mi(a,"while");){e.advance(),"when"===a[1]?(n.push("&when"),i=e.parseExpression()):(n.push("&while"),c=e.parseExpression()),a=e.peek();vs(a,n.includes("&when")&&n.includes("&while")?[]:n.includes("&when")?["while"]:["when"]),a=e.peek()}return vs(a,[]),[t,o,i,c]}function vs(e,t){if(!function(e,t){if(Pi(e,",")||Ui(e))return!0;for(const r of t){if("let"===r&&Ei(e,"let"))return!0;if(["when","while"].includes(r)&&Mi(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 fs(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,a,o,i,s,c)=>t?"\\":n?"\n":a?"\t":o?"\r":i?"\b":s?"\f":r?'"':c);return ts([s.String,r],t[2])}function bs(e,t=!1){const n=Ri(e.tryPeek(),"do");e.advance();let a="";t&&function(e){return"DocString"===e?.[0]}(e.tryPeek())&&(a=function(e){const t=e.peek(),r=t[2]?["string",t[1].slice(2,-2),t[2]]:["string",t[1].slice(2,-2)],n=fs(e,r);return be(n[1])}(e));const o=[];for(;!e.isAtEnd()&&!Mi(e.tryPeek(),"end");)if(o.push(e.parseExpression()),Pi(e.tryPeek(),";"))e.advance();else if(!Mi(e.tryPeek(),"end"))throw new r("Expected end",e.peekSourceCodeInfo());return Ci(e.tryPeek(),"end"),e.advance(),[ts([s.SpecialExpression,[yr.block,o]],n[2]),a]}function xs(e){const t=Ri(e.tryPeek());e.advance();const r=t[1];return function(e){return e in ai}(r)?ts([s.Number,ai[r]],t[2]):ts([s.ReservedSymbol,t[1]],t[2])}const ws=/^\$([1-9]\d?)?$/;function qs(e){const t=e.peek();if(Oi(t)&&Ei(e.peekAhead(1))&&Pi(e.peekAhead(2),"->"))return null;try{const n=function(e){const t=e.peek();if(Ei(t))return[ts([Dt,[ms(e),void 0]],t[2])];Fi(t),e.advance();let n=!1,a=!1;const o=[];for(;!e.isAtEnd()&&!Ui(e.peek())&&!Ei(e.peek(),"let");){if(n)throw new r("Rest argument must be last",e.peekSourceCodeInfo());const t=us(e);if(void 0!==t[1][1]&&(a=!0),t[0]===Gt&&(n=!0),a&&!t[1][1])throw new r("Default arguments must be last",e.peekSourceCodeInfo());if(o.push(t),!Pi(e.peek(),",")&&!Ui(e.peek())&&!Ei(e.peek(),"let"))throw new r("Expected comma or closing parenthesis",e.peekSourceCodeInfo());Pi(e.peek(),",")&&e.advance()}if(!Ui(e.peek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());return e.advance(),o}(e);if(!Pi(e.peek(),"->"))return null;let a;e.advance();let o="";if(Mi(e.peek(),"do")){const t=bs(e,!0);o=t[1],a=t[0][1][1]}else a=[e.parseExpression()];return ts([s.SpecialExpression,[yr["0_lambda"],[n,a],o]],t[2])}catch{return null}}function ks(e,t){e.advance();const n=[];for(;!e.isAtEnd()&&!Ui(e.tryPeek());){Pi(e.tryPeek(),"...")?(e.advance(),n.push(ts([s.Spread,e.parseExpression()],e.peekSourceCodeInfo()))):n.push(e.parseExpression());const t=e.tryPeek();if(!Pi(t,",")&&!Ui(t))throw new r("Expected comma or closing parenthesis",e.tryPeek()?.[2]);Pi(t,",")&&e.advance()}if(!Ui(e.tryPeek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());if(e.advance(),!Pt(t))return Rt(t)||Mt(t)?ss(t,n,t[2]):ts([s.NormalExpression,[t,n]],t[2]);{const e=t[1];switch(H(fr.specialExpressions[e].arity,n.length,t[2]),e){case yr["||"]:case yr["&&"]:case yr.recur:case yr.array:case yr.object:case yr["??"]:return ts([s.SpecialExpression,[e,n]],t[2]);case yr["defined?"]:{const[r]=n;return ts([s.SpecialExpression,[e,r]],t[2])}case yr.throw:{const[r]=n;return ts([s.SpecialExpression,[e,r]],t[2])}case yr["0_lambda"]:case yr["0_def"]:throw new r(`${e} is not allowed`,t[2]);default:throw new r(`Unknown special expression: ${e}`,t[2])}}}function As(e){const t=_i(e.tryPeek());e.advance();const n=[];for(;!e.isAtEnd()&&!Ki(e.tryPeek());){if(Pi(e.tryPeek(),"..."))e.advance(),n.push(ts([s.Spread,e.parseExpression()],e.peekSourceCodeInfo()));else{const t=e.tryPeek();if(Ji(t)){const r=fs(e,t);n.push(ts([s.String,r[1]],t[2]))}else if(Ei(t)){const r=t[1].startsWith("'")?ns(t[1]):t[1];n.push(ts([s.String,r],t[2])),e.advance()}else{if(!Gi(t))throw new r("Expected key to be a symbol or a string",e.peekSourceCodeInfo());e.advance(),n.push(e.parseExpression()),Bi(e.tryPeek()),e.advance()}Ii(e.tryPeek(),":"),e.advance(),n.push(e.parseExpression())}const t=e.tryPeek();if(!Pi(t,",")&&!Ki(t))throw new r("Expected comma or closing brace",e.peekSourceCodeInfo());Pi(t,",")&&e.advance()}var a;return Ki(a=e.tryPeek())||Hi("RBrace",void 0,a),e.advance(),ts([s.SpecialExpression,[yr.object,n]],t[2])}function Ns(e){let t=function(e){const t=e.peek();if(Oi(t)){e.storePosition();const t=qs(e);if(t)return t;e.restorePosition(),e.advance();const n=e.parseExpression();if(!Ui(e.peek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());return e.advance(),n}if(Pi(t)){const n=t[1];if($r(n))return e.advance(),ts(void 0!==yr[n]?[s.SpecialBuiltinSymbol,yr[n]]:[s.NormalBuiltinSymbol,$t[n]],t[2]);if("->"===n)return function(e){const t=e.peek();e.advance();const n=e.getPosition();let a,o="";if(Mi(e.peek(),"do")){const t=bs(e,!0);o=t[1],a=t[0][1][1]}else a=[e.parseExpression()];const i=e.getPosition()-1;let c=0,l="NOT_SET";for(let a=n;a<=i;a+=1){const n=e.getTokenAt(a);if(Ei(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(ts([Dt,[[s.UserDefinedSymbol,"$"],void 0]],t[2])):m.push(ts([Dt,[[s.UserDefinedSymbol,`$${e}`],void 0]],t[2]));return ts([s.SpecialExpression,[yr["0_lambda"],[m,a],o]],t[2])}(e);throw new r(`Illegal operator: ${n}`,t[2])}if(Li(t))return As(e);if(Gi(t))return function(e){const t=Wi(e.tryPeek());e.advance();const n=[];for(;!e.isAtEnd()&&!Vi(e.tryPeek());){Pi(e.tryPeek(),"...")?(e.advance(),n.push(ts([s.Spread,e.parseExpression()],e.peekSourceCodeInfo()))):n.push(e.parseExpression());const t=e.tryPeek();if(!Pi(t,",")&&!Vi(t))throw new r("Expected comma or closing parenthesis",e.peekSourceCodeInfo());Pi(t,",")&&e.advance()}return Bi(e.tryPeek()),e.advance(),ts([s.SpecialExpression,[yr.array,n]],t[2])}(e);const n=t[0];switch(n){case"Number":case"BasePrefixedNumber":return function(e){const t=e.peek();e.advance();const r=t[1],n="-"===r[0],a=(n?r.substring(1):r).replace(/_/g,"");return ts([s.Number,n?-Number(a):Number(a)],t[2])}(e);case"string":return fs(e,t);case"Symbol":{e.storePosition();const t=qs(e);return t||(e.restorePosition(),ms(e))}case"ReservedSymbol":return xs(e);case"RegexpShorthand":return function(e){const t=e.peek();e.advance();const r=t[1].lastIndexOf('"'),n=t[1].substring(2,r),a=t[1].substring(r+1),o=ts([s.String,n],t[2]),i=ts([s.String,a],t[2]);return ts([s.NormalExpression,[ts([s.NormalBuiltinSymbol,$t.regexp],t[2]),[o,i]]],t[2])}(e);default:throw new r(`Unknown token type: ${n}`,t[2])}}(e),n=e.tryPeek();for(;Pi(n,".")||Gi(n)||Oi(n);)if("."===n[1]){e.advance();const a=e.tryPeek();if(!Ei(a))throw new r("Expected symbol",e.peekSourceCodeInfo());t=$s(t,ts([s.String,a[1]],a[2]),n[2]),e.advance(),n=e.tryPeek()}else if(Gi(n)){e.advance();const a=e.parseExpression();if(!Vi(e.tryPeek()))throw new r("Expected closing bracket",e.peekSourceCodeInfo());t=$s(t,a,n[2]),e.advance(),n=e.tryPeek()}else Oi(n)&&(t=ks(e,t),n=e.tryPeek());return t}function $s(e,t,r){return ts([s.NormalExpression,[[s.NormalBuiltinSymbol,$t.get],[e,t]]],r)}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"!=":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=0,n=!1){const a=e.tryPeek();let o;if(Ei(a))switch(a[1]){case"let":return gs(e,a);case"if":case"unless":o=function(e,t){const r="unless"===t[1];e.advance();const n=e.parseExpression();Ci(e.tryPeek(),"then"),e.advance();const a=hs(e,["else","end"]);let o;return Mi(e.tryPeek(),"else")&&(e.advance(),o=hs(e,["end"])),e.advance(),ts(r?[s.SpecialExpression,[yr.unless,[n,a,o]]]:[s.SpecialExpression,[yr.if,[n,a,o]]],t[2])}(e,a);break;case"cond":o=function(e,t){e.advance();const r=[];for(;!e.isAtEnd()&&!Mi(e.tryPeek(),"end");){Ci(e.tryPeek(),"case"),e.advance();const t=e.parseExpression();Ci(e.tryPeek(),"then"),e.advance();const n=hs(e,["case","end"]);if(r.push([t,n]),Mi(e.tryPeek(),"end"))break}return Ci(e.tryPeek()),e.advance(),ts([s.SpecialExpression,[yr.cond,r]],t[2])}(e,a);break;case"switch":o=function(e,t){e.advance();const r=e.parseExpression(),n=[];for(;!e.isAtEnd()&&!Mi(e.tryPeek(),"end");){Ci(e.tryPeek(),"case"),e.advance();const t=e.parseExpression();Ci(e.tryPeek(),"then"),e.advance();const r=hs(e,["case","end"]);if(n.push([t,r]),Mi(e.tryPeek(),"end"))break}return Ci(e.tryPeek(),"end"),e.advance(),ts([s.SpecialExpression,[yr.switch,r,n]],t[2])}(e,a);break;case"for":case"doseq":o=function(e,t){const n="doseq"===t[1];e.advance(),Fi(e.tryPeek()),e.advance();const a=[];for(;!e.isAtEnd()&&!Ui(e.tryPeek());){const t=ys(e),n=a.flatMap(e=>Object.keys(Kt(e[0][1][0]))),o=Kt(t[0][1][0]);if(Object.keys(o).some(e=>n.includes(e)))throw new r("Duplicate binding",t[0][2]);a.push(t),Pi(e.tryPeek(),",")&&e.advance()}Di(e.tryPeek()),e.advance(),Ii(e.tryPeek(),"->"),e.advance();const o=e.parseExpression();return ts(n?[s.SpecialExpression,[yr.doseq,a,o]]:[s.SpecialExpression,[yr.for,a,o]],t[2])}(e,a);break;case"loop":o=function(e,t){e.advance(),Fi(e.tryPeek()),e.advance();const n=[];let a=e.tryPeek();for(;!e.isAtEnd()&&!Ui(a);){const t=us(e,{requireDefaultValue:!0,noRest:!0}),r=t[1][1];t[1][1]=void 0,n.push(ts([s.Binding,[t,r]],t[2])),Pi(e.tryPeek(),",")&&e.advance(),a=e.tryPeek()}if(0===n.length)throw new r("Expected binding",e.peekSourceCodeInfo());Di(a),e.advance(),Ii(e.tryPeek(),"->"),e.advance();const o=e.parseExpression();return ts([s.SpecialExpression,[yr.loop,n,o]],t[2])}(e,a);break;case"try":o=function(e,t){e.advance();const r=hs(e,["catch"]);let n;e.advance(),Oi(e.tryPeek())&&(e.advance(),n=ms(e),Di(e.tryPeek()),e.advance());const a=hs(e,["end"]);return e.advance(),ts([s.SpecialExpression,[yr.try,r,n,a]],t[2])}(e,a)}else if(Mi(a,"do"))o=bs(e)[0];else if(Mi(a,"export")){if(!n)throw new r("export is only allowed in module scope",a[2]);return function(e,t){e.advance();const n=e.tryPeek();if(Ei(n,"let")){const r=gs(e,ji(n));return ts([s.SpecialExpression,[yr["0_def"],r[1][1]]],t[2])}throw new r("Expected let",e.peekSourceCodeInfo())}(e,a)}o||=Ns(e);let i=e.tryPeek();for(;!cs(e);){if(Yi(i)){const r=i[1],n=Ts(r,i[2]);if(n<=t&&(12!==n||12!==t))break;const a=ts(yr[r]?[s.SpecialBuiltinSymbol,yr[r]]:[s.NormalBuiltinSymbol,$t[r]],i[2]);e.advance();o=ls(i,a,o,Ss(e,n),i[2])}else if(Ei(i)){if(!Ar(i[1]))break;const n=3;if(n<=t)break;const a=ms(e),s=Ss(e,n);if(Pt(a))throw new r("Special expressions are not allowed in binary functional operators",a[2]);o=ss(a,[o,s],i[2])}else{if("?"!==i?.[1])break;{if(1<=t)break;e.advance();const n=Ss(e);if(!Pi(e.tryPeek(),":"))throw new r("Expected :",e.peekSourceCodeInfo());e.advance();const a=Ss(e);o=ts([s.SpecialExpression,[yr.if,[o,n,a]]],o[2])}}i=e.tryPeek()}return o}class zs{cache={};firstEntry=void 0;lastEntry=void 0;_size=0;maxSize;constructor(e){if(this.maxSize=null===e?null:me(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 Es{astCache;astCacheSize;debug;modules;constructor(e={}){if(this.debug=e.debug??!1,this.astCacheSize=e.astCacheSize??null,this.astCacheSize){this.astCache=new zs(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={})=>{const r=this.generateAst(e,t);return this.evaluate(r,t)},context:async(e,t={})=>{const r="string"==typeof e?this.generateAst(e,t):e,n=pi(t,this.modules);return await si(r,n),n.globalContext},apply:async(e,t,r={})=>this.apply(e,t,r)};run(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}context(e,t={}){const r="string"==typeof e?this.generateAst(e,t):e,n=pi(t,this.modules);if(si(r,n)instanceof Promise)throw new TypeError("Unexpected async result in synchronous context(). Use lits.async.context() for async operations.");return n.globalContext}getUndefinedSymbols(e,t={}){const r="string"==typeof e?this.generateAst(e,t):e,n=pi(t,this.modules);return ti(r,n,fr,ci)}tokenize(e,t={}){const r=function(e,t,r){let n=0;const a={tokens:[],filePath:r,hasDebugData:t};for(;n<e.length;){const o=t?Si(e,n,r):void 0,i=zi(e,n),[s,c]=i;n+=s,c&&(o&&(c[2]=o),a.tokens.push(c))}return a}(e,this.debug,t.filePath);return t.minify?Xi(r,{removeWhiteSpace:!1}):r}parse(e){const t={body:[],hasDebugData:(e=Xi(e,{removeWhiteSpace:!0})).hasDebugData};return t.body=function(e){e.tokens.forEach(e=>{if("Error"===e[0])throw new r(e[3],e[2])});const t=[],n=new es(e);for(n.parseExpression=(e=0,t=!1)=>Ss(n,e,t);!n.isAtEnd();)if(t.push(Ss(n,0,!0)),Pi(n.tryPeek(),";"))n.advance();else if(!n.isAtEnd())throw new r("Expected ;",n.peekSourceCodeInfo());return t}(e),t}evaluate(e,t){return si(e,pi(t,this.modules))}transformSymbols(e,t){return function(e,t){return{...e,tokens:e.tokens.map(e=>Ei(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",a=this.generateApplyFunctionCall(n,t),o=this.generateAst(a,r),i=t.reduce((e,t,r)=>(e[`${n}_${r}`]=t,e),{[n]:e});return r.values={...r.values,...i},this.evaluate(o,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 Qi(e,t,this,r)}}const js=[Rr,Fr,Vr,Tn,Dn,Yn,so,ko,Ao,uo,fo,wo,$o];function Ms(e){return[`number-theory.${e}-seq`,`number-theory.${e}-nth`,`number-theory.${e}-take-while`,`number-theory.${e}?`]}function Cs(e){const t=e.replace(/^/,"");return[`vector.${e}`,`vector.moving-${t}`,`vector.centered-moving-${t}`,`vector.running-${t}`]}const Rs={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"],sequenceUtils:["sequence.position","sequence.last-index-of","sequence.shift","sequence.unshift","sequence.splice","sequence.sort-by","sequence.take","sequence.take-last","sequence.take-while","sequence.drop","sequence.drop-last","sequence.drop-while","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:["≠","==","<",">","<=",">=","!","write!","iso-date->epoch","epoch->iso-date","boolean","compare","identical?","import","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","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"],assert:["assert.assert","assert.assert=","assert.assert!=","assert.assert-gt","assert.assert-lt","assert.assert-gte","assert.assert-lte","assert.assert-true","assert.assert-false","assert.assert-truthy","assert.assert-falsy","assert.assert-null","assert.assert-throws","assert.assert-throws-error","assert.assert-not-throws","assert.assert-array","assert.assert-boolean","assert.assert-collection","assert.assert-function","assert.assert-grid","assert.assert-integer","assert.assert-matrix","assert.assert-number","assert.assert-object","assert.assert-regexp","assert.assert-sequence","assert.assert-string","assert.assert-vector"],grid:["grid.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.reverse-rows","grid.reverse-cols","grid.slice","grid.slice-rows","grid.slice-cols","grid.splice-rows","grid.splice-cols","grid.concat-rows","grid.concat-cols","grid.map","grid.mapi","grid.reduce","grid.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.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.median","vector.mode","vector.min-index","vector.max-index","vector.sort-indices","vector.count-values","vector.linspace","vector.ones","vector.zeros","vector.fill","vector.generate","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",...Cs("mean"),...Cs("median"),...Cs("variance"),...Cs("sample-variance"),...Cs("sum"),...Cs("prod"),...Cs("stdev"),...Cs("sample-stdev"),...Cs("iqr"),...Cs("span"),...Cs("geometric-mean"),...Cs("harmonic-mean"),...Cs("skewness"),...Cs("sample-skewness"),...Cs("kurtosis"),...Cs("sample-kurtosis"),...Cs("excess-kurtosis"),...Cs("sample-excess-kurtosis"),...Cs("rms"),...Cs("mad"),...Cs("medad"),...Cs("gini-coefficient"),...Cs("entropy"),...Cs("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:[...Ms("abundant"),...Ms("arithmetic"),...Ms("bell"),...Ms("catalan"),...Ms("composite"),...Ms("deficient"),...Ms("factorial"),...Ms("fibonacci"),...Ms("geometric"),...Ms("golomb"),...Ms("happy"),...Ms("look-and-say"),...Ms("lucas"),...Ms("lucky"),...Ms("mersenne"),...Ms("padovan"),...Ms("partition"),...Ms("pell"),...Ms("perfect"),...Ms("perfect-cube"),...Ms("perfect-power"),...Ms("perfect-square"),...Ms("polygonal"),...Ms("prime"),...Ms("recaman"),...Ms("sylvester"),...Ms("thue-morse"),...Ms("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!"],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"]},Ps=[...[...[...Rs.collection,...Rs.array,...Rs.sequence,...Rs.math,...Rs.functional,...Rs.meta,...Rs.misc,...Rs.object,...Rs.predicate,...Rs.regularExpression,...Rs.string,...Rs.bitwise,...Rs.vector],...[...Rs.matrix,...Rs.vectorUtils,...Rs.linAlg,...Rs.grid,...Rs.numberTheory,...Rs.random,...Rs.mathUtils,...Rs.functionalUtils,...Rs.assert,...Rs.stringUtils,...Rs.collectionUtils,...Rs.sequenceUtils,...Rs.bitwiseUtils]],...Rs.shorthand,...Rs.datatype];function Is(e){return Ps.includes(e)}export{Es as Lits,js as allBuiltinModules,Xo as apiReference,N as asLitsFunction,j as asNativeJsFunction,S as asUserDefinedFunction,$ as assertLitsFunction,Rr as assertModule,M as assertNativeJsFunction,z as assertUserDefinedFunction,$o as bitwiseUtilsModule,Ao as functionalUtilsModule,Fr as gridModule,Is as isApiName,C as isBuiltinFunction,_o as isCustomReference,Er as isDataType,Jo as isDatatypeReference,Lo as isFunctionReference,tt as isGrid,i as isLitsError,A as isLitsFunction,nt as isMatrix,E as isNativeJsFunction,Ko as isShorthandReference,T as isUserDefinedFunction,He as isVector,Dn as linearAlgebraModule,ko as mathUtilsModule,Yn as matrixModule,br as normalExpressionKeys,so as numberTheoryModule,Vr as randomModule,xr as specialExpressionKeys,Tn as vectorModule};
2
2
  //# sourceMappingURL=full.esm.js.map