@mojir/dvala 0.0.1 → 0.0.2

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 (914) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1613 -4
  3. package/dist/bundler.esm.js +2 -0
  4. package/dist/bundler.esm.js.map +1 -0
  5. package/dist/bundler.js +2 -0
  6. package/dist/bundler.js.map +1 -0
  7. package/dist/cli/cli/src/cli.d.ts +2 -0
  8. package/dist/cli/cli/src/cliDocumentation/formatCliDescription.d.ts +3 -0
  9. package/dist/cli/cli/src/cliDocumentation/getCliArgumentInfo.d.ts +3 -0
  10. package/dist/cli/cli/src/cliDocumentation/getCliDocumentation.d.ts +2 -0
  11. package/dist/cli/cli/src/cliDocumentation/getCliFunctionExamples.d.ts +3 -0
  12. package/dist/cli/cli/src/cliDocumentation/getCliFunctionSignature.d.ts +3 -0
  13. package/dist/cli/cli/src/cliDocumentation/getCliTitle.d.ts +3 -0
  14. package/dist/cli/cli/src/cliDocumentation/getCliType.d.ts +3 -0
  15. package/dist/cli/cli/src/cliFormatterRules.d.ts +13 -0
  16. package/dist/cli/cli/src/colorizer.d.ts +939 -0
  17. package/dist/cli/cli/src/createReadlineInterface.d.ts +5 -0
  18. package/dist/cli/cli/src/js-interop/Cli/Fs/index.d.ts +2 -0
  19. package/dist/cli/cli/src/js-interop/Cli/Proc/index.d.ts +3 -0
  20. package/dist/cli/cli/src/js-interop/Cli/index.d.ts +2 -0
  21. package/dist/cli/cli.js +38614 -0
  22. package/dist/cli/common/createFormatter.d.ts +6 -0
  23. package/dist/cli/common/utils.d.ts +2 -0
  24. package/dist/cli/reference/api.d.ts +75 -0
  25. package/dist/cli/reference/datatype.d.ts +3 -0
  26. package/dist/cli/reference/effect.d.ts +3 -0
  27. package/dist/cli/reference/examples.d.ts +11 -0
  28. package/dist/cli/reference/index.d.ts +191 -0
  29. package/dist/cli/reference/shorthand.d.ts +3 -0
  30. package/dist/cli/src/AutoCompleter/AutoCompleter.d.ts +25 -0
  31. package/dist/cli/src/Dvala/Cache.d.ts +16 -0
  32. package/dist/cli/src/Dvala/Dvala.d.ts +68 -0
  33. package/dist/cli/src/allModules.d.ts +2 -0
  34. package/dist/cli/src/builtin/bindingNode.d.ts +11 -0
  35. package/dist/cli/src/builtin/core/array.d.ts +2 -0
  36. package/dist/cli/src/builtin/core/assertion.d.ts +2 -0
  37. package/dist/cli/src/builtin/core/bitwise.d.ts +2 -0
  38. package/dist/cli/src/builtin/core/collection.d.ts +2 -0
  39. package/dist/cli/src/builtin/core/functional.d.ts +2 -0
  40. package/dist/cli/src/builtin/core/math.d.ts +2 -0
  41. package/dist/cli/src/builtin/core/meta.d.ts +3 -0
  42. package/dist/cli/src/builtin/core/misc.d.ts +2 -0
  43. package/dist/cli/src/builtin/core/object.d.ts +2 -0
  44. package/dist/cli/src/builtin/core/predicates.d.ts +2 -0
  45. package/dist/cli/src/builtin/core/regexp.d.ts +2 -0
  46. package/dist/cli/src/builtin/core/sequence.d.ts +2 -0
  47. package/dist/cli/src/builtin/core/string.d.ts +2 -0
  48. package/dist/cli/src/builtin/core/vector.d.ts +2 -0
  49. package/dist/cli/src/builtin/index.d.ts +13 -0
  50. package/dist/cli/src/builtin/interface.d.ts +113 -0
  51. package/dist/cli/src/builtin/modules/assertion/docs.d.ts +2 -0
  52. package/dist/cli/src/builtin/modules/assertion/index.d.ts +2 -0
  53. package/dist/cli/src/builtin/modules/bitwise/index.d.ts +2 -0
  54. package/dist/cli/src/builtin/modules/collection/index.d.ts +2 -0
  55. package/dist/cli/src/builtin/modules/convert/index.d.ts +2 -0
  56. package/dist/cli/src/builtin/modules/functional/index.d.ts +2 -0
  57. package/dist/cli/src/builtin/modules/grid/docs.d.ts +2 -0
  58. package/dist/cli/src/builtin/modules/grid/fromArray.d.ts +8 -0
  59. package/dist/cli/src/builtin/modules/grid/index.d.ts +2 -0
  60. package/dist/cli/src/builtin/modules/grid/transpose.d.ts +2 -0
  61. package/dist/cli/src/builtin/modules/interface.d.ts +11 -0
  62. package/dist/cli/src/builtin/modules/linear-algebra/docs.d.ts +2 -0
  63. package/dist/cli/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +1 -0
  64. package/dist/cli/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +2 -0
  65. package/dist/cli/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +8 -0
  66. package/dist/cli/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +4 -0
  67. package/dist/cli/src/builtin/modules/linear-algebra/helpers/dot.d.ts +1 -0
  68. package/dist/cli/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +7 -0
  69. package/dist/cli/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +2 -0
  70. package/dist/cli/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +1 -0
  71. package/dist/cli/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +10 -0
  72. package/dist/cli/src/builtin/modules/linear-algebra/helpers/length.d.ts +1 -0
  73. package/dist/cli/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +1 -0
  74. package/dist/cli/src/builtin/modules/linear-algebra/helpers/scale.d.ts +1 -0
  75. package/dist/cli/src/builtin/modules/linear-algebra/helpers/solve.d.ts +8 -0
  76. package/dist/cli/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +1 -0
  77. package/dist/cli/src/builtin/modules/linear-algebra/index.d.ts +4 -0
  78. package/dist/cli/src/builtin/modules/math/index.d.ts +2 -0
  79. package/dist/cli/src/builtin/modules/matrix/docs.d.ts +2 -0
  80. package/dist/cli/src/builtin/modules/matrix/helpers/adjugate.d.ts +1 -0
  81. package/dist/cli/src/builtin/modules/matrix/helpers/band.d.ts +9 -0
  82. package/dist/cli/src/builtin/modules/matrix/helpers/cofactor.d.ts +1 -0
  83. package/dist/cli/src/builtin/modules/matrix/helpers/determinant.d.ts +6 -0
  84. package/dist/cli/src/builtin/modules/matrix/helpers/inverse.d.ts +6 -0
  85. package/dist/cli/src/builtin/modules/matrix/helpers/isBanded.d.ts +11 -0
  86. package/dist/cli/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +10 -0
  87. package/dist/cli/src/builtin/modules/matrix/helpers/isIdentity.d.ts +1 -0
  88. package/dist/cli/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +1 -0
  89. package/dist/cli/src/builtin/modules/matrix/helpers/isSquare.d.ts +1 -0
  90. package/dist/cli/src/builtin/modules/matrix/helpers/isSymetric.d.ts +8 -0
  91. package/dist/cli/src/builtin/modules/matrix/helpers/isTriangular.d.ts +13 -0
  92. package/dist/cli/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +7 -0
  93. package/dist/cli/src/builtin/modules/matrix/helpers/minor.d.ts +1 -0
  94. package/dist/cli/src/builtin/modules/matrix/helpers/norm1.d.ts +1 -0
  95. package/dist/cli/src/builtin/modules/matrix/helpers/trace.d.ts +8 -0
  96. package/dist/cli/src/builtin/modules/matrix/index.d.ts +4 -0
  97. package/dist/cli/src/builtin/modules/number-theory/binomialCefficient.d.ts +1 -0
  98. package/dist/cli/src/builtin/modules/number-theory/combinations.d.ts +2 -0
  99. package/dist/cli/src/builtin/modules/number-theory/derangements.d.ts +2 -0
  100. package/dist/cli/src/builtin/modules/number-theory/divisors.d.ts +4 -0
  101. package/dist/cli/src/builtin/modules/number-theory/docs.d.ts +2 -0
  102. package/dist/cli/src/builtin/modules/number-theory/factorial.d.ts +3 -0
  103. package/dist/cli/src/builtin/modules/number-theory/index.d.ts +4 -0
  104. package/dist/cli/src/builtin/modules/number-theory/partitions.d.ts +2 -0
  105. package/dist/cli/src/builtin/modules/number-theory/permutations.d.ts +2 -0
  106. package/dist/cli/src/builtin/modules/number-theory/powerSet.d.ts +2 -0
  107. package/dist/cli/src/builtin/modules/number-theory/primeFactors.d.ts +11 -0
  108. package/dist/cli/src/builtin/modules/number-theory/sequences/abundant.d.ts +2 -0
  109. package/dist/cli/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +2 -0
  110. package/dist/cli/src/builtin/modules/number-theory/sequences/bell.d.ts +1 -0
  111. package/dist/cli/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +2 -0
  112. package/dist/cli/src/builtin/modules/number-theory/sequences/catalan.d.ts +1 -0
  113. package/dist/cli/src/builtin/modules/number-theory/sequences/collatz.d.ts +2 -0
  114. package/dist/cli/src/builtin/modules/number-theory/sequences/composite.d.ts +3 -0
  115. package/dist/cli/src/builtin/modules/number-theory/sequences/deficient.d.ts +2 -0
  116. package/dist/cli/src/builtin/modules/number-theory/sequences/factorial.d.ts +1 -0
  117. package/dist/cli/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +1 -0
  118. package/dist/cli/src/builtin/modules/number-theory/sequences/geometric.d.ts +2 -0
  119. package/dist/cli/src/builtin/modules/number-theory/sequences/golomb.d.ts +2 -0
  120. package/dist/cli/src/builtin/modules/number-theory/sequences/happy.d.ts +2 -0
  121. package/dist/cli/src/builtin/modules/number-theory/sequences/index.d.ts +27 -0
  122. package/dist/cli/src/builtin/modules/number-theory/sequences/juggler.d.ts +2 -0
  123. package/dist/cli/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +2 -0
  124. package/dist/cli/src/builtin/modules/number-theory/sequences/lucas.d.ts +1 -0
  125. package/dist/cli/src/builtin/modules/number-theory/sequences/lucky.d.ts +2 -0
  126. package/dist/cli/src/builtin/modules/number-theory/sequences/mersenne.d.ts +1 -0
  127. package/dist/cli/src/builtin/modules/number-theory/sequences/padovan.d.ts +2 -0
  128. package/dist/cli/src/builtin/modules/number-theory/sequences/partition.d.ts +1 -0
  129. package/dist/cli/src/builtin/modules/number-theory/sequences/pell.d.ts +1 -0
  130. package/dist/cli/src/builtin/modules/number-theory/sequences/perfect.d.ts +1 -0
  131. package/dist/cli/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +2 -0
  132. package/dist/cli/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +10 -0
  133. package/dist/cli/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +2 -0
  134. package/dist/cli/src/builtin/modules/number-theory/sequences/poligonal.d.ts +2 -0
  135. package/dist/cli/src/builtin/modules/number-theory/sequences/prime.d.ts +3 -0
  136. package/dist/cli/src/builtin/modules/number-theory/sequences/recaman.d.ts +9 -0
  137. package/dist/cli/src/builtin/modules/number-theory/sequences/sylvester.d.ts +1 -0
  138. package/dist/cli/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +2 -0
  139. package/dist/cli/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +1 -0
  140. package/dist/cli/src/builtin/modules/random/docs.d.ts +2 -0
  141. package/dist/cli/src/builtin/modules/random/index.d.ts +2 -0
  142. package/dist/cli/src/builtin/modules/sequence/index.d.ts +2 -0
  143. package/dist/cli/src/builtin/modules/string/index.d.ts +2 -0
  144. package/dist/cli/src/builtin/modules/vector/bincount.d.ts +9 -0
  145. package/dist/cli/src/builtin/modules/vector/calcMad.d.ts +1 -0
  146. package/dist/cli/src/builtin/modules/vector/calcMean.d.ts +1 -0
  147. package/dist/cli/src/builtin/modules/vector/calcMedad.d.ts +1 -0
  148. package/dist/cli/src/builtin/modules/vector/calcMedian.d.ts +1 -0
  149. package/dist/cli/src/builtin/modules/vector/calcStdDev.d.ts +2 -0
  150. package/dist/cli/src/builtin/modules/vector/calcVariance.d.ts +2 -0
  151. package/dist/cli/src/builtin/modules/vector/docs.d.ts +2 -0
  152. package/dist/cli/src/builtin/modules/vector/entropy.d.ts +8 -0
  153. package/dist/cli/src/builtin/modules/vector/histogram.d.ts +9 -0
  154. package/dist/cli/src/builtin/modules/vector/index.d.ts +2 -0
  155. package/dist/cli/src/builtin/modules/vector/mode.d.ts +6 -0
  156. package/dist/cli/src/builtin/modules/vector/outliers.d.ts +7 -0
  157. package/dist/cli/src/builtin/modules/vector/percentile.d.ts +7 -0
  158. package/dist/cli/src/builtin/modules/vector/quartiles.d.ts +1 -0
  159. package/dist/cli/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +2 -0
  160. package/dist/cli/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +2 -0
  161. package/dist/cli/src/builtin/modules/vector/reductionFunctions/index.d.ts +13 -0
  162. package/dist/cli/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +2 -0
  163. package/dist/cli/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +5 -0
  164. package/dist/cli/src/builtin/modules/vector/reductionFunctions/mad.d.ts +2 -0
  165. package/dist/cli/src/builtin/modules/vector/reductionFunctions/mean.d.ts +4 -0
  166. package/dist/cli/src/builtin/modules/vector/reductionFunctions/medad.d.ts +2 -0
  167. package/dist/cli/src/builtin/modules/vector/reductionFunctions/median.d.ts +2 -0
  168. package/dist/cli/src/builtin/modules/vector/reductionFunctions/prod.d.ts +2 -0
  169. package/dist/cli/src/builtin/modules/vector/reductionFunctions/rms.d.ts +2 -0
  170. package/dist/cli/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +3 -0
  171. package/dist/cli/src/builtin/modules/vector/reductionFunctions/span.d.ts +2 -0
  172. package/dist/cli/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +3 -0
  173. package/dist/cli/src/builtin/modules/vector/reductionFunctions/sum.d.ts +2 -0
  174. package/dist/cli/src/builtin/modules/vector/reductionFunctions/variance.d.ts +3 -0
  175. package/dist/cli/src/builtin/normalExpressions/index.d.ts +8 -0
  176. package/dist/cli/src/builtin/specialExpressionTypes.d.ts +26 -0
  177. package/dist/cli/src/builtin/specialExpressions/and.d.ts +6 -0
  178. package/dist/cli/src/builtin/specialExpressions/array.d.ts +6 -0
  179. package/dist/cli/src/builtin/specialExpressions/block.d.ts +6 -0
  180. package/dist/cli/src/builtin/specialExpressions/cond.d.ts +6 -0
  181. package/dist/cli/src/builtin/specialExpressions/defined.d.ts +5 -0
  182. package/dist/cli/src/builtin/specialExpressions/effect.d.ts +5 -0
  183. package/dist/cli/src/builtin/specialExpressions/functions.d.ts +6 -0
  184. package/dist/cli/src/builtin/specialExpressions/if.d.ts +6 -0
  185. package/dist/cli/src/builtin/specialExpressions/import.d.ts +6 -0
  186. package/dist/cli/src/builtin/specialExpressions/let.d.ts +6 -0
  187. package/dist/cli/src/builtin/specialExpressions/loop.d.ts +6 -0
  188. package/dist/cli/src/builtin/specialExpressions/loops.d.ts +9 -0
  189. package/dist/cli/src/builtin/specialExpressions/match.d.ts +7 -0
  190. package/dist/cli/src/builtin/specialExpressions/object.d.ts +6 -0
  191. package/dist/cli/src/builtin/specialExpressions/or.d.ts +6 -0
  192. package/dist/cli/src/builtin/specialExpressions/parallel.d.ts +6 -0
  193. package/dist/cli/src/builtin/specialExpressions/perform.d.ts +6 -0
  194. package/dist/cli/src/builtin/specialExpressions/qq.d.ts +6 -0
  195. package/dist/cli/src/builtin/specialExpressions/race.d.ts +6 -0
  196. package/dist/cli/src/builtin/specialExpressions/recur.d.ts +5 -0
  197. package/dist/cli/src/builtin/specialExpressions/throw.d.ts +5 -0
  198. package/dist/cli/src/builtin/specialExpressions/try.d.ts +7 -0
  199. package/dist/cli/src/builtin/specialExpressions/unless.d.ts +6 -0
  200. package/dist/cli/src/builtin/utils.d.ts +6 -0
  201. package/dist/cli/src/bundler/index.d.ts +9 -0
  202. package/dist/cli/src/bundler/interface.d.ts +15 -0
  203. package/dist/cli/src/bundler.d.ts +3 -0
  204. package/dist/cli/src/cli.d.ts +2 -0
  205. package/dist/cli/src/cliDocumentation/formatCliDescription.d.ts +3 -0
  206. package/dist/cli/src/cliDocumentation/getCliArgumentInfo.d.ts +3 -0
  207. package/dist/cli/src/cliDocumentation/getCliDocumentation.d.ts +2 -0
  208. package/dist/cli/src/cliDocumentation/getCliFunctionExamples.d.ts +3 -0
  209. package/dist/cli/src/cliDocumentation/getCliFunctionSignature.d.ts +3 -0
  210. package/dist/cli/src/cliDocumentation/getCliTitle.d.ts +3 -0
  211. package/dist/cli/src/cliDocumentation/getCliType.d.ts +3 -0
  212. package/dist/cli/src/cliFormatterRules.d.ts +13 -0
  213. package/dist/cli/src/colorizer.d.ts +939 -0
  214. package/dist/cli/src/constants/constants.d.ts +19 -0
  215. package/dist/cli/src/createReadlineInterface.d.ts +5 -0
  216. package/dist/cli/src/effects.d.ts +106 -0
  217. package/dist/cli/src/errors.d.ts +24 -0
  218. package/dist/cli/src/evaluator/ContextStack.d.ts +65 -0
  219. package/dist/cli/src/evaluator/effectRef.d.ts +27 -0
  220. package/dist/cli/src/evaluator/effectTypes.d.ts +79 -0
  221. package/dist/cli/src/evaluator/frames.d.ts +525 -0
  222. package/dist/cli/src/evaluator/interface.d.ts +14 -0
  223. package/dist/cli/src/evaluator/serialization.d.ts +45 -0
  224. package/dist/cli/src/evaluator/standardEffects.d.ts +35 -0
  225. package/dist/cli/src/evaluator/step.d.ts +159 -0
  226. package/dist/cli/src/evaluator/suspension.d.ts +53 -0
  227. package/dist/cli/src/evaluator/trampoline.d.ts +119 -0
  228. package/dist/cli/src/getUndefinedSymbols/index.d.ts +7 -0
  229. package/dist/cli/src/index.d.ts +18 -0
  230. package/dist/cli/src/initReferenceData.d.ts +1 -0
  231. package/dist/cli/src/interface.d.ts +7 -0
  232. package/dist/cli/src/js-interop/Cli/Fs/index.d.ts +2 -0
  233. package/dist/cli/src/js-interop/Cli/Proc/index.d.ts +3 -0
  234. package/dist/cli/src/js-interop/Cli/index.d.ts +2 -0
  235. package/dist/cli/src/parser/ParserContext.d.ts +20 -0
  236. package/dist/cli/src/parser/getPrecedence.d.ts +3 -0
  237. package/dist/cli/src/parser/helpers.d.ts +19 -0
  238. package/dist/cli/src/parser/index.d.ts +5 -0
  239. package/dist/cli/src/parser/subParsers/parseArray.d.ts +3 -0
  240. package/dist/cli/src/parser/subParsers/parseBindingTarget.d.ts +8 -0
  241. package/dist/cli/src/parser/subParsers/parseCond.d.ts +4 -0
  242. package/dist/cli/src/parser/subParsers/parseDo.d.ts +3 -0
  243. package/dist/cli/src/parser/subParsers/parseExpression.d.ts +5 -0
  244. package/dist/cli/src/parser/subParsers/parseForOrDoseq.d.ts +4 -0
  245. package/dist/cli/src/parser/subParsers/parseFunction.d.ts +4 -0
  246. package/dist/cli/src/parser/subParsers/parseFunctionCall.d.ts +3 -0
  247. package/dist/cli/src/parser/subParsers/parseIfOrUnless.d.ts +5 -0
  248. package/dist/cli/src/parser/subParsers/parseImplicitBlock.d.ts +5 -0
  249. package/dist/cli/src/parser/subParsers/parseLet.d.ts +4 -0
  250. package/dist/cli/src/parser/subParsers/parseLoop.d.ts +4 -0
  251. package/dist/cli/src/parser/subParsers/parseMatch.d.ts +4 -0
  252. package/dist/cli/src/parser/subParsers/parseNumber.d.ts +3 -0
  253. package/dist/cli/src/parser/subParsers/parseObject.d.ts +3 -0
  254. package/dist/cli/src/parser/subParsers/parseOperand.d.ts +3 -0
  255. package/dist/cli/src/parser/subParsers/parseRegexpShorthand.d.ts +3 -0
  256. package/dist/cli/src/parser/subParsers/parseReservedSymbol.d.ts +3 -0
  257. package/dist/cli/src/parser/subParsers/parseString.d.ts +4 -0
  258. package/dist/cli/src/parser/subParsers/parseSymbol.d.ts +3 -0
  259. package/dist/cli/src/parser/subParsers/parseTry.d.ts +4 -0
  260. package/dist/cli/src/parser/types.d.ts +129 -0
  261. package/dist/cli/src/symbolPatterns.d.ts +2 -0
  262. package/dist/cli/src/testFramework/index.d.ts +15 -0
  263. package/dist/cli/src/tokenizer/minifyTokenStream.d.ts +4 -0
  264. package/dist/cli/src/tokenizer/operators.d.ts +12 -0
  265. package/dist/cli/src/tokenizer/reservedNames.d.ts +66 -0
  266. package/dist/cli/src/tokenizer/token.d.ts +84 -0
  267. package/dist/cli/src/tokenizer/tokenize.d.ts +8 -0
  268. package/dist/cli/src/tokenizer/tokenizers.d.ts +14 -0
  269. package/dist/cli/src/transformer/index.d.ts +2 -0
  270. package/dist/cli/src/typeGuards/annotatedArrays.d.ts +16 -0
  271. package/dist/cli/src/typeGuards/array.d.ts +9 -0
  272. package/dist/cli/src/typeGuards/astNode.d.ts +19 -0
  273. package/dist/cli/src/typeGuards/dvala.d.ts +26 -0
  274. package/dist/cli/src/typeGuards/dvalaFunction.d.ts +12 -0
  275. package/dist/cli/src/typeGuards/index.d.ts +7 -0
  276. package/dist/cli/src/typeGuards/number.d.ts +66 -0
  277. package/dist/cli/src/typeGuards/string.d.ts +15 -0
  278. package/dist/cli/src/untokenizer/index.d.ts +2 -0
  279. package/dist/cli/src/utils/arity.d.ts +10 -0
  280. package/dist/cli/src/utils/debug/debugTools.d.ts +1 -0
  281. package/dist/cli/src/utils/debug/getCodeMarker.d.ts +2 -0
  282. package/dist/cli/src/utils/debug/getSourceCodeInfo.d.ts +2 -0
  283. package/dist/cli/src/utils/docString/generateDocString.d.ts +2 -0
  284. package/dist/cli/src/utils/getAssertionError.d.ts +3 -0
  285. package/dist/cli/src/utils/index.d.ts +14 -0
  286. package/dist/cli/src/utils/maybePromise.d.ts +54 -0
  287. package/dist/cli/src/utils/symbols.d.ts +3 -0
  288. package/dist/common/createFormatter.d.ts +6 -0
  289. package/dist/common/utils.d.ts +2 -0
  290. package/dist/debug.esm.js +2 -0
  291. package/dist/debug.esm.js.map +1 -0
  292. package/dist/debug.js +2 -0
  293. package/dist/debug.js.map +1 -0
  294. package/dist/dvala.iife.js +2 -0
  295. package/dist/dvala.iife.js.map +1 -0
  296. package/dist/full.esm.js +2 -0
  297. package/dist/full.esm.js.map +1 -0
  298. package/dist/full.js +2 -0
  299. package/dist/full.js.map +1 -0
  300. package/dist/index.esm.js +2 -0
  301. package/dist/index.esm.js.map +1 -0
  302. package/dist/index.js +2 -2
  303. package/dist/index.js.map +1 -1
  304. package/dist/modules/assertion.esm.js +2 -0
  305. package/dist/modules/assertion.esm.js.map +1 -0
  306. package/dist/modules/assertion.js +2 -0
  307. package/dist/modules/assertion.js.map +1 -0
  308. package/dist/modules/bitwise.esm.js +2 -0
  309. package/dist/modules/bitwise.esm.js.map +1 -0
  310. package/dist/modules/bitwise.js +2 -0
  311. package/dist/modules/bitwise.js.map +1 -0
  312. package/dist/modules/cli/src/cli.d.ts +2 -0
  313. package/dist/modules/cli/src/cliDocumentation/formatCliDescription.d.ts +3 -0
  314. package/dist/modules/cli/src/cliDocumentation/getCliArgumentInfo.d.ts +3 -0
  315. package/dist/modules/cli/src/cliDocumentation/getCliDocumentation.d.ts +2 -0
  316. package/dist/modules/cli/src/cliDocumentation/getCliFunctionExamples.d.ts +3 -0
  317. package/dist/modules/cli/src/cliDocumentation/getCliFunctionSignature.d.ts +3 -0
  318. package/dist/modules/cli/src/cliDocumentation/getCliTitle.d.ts +3 -0
  319. package/dist/modules/cli/src/cliDocumentation/getCliType.d.ts +3 -0
  320. package/dist/modules/cli/src/cliFormatterRules.d.ts +13 -0
  321. package/dist/modules/cli/src/colorizer.d.ts +939 -0
  322. package/dist/modules/cli/src/createReadlineInterface.d.ts +5 -0
  323. package/dist/modules/cli/src/js-interop/Cli/Fs/index.d.ts +2 -0
  324. package/dist/modules/cli/src/js-interop/Cli/Proc/index.d.ts +3 -0
  325. package/dist/modules/cli/src/js-interop/Cli/index.d.ts +2 -0
  326. package/dist/modules/collection.esm.js +2 -0
  327. package/dist/modules/collection.esm.js.map +1 -0
  328. package/dist/modules/collection.js +2 -0
  329. package/dist/modules/collection.js.map +1 -0
  330. package/dist/modules/common/createFormatter.d.ts +6 -0
  331. package/dist/modules/common/utils.d.ts +2 -0
  332. package/dist/modules/convert.esm.js +2 -0
  333. package/dist/modules/convert.esm.js.map +1 -0
  334. package/dist/modules/convert.js +2 -0
  335. package/dist/modules/convert.js.map +1 -0
  336. package/dist/modules/functional.esm.js +2 -0
  337. package/dist/modules/functional.esm.js.map +1 -0
  338. package/dist/modules/functional.js +2 -0
  339. package/dist/modules/functional.js.map +1 -0
  340. package/dist/modules/grid.esm.js +2 -0
  341. package/dist/modules/grid.esm.js.map +1 -0
  342. package/dist/modules/grid.js +2 -0
  343. package/dist/modules/grid.js.map +1 -0
  344. package/dist/modules/linear-algebra.esm.js +2 -0
  345. package/dist/modules/linear-algebra.esm.js.map +1 -0
  346. package/dist/modules/linear-algebra.js +2 -0
  347. package/dist/modules/linear-algebra.js.map +1 -0
  348. package/dist/modules/math.esm.js +2 -0
  349. package/dist/modules/math.esm.js.map +1 -0
  350. package/dist/modules/math.js +2 -0
  351. package/dist/modules/math.js.map +1 -0
  352. package/dist/modules/matrix.esm.js +2 -0
  353. package/dist/modules/matrix.esm.js.map +1 -0
  354. package/dist/modules/matrix.js +2 -0
  355. package/dist/modules/matrix.js.map +1 -0
  356. package/dist/modules/number-theory.esm.js +2 -0
  357. package/dist/modules/number-theory.esm.js.map +1 -0
  358. package/dist/modules/number-theory.js +2 -0
  359. package/dist/modules/number-theory.js.map +1 -0
  360. package/dist/modules/random.esm.js +2 -0
  361. package/dist/modules/random.esm.js.map +1 -0
  362. package/dist/modules/random.js +2 -0
  363. package/dist/modules/random.js.map +1 -0
  364. package/dist/modules/reference/api.d.ts +75 -0
  365. package/dist/modules/reference/datatype.d.ts +3 -0
  366. package/dist/modules/reference/effect.d.ts +3 -0
  367. package/dist/modules/reference/index.d.ts +191 -0
  368. package/dist/modules/reference/shorthand.d.ts +3 -0
  369. package/dist/modules/sequence.esm.js +2 -0
  370. package/dist/modules/sequence.esm.js.map +1 -0
  371. package/dist/modules/sequence.js +2 -0
  372. package/dist/modules/sequence.js.map +1 -0
  373. package/dist/modules/src/AutoCompleter/AutoCompleter.d.ts +25 -0
  374. package/dist/modules/src/Dvala/Cache.d.ts +16 -0
  375. package/dist/modules/src/Dvala/Dvala.d.ts +68 -0
  376. package/dist/modules/src/allModules.d.ts +2 -0
  377. package/dist/modules/src/builtin/bindingNode.d.ts +11 -0
  378. package/dist/modules/src/builtin/core/array.d.ts +2 -0
  379. package/dist/modules/src/builtin/core/assertion.d.ts +2 -0
  380. package/dist/modules/src/builtin/core/bitwise.d.ts +2 -0
  381. package/dist/modules/src/builtin/core/collection.d.ts +2 -0
  382. package/dist/modules/src/builtin/core/functional.d.ts +2 -0
  383. package/dist/modules/src/builtin/core/math.d.ts +2 -0
  384. package/dist/modules/src/builtin/core/meta.d.ts +3 -0
  385. package/dist/modules/src/builtin/core/misc.d.ts +2 -0
  386. package/dist/modules/src/builtin/core/object.d.ts +2 -0
  387. package/dist/modules/src/builtin/core/predicates.d.ts +2 -0
  388. package/dist/modules/src/builtin/core/regexp.d.ts +2 -0
  389. package/dist/modules/src/builtin/core/sequence.d.ts +2 -0
  390. package/dist/modules/src/builtin/core/string.d.ts +2 -0
  391. package/dist/modules/src/builtin/core/vector.d.ts +2 -0
  392. package/dist/modules/src/builtin/index.d.ts +13 -0
  393. package/dist/modules/src/builtin/interface.d.ts +113 -0
  394. package/dist/modules/src/builtin/modules/assertion/docs.d.ts +2 -0
  395. package/dist/modules/src/builtin/modules/assertion/index.d.ts +2 -0
  396. package/dist/modules/src/builtin/modules/bitwise/index.d.ts +2 -0
  397. package/dist/modules/src/builtin/modules/collection/index.d.ts +2 -0
  398. package/dist/modules/src/builtin/modules/convert/index.d.ts +2 -0
  399. package/dist/modules/src/builtin/modules/functional/index.d.ts +2 -0
  400. package/dist/modules/src/builtin/modules/grid/docs.d.ts +2 -0
  401. package/dist/modules/src/builtin/modules/grid/fromArray.d.ts +8 -0
  402. package/dist/modules/src/builtin/modules/grid/index.d.ts +2 -0
  403. package/dist/modules/src/builtin/modules/grid/transpose.d.ts +2 -0
  404. package/dist/modules/src/builtin/modules/interface.d.ts +11 -0
  405. package/dist/modules/src/builtin/modules/linear-algebra/docs.d.ts +2 -0
  406. package/dist/modules/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +1 -0
  407. package/dist/modules/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +2 -0
  408. package/dist/modules/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +8 -0
  409. package/dist/modules/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +4 -0
  410. package/dist/modules/src/builtin/modules/linear-algebra/helpers/dot.d.ts +1 -0
  411. package/dist/modules/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +7 -0
  412. package/dist/modules/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +2 -0
  413. package/dist/modules/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +1 -0
  414. package/dist/modules/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +10 -0
  415. package/dist/modules/src/builtin/modules/linear-algebra/helpers/length.d.ts +1 -0
  416. package/dist/modules/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +1 -0
  417. package/dist/modules/src/builtin/modules/linear-algebra/helpers/scale.d.ts +1 -0
  418. package/dist/modules/src/builtin/modules/linear-algebra/helpers/solve.d.ts +8 -0
  419. package/dist/modules/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +1 -0
  420. package/dist/modules/src/builtin/modules/linear-algebra/index.d.ts +4 -0
  421. package/dist/modules/src/builtin/modules/math/index.d.ts +2 -0
  422. package/dist/modules/src/builtin/modules/matrix/docs.d.ts +2 -0
  423. package/dist/modules/src/builtin/modules/matrix/helpers/adjugate.d.ts +1 -0
  424. package/dist/modules/src/builtin/modules/matrix/helpers/band.d.ts +9 -0
  425. package/dist/modules/src/builtin/modules/matrix/helpers/cofactor.d.ts +1 -0
  426. package/dist/modules/src/builtin/modules/matrix/helpers/determinant.d.ts +6 -0
  427. package/dist/modules/src/builtin/modules/matrix/helpers/diagonal.d.ts +1 -0
  428. package/dist/modules/src/builtin/modules/matrix/helpers/inverse.d.ts +6 -0
  429. package/dist/modules/src/builtin/modules/matrix/helpers/isBanded.d.ts +11 -0
  430. package/dist/modules/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +10 -0
  431. package/dist/modules/src/builtin/modules/matrix/helpers/isIdentity.d.ts +1 -0
  432. package/dist/modules/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +1 -0
  433. package/dist/modules/src/builtin/modules/matrix/helpers/isSquare.d.ts +1 -0
  434. package/dist/modules/src/builtin/modules/matrix/helpers/isSymetric.d.ts +8 -0
  435. package/dist/modules/src/builtin/modules/matrix/helpers/isTriangular.d.ts +13 -0
  436. package/dist/modules/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +7 -0
  437. package/dist/modules/src/builtin/modules/matrix/helpers/minor.d.ts +1 -0
  438. package/dist/modules/src/builtin/modules/matrix/helpers/norm1.d.ts +1 -0
  439. package/dist/modules/src/builtin/modules/matrix/helpers/trace.d.ts +8 -0
  440. package/dist/modules/src/builtin/modules/matrix/index.d.ts +4 -0
  441. package/dist/modules/src/builtin/modules/number-theory/binomialCefficient.d.ts +1 -0
  442. package/dist/modules/src/builtin/modules/number-theory/combinations.d.ts +2 -0
  443. package/dist/modules/src/builtin/modules/number-theory/derangements.d.ts +2 -0
  444. package/dist/modules/src/builtin/modules/number-theory/divisors.d.ts +4 -0
  445. package/dist/modules/src/builtin/modules/number-theory/docs.d.ts +2 -0
  446. package/dist/modules/src/builtin/modules/number-theory/factorial.d.ts +3 -0
  447. package/dist/modules/src/builtin/modules/number-theory/index.d.ts +4 -0
  448. package/dist/modules/src/builtin/modules/number-theory/partitions.d.ts +2 -0
  449. package/dist/modules/src/builtin/modules/number-theory/permutations.d.ts +2 -0
  450. package/dist/modules/src/builtin/modules/number-theory/powerSet.d.ts +2 -0
  451. package/dist/modules/src/builtin/modules/number-theory/primeFactors.d.ts +11 -0
  452. package/dist/modules/src/builtin/modules/number-theory/sequences/abundant.d.ts +2 -0
  453. package/dist/modules/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +2 -0
  454. package/dist/modules/src/builtin/modules/number-theory/sequences/bell.d.ts +1 -0
  455. package/dist/modules/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +2 -0
  456. package/dist/modules/src/builtin/modules/number-theory/sequences/catalan.d.ts +1 -0
  457. package/dist/modules/src/builtin/modules/number-theory/sequences/collatz.d.ts +2 -0
  458. package/dist/modules/src/builtin/modules/number-theory/sequences/composite.d.ts +3 -0
  459. package/dist/modules/src/builtin/modules/number-theory/sequences/deficient.d.ts +2 -0
  460. package/dist/modules/src/builtin/modules/number-theory/sequences/factorial.d.ts +1 -0
  461. package/dist/modules/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +1 -0
  462. package/dist/modules/src/builtin/modules/number-theory/sequences/geometric.d.ts +2 -0
  463. package/dist/modules/src/builtin/modules/number-theory/sequences/golomb.d.ts +2 -0
  464. package/dist/modules/src/builtin/modules/number-theory/sequences/happy.d.ts +2 -0
  465. package/dist/modules/src/builtin/modules/number-theory/sequences/index.d.ts +27 -0
  466. package/dist/modules/src/builtin/modules/number-theory/sequences/juggler.d.ts +2 -0
  467. package/dist/modules/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +2 -0
  468. package/dist/modules/src/builtin/modules/number-theory/sequences/lucas.d.ts +1 -0
  469. package/dist/modules/src/builtin/modules/number-theory/sequences/lucky.d.ts +2 -0
  470. package/dist/modules/src/builtin/modules/number-theory/sequences/mersenne.d.ts +1 -0
  471. package/dist/modules/src/builtin/modules/number-theory/sequences/padovan.d.ts +2 -0
  472. package/dist/modules/src/builtin/modules/number-theory/sequences/partition.d.ts +1 -0
  473. package/dist/modules/src/builtin/modules/number-theory/sequences/pell.d.ts +1 -0
  474. package/dist/modules/src/builtin/modules/number-theory/sequences/perfect.d.ts +1 -0
  475. package/dist/modules/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +2 -0
  476. package/dist/modules/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +10 -0
  477. package/dist/modules/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +2 -0
  478. package/dist/modules/src/builtin/modules/number-theory/sequences/poligonal.d.ts +2 -0
  479. package/dist/modules/src/builtin/modules/number-theory/sequences/prime.d.ts +3 -0
  480. package/dist/modules/src/builtin/modules/number-theory/sequences/recaman.d.ts +9 -0
  481. package/dist/modules/src/builtin/modules/number-theory/sequences/sylvester.d.ts +1 -0
  482. package/dist/modules/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +2 -0
  483. package/dist/modules/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +1 -0
  484. package/dist/modules/src/builtin/modules/random/docs.d.ts +2 -0
  485. package/dist/modules/src/builtin/modules/random/index.d.ts +2 -0
  486. package/dist/modules/src/builtin/modules/sequence/index.d.ts +2 -0
  487. package/dist/modules/src/builtin/modules/string/index.d.ts +2 -0
  488. package/dist/modules/src/builtin/modules/vector/bincount.d.ts +9 -0
  489. package/dist/modules/src/builtin/modules/vector/calcMad.d.ts +1 -0
  490. package/dist/modules/src/builtin/modules/vector/calcMean.d.ts +1 -0
  491. package/dist/modules/src/builtin/modules/vector/calcMedad.d.ts +1 -0
  492. package/dist/modules/src/builtin/modules/vector/calcMedian.d.ts +1 -0
  493. package/dist/modules/src/builtin/modules/vector/calcStdDev.d.ts +2 -0
  494. package/dist/modules/src/builtin/modules/vector/calcVariance.d.ts +2 -0
  495. package/dist/modules/src/builtin/modules/vector/docs.d.ts +2 -0
  496. package/dist/modules/src/builtin/modules/vector/entropy.d.ts +8 -0
  497. package/dist/modules/src/builtin/modules/vector/histogram.d.ts +9 -0
  498. package/dist/modules/src/builtin/modules/vector/index.d.ts +2 -0
  499. package/dist/modules/src/builtin/modules/vector/mode.d.ts +6 -0
  500. package/dist/modules/src/builtin/modules/vector/outliers.d.ts +7 -0
  501. package/dist/modules/src/builtin/modules/vector/percentile.d.ts +7 -0
  502. package/dist/modules/src/builtin/modules/vector/quartiles.d.ts +1 -0
  503. package/dist/modules/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +2 -0
  504. package/dist/modules/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +2 -0
  505. package/dist/modules/src/builtin/modules/vector/reductionFunctions/index.d.ts +13 -0
  506. package/dist/modules/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +2 -0
  507. package/dist/modules/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +5 -0
  508. package/dist/modules/src/builtin/modules/vector/reductionFunctions/mad.d.ts +2 -0
  509. package/dist/modules/src/builtin/modules/vector/reductionFunctions/mean.d.ts +4 -0
  510. package/dist/modules/src/builtin/modules/vector/reductionFunctions/medad.d.ts +2 -0
  511. package/dist/modules/src/builtin/modules/vector/reductionFunctions/median.d.ts +2 -0
  512. package/dist/modules/src/builtin/modules/vector/reductionFunctions/prod.d.ts +2 -0
  513. package/dist/modules/src/builtin/modules/vector/reductionFunctions/rms.d.ts +2 -0
  514. package/dist/modules/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +3 -0
  515. package/dist/modules/src/builtin/modules/vector/reductionFunctions/span.d.ts +2 -0
  516. package/dist/modules/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +3 -0
  517. package/dist/modules/src/builtin/modules/vector/reductionFunctions/sum.d.ts +2 -0
  518. package/dist/modules/src/builtin/modules/vector/reductionFunctions/variance.d.ts +3 -0
  519. package/dist/modules/src/builtin/normalExpressions/index.d.ts +8 -0
  520. package/dist/modules/src/builtin/specialExpressionTypes.d.ts +26 -0
  521. package/dist/modules/src/builtin/specialExpressions/and.d.ts +6 -0
  522. package/dist/modules/src/builtin/specialExpressions/array.d.ts +6 -0
  523. package/dist/modules/src/builtin/specialExpressions/block.d.ts +6 -0
  524. package/dist/modules/src/builtin/specialExpressions/cond.d.ts +6 -0
  525. package/dist/modules/src/builtin/specialExpressions/defined.d.ts +5 -0
  526. package/dist/modules/src/builtin/specialExpressions/effect.d.ts +5 -0
  527. package/dist/modules/src/builtin/specialExpressions/functions.d.ts +6 -0
  528. package/dist/modules/src/builtin/specialExpressions/if.d.ts +6 -0
  529. package/dist/modules/src/builtin/specialExpressions/import.d.ts +6 -0
  530. package/dist/modules/src/builtin/specialExpressions/let.d.ts +6 -0
  531. package/dist/modules/src/builtin/specialExpressions/loop.d.ts +6 -0
  532. package/dist/modules/src/builtin/specialExpressions/loops.d.ts +9 -0
  533. package/dist/modules/src/builtin/specialExpressions/match.d.ts +7 -0
  534. package/dist/modules/src/builtin/specialExpressions/object.d.ts +6 -0
  535. package/dist/modules/src/builtin/specialExpressions/or.d.ts +6 -0
  536. package/dist/modules/src/builtin/specialExpressions/parallel.d.ts +6 -0
  537. package/dist/modules/src/builtin/specialExpressions/perform.d.ts +6 -0
  538. package/dist/modules/src/builtin/specialExpressions/qq.d.ts +6 -0
  539. package/dist/modules/src/builtin/specialExpressions/race.d.ts +6 -0
  540. package/dist/modules/src/builtin/specialExpressions/recur.d.ts +5 -0
  541. package/dist/modules/src/builtin/specialExpressions/throw.d.ts +5 -0
  542. package/dist/modules/src/builtin/specialExpressions/try.d.ts +7 -0
  543. package/dist/modules/src/builtin/specialExpressions/unless.d.ts +6 -0
  544. package/dist/modules/src/builtin/utils.d.ts +6 -0
  545. package/dist/modules/src/bundler/index.d.ts +9 -0
  546. package/dist/modules/src/bundler/interface.d.ts +15 -0
  547. package/dist/modules/src/bundler.d.ts +3 -0
  548. package/dist/modules/src/constants/constants.d.ts +19 -0
  549. package/dist/modules/src/debug.d.ts +115 -0
  550. package/dist/modules/src/effects.d.ts +106 -0
  551. package/dist/modules/src/errors.d.ts +24 -0
  552. package/dist/modules/src/evaluator/ContextStack.d.ts +65 -0
  553. package/dist/modules/src/evaluator/effectRef.d.ts +27 -0
  554. package/dist/modules/src/evaluator/effectTypes.d.ts +79 -0
  555. package/dist/modules/src/evaluator/frames.d.ts +525 -0
  556. package/dist/modules/src/evaluator/interface.d.ts +14 -0
  557. package/dist/modules/src/evaluator/serialization.d.ts +45 -0
  558. package/dist/modules/src/evaluator/standardEffects.d.ts +35 -0
  559. package/dist/modules/src/evaluator/step.d.ts +159 -0
  560. package/dist/modules/src/evaluator/suspension.d.ts +53 -0
  561. package/dist/modules/src/evaluator/trampoline.d.ts +119 -0
  562. package/dist/modules/src/full.d.ts +17 -0
  563. package/dist/modules/src/getUndefinedSymbols/index.d.ts +7 -0
  564. package/dist/modules/src/index.d.ts +18 -0
  565. package/dist/modules/src/initReferenceData.d.ts +1 -0
  566. package/dist/modules/src/interface.d.ts +7 -0
  567. package/dist/modules/src/modules/assertion.d.ts +2 -0
  568. package/dist/modules/src/modules/bitwise.d.ts +2 -0
  569. package/dist/modules/src/modules/collection.d.ts +2 -0
  570. package/dist/modules/src/modules/convert.d.ts +2 -0
  571. package/dist/modules/src/modules/functional.d.ts +2 -0
  572. package/dist/modules/src/modules/grid.d.ts +2 -0
  573. package/dist/modules/src/modules/linear-algebra.d.ts +2 -0
  574. package/dist/modules/src/modules/math.d.ts +2 -0
  575. package/dist/modules/src/modules/matrix.d.ts +2 -0
  576. package/dist/modules/src/modules/number-theory.d.ts +2 -0
  577. package/dist/modules/src/modules/random.d.ts +2 -0
  578. package/dist/modules/src/modules/sequence.d.ts +2 -0
  579. package/dist/modules/src/modules/string.d.ts +2 -0
  580. package/dist/modules/src/modules/vector.d.ts +2 -0
  581. package/dist/modules/src/parser/ParserContext.d.ts +20 -0
  582. package/dist/modules/src/parser/getPrecedence.d.ts +3 -0
  583. package/dist/modules/src/parser/helpers.d.ts +19 -0
  584. package/dist/modules/src/parser/index.d.ts +5 -0
  585. package/dist/modules/src/parser/subParsers/parseArray.d.ts +3 -0
  586. package/dist/modules/src/parser/subParsers/parseBindingTarget.d.ts +8 -0
  587. package/dist/modules/src/parser/subParsers/parseCond.d.ts +4 -0
  588. package/dist/modules/src/parser/subParsers/parseDo.d.ts +3 -0
  589. package/dist/modules/src/parser/subParsers/parseExpression.d.ts +5 -0
  590. package/dist/modules/src/parser/subParsers/parseForOrDoseq.d.ts +4 -0
  591. package/dist/modules/src/parser/subParsers/parseFunction.d.ts +4 -0
  592. package/dist/modules/src/parser/subParsers/parseFunctionCall.d.ts +3 -0
  593. package/dist/modules/src/parser/subParsers/parseIfOrUnless.d.ts +5 -0
  594. package/dist/modules/src/parser/subParsers/parseImplicitBlock.d.ts +5 -0
  595. package/dist/modules/src/parser/subParsers/parseLet.d.ts +4 -0
  596. package/dist/modules/src/parser/subParsers/parseLoop.d.ts +4 -0
  597. package/dist/modules/src/parser/subParsers/parseMatch.d.ts +4 -0
  598. package/dist/modules/src/parser/subParsers/parseNumber.d.ts +3 -0
  599. package/dist/modules/src/parser/subParsers/parseObject.d.ts +3 -0
  600. package/dist/modules/src/parser/subParsers/parseOperand.d.ts +3 -0
  601. package/dist/modules/src/parser/subParsers/parseRegexpShorthand.d.ts +3 -0
  602. package/dist/modules/src/parser/subParsers/parseReservedSymbol.d.ts +3 -0
  603. package/dist/modules/src/parser/subParsers/parseString.d.ts +4 -0
  604. package/dist/modules/src/parser/subParsers/parseSymbol.d.ts +3 -0
  605. package/dist/modules/src/parser/subParsers/parseTry.d.ts +4 -0
  606. package/dist/modules/src/parser/types.d.ts +129 -0
  607. package/dist/modules/src/symbolPatterns.d.ts +2 -0
  608. package/dist/modules/src/testFramework/index.d.ts +15 -0
  609. package/dist/modules/src/tokenizer/minifyTokenStream.d.ts +4 -0
  610. package/dist/modules/src/tokenizer/operators.d.ts +12 -0
  611. package/dist/modules/src/tokenizer/reservedNames.d.ts +66 -0
  612. package/dist/modules/src/tokenizer/token.d.ts +84 -0
  613. package/dist/modules/src/tokenizer/tokenize.d.ts +8 -0
  614. package/dist/modules/src/tokenizer/tokenizers.d.ts +14 -0
  615. package/dist/modules/src/transformer/index.d.ts +2 -0
  616. package/dist/modules/src/typeGuards/annotatedArrays.d.ts +16 -0
  617. package/dist/modules/src/typeGuards/array.d.ts +9 -0
  618. package/dist/modules/src/typeGuards/astNode.d.ts +19 -0
  619. package/dist/modules/src/typeGuards/dvala.d.ts +26 -0
  620. package/dist/modules/src/typeGuards/dvalaFunction.d.ts +12 -0
  621. package/dist/modules/src/typeGuards/index.d.ts +7 -0
  622. package/dist/modules/src/typeGuards/number.d.ts +66 -0
  623. package/dist/modules/src/typeGuards/string.d.ts +15 -0
  624. package/dist/modules/src/untokenizer/index.d.ts +2 -0
  625. package/dist/modules/src/utils/arity.d.ts +10 -0
  626. package/dist/modules/src/utils/debug/debugTools.d.ts +1 -0
  627. package/dist/modules/src/utils/debug/getCodeMarker.d.ts +2 -0
  628. package/dist/modules/src/utils/debug/getSourceCodeInfo.d.ts +2 -0
  629. package/dist/modules/src/utils/docString/generateDocString.d.ts +2 -0
  630. package/dist/modules/src/utils/getAssertionError.d.ts +3 -0
  631. package/dist/modules/src/utils/index.d.ts +14 -0
  632. package/dist/modules/src/utils/maybePromise.d.ts +54 -0
  633. package/dist/modules/src/utils/symbols.d.ts +3 -0
  634. package/dist/modules/string.esm.js +2 -0
  635. package/dist/modules/string.esm.js.map +1 -0
  636. package/dist/modules/string.js +2 -0
  637. package/dist/modules/string.js.map +1 -0
  638. package/dist/modules/vector.esm.js +2 -0
  639. package/dist/modules/vector.esm.js.map +1 -0
  640. package/dist/modules/vector.js +2 -0
  641. package/dist/modules/vector.js.map +1 -0
  642. package/dist/reference/api.d.ts +75 -0
  643. package/dist/reference/datatype.d.ts +3 -0
  644. package/dist/reference/effect.d.ts +3 -0
  645. package/dist/reference/index.d.ts +191 -0
  646. package/dist/reference/shorthand.d.ts +3 -0
  647. package/dist/src/AutoCompleter/AutoCompleter.d.ts +25 -0
  648. package/dist/src/Dvala/Cache.d.ts +16 -0
  649. package/dist/src/Dvala/Dvala.d.ts +68 -0
  650. package/dist/src/allModules.d.ts +2 -0
  651. package/dist/src/builtin/bindingNode.d.ts +11 -0
  652. package/dist/src/builtin/core/array.d.ts +2 -0
  653. package/dist/src/builtin/core/assertion.d.ts +2 -0
  654. package/dist/src/builtin/core/bitwise.d.ts +2 -0
  655. package/dist/src/builtin/core/collection.d.ts +2 -0
  656. package/dist/src/builtin/core/functional.d.ts +2 -0
  657. package/dist/src/builtin/core/math.d.ts +2 -0
  658. package/dist/src/builtin/core/meta.d.ts +3 -0
  659. package/dist/src/builtin/core/misc.d.ts +2 -0
  660. package/dist/src/builtin/core/object.d.ts +2 -0
  661. package/dist/src/builtin/core/predicates.d.ts +2 -0
  662. package/dist/src/builtin/core/regexp.d.ts +2 -0
  663. package/dist/src/builtin/core/sequence.d.ts +2 -0
  664. package/dist/src/builtin/core/string.d.ts +2 -0
  665. package/dist/src/builtin/core/vector.d.ts +2 -0
  666. package/dist/src/builtin/index.d.ts +13 -0
  667. package/dist/src/builtin/interface.d.ts +113 -0
  668. package/dist/src/builtin/modules/assertion/docs.d.ts +2 -0
  669. package/dist/src/builtin/modules/assertion/index.d.ts +2 -0
  670. package/dist/src/builtin/modules/bitwise/index.d.ts +2 -0
  671. package/dist/src/builtin/modules/collection/index.d.ts +2 -0
  672. package/dist/src/builtin/modules/convert/index.d.ts +2 -0
  673. package/dist/src/builtin/modules/functional/index.d.ts +2 -0
  674. package/dist/src/builtin/modules/grid/docs.d.ts +2 -0
  675. package/dist/src/builtin/modules/grid/fromArray.d.ts +8 -0
  676. package/dist/src/builtin/modules/grid/index.d.ts +2 -0
  677. package/dist/src/builtin/modules/grid/transpose.d.ts +2 -0
  678. package/dist/src/builtin/modules/interface.d.ts +11 -0
  679. package/dist/src/builtin/modules/linear-algebra/docs.d.ts +2 -0
  680. package/dist/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +1 -0
  681. package/dist/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +2 -0
  682. package/dist/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +8 -0
  683. package/dist/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +4 -0
  684. package/dist/src/builtin/modules/linear-algebra/helpers/dot.d.ts +1 -0
  685. package/dist/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +7 -0
  686. package/dist/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +2 -0
  687. package/dist/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +1 -0
  688. package/dist/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +10 -0
  689. package/dist/src/builtin/modules/linear-algebra/helpers/length.d.ts +1 -0
  690. package/dist/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +1 -0
  691. package/dist/src/builtin/modules/linear-algebra/helpers/scale.d.ts +1 -0
  692. package/dist/src/builtin/modules/linear-algebra/helpers/solve.d.ts +8 -0
  693. package/dist/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +1 -0
  694. package/dist/src/builtin/modules/linear-algebra/index.d.ts +4 -0
  695. package/dist/src/builtin/modules/math/index.d.ts +2 -0
  696. package/dist/src/builtin/modules/matrix/docs.d.ts +2 -0
  697. package/dist/src/builtin/modules/matrix/helpers/adjugate.d.ts +1 -0
  698. package/dist/src/builtin/modules/matrix/helpers/band.d.ts +9 -0
  699. package/dist/src/builtin/modules/matrix/helpers/cofactor.d.ts +1 -0
  700. package/dist/src/builtin/modules/matrix/helpers/determinant.d.ts +6 -0
  701. package/dist/src/builtin/modules/matrix/helpers/diagonal.d.ts +1 -0
  702. package/dist/src/builtin/modules/matrix/helpers/inverse.d.ts +6 -0
  703. package/dist/src/builtin/modules/matrix/helpers/isBanded.d.ts +11 -0
  704. package/dist/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +10 -0
  705. package/dist/src/builtin/modules/matrix/helpers/isIdentity.d.ts +1 -0
  706. package/dist/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +1 -0
  707. package/dist/src/builtin/modules/matrix/helpers/isSquare.d.ts +1 -0
  708. package/dist/src/builtin/modules/matrix/helpers/isSymetric.d.ts +8 -0
  709. package/dist/src/builtin/modules/matrix/helpers/isTriangular.d.ts +13 -0
  710. package/dist/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +7 -0
  711. package/dist/src/builtin/modules/matrix/helpers/minor.d.ts +1 -0
  712. package/dist/src/builtin/modules/matrix/helpers/norm1.d.ts +1 -0
  713. package/dist/src/builtin/modules/matrix/helpers/trace.d.ts +8 -0
  714. package/dist/src/builtin/modules/matrix/index.d.ts +4 -0
  715. package/dist/src/builtin/modules/number-theory/binomialCefficient.d.ts +1 -0
  716. package/dist/src/builtin/modules/number-theory/combinations.d.ts +2 -0
  717. package/dist/src/builtin/modules/number-theory/derangements.d.ts +2 -0
  718. package/dist/src/builtin/modules/number-theory/divisors.d.ts +4 -0
  719. package/dist/src/builtin/modules/number-theory/docs.d.ts +2 -0
  720. package/dist/src/builtin/modules/number-theory/factorial.d.ts +3 -0
  721. package/dist/src/builtin/modules/number-theory/index.d.ts +4 -0
  722. package/dist/src/builtin/modules/number-theory/partitions.d.ts +2 -0
  723. package/dist/src/builtin/modules/number-theory/permutations.d.ts +2 -0
  724. package/dist/src/builtin/modules/number-theory/powerSet.d.ts +2 -0
  725. package/dist/src/builtin/modules/number-theory/primeFactors.d.ts +11 -0
  726. package/dist/src/builtin/modules/number-theory/sequences/abundant.d.ts +2 -0
  727. package/dist/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +2 -0
  728. package/dist/src/builtin/modules/number-theory/sequences/bell.d.ts +1 -0
  729. package/dist/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +2 -0
  730. package/dist/src/builtin/modules/number-theory/sequences/catalan.d.ts +1 -0
  731. package/dist/src/builtin/modules/number-theory/sequences/collatz.d.ts +2 -0
  732. package/dist/src/builtin/modules/number-theory/sequences/composite.d.ts +3 -0
  733. package/dist/src/builtin/modules/number-theory/sequences/deficient.d.ts +2 -0
  734. package/dist/src/builtin/modules/number-theory/sequences/factorial.d.ts +1 -0
  735. package/dist/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +1 -0
  736. package/dist/src/builtin/modules/number-theory/sequences/geometric.d.ts +2 -0
  737. package/dist/src/builtin/modules/number-theory/sequences/golomb.d.ts +2 -0
  738. package/dist/src/builtin/modules/number-theory/sequences/happy.d.ts +2 -0
  739. package/dist/src/builtin/modules/number-theory/sequences/index.d.ts +27 -0
  740. package/dist/src/builtin/modules/number-theory/sequences/juggler.d.ts +2 -0
  741. package/dist/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +2 -0
  742. package/dist/src/builtin/modules/number-theory/sequences/lucas.d.ts +1 -0
  743. package/dist/src/builtin/modules/number-theory/sequences/lucky.d.ts +2 -0
  744. package/dist/src/builtin/modules/number-theory/sequences/mersenne.d.ts +1 -0
  745. package/dist/src/builtin/modules/number-theory/sequences/padovan.d.ts +2 -0
  746. package/dist/src/builtin/modules/number-theory/sequences/partition.d.ts +1 -0
  747. package/dist/src/builtin/modules/number-theory/sequences/pell.d.ts +1 -0
  748. package/dist/src/builtin/modules/number-theory/sequences/perfect.d.ts +1 -0
  749. package/dist/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +2 -0
  750. package/dist/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +10 -0
  751. package/dist/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +2 -0
  752. package/dist/src/builtin/modules/number-theory/sequences/poligonal.d.ts +2 -0
  753. package/dist/src/builtin/modules/number-theory/sequences/prime.d.ts +3 -0
  754. package/dist/src/builtin/modules/number-theory/sequences/recaman.d.ts +9 -0
  755. package/dist/src/builtin/modules/number-theory/sequences/sylvester.d.ts +1 -0
  756. package/dist/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +2 -0
  757. package/dist/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +1 -0
  758. package/dist/src/builtin/modules/random/docs.d.ts +2 -0
  759. package/dist/src/builtin/modules/random/index.d.ts +2 -0
  760. package/dist/src/builtin/modules/sequence/index.d.ts +2 -0
  761. package/dist/src/builtin/modules/string/index.d.ts +2 -0
  762. package/dist/src/builtin/modules/vector/bincount.d.ts +9 -0
  763. package/dist/src/builtin/modules/vector/calcMad.d.ts +1 -0
  764. package/dist/src/builtin/modules/vector/calcMean.d.ts +1 -0
  765. package/dist/src/builtin/modules/vector/calcMedad.d.ts +1 -0
  766. package/dist/src/builtin/modules/vector/calcMedian.d.ts +1 -0
  767. package/dist/src/builtin/modules/vector/calcStdDev.d.ts +2 -0
  768. package/dist/src/builtin/modules/vector/calcVariance.d.ts +2 -0
  769. package/dist/src/builtin/modules/vector/docs.d.ts +2 -0
  770. package/dist/src/builtin/modules/vector/entropy.d.ts +8 -0
  771. package/dist/src/builtin/modules/vector/histogram.d.ts +9 -0
  772. package/dist/src/builtin/modules/vector/index.d.ts +2 -0
  773. package/dist/src/builtin/modules/vector/mode.d.ts +6 -0
  774. package/dist/src/builtin/modules/vector/outliers.d.ts +7 -0
  775. package/dist/src/builtin/modules/vector/percentile.d.ts +7 -0
  776. package/dist/src/builtin/modules/vector/quartiles.d.ts +1 -0
  777. package/dist/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +2 -0
  778. package/dist/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +2 -0
  779. package/dist/src/builtin/modules/vector/reductionFunctions/index.d.ts +13 -0
  780. package/dist/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +2 -0
  781. package/dist/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +5 -0
  782. package/dist/src/builtin/modules/vector/reductionFunctions/mad.d.ts +2 -0
  783. package/dist/src/builtin/modules/vector/reductionFunctions/mean.d.ts +4 -0
  784. package/dist/src/builtin/modules/vector/reductionFunctions/medad.d.ts +2 -0
  785. package/dist/src/builtin/modules/vector/reductionFunctions/median.d.ts +2 -0
  786. package/dist/src/builtin/modules/vector/reductionFunctions/prod.d.ts +2 -0
  787. package/dist/src/builtin/modules/vector/reductionFunctions/rms.d.ts +2 -0
  788. package/dist/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +3 -0
  789. package/dist/src/builtin/modules/vector/reductionFunctions/span.d.ts +2 -0
  790. package/dist/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +3 -0
  791. package/dist/src/builtin/modules/vector/reductionFunctions/sum.d.ts +2 -0
  792. package/dist/src/builtin/modules/vector/reductionFunctions/variance.d.ts +3 -0
  793. package/dist/src/builtin/normalExpressions/index.d.ts +8 -0
  794. package/dist/src/builtin/specialExpressionTypes.d.ts +26 -0
  795. package/dist/src/builtin/specialExpressions/and.d.ts +6 -0
  796. package/dist/src/builtin/specialExpressions/array.d.ts +6 -0
  797. package/dist/src/builtin/specialExpressions/block.d.ts +6 -0
  798. package/dist/src/builtin/specialExpressions/cond.d.ts +6 -0
  799. package/dist/src/builtin/specialExpressions/defined.d.ts +5 -0
  800. package/dist/src/builtin/specialExpressions/effect.d.ts +5 -0
  801. package/dist/src/builtin/specialExpressions/functions.d.ts +6 -0
  802. package/dist/src/builtin/specialExpressions/if.d.ts +6 -0
  803. package/dist/src/builtin/specialExpressions/import.d.ts +6 -0
  804. package/dist/src/builtin/specialExpressions/let.d.ts +6 -0
  805. package/dist/src/builtin/specialExpressions/loop.d.ts +6 -0
  806. package/dist/src/builtin/specialExpressions/loops.d.ts +9 -0
  807. package/dist/src/builtin/specialExpressions/match.d.ts +7 -0
  808. package/dist/src/builtin/specialExpressions/object.d.ts +6 -0
  809. package/dist/src/builtin/specialExpressions/or.d.ts +6 -0
  810. package/dist/src/builtin/specialExpressions/parallel.d.ts +6 -0
  811. package/dist/src/builtin/specialExpressions/perform.d.ts +6 -0
  812. package/dist/src/builtin/specialExpressions/qq.d.ts +6 -0
  813. package/dist/src/builtin/specialExpressions/race.d.ts +6 -0
  814. package/dist/src/builtin/specialExpressions/recur.d.ts +5 -0
  815. package/dist/src/builtin/specialExpressions/throw.d.ts +5 -0
  816. package/dist/src/builtin/specialExpressions/try.d.ts +7 -0
  817. package/dist/src/builtin/specialExpressions/unless.d.ts +6 -0
  818. package/dist/src/builtin/utils.d.ts +6 -0
  819. package/dist/src/bundler/index.d.ts +9 -0
  820. package/dist/src/bundler/interface.d.ts +15 -0
  821. package/dist/src/bundler.d.ts +3 -0
  822. package/dist/src/constants/constants.d.ts +19 -0
  823. package/dist/src/debug.d.ts +115 -0
  824. package/dist/src/effects.d.ts +106 -0
  825. package/dist/src/errors.d.ts +24 -0
  826. package/dist/src/evaluator/ContextStack.d.ts +65 -0
  827. package/dist/src/evaluator/effectRef.d.ts +27 -0
  828. package/dist/src/evaluator/effectTypes.d.ts +79 -0
  829. package/dist/src/evaluator/frames.d.ts +525 -0
  830. package/dist/src/evaluator/interface.d.ts +14 -0
  831. package/dist/src/evaluator/serialization.d.ts +45 -0
  832. package/dist/src/evaluator/standardEffects.d.ts +35 -0
  833. package/dist/src/evaluator/step.d.ts +159 -0
  834. package/dist/src/evaluator/suspension.d.ts +53 -0
  835. package/dist/src/evaluator/trampoline.d.ts +119 -0
  836. package/dist/src/full.d.ts +17 -0
  837. package/dist/src/getUndefinedSymbols/index.d.ts +7 -0
  838. package/dist/src/index.d.ts +18 -0
  839. package/dist/src/initReferenceData.d.ts +1 -0
  840. package/dist/src/interface.d.ts +7 -0
  841. package/dist/src/modules/assertion.d.ts +2 -0
  842. package/dist/src/modules/bitwise.d.ts +2 -0
  843. package/dist/src/modules/collection.d.ts +2 -0
  844. package/dist/src/modules/convert.d.ts +2 -0
  845. package/dist/src/modules/functional.d.ts +2 -0
  846. package/dist/src/modules/grid.d.ts +2 -0
  847. package/dist/src/modules/linear-algebra.d.ts +2 -0
  848. package/dist/src/modules/math.d.ts +2 -0
  849. package/dist/src/modules/matrix.d.ts +2 -0
  850. package/dist/src/modules/number-theory.d.ts +2 -0
  851. package/dist/src/modules/random.d.ts +2 -0
  852. package/dist/src/modules/sequence.d.ts +2 -0
  853. package/dist/src/modules/string.d.ts +2 -0
  854. package/dist/src/modules/vector.d.ts +2 -0
  855. package/dist/src/parser/ParserContext.d.ts +20 -0
  856. package/dist/src/parser/getPrecedence.d.ts +3 -0
  857. package/dist/src/parser/helpers.d.ts +19 -0
  858. package/dist/src/parser/index.d.ts +5 -0
  859. package/dist/src/parser/subParsers/parseArray.d.ts +3 -0
  860. package/dist/src/parser/subParsers/parseBindingTarget.d.ts +8 -0
  861. package/dist/src/parser/subParsers/parseCond.d.ts +4 -0
  862. package/dist/src/parser/subParsers/parseDo.d.ts +3 -0
  863. package/dist/src/parser/subParsers/parseExpression.d.ts +5 -0
  864. package/dist/src/parser/subParsers/parseForOrDoseq.d.ts +4 -0
  865. package/dist/src/parser/subParsers/parseFunction.d.ts +4 -0
  866. package/dist/src/parser/subParsers/parseFunctionCall.d.ts +3 -0
  867. package/dist/src/parser/subParsers/parseIfOrUnless.d.ts +5 -0
  868. package/dist/src/parser/subParsers/parseImplicitBlock.d.ts +5 -0
  869. package/dist/src/parser/subParsers/parseLet.d.ts +4 -0
  870. package/dist/src/parser/subParsers/parseLoop.d.ts +4 -0
  871. package/dist/src/parser/subParsers/parseMatch.d.ts +4 -0
  872. package/dist/src/parser/subParsers/parseNumber.d.ts +3 -0
  873. package/dist/src/parser/subParsers/parseObject.d.ts +3 -0
  874. package/dist/src/parser/subParsers/parseOperand.d.ts +3 -0
  875. package/dist/src/parser/subParsers/parseRegexpShorthand.d.ts +3 -0
  876. package/dist/src/parser/subParsers/parseReservedSymbol.d.ts +3 -0
  877. package/dist/src/parser/subParsers/parseString.d.ts +4 -0
  878. package/dist/src/parser/subParsers/parseSymbol.d.ts +3 -0
  879. package/dist/src/parser/subParsers/parseTry.d.ts +4 -0
  880. package/dist/src/parser/types.d.ts +129 -0
  881. package/dist/src/symbolPatterns.d.ts +2 -0
  882. package/dist/src/testFramework/index.d.ts +15 -0
  883. package/dist/src/tokenizer/minifyTokenStream.d.ts +4 -0
  884. package/dist/src/tokenizer/operators.d.ts +12 -0
  885. package/dist/src/tokenizer/reservedNames.d.ts +66 -0
  886. package/dist/src/tokenizer/token.d.ts +84 -0
  887. package/dist/src/tokenizer/tokenize.d.ts +8 -0
  888. package/dist/src/tokenizer/tokenizers.d.ts +14 -0
  889. package/dist/src/transformer/index.d.ts +2 -0
  890. package/dist/src/typeGuards/annotatedArrays.d.ts +16 -0
  891. package/dist/src/typeGuards/array.d.ts +9 -0
  892. package/dist/src/typeGuards/astNode.d.ts +19 -0
  893. package/dist/src/typeGuards/dvala.d.ts +26 -0
  894. package/dist/src/typeGuards/dvalaFunction.d.ts +12 -0
  895. package/dist/src/typeGuards/index.d.ts +7 -0
  896. package/dist/src/typeGuards/number.d.ts +66 -0
  897. package/dist/src/typeGuards/string.d.ts +15 -0
  898. package/dist/src/untokenizer/index.d.ts +2 -0
  899. package/dist/src/utils/arity.d.ts +10 -0
  900. package/dist/src/utils/debug/debugTools.d.ts +1 -0
  901. package/dist/src/utils/debug/getCodeMarker.d.ts +2 -0
  902. package/dist/src/utils/debug/getSourceCodeInfo.d.ts +2 -0
  903. package/dist/src/utils/docString/generateDocString.d.ts +2 -0
  904. package/dist/src/utils/getAssertionError.d.ts +3 -0
  905. package/dist/src/utils/index.d.ts +14 -0
  906. package/dist/src/utils/maybePromise.d.ts +54 -0
  907. package/dist/src/utils/symbols.d.ts +3 -0
  908. package/dist/testFramework.esm.js +2 -0
  909. package/dist/testFramework.esm.js.map +1 -0
  910. package/dist/testFramework.js +2 -0
  911. package/dist/testFramework.js.map +1 -0
  912. package/package.json +144 -16
  913. package/dist/index.d.ts +0 -2
  914. package/dist/index.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testFramework.js","sources":["../src/utils/debug/getCodeMarker.ts","../src/errors.ts","../src/builtin/specialExpressionTypes.ts","../src/constants/constants.ts","../src/utils/symbols.ts","../src/utils/debug/debugTools.ts","../src/utils/debug/getSourceCodeInfo.ts","../src/utils/getAssertionError.ts","../src/typeGuards/astNode.ts","../src/getUndefinedSymbols/index.ts","../src/typeGuards/index.ts","../src/typeGuards/dvalaFunction.ts","../src/typeGuards/dvala.ts","../src/typeGuards/string.ts","../src/builtin/core/assertion.ts","../src/typeGuards/number.ts","../src/utils/arity.ts","../src/builtin/core/bitwise.ts","../src/utils/index.ts","../src/typeGuards/array.ts","../src/utils/maybePromise.ts","../src/builtin/core/collection.ts","../src/builtin/core/array.ts","../src/builtin/core/sequence.ts","../src/typeGuards/annotatedArrays.ts","../src/builtin/core/math.ts","../src/builtin/core/misc.ts","../src/builtin/core/object.ts","../src/builtin/core/predicates.ts","../src/builtin/core/regexp.ts","../src/builtin/core/string.ts","../src/builtin/core/functional.ts","../src/utils/docString/generateDocString.ts","../src/builtin/core/vector.ts","../src/builtin/normalExpressions/index.ts","../src/builtin/core/meta.ts","../src/builtin/specialExpressions/and.ts","../src/builtin/specialExpressions/cond.ts","../src/parser/types.ts","../src/builtin/bindingNode.ts","../src/builtin/specialExpressions/match.ts","../src/builtin/specialExpressions/defined.ts","../src/builtin/specialExpressions/block.ts","../src/builtin/specialExpressions/functions.ts","../src/builtin/specialExpressions/if.ts","../src/builtin/specialExpressions/unless.ts","../src/builtin/specialExpressions/let.ts","../src/builtin/specialExpressions/loop.ts","../src/builtin/specialExpressions/loops.ts","../src/builtin/specialExpressions/or.ts","../src/builtin/specialExpressions/qq.ts","../src/builtin/specialExpressions/recur.ts","../src/builtin/specialExpressions/throw.ts","../src/builtin/specialExpressions/try.ts","../src/builtin/specialExpressions/array.ts","../src/builtin/specialExpressions/effect.ts","../src/builtin/specialExpressions/object.ts","../src/builtin/specialExpressions/parallel.ts","../src/builtin/specialExpressions/perform.ts","../src/builtin/specialExpressions/race.ts","../src/builtin/index.ts","../src/builtin/specialExpressions/import.ts","../src/tokenizer/reservedNames.ts","../src/evaluator/effectTypes.ts","../src/evaluator/effectRef.ts","../src/evaluator/ContextStack.ts","../src/evaluator/interface.ts","../src/evaluator/serialization.ts","../src/evaluator/suspension.ts","../src/evaluator/standardEffects.ts","../src/evaluator/trampoline.ts","../src/tokenizer/operators.ts","../src/tokenizer/tokenizers.ts","../src/tokenizer/tokenize.ts","../src/tokenizer/token.ts","../src/tokenizer/minifyTokenStream.ts","../src/AutoCompleter/AutoCompleter.ts","../src/bundler/interface.ts","../src/parser/helpers.ts","../src/parser/ParserContext.ts","../src/parser/getPrecedence.ts","../src/parser/subParsers/parseImplicitBlock.ts","../src/parser/subParsers/parseString.ts","../src/parser/subParsers/parseDo.ts","../src/parser/subParsers/parseSymbol.ts","../src/parser/subParsers/parseNumber.ts","../src/parser/subParsers/parseBindingTarget.ts","../src/parser/subParsers/parseLet.ts","../src/parser/subParsers/parseForOrDoseq.ts","../src/parser/subParsers/parseReservedSymbol.ts","../src/parser/subParsers/parseFunction.ts","../src/parser/subParsers/parseFunctionCall.ts","../src/parser/subParsers/parseObject.ts","../src/parser/subParsers/parseOperand.ts","../src/parser/subParsers/parseArray.ts","../src/parser/subParsers/parseRegexpShorthand.ts","../src/parser/subParsers/parseExpression.ts","../src/parser/subParsers/parseIfOrUnless.ts","../src/parser/subParsers/parseCond.ts","../src/parser/subParsers/parseMatch.ts","../src/parser/subParsers/parseLoop.ts","../src/parser/subParsers/parseTry.ts","../src/parser/index.ts","../src/Dvala/Cache.ts","../src/Dvala/Dvala.ts","../src/transformer/index.ts","../src/untokenizer/index.ts","../src/builtin/modules/assertion/docs.ts","../src/builtin/modules/assertion/index.ts","../src/builtin/modules/grid/docs.ts","../src/builtin/modules/grid/transpose.ts","../src/builtin/modules/grid/index.ts","../src/builtin/modules/grid/fromArray.ts","../src/builtin/modules/random/docs.ts","../src/builtin/modules/random/index.ts","../src/builtin/modules/vector/docs.ts","../src/builtin/modules/vector/outliers.ts","../src/builtin/modules/vector/percentile.ts","../src/builtin/modules/vector/quartiles.ts","../src/builtin/modules/vector/calcMean.ts","../src/builtin/modules/vector/reductionFunctions/mean.ts","../src/builtin/modules/vector/calcMedian.ts","../src/builtin/modules/vector/reductionFunctions/median.ts","../src/builtin/modules/vector/calcVariance.ts","../src/builtin/modules/vector/reductionFunctions/variance.ts","../src/builtin/modules/vector/calcStdDev.ts","../src/builtin/modules/vector/reductionFunctions/standardDeviation.ts","../src/builtin/modules/vector/reductionFunctions/iqr.ts","../src/builtin/modules/vector/reductionFunctions/span.ts","../src/builtin/modules/vector/reductionFunctions/skewness.ts","../src/builtin/modules/vector/reductionFunctions/kurtosis.ts","../src/builtin/modules/vector/reductionFunctions/rms.ts","../src/builtin/modules/vector/reductionFunctions/mad.ts","../src/builtin/modules/vector/calcMad.ts","../src/builtin/modules/vector/calcMedad.ts","../src/builtin/modules/vector/reductionFunctions/medad.ts","../src/builtin/modules/vector/reductionFunctions/giniCoefficient.ts","../src/builtin/modules/vector/reductionFunctions/entropy.ts","../src/builtin/modules/vector/entropy.ts","../src/builtin/modules/vector/reductionFunctions/index.ts","../src/builtin/modules/vector/reductionFunctions/sum.ts","../src/builtin/modules/vector/reductionFunctions/prod.ts","../src/builtin/modules/vector/index.ts","../src/builtin/modules/vector/mode.ts","../src/builtin/modules/vector/histogram.ts","../src/builtin/modules/vector/bincount.ts","../src/builtin/modules/linear-algebra/docs.ts","../src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.ts","../src/builtin/modules/linear-algebra/helpers/collinear.ts","../src/builtin/modules/linear-algebra/helpers/isZeroVector.ts","../src/builtin/modules/linear-algebra/helpers/pearsonCorr.ts","../src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.ts","../src/builtin/modules/linear-algebra/helpers/covariance.ts","../src/builtin/modules/linear-algebra/helpers/getUnit.ts","../src/builtin/modules/linear-algebra/helpers/dot.ts","../src/builtin/modules/linear-algebra/helpers/subtract.ts","../src/builtin/modules/linear-algebra/helpers/scale.ts","../src/builtin/modules/linear-algebra/index.ts","../src/builtin/modules/linear-algebra/helpers/length.ts","../src/builtin/modules/linear-algebra/helpers/kendallTau.ts","../src/builtin/modules/linear-algebra/helpers/corrleation.ts","../src/builtin/modules/linear-algebra/helpers/solve.ts","../src/builtin/modules/matrix/docs.ts","../src/builtin/modules/matrix/helpers/determinant.ts","../src/builtin/modules/matrix/helpers/minor.ts","../src/builtin/modules/matrix/helpers/adjugate.ts","../src/builtin/modules/matrix/helpers/isSquare.ts","../src/builtin/modules/matrix/helpers/isIdentity.ts","../src/builtin/modules/matrix/helpers/matrixMultiply.ts","../src/builtin/modules/matrix/index.ts","../src/builtin/modules/matrix/helpers/inverse.ts","../src/builtin/modules/matrix/helpers/cofactor.ts","../src/builtin/modules/matrix/helpers/trace.ts","../src/builtin/modules/matrix/helpers/isSymetric.ts","../src/builtin/modules/matrix/helpers/isTriangular.ts","../src/builtin/modules/matrix/helpers/isDiagonal.ts","../src/builtin/modules/matrix/helpers/isOrthogonal.ts","../src/builtin/modules/matrix/helpers/band.ts","../src/builtin/modules/matrix/helpers/isBanded.ts","../src/builtin/modules/matrix/helpers/norm1.ts","../src/builtin/modules/number-theory/docs.ts","../src/builtin/modules/number-theory/binomialCefficient.ts","../src/builtin/modules/number-theory/combinations.ts","../src/builtin/modules/number-theory/derangements.ts","../src/builtin/modules/number-theory/divisors.ts","../src/builtin/modules/number-theory/sequences/factorial.ts","../src/builtin/modules/number-theory/factorial.ts","../src/builtin/modules/number-theory/sequences/partition.ts","../src/builtin/modules/number-theory/partitions.ts","../src/builtin/modules/number-theory/permutations.ts","../src/builtin/modules/number-theory/powerSet.ts","../src/builtin/modules/number-theory/primeFactors.ts","../src/builtin/modules/number-theory/sequences/abundant.ts","../src/builtin/modules/number-theory/sequences/arithmetic.ts","../src/builtin/modules/number-theory/sequences/bernoulli.ts","../src/builtin/modules/number-theory/sequences/prime.ts","../src/builtin/modules/number-theory/sequences/composite.ts","../src/builtin/modules/number-theory/sequences/deficient.ts","../src/builtin/modules/number-theory/sequences/geometric.ts","../src/builtin/modules/number-theory/sequences/golomb.ts","../src/builtin/modules/number-theory/sequences/happy.ts","../src/builtin/modules/number-theory/sequences/juggler.ts","../src/builtin/modules/number-theory/sequences/lookAndSay.ts","../src/builtin/modules/number-theory/sequences/lucky.ts","../src/builtin/modules/number-theory/sequences/padovan.ts","../src/builtin/modules/number-theory/sequences/perfectCube.ts","../src/builtin/modules/number-theory/sequences/perfectPower.ts","../src/builtin/modules/number-theory/sequences/perfectSquare.ts","../src/builtin/modules/number-theory/sequences/poligonal.ts","../src/builtin/modules/number-theory/sequences/recaman.ts","../src/builtin/modules/number-theory/sequences/thueMorse.ts","../src/builtin/modules/number-theory/sequences/tribonacci.ts","../src/builtin/modules/number-theory/sequences/index.ts","../src/builtin/modules/number-theory/index.ts","../src/builtin/modules/number-theory/sequences/collatz.ts","../src/builtin/modules/number-theory/sequences/catalan.ts","../src/builtin/modules/number-theory/sequences/fibonacci.ts","../src/builtin/modules/number-theory/sequences/lucas.ts","../src/builtin/modules/number-theory/sequences/mersenne.ts","../src/builtin/modules/number-theory/sequences/pell.ts","../src/builtin/modules/number-theory/sequences/perfect.ts","../src/builtin/modules/number-theory/sequences/sylvester.ts","../src/builtin/modules/number-theory/sequences/bell.ts","../src/builtin/modules/math/index.ts","../src/builtin/modules/functional/index.ts","../src/builtin/modules/string/index.ts","../src/builtin/modules/collection/index.ts","../src/builtin/modules/sequence/index.ts","../src/builtin/modules/bitwise/index.ts","../src/builtin/modules/convert/index.ts","../src/allModules.ts","../src/testFramework/index.ts"],"sourcesContent":["import type { SourceCodeInfo } from '../../tokenizer/token'\n\nexport function getCodeMarker(sourceCodeInfo: SourceCodeInfo): string {\n if (!sourceCodeInfo.position || !sourceCodeInfo.code)\n return ''\n\n const leftPadding = sourceCodeInfo.position.column - 1\n const rightPadding = sourceCodeInfo.code.length - leftPadding - 1\n return `${' '.repeat(Math.max(leftPadding, 0))}^${' '.repeat(Math.max(rightPadding, 0))}`\n}\n","import { getCodeMarker } from '../src/utils/debug/getCodeMarker'\nimport type { Arr } from './interface'\nimport type { SourceCodeInfo } from './tokenizer/token'\n\nfunction getDvalaErrorMessage(message: string, sourceCodeInfo?: SourceCodeInfo) {\n if (!sourceCodeInfo) {\n return message\n }\n const location = `${sourceCodeInfo.position.line}:${sourceCodeInfo.position.column}`\n const filePathLine = sourceCodeInfo.filePath\n ? `\\n${sourceCodeInfo.filePath}:${location}`\n : `\\nLocation ${location}`\n const codeLine = `\\n${sourceCodeInfo.code}`\n const codeMarker = `\\n${getCodeMarker(sourceCodeInfo)}`\n return `${message}${filePathLine}${codeLine}${codeMarker}`\n}\n\nexport class RecurSignal extends Error {\n public params: Arr\n constructor(params: Arr) {\n super(`recur, params: ${params}`)\n Object.setPrototypeOf(this, RecurSignal.prototype)\n this.name = 'RecurSignal'\n this.params = params\n }\n}\n\nexport class DvalaError extends Error {\n public readonly sourceCodeInfo?: SourceCodeInfo\n public readonly shortMessage: string\n constructor(err: unknown, sourceCodeInfo: SourceCodeInfo | undefined) {\n const message = err instanceof Error\n ? err.message\n : `${err}`\n\n super(getDvalaErrorMessage(message, sourceCodeInfo))\n this.shortMessage = message\n this.sourceCodeInfo = sourceCodeInfo\n Object.setPrototypeOf(this, DvalaError.prototype)\n this.name = 'DvalaError'\n }\n\n public getCodeMarker(): string | undefined {\n return this.sourceCodeInfo && getCodeMarker(this.sourceCodeInfo)\n }\n}\n\nexport class UserDefinedError extends DvalaError {\n public userMessage: string\n constructor(message: string, sourceCodeInfo?: SourceCodeInfo) {\n super(message, sourceCodeInfo)\n this.userMessage = message\n Object.setPrototypeOf(this, UserDefinedError.prototype)\n this.name = 'UserDefinedError'\n }\n}\n\nexport class AssertionError extends DvalaError {\n constructor(message: string | Error, sourceCodeInfo?: SourceCodeInfo) {\n super(message, sourceCodeInfo)\n Object.setPrototypeOf(this, AssertionError.prototype)\n this.name = 'AssertionError'\n }\n}\n\nexport class UndefinedSymbolError extends DvalaError {\n public symbol: string\n constructor(symbolName: string, sourceCodeInfo?: SourceCodeInfo) {\n const message = `Undefined symbol '${symbolName}'.`\n super(message, sourceCodeInfo)\n this.symbol = symbolName\n Object.setPrototypeOf(this, UndefinedSymbolError.prototype)\n this.name = 'UndefinedSymbolError'\n }\n}\n\nexport function isDvalaError(error: unknown): error is DvalaError {\n return error instanceof DvalaError\n}\n","export const specialExpressionTypes = {\n '??': 0,\n '&&': 1,\n '||': 2,\n 'array': 3,\n 'cond': 4,\n 'defined?': 5,\n 'block': 6,\n 'doseq': 7,\n '0_lambda': 8,\n 'for': 9,\n 'if': 10,\n 'let': 11,\n 'loop': 12,\n 'object': 13,\n 'recur': 14,\n 'match': 15,\n 'throw': 16,\n 'try': 17,\n 'unless': 18,\n 'import': 19,\n 'effect': 20,\n 'perform': 21,\n 'parallel': 22,\n 'race': 23,\n} as const\n","export const NodeTypes = {\n Number: 1,\n String: 2,\n NormalExpression: 3,\n SpecialExpression: 4,\n UserDefinedSymbol: 5,\n NormalBuiltinSymbol: 6,\n SpecialBuiltinSymbol: 7,\n ReservedSymbol: 8,\n Binding: 9,\n Spread: 10,\n} as const\n\nconst NodeTypesSet = new Set(Object.values(NodeTypes))\n\nexport type NodeType = typeof NodeTypes[keyof typeof NodeTypes]\n\nexport function getNodeTypeName(type: NodeType): keyof typeof NodeTypes {\n return Object.keys(NodeTypes).find(key => NodeTypes[key as keyof typeof NodeTypes] === type) as keyof typeof NodeTypes\n}\n\n// TODO, is this needed?\nexport function isNodeType(type: unknown): type is NodeType {\n return typeof type === 'number' && NodeTypesSet.has(type as NodeType)\n}\n\nconst functionTypes = [\n 'UserDefined',\n 'Partial',\n 'Comp',\n 'Constantly',\n 'Juxt',\n 'Complement',\n 'EveryPred',\n 'SomePred',\n 'Fnull',\n 'Builtin',\n 'SpecialBuiltin',\n 'NativeJsFunction',\n 'Module',\n] as const\n\nconst functionTypeSet = new Set(functionTypes)\n\nexport type FunctionType = typeof functionTypes[number]\n\nexport function isFunctionType(type: unknown): type is FunctionType {\n return typeof type === 'string' && functionTypeSet.has(type as FunctionType)\n}\n","export const FUNCTION_SYMBOL = '^^fn^^'\nexport const REGEXP_SYMBOL = '^^re^^'\nexport const EFFECT_SYMBOL = '^^ef^^'\n","import { getNodeTypeName, isFunctionType, isNodeType } from '../../constants/constants'\nimport type { AstNode, DvalaFunction } from '../../parser/types'\nimport { FUNCTION_SYMBOL } from '../symbols'\n\nfunction isDvalaFunction(func: unknown): func is DvalaFunction {\n if (func === null || typeof func !== 'object')\n return false\n\n return FUNCTION_SYMBOL in func && 'functionType' in func && isFunctionType(func.functionType)\n}\n\nfunction isNode(value: unknown): value is AstNode {\n if (!Array.isArray(value) || value.length < 2)\n return false\n return isNodeType(value[0])\n}\n\nexport function valueToString(value: unknown): string {\n if (isDvalaFunction(value))\n // eslint-disable-next-line ts/no-unsafe-member-access\n return `<function ${(value as any).name || '\\u03BB'}>`\n\n if (isNode(value))\n return `${getNodeTypeName(value[0])}-node`\n\n if (value === null)\n return 'null'\n\n if (typeof value === 'object' && value instanceof RegExp)\n return `${value}`\n\n if (typeof value === 'object' && value instanceof Error)\n return value.toString()\n\n return JSON.stringify(value)\n}\n","import type { SourceCodeInfo } from '../../tokenizer/token'\n\nexport function getSourceCodeInfo(anyValue: any, sourceCodeInfo: SourceCodeInfo | undefined): SourceCodeInfo | undefined {\n // eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access\n return anyValue?.sourceCodeInfo ?? sourceCodeInfo\n}\n","import { DvalaError } from '../errors'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from './debug/debugTools'\nimport { getSourceCodeInfo } from './debug/getSourceCodeInfo'\n\nexport function getAssertionError(typeName: string, value: unknown, sourceCodeInfo?: SourceCodeInfo): DvalaError {\n return new DvalaError(`Expected ${typeName}, got ${valueToString(value)}.`, getSourceCodeInfo(value, sourceCodeInfo))\n}\n","import { NodeTypes } from '../constants/constants'\nimport type {\n AstNode,\n ExpressionNode,\n NormalBuiltinSymbolNode,\n NormalExpressionNode,\n NormalExpressionNodeWithName,\n SpecialBuiltinSymbolNode,\n SpreadNode,\n SymbolNode,\n UserDefinedSymbolNode,\n} from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\n\nexport function isSymbolNode(node: AstNode): node is SymbolNode {\n const nodeType = node[0]\n return NodeTypes.UserDefinedSymbol === nodeType\n || NodeTypes.NormalBuiltinSymbol === nodeType\n || NodeTypes.SpecialBuiltinSymbol === nodeType\n}\nexport function asSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): SymbolNode {\n assertSymbolNode(node, sourceCodeInfo)\n return node\n}\nexport function assertSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): asserts node is SymbolNode {\n if (!isSymbolNode(node))\n throw getAssertionError('SymbolNode', node, sourceCodeInfo)\n}\n\nexport function isUserDefinedSymbolNode(node: AstNode): node is UserDefinedSymbolNode {\n return NodeTypes.UserDefinedSymbol === node[0]\n}\nexport function asUserDefinedSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): UserDefinedSymbolNode {\n assertUserDefinedSymbolNode(node, sourceCodeInfo)\n return node\n}\nfunction assertUserDefinedSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): asserts node is UserDefinedSymbolNode {\n if (!isUserDefinedSymbolNode(node))\n throw getAssertionError('UserDefinedSymbolNode', node, sourceCodeInfo)\n}\n\nexport function isNormalBuiltinSymbolNode(node: AstNode): node is NormalBuiltinSymbolNode {\n return NodeTypes.NormalBuiltinSymbol === node[0]\n}\n\nexport function isSpecialBuiltinSymbolNode(node: AstNode): node is SpecialBuiltinSymbolNode {\n return NodeTypes.SpecialBuiltinSymbol === node[0]\n}\n\nexport function isNormalExpressionNode(node: AstNode): node is NormalExpressionNode {\n return node[0] === NodeTypes.NormalExpression\n}\nexport function asNormalExpressionNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): NormalExpressionNode {\n assertNormalExpressionNode(node, sourceCodeInfo)\n return node\n}\nexport function assertNormalExpressionNode(\n node: AstNode,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts node is NormalExpressionNode {\n if (!isNormalExpressionNode(node))\n throw getAssertionError('NormalExpressionNode', node, sourceCodeInfo)\n}\n\nexport function isNormalExpressionNodeWithName(node: AstNode): node is NormalExpressionNodeWithName {\n if (!isNormalExpressionNode(node)) {\n return false\n }\n return isSymbolNode(node[1][0])\n}\nexport function asNormalExpressionNodeWithName(\n node: AstNode,\n sourceCodeInfo?: SourceCodeInfo,\n): NormalExpressionNodeWithName {\n assertNormalExpressionNodeWithName(node, sourceCodeInfo)\n return node\n}\nexport function assertNormalExpressionNodeWithName(\n node: AstNode,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts node is NormalExpressionNodeWithName {\n if (!isNormalExpressionNodeWithName(node))\n throw getAssertionError('NormalExpressionNodeWithName', node, sourceCodeInfo)\n}\n\nexport function isExpressionNode(node: AstNode): node is ExpressionNode {\n return isNormalExpressionNode(node)\n || node[0] === NodeTypes.SpecialExpression\n || node[0] === NodeTypes.Number\n || node[0] === NodeTypes.String\n}\nexport function asExpressionNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): ExpressionNode {\n assertExpressionNode(node, sourceCodeInfo)\n return node\n}\nexport function assertExpressionNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): asserts node is ExpressionNode {\n if (!isExpressionNode(node))\n throw getAssertionError('ExpressionNode', node, sourceCodeInfo)\n}\n\nexport function isSpreadNode(node: AstNode): node is SpreadNode {\n return node[0] === NodeTypes.Spread\n}\n","import type { Builtin } from '../builtin/interface'\nimport type { DoNode } from '../builtin/specialExpressions/block'\nimport { specialExpressionTypes } from '../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../constants/constants'\nimport { DvalaError } from '../errors'\nimport type { ContextStack } from '../evaluator/ContextStack'\nimport type { EvaluateNode } from '../evaluator/interface'\nimport type { Ast, AstNode, NormalExpressionNode, SpecialExpressionNode, SpreadNode, UserDefinedSymbolNode } from '../parser/types'\nimport { isNormalExpressionNodeWithName, isUserDefinedSymbolNode } from '../typeGuards/astNode'\n\nexport type UndefinedSymbols = Set<string>\n\nexport const getUndefinedSymbols: GetUndefinedSymbols = (ast, contextStack, builtin, evaluateNode) => {\n const nodes: AstNode[] = Array.isArray(ast)\n ? ast\n : [[NodeTypes.SpecialExpression, [specialExpressionTypes.block, ast.body]] satisfies DoNode]\n\n const unresolvedSymbols = new Set<string>()\n\n for (const subNode of nodes) {\n findUnresolvedSymbolsInNode(subNode, contextStack, builtin, evaluateNode)\n ?.forEach(symbol => unresolvedSymbols.add(symbol))\n }\n return unresolvedSymbols\n}\n\nexport type GetUndefinedSymbols = (ast: Ast | AstNode[], contextStack: ContextStack, builtin: Builtin, evaluateNode: EvaluateNode) => UndefinedSymbols\n\nfunction findUnresolvedSymbolsInNode(node: AstNode, contextStack: ContextStack, builtin: Builtin, evaluateNode: EvaluateNode): UndefinedSymbols | null {\n const nodeType = node[0]\n switch (nodeType) {\n case NodeTypes.UserDefinedSymbol: {\n const symbolNode = node as UserDefinedSymbolNode\n const lookUpResult = contextStack.lookUp(symbolNode)\n if (lookUpResult === null)\n return new Set([symbolNode[1]])\n\n return null\n }\n case NodeTypes.NormalBuiltinSymbol:\n case NodeTypes.SpecialBuiltinSymbol:\n case NodeTypes.String:\n case NodeTypes.Number:\n case NodeTypes.ReservedSymbol:\n case NodeTypes.Binding:\n return null\n case NodeTypes.NormalExpression: {\n const normalExpressionNode = node as NormalExpressionNode\n const unresolvedSymbols = new Set<string>()\n if (isNormalExpressionNodeWithName(normalExpressionNode)) {\n const [, [symbolNode]] = normalExpressionNode\n if (isUserDefinedSymbolNode(symbolNode)) {\n const lookUpResult = contextStack.lookUp(symbolNode)\n if (lookUpResult === null)\n unresolvedSymbols.add(symbolNode[1])\n }\n }\n else {\n const [, [expressionNode]] = normalExpressionNode\n findUnresolvedSymbolsInNode(expressionNode, contextStack, builtin, evaluateNode)?.forEach(symbol => unresolvedSymbols.add(symbol))\n }\n for (const subNode of normalExpressionNode[1][1]) {\n findUnresolvedSymbolsInNode(subNode, contextStack, builtin, evaluateNode)?.forEach(symbol => unresolvedSymbols.add(symbol))\n }\n return unresolvedSymbols\n }\n case NodeTypes.SpecialExpression: {\n const specialExpressionNode = node as SpecialExpressionNode\n const specialExpressionType = specialExpressionNode[1][0]\n const specialExpression = builtin.specialExpressions[specialExpressionType]\n\n const castedGetUndefinedSymbols = specialExpression.getUndefinedSymbols as Function\n\n return castedGetUndefinedSymbols(specialExpressionNode, contextStack, {\n getUndefinedSymbols,\n builtin,\n evaluateNode,\n }) as UndefinedSymbols\n }\n case NodeTypes.Spread:\n return findUnresolvedSymbolsInNode((node as SpreadNode)[1], contextStack, builtin, evaluateNode)\n\n /* v8 ignore next 2 */\n default:\n throw new DvalaError(`Unhandled node type: ${nodeType satisfies never}`, node[2])\n }\n}\n","import { DvalaError } from '../errors'\nimport type { UnknownRecord } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from '../utils/debug/debugTools'\nimport { getSourceCodeInfo } from '../utils/debug/getSourceCodeInfo'\n\nfunction isNonUndefined<T>(value: T | undefined): value is T {\n return value !== undefined\n}\n\nexport function asNonUndefined<T>(value: T | undefined, sourceCodeInfo?: SourceCodeInfo): T {\n assertNonUndefined(value, sourceCodeInfo)\n return value\n}\n\nexport function assertNonUndefined<T>(value: T | undefined, sourceCodeInfo?: SourceCodeInfo): asserts value is T {\n if (!isNonUndefined(value))\n throw new DvalaError('Unexpected undefined', getSourceCodeInfo(value, sourceCodeInfo))\n}\n\nexport function isUnknownRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\nexport function assertUnknownRecord(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is UnknownRecord {\n if (!isUnknownRecord(value)) {\n throw new DvalaError(\n `Expected ${'UnknownRecord'}, got ${valueToString(value)}.`,\n getSourceCodeInfo(value, sourceCodeInfo),\n )\n }\n}\n\nexport function asUnknownRecord(value: unknown, sourceCodeInfo?: SourceCodeInfo): UnknownRecord {\n assertUnknownRecord(value, sourceCodeInfo)\n return value\n}\n","import type { DvalaFunction, NativeJsFunction, NormalBuiltinFunction, UserDefinedFunction } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\nimport { FUNCTION_SYMBOL } from '../utils/symbols'\nimport { isUnknownRecord } from '.'\n\nexport function isDvalaFunction(value: unknown): value is DvalaFunction {\n if (value === null || typeof value !== 'object')\n return false\n\n return !!(value as DvalaFunction)[FUNCTION_SYMBOL]\n}\nexport function asDvalaFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): DvalaFunction {\n assertDvalaFunction(value, sourceCodeInfo)\n return value\n}\nexport function assertDvalaFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is DvalaFunction {\n if (!isDvalaFunction(value))\n throw getAssertionError('DvalaFunction', value, sourceCodeInfo)\n}\n\nexport function isUserDefinedFunction(value: unknown): value is UserDefinedFunction {\n return isDvalaFunction(value) && value.functionType === 'UserDefined'\n}\nexport function asUserDefinedFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): UserDefinedFunction {\n assertUserDefinedFunction(value, sourceCodeInfo)\n return value\n}\nexport function assertUserDefinedFunction(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is UserDefinedFunction {\n if (!isUserDefinedFunction(value))\n throw getAssertionError('NativeJsFunction', value, sourceCodeInfo)\n}\n\nexport function isNativeJsFunction(value: unknown): value is NativeJsFunction {\n return isDvalaFunction(value) && value.functionType === 'NativeJsFunction'\n}\nexport function asNativeJsFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): NativeJsFunction {\n assertNativeJsFunction(value, sourceCodeInfo)\n return value\n}\nexport function assertNativeJsFunction(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is NativeJsFunction {\n if (!isNativeJsFunction(value))\n throw getAssertionError('NativeJsFunction', value, sourceCodeInfo)\n}\n\nexport function isBuiltinFunction(value: unknown): value is NormalBuiltinFunction {\n return isUnknownRecord(value) && value.functionType === 'Builtin'\n}\n","import type { Any, Coll, Obj, Seq } from '../interface'\nimport type { EffectRef, FunctionLike, RegularExpression } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\nimport { EFFECT_SYMBOL, REGEXP_SYMBOL } from '../utils/symbols'\nimport { isDvalaFunction } from './dvalaFunction'\n\nexport function isAny(value: unknown): value is Any {\n // TODO weak test\n return value !== undefined\n}\nexport function asAny(value: unknown, sourceCodeInfo?: SourceCodeInfo): Any {\n assertAny(value, sourceCodeInfo)\n return value\n}\nexport function assertAny(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Any {\n if (!isAny(value))\n throw getAssertionError('not undefined', value, sourceCodeInfo)\n}\n\nexport function isSeq(value: unknown): value is Seq {\n return Array.isArray(value) || typeof value === 'string'\n}\nexport function asSeq(value: unknown, sourceCodeInfo?: SourceCodeInfo): Seq {\n assertSeq(value, sourceCodeInfo)\n return value\n}\nexport function assertSeq(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Seq {\n if (!isSeq(value))\n throw getAssertionError('string or array', value, sourceCodeInfo)\n}\n\nexport function isObj(value: unknown): value is Obj {\n return !(\n value === null\n || typeof value !== 'object'\n || Array.isArray(value)\n || value instanceof RegExp\n || isDvalaFunction(value)\n || isRegularExpression(value)\n || isEffectRef(value)\n )\n}\nexport function asObj(value: unknown, sourceCodeInfo?: SourceCodeInfo): Obj {\n assertObj(value, sourceCodeInfo)\n return value\n}\nexport function assertObj(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Obj {\n if (!isObj(value))\n throw getAssertionError('object', value, sourceCodeInfo)\n}\n\nexport function isColl(value: unknown): value is Coll {\n return isSeq(value) || isObj(value)\n}\nexport function asColl(value: unknown, sourceCodeInfo?: SourceCodeInfo): Coll {\n assertColl(value, sourceCodeInfo)\n return value\n}\nexport function assertColl(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Coll {\n if (!isColl(value))\n throw getAssertionError('string, array or object', value, sourceCodeInfo)\n}\n\nexport function isRegularExpression(regexp: unknown): regexp is RegularExpression {\n if (regexp === null || typeof regexp !== 'object')\n return false\n\n return !!(regexp as RegularExpression)[REGEXP_SYMBOL]\n}\nexport function asRegularExpression(value: unknown, sourceCodeInfo?: SourceCodeInfo): RegularExpression {\n assertRegularExpression(value, sourceCodeInfo)\n return value\n}\nexport function assertRegularExpression(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is RegularExpression {\n if (!isRegularExpression(value))\n throw getAssertionError('RegularExpression', value, sourceCodeInfo)\n}\n\nexport function isStringOrRegularExpression(value: unknown): value is string | RegularExpression {\n return isRegularExpression(value) || typeof value === 'string'\n}\nexport function asStringOrRegularExpression(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): string | RegularExpression {\n assertStringOrRegularExpression(value, sourceCodeInfo)\n return value\n}\nexport function assertStringOrRegularExpression(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is string | RegularExpression {\n if (!isStringOrRegularExpression(value))\n throw getAssertionError('string or RegularExpression', value, sourceCodeInfo)\n}\n\nexport function isEffectRef(value: unknown): value is EffectRef {\n if (value === null || typeof value !== 'object')\n return false\n\n return !!(value as EffectRef)[EFFECT_SYMBOL]\n}\nexport function asEffectRef(value: unknown, sourceCodeInfo?: SourceCodeInfo): EffectRef {\n assertEffectRef(value, sourceCodeInfo)\n return value\n}\nexport function assertEffectRef(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is EffectRef {\n if (!isEffectRef(value))\n throw getAssertionError('EffectRef', value, sourceCodeInfo)\n}\n\nfunction isFunctionLike(value: unknown): value is FunctionLike {\n if (typeof value === 'number')\n return true\n if (isColl(value))\n return true\n if (isDvalaFunction(value))\n return true\n\n return false\n}\nexport function asFunctionLike(value: unknown, sourceCodeInfo?: SourceCodeInfo): FunctionLike {\n assertFunctionLike(value, sourceCodeInfo)\n return value\n}\nexport function assertFunctionLike(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is FunctionLike {\n if (!isFunctionLike(value))\n throw getAssertionError('FunctionLike', value, sourceCodeInfo)\n}\n","import type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\n\ntype StringAssertionOptions =\n | {\n nonEmpty?: true\n char?: never\n }\n | {\n nonEmpty?: never\n char?: true\n }\n\nexport function isString(value: unknown, options: StringAssertionOptions = {}): value is string {\n if (typeof value !== 'string')\n return false\n\n if (options.nonEmpty && value.length === 0)\n return false\n\n if (options.char && value.length !== 1)\n return false\n\n return true\n}\n\nexport function assertString(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: StringAssertionOptions = {},\n): asserts value is string {\n if (!isString(value, options)) {\n throw getAssertionError(\n `${options.nonEmpty ? 'non empty string' : options.char ? 'character' : 'string'}`,\n value,\n sourceCodeInfo,\n )\n }\n}\n\nexport function asString(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: StringAssertionOptions = {},\n): string {\n assertString(value, sourceCodeInfo, options)\n return value\n}\n\nexport function isStringOrNumber(value: unknown): value is string | number {\n return typeof value === 'string' || typeof value === 'number'\n}\nexport function asStringOrNumber(value: unknown, sourceCodeInfo?: SourceCodeInfo): string | number {\n assertStringOrNumber(value, sourceCodeInfo)\n return value\n}\nexport function assertStringOrNumber(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is string | number {\n if (!isStringOrNumber(value))\n throw getAssertionError('string or number', value, sourceCodeInfo)\n}\n","import type { Any } from '../../interface'\nimport { AssertionError } from '../../errors'\nimport { asAny } from '../../typeGuards/dvala'\nimport { assertString } from '../../typeGuards/string'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const assertionNormalExpression: BuiltinNormalExpressions = {\n assert: {\n evaluate: (params, sourceCodeInfo): Any => {\n const value = params[0]\n const message = params.length === 2 ? params[1] : `${value}`\n assertString(message, sourceCodeInfo)\n if (!value)\n throw new AssertionError(message, sourceCodeInfo)\n\n return asAny(value, sourceCodeInfo)\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'assertion',\n description: 'If $value is falsy it throws `AssertionError` with $message. If no $message is provided, message is set to $value.',\n returns: {\n type: 'any',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'try assert(0, \"Expected a positive value\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-truthy', 'assertion.assert-true'],\n hideOperatorForm: true,\n },\n },\n}\n","import { DvalaError } from '../errors'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from '../utils/debug/debugTools'\nimport { getSourceCodeInfo } from '../utils/debug/getSourceCodeInfo'\n\ntype SignOptions =\n | {\n positive?: true\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: true\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: true\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: true\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: true\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: true\n }\n\ntype GtOptions =\n | {\n gt?: number\n gte?: never\n }\n | {\n gt?: never\n gte?: number\n }\n\ntype LtOptions =\n | {\n lt?: number\n lte?: never\n }\n | {\n lt?: never\n lte?: number\n }\n\ntype NumberOptions = {\n integer?: true\n finite?: true\n} & SignOptions &\nGtOptions &\nLtOptions\n\nfunction getRangeString(options: NumberOptions): string {\n const hasUpperAndLowerBound\n = (typeof options.gt === 'number' || typeof options.gte === 'number')\n && (typeof options.lt === 'number' || typeof options.lte === 'number')\n if (hasUpperAndLowerBound) {\n return `${typeof options.gt === 'number' ? `${options.gt} < n ` : `${options.gte} <= n `}${\n typeof options.lt === 'number' ? `< ${options.lt}` : `<= ${options.lte}`\n }`\n }\n else if (typeof options.gt === 'number' || typeof options.gte === 'number') {\n return `${typeof options.gt === 'number' ? `n > ${options.gt}` : `n >= ${options.gte}`}`\n }\n else if (typeof options.lt === 'number' || typeof options.lte === 'number') {\n return `${typeof options.lt === 'number' ? `n < ${options.lt}` : `n <= ${options.lte}`}`\n }\n else { return '' }\n}\n\nfunction getSignString(options: NumberOptions): string {\n return options.positive\n ? 'positive'\n : options.negative\n ? 'negative'\n : options.nonNegative\n ? 'non negative'\n : options.nonPositive\n ? 'non positive'\n : options.nonZero\n ? 'non zero'\n : ''\n}\n\nfunction getNumberTypeName(options: NumberOptions): string {\n if (options.zero)\n return 'zero'\n\n const sign = getSignString(options)\n const numberType = options.integer ? 'integer' : 'number'\n const finite = options.finite ? 'finite' : ''\n const range = getRangeString(options)\n\n return [sign, finite, numberType, range].filter(x => !!x).join(' ')\n}\n\nexport function isNumber(value: unknown, options: NumberOptions = {}): value is number {\n if (typeof value !== 'number')\n return false\n\n if (Number.isNaN(value))\n return false\n\n if (options.integer && !Number.isInteger(value))\n return false\n\n if (options.finite && !Number.isFinite(value))\n return false\n\n if (options.zero && value !== 0)\n return false\n\n if (options.nonZero && value === 0)\n return false\n\n if (options.positive && value <= 0)\n return false\n\n if (options.negative && value >= 0)\n return false\n\n if (options.nonPositive && value > 0)\n return false\n\n if (options.nonNegative && value < 0)\n return false\n\n if (typeof options.gt === 'number' && value <= options.gt)\n return false\n\n if (typeof options.gte === 'number' && value < options.gte)\n return false\n\n if (typeof options.lt === 'number' && value >= options.lt)\n return false\n\n if (typeof options.lte === 'number' && value > options.lte)\n return false\n\n return true\n}\n\nexport function assertNumber(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n options: NumberOptions = {},\n): asserts value is number {\n if (!isNumber(value, options)) {\n throw new DvalaError(\n `Expected ${getNumberTypeName(options)}, got ${valueToString(value)}.`,\n getSourceCodeInfo(value, sourceCodeInfo),\n )\n }\n}\n\nexport function asNumber(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: NumberOptions = {},\n): number {\n assertNumber(value, sourceCodeInfo, options)\n return value\n}\n","import type { Arity } from '../builtin/interface'\nimport { DvalaError } from '../errors'\nimport type { FunctionLike } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isColl } from '../typeGuards/dvala'\nimport { valueToString } from './debug/debugTools'\n\nexport function arityAccepts(arity: Arity, nbrOfParams: number): boolean {\n const { min, max } = arity\n if (typeof min === 'number' && nbrOfParams < min) {\n return false\n }\n if (typeof max === 'number' && nbrOfParams > max) {\n return false\n }\n return true\n}\n\nexport function arityAcceptsMin(arity: Arity, nbrOfParams: number): boolean {\n const { min } = arity\n if (typeof min === 'number' && nbrOfParams < min) {\n return false\n }\n return true\n}\n\nexport function getCommonArityFromFunctions(params: FunctionLike[]): Arity | null {\n return params.reduce((acc: Arity | null, param): Arity | null => {\n if (acc === null) {\n return null\n }\n const arity: Arity = (typeof param === 'number' || isColl(param)) ? toFixedArity(1) : param.arity\n const { min: aMin, max: aMax } = arity\n const { min: bMin, max: bMax } = acc\n const min = typeof aMin === 'number' && typeof bMin === 'number'\n ? Math.max(aMin, bMin)\n : typeof aMin === 'number' ? aMin : typeof bMin === 'number' ? bMin : undefined\n const max = typeof aMax === 'number' && typeof bMax === 'number'\n ? Math.min(aMax, bMax)\n : typeof aMax === 'number' ? aMax : typeof bMax === 'number' ? bMax : undefined\n\n if (typeof min === 'number' && typeof max === 'number' && min > max) {\n return null\n }\n\n return { min, max }\n }, {})\n}\n\nexport function getArityFromFunction(param: FunctionLike): Arity {\n return (typeof param === 'number' || isColl(param)) ? toFixedArity(1) : param.arity\n}\n\nexport function assertNumberOfParams(arity: Arity, length: number, sourceCodeInfo: SourceCodeInfo | undefined): void {\n const { min, max } = arity\n if (typeof min === 'number' && length < min) {\n throw new DvalaError(\n `Wrong number of arguments, expected at least ${min}, got ${valueToString(length)}.`,\n sourceCodeInfo,\n )\n }\n\n if (typeof max === 'number' && length > max) {\n throw new DvalaError(\n `Wrong number of arguments, expected at most ${max}, got ${valueToString(length)}.`,\n sourceCodeInfo,\n )\n }\n}\n\nexport function canBeOperator(count: Arity): boolean {\n if (typeof count.max === 'number' && count.max < 2) {\n return false\n }\n\n if (typeof count.min === 'number' && count.min > 2) {\n return false\n }\n\n return true\n}\n\nexport function toFixedArity(arity: number): Arity {\n return { min: arity, max: arity }\n}\n","import { assertNumber } from '../../typeGuards/number'\nimport { toFixedArity } from '../../utils/arity'\nimport type { Argument, BuiltinNormalExpressions } from '../interface'\n\nfunction getOperatorArgs(a: 'integer', b: 'integer'): Record<string, Argument> {\n return { a: { type: a }, b: { type: b } }\n}\n\nexport const bitwiseNormalExpression: BuiltinNormalExpressions = {\n '<<': {\n evaluate: ([num, count], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return num << count\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Shifts $a arithmetically left by $b bit positions.',\n seeAlso: ['>>', '>>>'],\n examples: [\n '1 << 10',\n '<<(1, 10)',\n '<<(-4, 2)',\n ],\n },\n },\n '>>': {\n evaluate: ([num, count], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return num >> count\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Shifts $a arithmetically right by $b bit positions.',\n seeAlso: ['<<', '>>>'],\n examples: [\n '2048 >> 10',\n '>>(2048, 10)',\n '>>>(-16, 2)',\n '>>(4, 10)',\n ],\n },\n },\n '>>>': {\n evaluate: ([num, count], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return num >>> count\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Shifts $a arithmetically right by $b bit positions without sign extension.',\n seeAlso: ['<<', '>>'],\n examples: [\n '-16 >>> 2',\n '>>>(2048, 10)',\n '>>>(-16, 2)',\n '>>>(4, 10)',\n '>>>(-1, 10)',\n ],\n },\n },\n '&': {\n evaluate: ([first, ...rest], sourceCodeInfo): number => {\n assertNumber(first, sourceCodeInfo, { integer: true })\n\n return rest.reduce((result: number, value) => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n return result & value\n }, first)\n },\n arity: { min: 2 },\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: {\n ...getOperatorArgs('integer', 'integer'),\n c: { type: 'integer', rest: true },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: 'Returns bitwise `and` of all arguments.',\n seeAlso: ['|', 'xor', 'bitwise.bit-not', 'bitwise.bit-and-not'],\n examples: [\n '0b0011 & 0b0110',\n '&(0b0011, 0b0110)',\n '&(0b0011, 0b0110, 0b1001)',\n ],\n },\n },\n '|': {\n evaluate: ([first, ...rest], sourceCodeInfo): number => {\n assertNumber(first, sourceCodeInfo, { integer: true })\n\n return rest.reduce((result: number, value) => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n return result | value\n }, first)\n },\n arity: { min: 2 },\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: {\n ...getOperatorArgs('integer', 'integer'),\n c: { type: 'integer', rest: true },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: 'Returns bitwise `or` of all arguments.',\n seeAlso: ['&', 'xor', 'bitwise.bit-not', 'bitwise.bit-and-not'],\n examples: [\n '0b0011 | 0b0110',\n '|(0b0011, 0b0110)',\n '|(0b1000, 0b0100, 0b0010)',\n ],\n },\n },\n 'xor': {\n evaluate: ([first, ...rest], sourceCodeInfo): number => {\n assertNumber(first, sourceCodeInfo, { integer: true })\n\n return rest.reduce((result: number, value) => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n return result ^ value\n }, first)\n },\n arity: { min: 2 },\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: {\n ...getOperatorArgs('integer', 'integer'),\n c: { type: 'integer', rest: true },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: 'Returns bitwise `xor` of all arguments.',\n seeAlso: ['&', '|', 'bitwise.bit-not', 'bitwise.bit-and-not'],\n examples: [\n '0b0011 xor 0b0110',\n 'xor(0b0011, 0b0110)',\n 'xor(0b11110000, 0b00111100, 0b10101010)',\n ],\n },\n },\n}\n","import type { Any, Coll, Obj } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asAny, isColl, isObj, isRegularExpression } from '../typeGuards/dvala'\nimport { isNumber } from '../typeGuards/number'\nimport { asString, assertStringOrNumber } from '../typeGuards/string'\nimport { isUnknownRecord } from '../typeGuards'\nimport { DvalaError } from '../errors'\n\nexport function collHasKey(coll: unknown, key: string | number): boolean {\n if (!isColl(coll))\n return false\n\n if (typeof coll === 'string' || Array.isArray(coll)) {\n if (!isNumber(key, { integer: true }))\n return false\n\n return key >= 0 && key < coll.length\n }\n return !!Object.getOwnPropertyDescriptor(coll, key)\n}\n\nexport function compare<T extends string | number>(a: T, b: T, sourceCodeInfo: SourceCodeInfo | undefined): number {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n\n if (typeof a === 'string' && typeof b === 'string') {\n return a < b ? -1 : a > b ? 1 : 0\n }\n if (typeof a === 'number' && typeof b === 'number') {\n return Math.sign((a) - (b))\n }\n throw new DvalaError(`Cannot compare values of different types: ${typeof a} and ${typeof b}`, sourceCodeInfo)\n}\n\nexport function deepEqual(a: unknown, b: unknown, sourceCodeInfo?: SourceCodeInfo): boolean {\n if (a === b)\n return true\n\n if (typeof a === 'number' && typeof b === 'number')\n return approxEqual(a, b)\n\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length)\n return false\n\n for (let i = 0; i < a.length; i += 1) {\n if (!deepEqual(asAny(a[i], sourceCodeInfo), asAny(b[i], sourceCodeInfo), sourceCodeInfo))\n return false\n }\n return true\n }\n if (isRegularExpression(a) && isRegularExpression(b))\n return a.s === b.s && a.f === b.f\n\n if (isUnknownRecord(a) && isUnknownRecord(b)) {\n const aKeys = Object.keys(a)\n const bKeys = Object.keys(b)\n if (aKeys.length !== bKeys.length)\n return false\n\n for (let i = 0; i < aKeys.length; i += 1) {\n const key = asString(aKeys[i], sourceCodeInfo)\n if (!deepEqual(a[key], b[key], sourceCodeInfo))\n return false\n }\n return true\n }\n return false\n}\n\nexport function toNonNegativeInteger(num: number): number {\n return Math.max(0, Math.ceil(num))\n}\n\nexport function toAny(value: unknown): Any {\n return (value ?? null) as Any\n}\n\nfunction clone<T>(value: T): T {\n if (isObj(value)) {\n return Object.entries(value).reduce((result: Obj, entry) => {\n const [key, val] = entry\n result[key] = clone(val)\n return result\n }, {}) as T\n }\n if (Array.isArray(value))\n // eslint-disable-next-line ts/no-unsafe-return\n return value.map(item => clone(item)) as unknown as T\n\n return value\n}\n\nexport function cloneColl<T extends Coll>(value: T): T {\n return clone(value)\n}\n\nexport function joinSets<T>(...results: Set<T>[]): Set<T> {\n const result = new Set<T>()\n for (const symbols of results)\n symbols.forEach(symbol => result.add(symbol))\n\n return result\n}\n\nexport function addToSet<T>(target: Set<T>, source: Set<T>): void {\n source.forEach(symbol => target.add(symbol))\n}\n\nexport const EPSILON = 1e-10\n\nexport function approxEqual(a: number, b: number, epsilon: number = EPSILON): boolean {\n if (a === b) {\n return true\n }\n\n const diff = Math.abs(a - b)\n\n if (a === 0 || b === 0 || diff < epsilon) {\n // Use absolute error for values near zero\n return diff < epsilon\n }\n const absA = Math.abs(a)\n const absB = Math.abs(b)\n\n // Use relative error for larger values\n return diff / (absA + absB) < epsilon\n}\n\nexport function approxZero(value: number): boolean {\n return Math.abs(value) < EPSILON\n}\n\nexport function smartTrim(str: string, minIndent = 0): string {\n const lines = str.split('\\n')\n while (lines[0]?.match(/^\\s*$/)) {\n lines.shift() // Remove leading empty lines\n }\n while (lines[lines.length - 1]?.match(/^\\s*$/)) {\n lines.pop() // Remove trailing empty lines\n }\n const indent = lines.reduce((acc, line) => {\n if (line.match(/^\\s*$/))\n return acc // Skip empty lines\n const lineIndent = line.match(/^\\s*/)![0].length\n return Math.min(acc, lineIndent)\n }, Infinity)\n return lines.map(line => ' '.repeat(minIndent) + line.slice(indent)).join('\\n').trimEnd()\n}\n","import type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\n\n// isArray not needed, use Array.isArary\nexport function asArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): unknown[] {\n assertArray(value, sourceCodeInfo)\n return value\n}\nexport function assertArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is unknown[] {\n if (!Array.isArray(value))\n throw getAssertionError('array', value, sourceCodeInfo)\n}\n\nexport function isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every(v => typeof v === 'string')\n}\nexport function asStringArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): string[] {\n assertStringArray(value, sourceCodeInfo)\n return value\n}\nexport function assertStringArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is string[] {\n if (!isStringArray(value))\n throw getAssertionError('array of strings', value, sourceCodeInfo)\n}\n\nexport function isCharArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every(v => typeof v === 'string' && v.length === 1)\n}\nexport function asCharArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): string[] {\n assertCharArray(value, sourceCodeInfo)\n return value\n}\nexport function assertCharArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is string[] {\n if (!isCharArray(value))\n throw getAssertionError('array of strings', value, sourceCodeInfo)\n}\n","/**\n * MaybePromise utilities for transparent async support.\n *\n * The sync path stays zero-overhead — when no async JS functions are involved,\n * everything runs synchronously with only `instanceof Promise` checks as overhead.\n * When an async value is detected, the evaluation chain switches to Promise-based\n * execution for the remainder.\n */\n\nexport type MaybePromise<T> = T | Promise<T>\n\n/**\n * Chain a value that might be a Promise. If the value is sync, calls fn synchronously.\n * If it's a Promise, chains with .then().\n */\nexport function chain<T, U>(value: MaybePromise<T>, fn: (v: T) => MaybePromise<U>): MaybePromise<U> {\n if (value instanceof Promise) {\n return value.then(fn)\n }\n return fn(value)\n}\n\n/**\n * Like Array.map but handles MaybePromise callbacks sequentially.\n * In the sync case, runs as a simple loop. Switches to async only when needed.\n */\nexport function mapSequential<T, U>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<U>,\n): MaybePromise<U[]> {\n const results: U[] = []\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingMap(result, results, arr, fn, i)\n }\n results.push(result)\n }\n return results\n}\n\nasync function chainRemainingMap<T, U>(\n currentPromise: Promise<U>,\n results: U[],\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<U>,\n startIndex: number,\n): Promise<U[]> {\n results.push(await currentPromise)\n for (let i = startIndex + 1; i < arr.length; i++) {\n results.push(await fn(arr[i]!, i))\n }\n return results\n}\n\n/**\n * Like Array.reduce but handles MaybePromise callbacks sequentially.\n * In the sync case, runs as a simple loop. Switches to async only when needed.\n */\nexport function reduceSequential<T, U>(\n arr: readonly T[],\n fn: (acc: U, elem: T, index: number) => MaybePromise<U>,\n initial: U,\n): MaybePromise<U> {\n let result: U = initial\n for (let i = 0; i < arr.length; i++) {\n const next = fn(result, arr[i]!, i)\n if (next instanceof Promise) {\n return chainRemainingReduce(next, arr, fn, i)\n }\n result = next\n }\n return result\n}\n\nasync function chainRemainingReduce<T, U>(\n currentPromise: Promise<U>,\n arr: readonly T[],\n fn: (acc: U, elem: T, index: number) => MaybePromise<U>,\n startIndex: number,\n): Promise<U> {\n let result = await currentPromise\n for (let i = startIndex + 1; i < arr.length; i++) {\n result = await fn(result, arr[i]!, i)\n }\n return result\n}\n\n/**\n * Like Array.forEach but handles MaybePromise callbacks sequentially.\n * In the sync case, runs as a simple loop. Switches to async only when needed.\n */\nexport function forEachSequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<void>,\n): MaybePromise<void> {\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingForEach(result, arr, fn, i)\n }\n }\n}\n\nasync function chainRemainingForEach<T>(\n currentPromise: Promise<void>,\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<void>,\n startIndex: number,\n): Promise<void> {\n await currentPromise\n for (let i = startIndex + 1; i < arr.length; i++) {\n await fn(arr[i]!, i)\n }\n}\n\n/**\n * Try/catch that handles MaybePromise values correctly.\n * If tryFn returns a Promise, catches both sync throws and Promise rejections.\n */\nexport function tryCatch<T>(\n tryFn: () => MaybePromise<T>,\n catchFn: (error: unknown) => MaybePromise<T>,\n): MaybePromise<T> {\n try {\n const result = tryFn()\n if (result instanceof Promise) {\n return result.catch(catchFn)\n }\n return result\n }\n catch (error) {\n return catchFn(error)\n }\n}\n\n/**\n * Like Array.some but handles MaybePromise callbacks sequentially.\n * Returns the first truthy MaybePromise result, or false.\n */\nexport function someSequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n): MaybePromise<boolean> {\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingSome(result, arr, fn, i)\n }\n if (result)\n return true\n }\n return false\n}\n\nasync function chainRemainingSome<T>(\n currentPromise: Promise<unknown>,\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n startIndex: number,\n): Promise<boolean> {\n if (await currentPromise)\n return true\n for (let i = startIndex + 1; i < arr.length; i++) {\n if (await fn(arr[i]!, i))\n return true\n }\n return false\n}\n\n/**\n * Like Array.every but handles MaybePromise callbacks sequentially.\n * Returns false as soon as a falsy result is found.\n */\nexport function everySequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n): MaybePromise<boolean> {\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingEvery(result, arr, fn, i)\n }\n if (!result)\n return false\n }\n return true\n}\n\nasync function chainRemainingEvery<T>(\n currentPromise: Promise<unknown>,\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n startIndex: number,\n): Promise<boolean> {\n if (!await currentPromise)\n return false\n for (let i = startIndex + 1; i < arr.length; i++) {\n if (!await fn(arr[i]!, i))\n return false\n }\n return true\n}\n\n/**\n * Like Array.filter but handles MaybePromise callbacks sequentially.\n * Returns the filtered array.\n */\nexport function filterSequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n): MaybePromise<T[]> {\n const results: T[] = []\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingFilter(result, results, arr, fn, i)\n }\n if (result)\n results.push(arr[i]!)\n }\n return results\n}\n\nasync function chainRemainingFilter<T>(\n currentPromise: Promise<unknown>,\n results: T[],\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n startIndex: number,\n): Promise<T[]> {\n if (await currentPromise)\n results.push(arr[startIndex]!)\n for (let i = startIndex + 1; i < arr.length; i++) {\n if (await fn(arr[i]!, i))\n results.push(arr[i]!)\n }\n return results\n}\n\n/**\n * Like Array.findIndex but handles MaybePromise callbacks sequentially.\n * Returns -1 if no element matches.\n */\nexport function findIndexSequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n): MaybePromise<number> {\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingFindIndex(result, arr, fn, i)\n }\n if (result)\n return i\n }\n return -1\n}\n\nasync function chainRemainingFindIndex<T>(\n currentPromise: Promise<unknown>,\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n startIndex: number,\n): Promise<number> {\n if (await currentPromise)\n return startIndex\n for (let i = startIndex + 1; i < arr.length; i++) {\n if (await fn(arr[i]!, i))\n return i\n }\n return -1\n}\n","import type { ContextStack } from '../../evaluator/ContextStack'\nimport type { ExecuteFunction } from '../../evaluator/interface'\nimport type { Any, Arr, Coll, Obj, Seq } from '../../interface'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { collHasKey, deepEqual, toAny } from '../../utils'\nimport { asAny, asFunctionLike, assertAny, assertColl, assertFunctionLike, assertObj, assertSeq, isObj, isSeq } from '../../typeGuards/dvala'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { assertNumber, isNumber } from '../../typeGuards/number'\nimport { assertString, assertStringOrNumber, isString, isStringOrNumber } from '../../typeGuards/string'\nimport type { FunctionLike } from '../../parser/types'\nimport { DvalaError } from '../../errors'\nimport { toFixedArity } from '../../utils/arity'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain, mapSequential, reduceSequential } from '../../utils/maybePromise'\n\nfunction mapObjects({\n colls,\n contextStack,\n executeFunction,\n fn,\n sourceCodeInfo,\n}: {\n colls: unknown[]\n fn: FunctionLike\n sourceCodeInfo: SourceCodeInfo | undefined\n contextStack: ContextStack\n executeFunction: ExecuteFunction\n}): MaybePromise<Obj> {\n assertObj(colls[0], sourceCodeInfo)\n const keys = Object.keys(colls[0])\n const params: Record<string, unknown[]> = {}\n colls.forEach((obj) => {\n assertObj(obj, sourceCodeInfo)\n const objKeys = Object.keys(obj)\n if (objKeys.length !== keys.length) {\n throw new DvalaError(`All objects must have the same keys. Expected: ${keys.join(', ')}. Found: ${objKeys.join(', ')}`, sourceCodeInfo)\n }\n if (!objKeys.every(key => keys.includes(key))) {\n throw new DvalaError(`All objects must have the same keys. Expected: ${keys.join(', ')}. Found: ${objKeys.join(', ')}`, sourceCodeInfo)\n }\n Object.entries(obj).forEach(([key, value]) => {\n if (!params[key])\n params[key] = []\n params[key].push(value)\n })\n })\n\n const initialObj: Obj = {}\n return reduceSequential(keys, (result: Obj, key) => {\n return chain(\n executeFunction(fn, params[key]!, contextStack, sourceCodeInfo),\n (value) => {\n result[key] = value\n return result\n },\n )\n }, initialObj)\n}\n\nfunction get(coll: Coll, key: string | number): Any | undefined {\n if (isObj(coll)) {\n if (typeof key === 'string' && collHasKey(coll, key))\n return toAny(coll[key])\n }\n else {\n if (isNumber(key, { nonNegative: true, integer: true }) && key >= 0 && key < coll.length)\n return toAny(coll[key])\n }\n return undefined\n}\n\nfunction assoc(coll: Coll, key: string | number, value: Any, sourceCodeInfo?: SourceCodeInfo) {\n assertColl(coll, sourceCodeInfo)\n assertStringOrNumber(key, sourceCodeInfo)\n if (Array.isArray(coll) || typeof coll === 'string') {\n assertNumber(key, sourceCodeInfo, { integer: true })\n assertNumber(key, sourceCodeInfo, { gte: 0 })\n assertNumber(key, sourceCodeInfo, { lte: coll.length })\n if (typeof coll === 'string') {\n assertString(value, sourceCodeInfo, { char: true })\n return `${coll.slice(0, key)}${value}${coll.slice(key + 1)}`\n }\n const copy = [...coll]\n copy[key] = value\n return copy\n }\n assertString(key, sourceCodeInfo)\n const copy = { ...coll }\n copy[key] = value\n return copy\n}\n\nexport const collectionNormalExpression: BuiltinNormalExpressions = {\n 'filter': {\n evaluate: ([coll, fn]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Coll> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n if (Array.isArray(coll)) {\n return reduceSequential(coll, (result: Arr, elem) => {\n return chain(executeFunction(fn, [elem], contextStack, sourceCodeInfo), (keep) => {\n if (keep)\n result.push(elem)\n return result\n })\n }, [] as Arr)\n }\n if (isString(coll)) {\n const chars = coll.split('')\n return chain(\n reduceSequential(chars, (result: string[], elem) => {\n return chain(executeFunction(fn, [elem], contextStack, sourceCodeInfo), (keep) => {\n if (keep)\n result.push(elem)\n return result\n })\n }, [] as string[]),\n filtered => filtered.join(''),\n )\n }\n const entries = Object.entries(coll)\n const initialObj: Obj = {}\n return reduceSequential(entries, (result: Obj, [key, value]) => {\n return chain(executeFunction(fn, [value], contextStack, sourceCodeInfo), (keep) => {\n if (keep)\n result[key] = value\n return result\n })\n }, initialObj)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n coll: { type: 'collection' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['coll', 'fun'] }],\n description: 'Creates a new collection with all elements that pass the test implemented by $fun.',\n seeAlso: ['collection.filteri', 'map', 'sequence.remove'],\n examples: [\n `\nfilter(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)`,\n `\nfilter(\n [5, 10, 15, 20],\n -> $ > 10\n)`,\n `\nfilter(\n { a: 1, b: 2 },\n odd?\n)`,\n ],\n },\n },\n 'map': {\n evaluate: (params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const fn = asFunctionLike(params.at(-1), sourceCodeInfo)\n\n if (isObj(params[0])) {\n return mapObjects({\n colls: params.slice(0, -1),\n fn,\n sourceCodeInfo,\n contextStack,\n executeFunction,\n })\n }\n\n const seqs = params.slice(0, -1) as Seq[]\n assertSeq(seqs[0], sourceCodeInfo)\n\n const isStr = typeof seqs[0] === 'string'\n let len = seqs[0].length\n seqs.slice(1).forEach((seq) => {\n if (isStr) {\n assertString(seq, sourceCodeInfo)\n }\n else {\n assertArray(seq, sourceCodeInfo)\n }\n len = Math.min(len, seq.length)\n })\n\n const paramArray: unknown[][] = []\n for (let i = 0; i < len; i++) {\n paramArray.push(seqs.map(seq => seq[i]))\n }\n\n const mapped = mapSequential(paramArray, p => executeFunction(fn, p, contextStack, sourceCodeInfo))\n\n if (!isStr) {\n return mapped\n }\n return chain(mapped, (resolvedMapped) => {\n resolvedMapped.forEach(char => assertString(char, sourceCodeInfo))\n return resolvedMapped.join('')\n })\n },\n arity: { min: 2 },\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n colls: { type: 'collection', rest: true, description: 'At least one.' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['colls', 'fun'] }],\n description: 'Creates a new collection populated with the results of calling $fun on every element in $colls.',\n seeAlso: ['collection.mapi', 'filter', 'reduce', 'mapcat', 'grid.cell-map', 'grid.cell-mapi'],\n examples: [\n '[1, 2, 3] map -',\n '[1, 2, 3] map -> -($)',\n 'map([\"Albert\", \"Mojir\", 42], str)',\n 'map([1, 2, 3], inc)',\n 'map([1, 2, 3], [1, 10, 100], *)',\n 'map({ a: 1, b: 2 }, inc)',\n 'map({ a: 1, b: 2 }, { a: 10, b: 20 }, +)',\n ],\n },\n },\n 'reduce': {\n evaluate: ([coll, fn, initial], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n assertAny(initial, sourceCodeInfo)\n\n if (typeof coll === 'string') {\n assertString(initial, sourceCodeInfo)\n if (coll.length === 0)\n return initial\n\n return reduceSequential(coll.split(''), (result: Any, elem) => {\n return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo)\n }, initial)\n }\n else if (Array.isArray(coll)) {\n if (coll.length === 0)\n return initial\n\n return reduceSequential(coll, (result: Any, elem) => {\n return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo)\n }, initial)\n }\n else {\n if (Object.keys(coll).length === 0)\n return initial\n\n return reduceSequential(Object.entries(coll), (result: Any, [, elem]) => {\n return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo)\n }, initial)\n }\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'any' },\n args: {\n fun: { type: 'function' },\n coll: { type: 'collection' },\n initial: { type: 'any' },\n },\n variants: [{ argumentNames: ['coll', 'fun', 'initial'] }],\n 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.',\n seeAlso: ['collection.reduce-right', 'collection.reducei', 'collection.reductions', 'map', 'grid.cell-reduce', 'grid.cell-reducei'],\n examples: [\n 'reduce([1, 2, 3], +, 0)',\n 'reduce([], +, 0)',\n 'reduce({ a: 1, b: 2 }, +, 0)',\n `\nreduce(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + (even?(value) ? value : 0),\n 0)`,\n ],\n },\n },\n 'get': {\n evaluate: (params, sourceCodeInfo) => {\n const [coll, key] = params\n const defaultValue = toAny(params[2])\n assertStringOrNumber(key, sourceCodeInfo)\n if (coll === null)\n return defaultValue\n\n assertColl(coll, sourceCodeInfo)\n const result = get(coll, key)\n return result === undefined ? defaultValue : result\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'collection',\n returns: { type: 'any' },\n args: {\n 'a': { type: 'collection' },\n 'b': { type: ['string', 'integer'] },\n 'not-found': { type: 'any', description: 'Default value to return if $b is not found.' },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'not-found'] },\n ],\n description: 'Returns value in $a mapped at $b.',\n seeAlso: ['collection.get-in', 'contains?', 'find', 'nth'],\n examples: [\n '[1, 2, 3] get 1',\n '{ a: 1 } get \"a\"',\n '\"Albert\" get \"3\"',\n `\nget(\n [1, 2, 3],\n 1, // Optional comma after last argument\n)`,\n `\nget(\n [],\n 1\n)`,\n `\nget(\n [],\n 1,\n \"default\"\n)`,\n `\nget(\n { a: 1 },\n \"a\"\n)`,\n `\nget(\n { a: 1 },\n \"b\"\n)`,\n `\nget(\n { a: 1 },\n \"b\",\n \"default\"\n)`,\n `\nget(\n null,\n \"a\"\n)`,\n `\nget(\n null,\n \"b\",\n \"default\"\n)`,\n ],\n },\n },\n 'count': {\n evaluate: ([coll], sourceCodeInfo): number => {\n if (coll === null)\n return 0\n\n if (typeof coll === 'string')\n return coll.length\n\n assertColl(coll, sourceCodeInfo)\n if (Array.isArray(coll))\n return coll.length\n\n return Object.keys(coll).length\n },\n arity: toFixedArity(1),\n docs: {\n category: 'collection',\n returns: { type: 'number' },\n args: {\n coll: { type: ['collection', 'null'] },\n },\n variants: [{ argumentNames: ['coll'] }],\n description: 'Returns number of elements in $coll.',\n seeAlso: ['empty?'],\n examples: [\n 'count([1, 2, 3])',\n 'count([])',\n 'count({ a: 1 })',\n 'count(\"\")',\n 'count(\"Albert\")',\n 'count(null)',\n ],\n },\n },\n 'contains?': {\n evaluate: ([coll, key], sourceCodeInfo): boolean => {\n if (coll === null)\n return false\n\n assertColl(coll, sourceCodeInfo)\n if (isString(coll)) {\n assertString(key, sourceCodeInfo)\n return coll.includes(key)\n }\n if (isSeq(coll)) {\n assertAny(key, sourceCodeInfo)\n return !!coll.find(elem => deepEqual(asAny(elem), key, sourceCodeInfo))\n }\n assertString(key, sourceCodeInfo)\n return key in coll\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['collection', 'null'] },\n b: { type: ['string', 'integer'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns `true` if $a contains $b, otherwise returns `false`. For strings, it checks if substring is included.',\n seeAlso: ['get', 'find', 'index-of'],\n examples: [\n '[1, 2, 3] contains? 1',\n 'null contains? 1',\n '{ a: 1, b: 2 } contains? \"a\"',\n `\ncontains?(\n [],\n 1\n)`,\n `\ncontains?(\n [1],\n 1\n)`,\n `\ncontains?(\n [1, 2, 3],\n 1\n)`,\n `\ncontains?(\n {},\n \"a\"\n)`,\n `\ncontains?(\n { a: 1, b: 2 },\n \"a\"\n)`,\n ],\n },\n },\n 'assoc': {\n evaluate: ([coll, key, value], sourceCodeInfo): Coll => {\n assertColl(coll, sourceCodeInfo)\n assertStringOrNumber(key, sourceCodeInfo)\n assertAny(value, sourceCodeInfo)\n return assoc(coll, key, value, sourceCodeInfo)\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n coll: { type: 'collection' },\n key: { type: ['string', 'number'] },\n value: { type: 'any' },\n kvs: { type: 'any', description: 'Key-value pairs to associate.', rest: true },\n },\n variants: [\n { argumentNames: ['coll', 'key', 'value'] },\n { argumentNames: ['coll', 'key', 'value', 'kvs'] },\n ],\n 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\\`.`,\n seeAlso: ['collection.assoc-in', 'dissoc', 'merge', 'collection.update'],\n examples: [\n `\nassoc(\n [1, 2, 3],\n 1,\n \"Two\"\n)`,\n `\nassoc(\n [1, 2, 3],\n 3,\n \"Four\"\n)`,\n `\nassoc(\n { a: 1, b: 2 },\n \"a\",\n \"One\")`,\n `\nassoc(\n { a: 1, b: 2 },\n \"c\",\n \"Three\")`,\n `\nassoc(\n \"Albert\",\n 6,\n \"a\")`,\n ],\n },\n },\n '++': {\n evaluate: (params, sourceCodeInfo): Any => {\n if (!isNumber(params[0])) {\n assertColl(params[0], sourceCodeInfo)\n }\n if (Array.isArray(params[0])) {\n return params.reduce((result: Arr, arr) => {\n assertArray(arr, sourceCodeInfo)\n return result.concat(arr)\n }, [])\n }\n else if (isStringOrNumber(params[0])) {\n return params.reduce((result: string, s) => {\n assertStringOrNumber(s, sourceCodeInfo)\n return `${result}${s}`\n }, '')\n }\n else {\n return params.reduce((result: Obj, obj) => {\n assertObj(obj, sourceCodeInfo)\n return Object.assign(result, obj)\n }, {})\n }\n },\n arity: { min: 1 },\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'collection' },\n colls: { type: 'collection', rest: true },\n },\n variants: [\n { argumentNames: ['a'] },\n { argumentNames: ['a', 'colls'] },\n ],\n description: 'Concatenates collections into one collection.',\n seeAlso: ['mapcat', 'str', 'join', 'push', 'sequence.unshift'],\n examples: [\n '\"Albert\" ++ \" \" ++ \"Mojir\"',\n '\"Albert\" ++ \"Mojir\"',\n\n '++(\"Albert\", \"-\", \"Mojir\")',\n '++(\"Albert\")',\n\n '++(\"A\", \"l\", \"b\", \"e\", \"r\", \"t\")',\n '++([1, 2], [3, 4])',\n '++([], [3, 4])',\n '++([1, 2], [])',\n '++([1, 2], [3, 4], [5, 6])',\n '++([])',\n '++({ a: 1, b: 2 }, { b: 1, c: 2 })',\n '++({}, { a: 1 })',\n ],\n },\n },\n}\n","import type { Arr } from '../../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { asNumber, assertNumber } from '../../typeGuards/number'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { assertFunctionLike } from '../../typeGuards/dvala'\nimport { toFixedArity } from '../../utils/arity'\nimport { chain, mapSequential } from '../../utils/maybePromise'\n\nexport const arrayNormalExpression: BuiltinNormalExpressions = {\n 'range': {\n evaluate: (params, sourceCodeInfo): Arr => {\n const [first, second, third] = params\n let from: number\n let to: number\n let step: number\n assertNumber(first, sourceCodeInfo, { finite: true })\n\n if (params.length === 1) {\n from = 0\n to = first\n step = to >= 0 ? 1 : -1\n }\n else if (params.length === 2) {\n assertNumber(second, sourceCodeInfo, { finite: true })\n from = first\n to = second\n step = to >= from ? 1 : -1\n }\n else {\n assertNumber(second, sourceCodeInfo, { finite: true })\n assertNumber(third, sourceCodeInfo, { finite: true })\n from = first\n to = second\n step = third\n if (to > from)\n assertNumber(step, sourceCodeInfo, { positive: true })\n else if (to < from)\n assertNumber(step, sourceCodeInfo, { negative: true })\n else\n assertNumber(step, sourceCodeInfo, { nonZero: true })\n }\n\n const result: number[] = []\n\n for (let i = from; step < 0 ? i > to : i < to; i += step)\n result.push(i)\n\n return result\n },\n arity: { min: 1, max: 3 },\n docs: {\n category: 'array',\n returns: { type: 'number', array: true },\n args: {\n a: { type: 'number' },\n b: { type: 'number' },\n step: { type: 'number' },\n },\n variants: [\n { argumentNames: ['b'] },\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'step'] },\n ],\n 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.`,\n seeAlso: ['repeat', 'vector.linspace'],\n examples: [\n 'range(4)',\n 'range(1, 4)',\n '1 range 10',\n 'range(0.4, 4.9)',\n `\nrange(\n 0.25, // start value\n 1, // end value (exclusive)\n 0.25, // step value\n)`,\n ],\n },\n },\n\n 'repeat': {\n evaluate: ([value, count], sourceCodeInfo): Arr => {\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n const result: Arr = []\n for (let i = 0; i < count; i += 1)\n result.push(value)\n\n return result\n },\n arity: toFixedArity(2),\n docs: {\n category: 'array',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'any' },\n b: { type: 'integer' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns an array with $a repeated $b times.',\n seeAlso: ['range', 'string.string-repeat'],\n examples: [\n 'repeat(10, 3)',\n 'repeat(10, 0)',\n '\"Albert\" repeat 5',\n ],\n },\n },\n\n 'flatten': {\n evaluate: ([seq, depth], sourceCodeInfo): Arr => {\n assertArray(seq, sourceCodeInfo)\n\n const actualDepth = depth === undefined || depth === Number.POSITIVE_INFINITY\n ? Number.POSITIVE_INFINITY\n : asNumber(depth, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return seq.flat(actualDepth)\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'array',\n returns: { type: 'any', array: true },\n args: {\n x: { type: ['array', 'any'], description: 'If $x is not an array, `[ ]` is returned.' },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'Takes a nested array $x and flattens it.',\n seeAlso: ['mapcat'],\n examples: [\n 'flatten([1, 2, [3, 4], 5])',\n `\nlet foo = \"bar\";\nflatten([\n 1,\n \" 2 A \",\n [foo, [4, [\"ABC\"]]],\n 6,\n])`,\n ],\n hideOperatorForm: true,\n },\n },\n 'mapcat': {\n evaluate: ([arr, fn], sourceCodeInfo, contextStack, { executeFunction }) => {\n assertArray(arr, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n return chain(\n mapSequential(arr, elem => executeFunction(fn, [elem], contextStack, sourceCodeInfo)),\n mapped => mapped.flat(1),\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'array',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n colls: { type: 'collection', array: true },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['colls', 'fun'] }],\n description: 'Returns the result of applying concat to the result of applying map to $fun and $colls.',\n seeAlso: ['flatten', 'map', '++'],\n examples: [\n '[[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]] mapcat reverse',\n 'mapcat([[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]], reverse)',\n '[[3, 2, 1, 0,], [6, 5, 4,], [9, 8, 7]] mapcat reverse',\n `\nlet foo = (n) -> do\n [n - 1, n, n + 1]\nend;\n[1, 2, 3] mapcat foo`,\n `\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ filter odd?\n)`,\n ],\n },\n },\n 'moving-fn': {\n evaluate: ([arr, windowSize, fn], sourceCodeInfo, contextStack, { executeFunction }) => {\n assertArray(arr, sourceCodeInfo)\n assertNumber(windowSize, sourceCodeInfo, { integer: true, lte: arr.length })\n assertFunctionLike(fn, sourceCodeInfo)\n\n const windows: Arr[] = []\n for (let i = 0; i <= arr.length - windowSize; i++) {\n windows.push(arr.slice(i, i + windowSize))\n }\n return mapSequential(windows, window => executeFunction(fn, [window], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(3),\n docs: {\n category: 'array',\n returns: { type: 'array' },\n args: {\n arr: { type: 'array' },\n windowSize: { type: 'number', description: 'The size of the moving window.' },\n fn: { type: 'function' },\n },\n variants: [{ argumentNames: ['arr', 'windowSize', 'fn'] }],\n description: 'Returns the result of applying $fn to each moving window of size $windowSize in $arr.',\n seeAlso: ['running-fn', 'vector.moving-mean'],\n examples: [\n 'moving-fn([1, 2, 3], 2, sum)',\n 'moving-fn([1, 2, 3], 1, sum)',\n 'moving-fn([1, 2, 3], 3, sum)',\n ],\n },\n },\n 'running-fn': {\n evaluate: ([arr, fn], sourceCodeInfo, contextStack, { executeFunction }) => {\n assertArray(arr, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n const subArrays: Arr[] = []\n for (let i = 0; i < arr.length; i += 1) {\n subArrays.push(arr.slice(0, i + 1))\n }\n return mapSequential(subArrays, subArr => executeFunction(fn, [subArr], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(2),\n docs: {\n category: 'array',\n returns: { type: 'array' },\n args: {\n a: { type: 'array' },\n b: { type: 'function' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns the result of applying $b to each element of $a.',\n seeAlso: ['moving-fn', 'vector.running-mean'],\n examples: [\n 'running-fn([1, 2, 3], sum)',\n 'running-fn([1, 2, 3], max)',\n 'running-fn([1, 2, 3], min)',\n ],\n },\n },\n}\n","import type { Any, Arr, Seq } from '../../interface'\nimport { assertCharArray } from '../../typeGuards/array'\nimport { asAny, assertAny, assertFunctionLike, assertSeq } from '../../typeGuards/dvala'\nimport { assertNumber } from '../../typeGuards/number'\nimport { assertString, assertStringOrNumber } from '../../typeGuards/string'\nimport { compare, deepEqual, toAny } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain, findIndexSequential, reduceSequential } from '../../utils/maybePromise'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const sequenceNormalExpression: BuiltinNormalExpressions = {\n 'nth': {\n evaluate: (params, sourceCodeInfo): Any => {\n const [seq, i] = params\n const defaultValue = toAny(params[2])\n\n assertNumber(i, sourceCodeInfo, { integer: true })\n\n if (seq === null)\n return defaultValue\n\n assertSeq(seq, sourceCodeInfo)\n if (i >= 0 && i < seq.length) {\n const result = toAny(seq[i])\n return result\n }\n else {\n return defaultValue\n }\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: {\n 'a': { type: 'sequence' },\n 'b': { type: 'integer' },\n 'seq': { type: ['sequence', 'null'] },\n 'n': { type: 'integer' },\n 'not-found': { type: 'any' },\n },\n variants: [\n { argumentNames: ['seq', 'n'] },\n { argumentNames: ['seq', 'n', 'not-found'] },\n ],\n description: 'Accesses element $n of $seq. Accessing out-of-bounds indices returns $not-found, if present, else `null`.',\n seeAlso: ['first', 'second', 'last', 'get', 'slice'],\n examples: [\n '[1, 2, 3] nth 1',\n '\"A string\" nth 3',\n 'nth([1, 2, 3], 1)',\n 'nth([1, 2, 3], 3)',\n 'nth([1, 2, 3], -1)',\n 'nth([1, 2, 3], 3, 99)',\n 'nth(\"A string\", 1)',\n 'nth(\"A string\", 3)',\n 'nth(\"A string\", -3)',\n 'nth(\"A string\", 30, \"X\")',\n 'nth(null, 1)',\n 'nth(null, 1, \"Default value\")',\n ],\n },\n },\n 'first': {\n evaluate: ([array], sourceCodeInfo): Any => {\n if (array === null)\n return null\n\n assertSeq(array, sourceCodeInfo)\n const result = toAny(array[0])\n\n return result\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns the first element of $seq. If $seq is empty or `null`, `null` is returned.',\n seeAlso: ['second', 'last', 'nth', 'rest', 'next'],\n examples: [\n 'first([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'first([])',\n 'first(null)',\n ],\n },\n },\n 'last': {\n evaluate: ([array], sourceCodeInfo): Any => {\n if (array === null)\n return null\n\n assertSeq(array, sourceCodeInfo)\n const result = toAny(array.at(-1))\n\n return result\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns the last element of $seq. If $seq is empty, `null` is returned.',\n seeAlso: ['first', 'second', 'nth', 'pop'],\n examples: [\n 'last([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'last([1, 2])',\n 'last([1])',\n 'last([])',\n 'last(null)',\n ],\n },\n },\n 'pop': {\n evaluate: ([seq], sourceCodeInfo): Seq => {\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n return seq.substring(0, seq.length - 1)\n }\n\n return seq.slice(0, seq.length - 1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'], rest: true },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns a copy of $seq with last element removed. If $seq is empty `null` is returned.',\n seeAlso: ['push', 'last'],\n examples: [\n 'pop([1, 2, 3])',\n 'pop([])',\n ],\n },\n },\n 'index-of': {\n evaluate: ([seq, value], sourceCodeInfo): number | null => {\n assertAny(value, sourceCodeInfo)\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n assertString(value, sourceCodeInfo)\n const index = seq.indexOf(value)\n return index !== -1 ? index : null\n }\n else {\n const index = seq.findIndex(item => deepEqual(asAny(item, sourceCodeInfo), value), sourceCodeInfo)\n return index !== -1 ? index : null\n }\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: ['number', 'null'] },\n args: {\n a: { type: 'sequence' },\n b: { type: 'any' },\n seq: { type: ['sequence', 'null'] },\n x: { type: 'any' },\n },\n variants: [{ argumentNames: ['seq', 'x'] }],\n description: 'Returns the index of $x in $seq. If element is not present in $seq `null` is returned.',\n seeAlso: ['sequence.last-index-of', 'sequence.position', 'contains?'],\n examples: [\n '[[1], [2], [1], [2]] index-of [1]',\n 'index-of([\"Albert\", \"Mojir\", 160, [1, 2]], \"Mojir\")',\n 'index-of([5, 10, 15, 20], 15)',\n 'index-of([5, 10, 15, 20], 1)',\n 'index-of(null, 1)',\n ],\n },\n },\n 'push': {\n evaluate: ([seq, ...values], sourceCodeInfo): Seq => {\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n assertCharArray(values, sourceCodeInfo)\n return [seq, ...values].join('')\n }\n else {\n return [...seq, ...values]\n }\n },\n arity: { min: 2 },\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'any' },\n seq: { type: 'sequence' },\n values: { type: 'any', rest: true, description: 'At least one.' },\n },\n variants: [{ argumentNames: ['seq', 'values'] }],\n description: 'Returns copy of $seq with $values added to the end of it.',\n seeAlso: ['sequence.unshift', 'pop', '++'],\n examples: [\n '[1, 2, 3] push 4',\n '\"Albert\" push \"!\"',\n 'push([1, 2, 3], 4)',\n 'push([1, 2, 3], 4, 5, 6)',\n `\nlet l = [1, 2, 3];\npush(l, 4);\nl`,\n ],\n },\n },\n 'rest': {\n evaluate: ([seq], sourceCodeInfo): Arr | string => {\n assertSeq(seq, sourceCodeInfo)\n if (Array.isArray(seq)) {\n if (seq.length <= 1)\n return []\n\n return seq.slice(1)\n }\n return seq.substring(1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'] },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n 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.`,\n seeAlso: ['next', 'first'],\n examples: [\n 'rest([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'rest([\"Albert\"])',\n 'rest([])',\n 'rest(\"Albert\")',\n 'rest(\"A\",)',\n 'rest(\"\")',\n ],\n },\n },\n 'next': {\n evaluate: ([seq], sourceCodeInfo): Arr | string | null => {\n assertSeq(seq, sourceCodeInfo)\n if (Array.isArray(seq)) {\n if (seq.length <= 1)\n return null\n\n return seq.slice(1)\n }\n if (seq.length <= 1)\n return null\n\n return seq.substring(1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'] },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n 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.',\n seeAlso: ['rest', 'first'],\n examples: [\n 'next([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'next([\"Albert\"])',\n 'next([])',\n 'next(\"Albert\")',\n 'next(\"A\",)',\n 'next(\"\")',\n ],\n },\n },\n 'reverse': {\n evaluate: ([seq], sourceCodeInfo): Any => {\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n if (Array.isArray(seq)) {\n return [...seq].reverse()\n }\n\n return seq.split('').reverse().join('')\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'] },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n 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.',\n seeAlso: ['sort'],\n examples: [\n 'reverse([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'reverse([])',\n 'reverse(\"Albert\")',\n 'reverse(null)',\n ],\n },\n },\n 'second': {\n evaluate: ([seq], sourceCodeInfo): Any => {\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n return toAny(seq[1])\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns the second element of $seq. If $seq has less than two elements or is `null`, `null` is returned.',\n seeAlso: ['first', 'last', 'nth'],\n examples: [\n 'second([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'second([1])',\n 'second([])',\n 'second(null)',\n ],\n },\n },\n 'slice': {\n evaluate: (params, sourceCodeInfo): Any => {\n const [seq, from, to] = params\n assertSeq(seq, sourceCodeInfo)\n assertNumber(from, sourceCodeInfo, { integer: true })\n\n if (params.length === 2) {\n if (Array.isArray(seq)) {\n return seq.slice(from)\n }\n return seq.slice(from)\n }\n\n assertNumber(to, sourceCodeInfo, { integer: true })\n if (Array.isArray(seq)) {\n return seq.slice(from, to)\n }\n return seq.slice(from, to)\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n seq: { type: 'sequence', rest: true },\n start: { type: 'integer', description: 'Defaults to `0`.' },\n stop: { type: 'integer', description: 'Defaults lenght of sequence + 1.' },\n },\n variants: [\n { argumentNames: ['seq'] },\n { argumentNames: ['seq', 'start'] },\n { argumentNames: ['seq', 'start', 'stop'] },\n ],\n description: 'Returns a copy of a portion of $seq from index $start (inclusive) to $stop (exclusive).',\n seeAlso: ['take', 'drop', 'sequence.splice', 'nth'],\n examples: [\n '[1, 2, 3, 4, 5] slice 2',\n 'slice([1, 2, 3, 4, 5], 2, 4)',\n 'slice([1, 2, 3, 4, 5], 2)',\n ],\n },\n },\n 'some': {\n evaluate: ([seq, fn]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertFunctionLike(fn, sourceCodeInfo)\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n\n if (seq.length === 0)\n return null\n\n const items = typeof seq === 'string' ? seq.split('') : seq\n return reduceSequential(\n items,\n (found: Any, elem) => {\n if (found !== null)\n return found\n return chain(executeFunction(fn, [elem], contextStack, sourceCodeInfo), (result) => {\n return result ? toAny(elem) : null\n })\n },\n null as Any,\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: ['sequence', 'null'] },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['seq', 'fun'] }],\n description: 'Returns the first element that passes the test implemented by $fun. I no element was found, `null` is returned.',\n seeAlso: ['sequence.position', 'collection.any?', 'find'],\n examples: [\n `\nsome(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)`,\n `\nsome(\n [5, 10, 15, 20],\n -> $ > 10\n)`,\n `\nsome(\n [1, 2, 3, 4],\n -> $ > 10\n)`,\n `\nsome(\n [],\n -> $ > 10\n)`,\n `\nsome(\n null,\n -> $ > 10\n)`,\n ],\n },\n },\n 'sort': {\n evaluate: (params: Arr, sourceCodeInfo, _contextStack, { executeFunction: _executeFunction }): Seq => {\n const [seq] = params\n const defaultComparer = params.length === 1\n const comparer = defaultComparer ? null : params[1]\n assertSeq(seq, sourceCodeInfo)\n\n if (typeof seq === 'string') {\n const result = seq.split('')\n if (defaultComparer) {\n result.sort((a, b) => compare(a, b, sourceCodeInfo))\n }\n else {\n assertFunctionLike(comparer, sourceCodeInfo)\n // Note: sort comparator must be synchronous — async comparators would need a different approach\n result.sort((a, b) => {\n const compareValue = _executeFunction(comparer, [a, b], _contextStack, sourceCodeInfo)\n if (compareValue instanceof Promise) {\n throw new TypeError('Async functions cannot be used as sort comparators')\n }\n assertNumber(compareValue, sourceCodeInfo, { finite: true })\n return compareValue\n })\n }\n return result.join('')\n }\n\n const result = [...seq]\n if (defaultComparer) {\n result.sort((a, b) => {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n return compare(a, b, sourceCodeInfo)\n })\n }\n else {\n result.sort((a, b) => {\n assertFunctionLike(comparer, sourceCodeInfo)\n // Note: sort comparator must be synchronous\n const compareValue = _executeFunction(comparer, [a, b], _contextStack, sourceCodeInfo)\n if (compareValue instanceof Promise) {\n throw new TypeError('Async functions cannot be used as sort comparators')\n }\n assertNumber(compareValue, sourceCodeInfo, { finite: true })\n return compareValue\n })\n }\n return result\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'sequence',\n returns: { type: 'any', rest: true },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: 'sequence' },\n fun: { type: 'function' },\n },\n variants: [\n { argumentNames: ['seq'] },\n { argumentNames: ['seq', 'fun'] },\n ],\n description: 'Returns a new sequence with the elements from $seq sorted according to $fun. If no $fun is supplied, builtin `compare` will be used.',\n seeAlso: ['sequence.sort-by', 'compare', 'reverse', 'vector.sort-indices'],\n examples: [\n '[3, 1, 2] sort (a, b) -> b - a',\n 'sort([3, 1, 2])',\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)`,\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)`,\n ],\n },\n },\n 'take': {\n evaluate: ([input, n], sourceCodeInfo): Seq => {\n assertNumber(n, sourceCodeInfo)\n assertSeq(input, sourceCodeInfo)\n const num = Math.max(Math.ceil(n), 0)\n return input.slice(0, num)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n n: { type: 'integer' },\n seq: { type: 'sequence' },\n },\n variants: [{ argumentNames: ['seq', 'n'] }],\n description: 'Constructs a new array/string with the $n first elements from $seq.',\n seeAlso: ['take-last', 'take-while', 'drop', 'slice', 'sequence.split-at'],\n examples: [\n 'take([1, 2, 3, 4, 5], 3)',\n '[1, 2, 3, 4, 5] take 3',\n 'take([1, 2, 3, 4, 5], 0)',\n 'take(\"Albert\", 2)',\n 'take(\"Albert\", 50)',\n ],\n },\n },\n 'take-last': {\n evaluate: ([array, n], sourceCodeInfo): Seq => {\n assertSeq(array, sourceCodeInfo)\n assertNumber(n, sourceCodeInfo)\n const num = Math.max(Math.ceil(n), 0)\n const from = array.length - num\n return array.slice(from)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n n: { type: 'integer' },\n seq: { type: 'sequence' },\n },\n variants: [{ argumentNames: ['seq', 'n'] }],\n description: 'Constructs a new array with the $n last elements from $seq.',\n seeAlso: ['take', 'drop-last'],\n examples: [\n 'take-last([1, 2, 3, 4, 5], 3)',\n '[1, 2, 3, 4, 5] take-last 3',\n 'take-last([1, 2, 3, 4, 5], 0)',\n ],\n },\n },\n 'drop': {\n evaluate: ([input, n], sourceCodeInfo): Seq => {\n assertNumber(n, sourceCodeInfo)\n const num = Math.max(Math.ceil(n), 0)\n assertSeq(input, sourceCodeInfo)\n return input.slice(num)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n seq: { type: 'sequence' },\n n: { type: 'integer' },\n },\n variants: [{ argumentNames: ['seq', 'n'] }],\n description: 'Constructs a new array/string with the $n first elements dropped from $seq.',\n seeAlso: ['drop-last', 'drop-while', 'take', 'slice', 'sequence.split-at'],\n examples: [\n 'drop([1, 2, 3, 4, 5], 3)',\n '[1, 2, 3, 4, 5] drop 0',\n 'drop(\"Albert\", 2)',\n 'drop(\"Albert\", 50)',\n ],\n },\n },\n 'drop-last': {\n evaluate: ([array, n], sourceCodeInfo): Seq => {\n assertSeq(array, sourceCodeInfo)\n assertNumber(n, sourceCodeInfo)\n const num = Math.max(Math.ceil(n), 0)\n const from = array.length - num\n return array.slice(0, from)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n seq: { type: 'sequence' },\n n: { type: 'integer' },\n },\n variants: [{ argumentNames: ['seq', 'n'] }],\n description: 'Constructs a new array with the $n last elements dropped from $seq.',\n seeAlso: ['drop', 'take-last'],\n examples: [\n 'drop-last([1, 2, 3, 4, 5], 3)',\n '[1, 2, 3, 4, 5] drop-last 3',\n 'drop-last([1, 2, 3, 4, 5], 0)',\n ],\n },\n },\n 'take-while': {\n evaluate: ([seq, fn]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertSeq(seq, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n const arr = typeof seq === 'string' ? seq.split('') : Array.from(seq)\n // Find the first index where the predicate is false\n return chain(\n findIndexSequential(arr, elem => chain(\n executeFunction(fn, [elem], contextStack, sourceCodeInfo),\n result => !result,\n )),\n (index) => {\n const taken = index === -1 ? arr : arr.slice(0, index)\n return typeof seq === 'string' ? taken.join('') : taken\n },\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: 'sequence' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['seq', 'fun'] }],\n description: 'Returns the members of $seq in order, stopping before the first one for which `predicate` returns a falsy value.',\n seeAlso: ['take', 'drop-while', 'sequence.split-with'],\n examples: [\n `take-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)`,\n `take-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)`,\n ],\n },\n },\n 'drop-while': {\n evaluate: ([seq, fn]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertSeq(seq, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n const arr = Array.isArray(seq) ? seq : seq.split('')\n return chain(\n findIndexSequential(arr, elem => chain(\n executeFunction(fn, [elem], contextStack, sourceCodeInfo),\n result => !result,\n )),\n (from) => {\n if (from === -1)\n return typeof seq === 'string' ? '' : []\n return typeof seq === 'string' ? arr.slice(from).join('') : seq.slice(from)\n },\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: 'sequence' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['seq', 'fun'] }],\n description: 'Returns the members of $seq in order, skipping the fist elements for witch the `predicate` returns a truethy value.',\n seeAlso: ['drop', 'take-while', 'sequence.split-with'],\n examples: [\n `drop-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)`,\n `drop-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)`,\n ],\n },\n },\n}\n","import { DvalaError } from '../errors'\nimport type { Any } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isNumber } from './number'\n\nconst annotatedArrays = new WeakSet<unknown[]>()\nconst vectors = new WeakSet<unknown[]>()\nconst notVectors = new WeakSet<unknown[]>()\nconst matrices = new WeakSet<unknown[]>()\nconst notMatrices = new WeakSet<unknown[]>()\nconst grids = new WeakSet<unknown[]>()\nconst notGrids = new WeakSet<unknown[]>()\n\nexport function annotate<T>(value: T): T {\n if (!Array.isArray(value)) {\n return value\n }\n if (annotatedArrays.has(value)) {\n return value\n }\n isVector(value)\n if (!isMatrix(value)) {\n isGrid(value)\n }\n\n return value\n}\nexport function isVector(vector: unknown): vector is number[] {\n if (!Array.isArray(vector)) {\n return false\n }\n\n if (vectors.has(vector)) {\n return true\n }\n if (notVectors.has(vector)) {\n return false\n }\n\n if (vector.every(elem => isNumber(elem))) {\n annotatedArrays.add(vector)\n vectors.add(vector)\n return true\n }\n notVectors.add(vector)\n return false\n}\n\nexport function assertVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is number[] {\n if (!isVector(vector)) {\n throw new DvalaError(`Expected a vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function is2dVector(vector: unknown): vector is [number, number] {\n if (!isVector(vector)) {\n return false\n }\n return vector.length === 2\n}\nexport function assert2dVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is [number, number] {\n if (!is2dVector(vector)) {\n throw new DvalaError(`Expected a 2d vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function is3dVector(vector: unknown): vector is [number, number, number] {\n if (!isVector(vector)) {\n return false\n }\n return vector.length === 3\n}\nexport function assert3dVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is [number, number, number] {\n if (!is3dVector(vector)) {\n throw new DvalaError(`Expected a 3d vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function assertNonEmptyVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is number[] {\n assertVector(vector, sourceCodeInfo)\n if (vector.length === 0) {\n throw new DvalaError(`Expected a non empty vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function isGrid(grid: unknown): grid is unknown[][] {\n if (!Array.isArray(grid)) {\n return false\n }\n if (grids.has(grid)) {\n return true\n }\n if (notGrids.has(grid)) {\n return false\n }\n if (grid.length === 0) {\n notGrids.add(grid)\n return false\n }\n if (!Array.isArray(grid[0])) {\n notGrids.add(grid)\n return false\n }\n const nbrOfCols = grid[0].length\n for (const row of grid.slice(1)) {\n if (!Array.isArray(row)) {\n notGrids.add(grid)\n return false\n }\n if (row.length !== nbrOfCols) {\n notGrids.add(grid)\n return false\n }\n }\n annotatedArrays.add(grid)\n grids.add(grid)\n return true\n}\n\nexport function assertGrid(grid: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts grid is Any[][] {\n if (!isGrid(grid)) {\n throw new DvalaError(`Expected a grid, but got ${grid}`, sourceCodeInfo)\n }\n}\n\nexport function isMatrix(matrix: unknown): matrix is number[][] {\n if (!Array.isArray(matrix)) {\n return false\n }\n if (matrices.has(matrix)) {\n return true\n }\n if (notMatrices.has(matrix)) {\n return false\n }\n if (matrix.length === 0) {\n notMatrices.add(matrix)\n return false\n }\n if (!Array.isArray(matrix[0]) || matrix[0].length === 0) {\n notMatrices.add(matrix)\n return false\n }\n const nbrOfCols = matrix[0].length\n for (const row of matrix) {\n if (!Array.isArray(row) || row.length !== nbrOfCols || row.some(cell => !isNumber(cell))) {\n notMatrices.add(matrix)\n return false\n }\n }\n annotatedArrays.add(matrix)\n grids.add(matrix)\n matrices.add(matrix)\n return true\n}\n\nexport function assertMatrix(matrix: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts matrix is number[][] {\n if (!isMatrix(matrix)) {\n throw new DvalaError(`Expected a matrix, but got ${matrix}`, sourceCodeInfo)\n }\n}\n\nexport function assertSquareMatrix(matrix: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts matrix is number[][] {\n if (!isMatrix(matrix)) {\n throw new DvalaError(`Expected a matrix, but got ${matrix}`, sourceCodeInfo)\n }\n if (matrix.length !== matrix[0]!.length) {\n throw new DvalaError(`Expected square matrix, but got ${matrix.length} and ${matrix[0]!.length}`, sourceCodeInfo)\n }\n}\n\nexport function isSquareMatrix(matrix: unknown): matrix is number[][] {\n if (!isMatrix(matrix)) {\n return false\n }\n if (matrix.length !== matrix[0]!.length) {\n return false\n }\n return true\n}\n","import { DvalaError } from '../../errors'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { assertNonEmptyVector, isMatrix, isVector } from '../../typeGuards/annotatedArrays'\nimport { assertNumber, isNumber } from '../../typeGuards/number'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\ntype NumberVectorOrMatrix = number | number[] | number[][]\n\nfunction getNumberVectorOrMatrixOperation(\n params: unknown[],\n sourceCodeInfo: SourceCodeInfo | undefined,\n):\n | ['number', number[]]\n | ['vector', number[][]]\n | ['matrix', number[][][]] {\n let hasVector: boolean = false\n let hasMatrix: boolean = false\n for (const param of params) {\n if (isVector(param)) {\n hasVector = true\n }\n else if (isMatrix(param)) {\n hasMatrix = true\n }\n else if (!isNumber(param)) {\n throw new DvalaError(`Invalid parameter type: ${typeof param}`, sourceCodeInfo)\n }\n }\n if (hasMatrix) {\n if (hasVector) {\n throw new DvalaError('Cannot mix vector and matrix types', sourceCodeInfo)\n }\n let rows: number | null = null\n let cold: number | null = null\n for (const param of params) {\n if (isMatrix(param)) {\n if (rows === null) {\n rows = param.length\n cold = param[0]!.length\n }\n else {\n if (param.length !== rows || param[0]!.length !== cold) {\n throw new DvalaError('Matrix dimensions do not match', sourceCodeInfo)\n }\n }\n }\n }\n const matrices = params.map((param) => {\n if (isMatrix(param)) {\n return param\n }\n return Array.from({ length: rows as number }, () => Array.from({ length: cold as number }, () => param as number))\n })\n return ['matrix', matrices]\n }\n if (hasVector) {\n let length: number | null = null\n for (const param of params) {\n if (isVector(param)) {\n if (length === null) {\n length = param.length\n }\n else {\n if (param.length !== length) {\n throw new DvalaError('Vector lengths do not match', sourceCodeInfo)\n }\n }\n }\n }\n const vectors = params.map((param) => {\n if (isVector(param)) {\n return param\n }\n return Array.from({ length: length as number }, () => param as number)\n })\n\n return ['vector', vectors]\n }\n return ['number', params as number[]]\n}\n\nfunction unaryMathOp(\n fn: (val: number) => number,\n): (params: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) => NumberVectorOrMatrix {\n return (params, sourceCodeInfo) => {\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n if (operation === 'number') {\n return fn(operands[0]!)\n }\n else if (operation === 'vector') {\n return operands[0]!.map(val => fn(val))\n }\n else {\n return operands[0]!.map(row => row.map(val => fn(val)))\n }\n }\n}\n\nfunction binaryMathOp(\n fn: (a: number, b: number) => number,\n): (params: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) => NumberVectorOrMatrix {\n return (params, sourceCodeInfo) => {\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n if (operation === 'number') {\n return fn(operands[0]!, operands[1]!)\n }\n else if (operation === 'vector') {\n return operands[0]!.map((val, i) => fn(val, operands[1]![i]!))\n }\n else {\n return operands[0]!.map((row, i) => row.map((val, j) => fn(val, operands[1]![i]![j]!)))\n }\n }\n}\n\nfunction reduceMathOp(\n identity: number,\n fn: (a: number, b: number) => number,\n): (params: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) => NumberVectorOrMatrix {\n return (params, sourceCodeInfo) => {\n if (params.length === 0)\n return identity\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n if (operation === 'number') {\n return operands.reduce((a, b) => fn(a, b), identity)\n }\n else if (operation === 'vector') {\n const [first, ...rest] = operands\n return rest.reduce((acc, v) => acc.map((val, i) => fn(val, v[i]!)), first!)\n }\n else {\n const [first, ...rest] = operands\n return rest.reduce((acc, m) => acc.map((row, i) => row.map((val, j) => fn(val, m[i]![j]!))), first!)\n }\n }\n}\n\nexport const mathNormalExpression: BuiltinNormalExpressions = {\n 'inc': {\n evaluate: unaryMathOp(val => val + 1),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: 'number' },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['dec', '+'],\n examples: [\n 'inc(0)',\n 'inc(1)',\n 'inc(100.1)',\n 'inc([1, 2, 3])',\n 'inc([[1, 2], [3, 4]])',\n ],\n },\n },\n 'dec': {\n evaluate: unaryMathOp(val => val - 1),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['inc', '-'],\n examples: [\n 'dec(0)',\n 'dec(1)',\n 'dec(100.1)',\n 'dec([1, 2, 3])',\n 'dec([[1, 2], [3, 4]])',\n ],\n },\n },\n '+': {\n evaluate: reduceMathOp(0, (a, b) => a + b),\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n 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.',\n seeAlso: ['-', '*', '/', 'inc'],\n examples: [\n '1 + 2',\n '1 + 20 + 30',\n '+(1, 2, 3, 4)',\n '+()',\n '+(1)',\n '[1, 2, 3] + 2',\n '[1, 2, 3] + [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] + [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] + 2',\n ],\n },\n },\n '*': {\n evaluate: reduceMathOp(1, (a, b) => a * b),\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n 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.',\n seeAlso: ['/', '+', '-', '^'],\n examples: [\n '6 * 7',\n '-1 * 4',\n '*(4, 7)',\n '*(1, 2, 3, 4, 5)',\n '*()',\n '*(8)',\n '[1, 2, 3] * 2',\n '[1, 2, 3] * [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] * [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] * 2',\n ],\n },\n },\n '/': {\n evaluate: (params, sourceCodeInfo): NumberVectorOrMatrix => {\n if (params.length === 0) {\n return 1\n }\n\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n\n if (operation === 'number') {\n const [first, ...rest] = operands\n if (rest.length === 0) {\n return 1 / first!\n }\n return rest.reduce((result, param) => {\n return result / param\n }, first!)\n }\n else if (operation === 'vector') {\n const firstVector = operands[0]!\n const restVectors = operands.slice(1)\n return restVectors.reduce((acc, vector) => acc.map((val, i) => val / vector[i]!), firstVector)\n }\n else {\n const firstMatrix = operands[0]!\n const restMatrices = operands.slice(1)\n return restMatrices.reduce((acc, matrix) => acc.map((row, i) => row.map((val, j) => val / matrix[i]![j]!)), firstMatrix)\n }\n },\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n 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.',\n seeAlso: ['*', '+', '-', 'quot', 'mod', '%'],\n examples: [\n '12 / 100',\n '-1 / 4',\n '/(7, 4)',\n '/(1, 2, 4, 8)',\n '/()',\n '/(8)',\n '[1, 2, 3] / 2',\n '[1, 2, 3] / [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] / [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] / 2',\n ],\n },\n },\n '-': {\n evaluate: (params, sourceCodeInfo): NumberVectorOrMatrix => {\n if (params.length === 0) {\n return 0\n }\n\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n\n if (operation === 'number') {\n const [first, ...rest] = operands\n if (rest.length === 0)\n return -first!\n\n return rest.reduce((result, param) => {\n return result - param\n }, first!)\n }\n else if (operation === 'vector') {\n const firstVector = operands[0]!\n const restVectors = operands.slice(1)\n return restVectors.reduce((acc, vector) => acc.map((val, i) => val - vector[i]!), firstVector)\n }\n else {\n const firstMatrix = operands[0]!\n const restMatrices = operands.slice(1)\n return restMatrices.reduce((acc, matrix) => acc.map((row, i) => row.map((val, j) => val - matrix[i]![j]!)), firstMatrix)\n }\n },\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n description: 'Computes difference between first value and sum of the rest. When called with only one argument, it does negation.',\n seeAlso: ['+', '*', '/', 'dec', 'abs'],\n examples: [\n '50 - 8',\n '1 - 1 - 1',\n '-()',\n '-(4, 2)',\n '-(4, 3, 2, 1,)',\n '[1, 2, 3] - 2',\n '[1, 2, 3] - [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] - [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] - 2',\n ],\n },\n },\n 'quot': {\n evaluate: binaryMathOp((a, b) => Math.trunc(a / b)),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n 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.',\n seeAlso: ['mod', '%', '/', 'trunc'],\n examples: [\n 'quot(5, 3)',\n 'quot(5.2, 3.1)',\n 'quot(-5, 3)',\n '5 quot -3',\n '-5 quot -3',\n 'quot(5, 0)',\n 'quot(0, 5)',\n '[1, 2, 3] quot 2',\n '2 quot [1, 2, 3]',\n 'quot([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]',\n 'quot([[1, 2, 3], [4, 5, 6]], 2)',\n '[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]',\n ],\n },\n },\n 'mod': {\n evaluate: binaryMathOp((a, b) => a - b * Math.floor(a / b)),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n 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.',\n seeAlso: ['%', 'quot', '/'],\n examples: [\n 'mod(5, 3)',\n 'mod(5.2, 3.1)',\n 'mod(-5, 3)',\n '5 mod -3',\n '-5 mod -3',\n '[1, 2, 3] mod 2',\n '2 mod [1, 2, 3]',\n 'mod([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] mod [[7, 8, 9], [10, 11, 12]]',\n 'mod([[1, 2, 3], [4, 5, 6]], 2)',\n ],\n },\n },\n '%': {\n evaluate: binaryMathOp((a, b) => a % b),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n 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.',\n seeAlso: ['mod', 'quot', '/'],\n examples: [\n '5 % 3',\n '5.2 % 3.1',\n '-5 % 3',\n '%(5, -3)',\n '%(-5, -3)',\n '[1, 2, 3] % 2',\n '2 % [1, 2, 3]',\n '%([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] % [[7, 8, 9], [10, 11, 12]]',\n '%([[1, 2, 3], [4, 5, 6]], 2)',\n ],\n },\n },\n 'sqrt': {\n evaluate: unaryMathOp(val => Math.sqrt(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['cbrt', '^'],\n examples: [\n 'sqrt(0)',\n 'sqrt(9)',\n 'sqrt(2)',\n 'sqrt(0)',\n 'sqrt(9)',\n 'sqrt(2)',\n 'sqrt([1, 4, 9])',\n 'sqrt([[1, 4], [9, 16]])',\n ],\n },\n },\n 'cbrt': {\n evaluate: unaryMathOp(val => Math.cbrt(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['sqrt', '^'],\n examples: [\n 'cbrt(0)',\n 'cbrt(27)',\n 'cbrt(2)',\n 'cbrt(1)',\n 'cbrt(0)',\n 'cbrt(27)',\n 'cbrt(2)',\n 'cbrt(1)',\n 'cbrt([1, 8, 27])',\n 'cbrt([[1, 8], [27, 64]])',\n ],\n },\n },\n '^': {\n evaluate: binaryMathOp((a, b) => a ** b),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n 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.',\n seeAlso: ['sqrt', 'cbrt', '*', 'math.ln'],\n examples: [\n '2 ^ 3',\n '2 ^ 0',\n '2 ^ -3',\n '^(-2, 3)',\n '^(-2, -3)',\n '[1, 2, 3] ^ 2',\n '2 ^ [1, 2, 3]',\n '^([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] ^ [[7, 8, 9], [10, 11, 12]]',\n '^([[1, 2, 3], [4, 5, 6]], 2)',\n ],\n },\n },\n 'round': {\n evaluate: ([value, decimals], sourceCodeInfo): NumberVectorOrMatrix => {\n const [operation, operands] = getNumberVectorOrMatrixOperation([value], sourceCodeInfo)\n if (operation === 'number') {\n if (decimals === undefined || decimals === 0) {\n return Math.round(operands[0]!)\n }\n else {\n assertNumber(decimals, sourceCodeInfo, { integer: true, positive: true })\n const factor = 10 ** decimals\n return Math.round(operands[0]! * factor) / factor\n }\n }\n else if (operation === 'vector') {\n const vector = operands[0]!\n if (decimals === undefined || decimals === 0) {\n return vector.map(val => Math.round(val))\n }\n else {\n assertNumber(decimals, sourceCodeInfo, { integer: true, positive: true })\n const factor = 10 ** decimals\n return vector.map(val => Math.round(val * factor) / factor)\n }\n }\n else {\n const matrix = operands[0]!\n if (decimals === undefined || decimals === 0) {\n return matrix.map(row => row.map(val => Math.round(val)))\n }\n else {\n assertNumber(decimals, sourceCodeInfo, { integer: true, positive: true })\n const factor = 10 ** decimals\n return matrix.map(row => row.map(val => Math.round(val * factor) / factor))\n }\n }\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: 'integer' },\n },\n variants: [\n { argumentNames: ['a'] },\n { argumentNames: ['a', 'b'] },\n ],\n 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.',\n seeAlso: ['floor', 'ceil', 'trunc'],\n examples: [\n 'round(2)',\n 'round(2.49)',\n 'round(2.5)',\n 'round(-2.49)',\n 'round(-2.5)',\n 'round(-2.501)',\n 'round(1.23456789, 4)',\n '1.123456789 round 2',\n 'round([1.23456789, 2.3456789], 1)',\n '[1.23456789, 2.3456789] round 4',\n '[[1.23456789, 2.3456789], [3.456789, 4.56789]] round 4',\n 'round([[1.23456789, 2.3456789], [3.456789, 4.56789]], 2)',\n ],\n },\n },\n 'trunc': {\n evaluate: unaryMathOp(val => Math.trunc(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['integer', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['round', 'floor', 'ceil', 'quot'],\n examples: [\n 'trunc(2)',\n 'trunc(2.49)',\n 'trunc(2.5)',\n 'trunc(-2.49)',\n 'trunc(-2.5)',\n 'trunc(-2.501)',\n 'trunc([1.23456789, 2.3456789])',\n 'trunc([[1.23456789, 2.3456789], [3.456789, 4.56789]])',\n ],\n },\n },\n 'floor': {\n evaluate: unaryMathOp(val => Math.floor(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['integer', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['ceil', 'round', 'trunc'],\n examples: [\n 'floor(2)',\n 'floor(2.49)',\n 'floor(2.5)',\n 'floor(-2.49)',\n 'floor(-2.5)',\n 'floor(-2.501)',\n 'floor([1.23456789, 2.3456789])',\n 'floor([[1.23456789, 2.3456789], [3.456789, 4.56789]])',\n ],\n },\n },\n 'ceil': {\n evaluate: unaryMathOp(val => Math.ceil(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['integer', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['floor', 'round', 'trunc'],\n examples: [\n 'ceil(2)',\n 'ceil(2.49)',\n 'ceil(2.5)',\n 'ceil(-2.49)',\n 'ceil(-2.5)',\n 'ceil(-2.501)',\n 'ceil([1.23456789, 2.3456789])',\n 'ceil([[1.23456789, 2.3456789], [3.456789, 4.56789]])',\n ],\n },\n },\n 'min': {\n evaluate: (params, sourceCodeInfo): number => {\n if (params.length === 1 && isVector(params[0])) {\n const vector = params[0]\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((m, val) => Math.min(m, val), Infinity)\n }\n const [first, ...rest] = params\n assertNumber(first, sourceCodeInfo)\n return rest.reduce((m: number, value) => {\n assertNumber(value, sourceCodeInfo)\n return Math.min(m, value)\n }, first)\n },\n arity: { min: 1 },\n docs: {\n category: 'math',\n returns: { type: 'number' },\n args: {\n a: { type: 'number' },\n b: { type: 'number' },\n xs: { type: 'number', rest: true },\n vector: { type: 'vector' },\n },\n variants: [\n { argumentNames: ['xs'] },\n { argumentNames: ['vector'] },\n ],\n description: 'Returns the smallest value. Accepts either multiple numbers or a single vector of numbers.',\n seeAlso: ['max', 'vector.span', 'vector.min-index'],\n examples: [\n '2 min 3',\n 'min(2, 0, 1)',\n 'min(2, -1, 1)',\n 'min([2, 0, -1])',\n '12 min 14',\n ],\n },\n },\n 'max': {\n evaluate: (params, sourceCodeInfo): number => {\n if (params.length === 1 && isVector(params[0])) {\n const vector = params[0]\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((m, val) => Math.max(m, val), -Infinity)\n }\n const [first, ...rest] = params\n assertNumber(first, sourceCodeInfo)\n return rest.reduce((m: number, value) => {\n assertNumber(value, sourceCodeInfo)\n return Math.max(m, value)\n }, first)\n },\n arity: { min: 1 },\n docs: {\n category: 'math',\n returns: { type: 'number' },\n args: {\n a: { type: 'number' },\n b: { type: 'number' },\n xs: { type: 'number', rest: true },\n vector: { type: 'vector' },\n },\n variants: [\n { argumentNames: ['xs'] },\n { argumentNames: ['vector'] },\n ],\n description: 'Returns the largest value. Accepts either multiple numbers or a single vector of numbers.',\n seeAlso: ['min', 'vector.span', 'vector.max-index'],\n examples: [\n '2 max 3',\n 'max(2, 0, 1)',\n 'max(2, -1, 1)',\n 'max([2, 0, -1])',\n '4 max 2',\n ],\n },\n },\n 'abs': {\n evaluate: unaryMathOp(val => Math.abs(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['sign', '-'],\n examples: [\n 'abs(-2.3)',\n 'abs(0)',\n 'abs(2.5)',\n 'abs([1, -2, 3])',\n 'abs([[1, -2], [3, -4]])',\n ],\n },\n },\n 'sign': {\n evaluate: unaryMathOp(val => Math.sign(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['abs'],\n examples: [\n 'sign(-2.3)',\n 'sign(-0)',\n 'sign(0)',\n 'sign(12312)',\n 'sign([1, -2, 3])',\n 'sign([[1, -2], [3, -4]])',\n ],\n },\n },\n}\n","import type { Any } from '../../interface'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { asAny, assertAny } from '../../typeGuards/dvala'\nimport { assertNumber } from '../../typeGuards/number'\nimport { asStringOrNumber, assertString, assertStringOrNumber } from '../../typeGuards/string'\nimport { compare, deepEqual } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nfunction isEqual([first, ...rest]: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) {\n const firstAny = asAny(first, sourceCodeInfo)\n for (const param of rest) {\n if (!deepEqual(firstAny, asAny(param, sourceCodeInfo), sourceCodeInfo))\n return false\n }\n return true\n}\n\nfunction isIdentical([first, ...rest]: unknown[]) {\n for (const param of rest) {\n if (param !== first)\n return false\n }\n return true\n}\n\nexport const miscNormalExpression: BuiltinNormalExpressions = {\n '==': {\n evaluate: (params, sourceCodeInfo): boolean => {\n return isEqual(params, sourceCodeInfo)\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n x: { type: 'any' },\n ys: { type: 'any', rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if all `values` are structaul equal to each other, otherwise result is `false`.',\n seeAlso: ['!=', 'identical?'],\n examples: [\n '1 == 1',\n '[1, 2] == [1, 2]',\n `\n{\n a: 1,\n b: 2,\n} == {\n b: 2,\n a: 1,\n}`,\n '==(1, 1)',\n '==(1.01, 1)',\n '==(\"1\", 1)',\n '==(\"2\", \"2\", \"2\", \"2\")',\n '==(2, 2, 1, 2)',\n '==([1, 2], [1, 2])',\n '==({ a: 1, b: 2 }, { b: 2, a: 1 })',\n ],\n },\n },\n '!=': {\n evaluate: (params, sourceCodeInfo): boolean => {\n return !isEqual(params, sourceCodeInfo)\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n x: { type: 'any' },\n ys: { type: 'any', rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if all `values` are not equal to each other, otherwise result is `false`. `(!= a b c)` is same as `(not (== a b c))`.',\n seeAlso: ['==', 'identical?'],\n examples: [\n '1 != 2',\n '3 != 3',\n '!=(3)',\n '!=(3, 3, 2)',\n '!=(\"3\", \"2\", \"1\", \"0\",)',\n '!=(0, -0)',\n ],\n },\n },\n 'identical?': {\n evaluate: (params): boolean => {\n return isIdentical(params)\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns true if $a and $b are referential equal.',\n seeAlso: ['==', '!='],\n examples: [\n 'identical?({ a: 10, b: 20 }, { b: 20, a: 10 })',\n 'identical?([1, true, null], [1, true, null])',\n 'identical?(0.3, 0.1 + 0.2)',\n ],\n },\n },\n '>': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) <= 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in decreasing order, `false` otherwise.',\n seeAlso: ['<', '>=', '<=', 'compare'],\n examples: [\n '>(1, 0)',\n '>(1.01, 1)',\n '>(1, 1)',\n '>(4, 3, 2, 1)',\n '>(3, 2, 2, 1)',\n ],\n },\n },\n\n '<': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) >= 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in increasing order, `false` otherwise.',\n seeAlso: ['>', '>=', '<=', 'compare'],\n examples: [\n '<(0, 1)',\n '<(1, 1.01)',\n '<(1, 1)',\n '<(1, 2, 2, 3)',\n '<(\"a\", \"b\")',\n ],\n },\n },\n '>=': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) < 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in non increasing order, `false` otherwise.',\n seeAlso: ['>', '<', '<=', 'compare'],\n examples: [\n '1 >= 1',\n '0 >= 1',\n '>=(1, 0)',\n '>=(1.01, 1)',\n '>=(1, 1)',\n '>=(4, 3, 2, 1)',\n '>=(3, 2, 2, 1)',\n ],\n },\n },\n '<=': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) > 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in non decreasing order, `false` otherwise.',\n seeAlso: ['>', '<', '>=', 'compare'],\n examples: [\n '1 <= 1',\n '<=(0, 1)',\n '<=(1, 1.01)',\n '<=(1, 1)',\n '<=(1, 2, 3, 4)',\n '<=(1, 2, 2, 3)',\n ],\n },\n },\n 'not': {\n evaluate: ([first]): boolean => !first,\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Computes logical negation. Note that any other $x than `false`, `0`, `null` and `\\'\\'` is truthy.',\n seeAlso: ['boolean'],\n examples: [\n 'not(3)',\n 'not(true)',\n 'not(\"A string\")',\n 'not(0)',\n 'not(false)',\n 'not(null)',\n 'not(\"\")',\n ],\n },\n },\n 'epoch->iso-date': {\n evaluate: ([ms], sourceCodeInfo): string => {\n assertNumber(ms, sourceCodeInfo)\n return new Date(ms).toISOString()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'string' },\n args: { ms: { type: 'number' } },\n variants: [{ argumentNames: ['ms'] }],\n description: 'Returns IOS date time string from `ms` (milliseconds elapsed since the UNIX epoch).',\n seeAlso: ['iso-date->epoch'],\n examples: [\n 'epoch->iso-date(1649756230899)',\n 'epoch->iso-date(0)',\n ],\n },\n },\n 'iso-date->epoch': {\n evaluate: ([dateTime], sourceCodeInfo): number => {\n assertString(dateTime, sourceCodeInfo)\n const ms = new Date(dateTime).valueOf()\n assertNumber(ms, sourceCodeInfo, { finite: true })\n return ms\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'number' },\n args: { iso: { type: 'string' } },\n variants: [{ argumentNames: ['iso'] }],\n description: 'Returns milliseconds elapsed since the UNIX epoch to `iso`.',\n seeAlso: ['epoch->iso-date'],\n examples: [\n 'iso-date->epoch(\"2022-04-12T09:37:10.899Z\")',\n 'iso-date->epoch(\"1980-01-01\")',\n ],\n },\n },\n 'write!': {\n evaluate: (params, sourceCodeInfo): Any => {\n // eslint-disable-next-line no-console\n console.log(...params)\n\n if (params.length > 0)\n return asAny(params[params.length - 1], sourceCodeInfo)\n\n return null\n },\n pure: false,\n arity: {},\n docs: {\n category: 'misc',\n returns: { type: 'any' },\n args: { values: { type: 'any', rest: true } },\n variants: [{ argumentNames: ['values'] }],\n description: 'It logs the $values and then returns the last argument. If called with no arguments `null` is returned.',\n examples: [\n 'write!(\"A string\")',\n 'write!(100, \"items\")',\n 'write!(object(\"a\", 10))',\n 'write!([\"a\", \"b\", \"c\"])',\n 'write!(#\"^start\")',\n 'write!(null, true, false)',\n ],\n hideOperatorForm: true,\n },\n },\n 'boolean': {\n evaluate: ([value]): boolean => {\n return !!value\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Coerces $x to boolean.',\n seeAlso: ['not', 'boolean?', 'true?', 'false?'],\n examples: [\n 'boolean(0)',\n 'boolean(1)',\n 'boolean(null)',\n 'boolean(\"Albert\")',\n ],\n },\n },\n 'compare': {\n evaluate: ([a, b], sourceCodeInfo): number => {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n return compare(a, b, sourceCodeInfo)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'misc',\n returns: { type: 'number' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Compares two values. Returns `-1` if $a < $b, `1` if $a > $b and `0` if $a and $b have the same sort order.',\n seeAlso: ['<', '>', '<=', '>=', 'sort', 'sequence.sort-by'],\n examples: [\n 'compare(0, 1)',\n 'compare(0, 0)',\n 'compare(1, 0)',\n 'compare(\"Albert\", \"Mojir\")',\n ],\n },\n },\n 'json-parse': {\n evaluate: ([first], sourceCodeInfo): Any => {\n assertString(first, sourceCodeInfo)\n // eslint-disable-next-line ts/no-unsafe-return\n return JSON.parse(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'any' },\n args: { x: { type: 'string' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `JSON.parse(`$x`)`.',\n seeAlso: ['json-stringify'],\n examples: [\n 'json-parse(\"[1, 2, 3]\")',\n ],\n },\n },\n 'json-stringify': {\n evaluate: ([first, second], sourceCodeInfo): string => {\n assertAny(first, sourceCodeInfo)\n if (second === undefined)\n return JSON.stringify(first)\n\n assertNumber(second, sourceCodeInfo)\n return JSON.stringify(first, null, second)\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'misc',\n returns: { type: 'string' },\n args: {\n x: { type: 'any' },\n indent: { type: 'integer', description: 'Number of spaces to use for indentation.' },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'indent'] },\n ],\n description: 'Returns `JSON.stringify(`$x`)`. If second argument is provided, returns `JSON.stringify(`$x`, null, `$indent`)`.',\n seeAlso: ['json-parse'],\n examples: [\n 'json-stringify([1, 2, 3])',\n 'json-stringify({ a: { b: 10 }}, 2)',\n ],\n hideOperatorForm: true,\n },\n },\n}\n","import type { Any, Arr, Obj } from '../../interface'\nimport { assertArray, assertStringArray } from '../../typeGuards/array'\nimport { assertFunctionLike, assertObj } from '../../typeGuards/dvala'\nimport { asString, assertString } from '../../typeGuards/string'\nimport { collHasKey, toAny } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain, reduceSequential } from '../../utils/maybePromise'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const objectNormalExpression: BuiltinNormalExpressions = {\n 'keys': {\n evaluate: ([obj], sourceCodeInfo): string[] => {\n assertObj(obj, sourceCodeInfo)\n return Object.keys(obj)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'object',\n returns: { type: 'any', array: true },\n args: { obj: { type: 'object' } },\n variants: [{ argumentNames: ['obj'] }],\n description: 'Returns array of all keys in $obj.',\n seeAlso: ['vals', 'entries', 'zipmap', 'select-keys'],\n examples: [\n 'keys({})',\n 'keys({ x: 10, y: true, z: \"A string\" })',\n 'keys(object(\"x\", 10, \"y\", true, \"z\", \"A string\"))',\n ],\n },\n },\n\n 'vals': {\n evaluate: ([obj], sourceCodeInfo): Arr => {\n assertObj(obj, sourceCodeInfo)\n return Object.values(obj)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'object',\n returns: { type: 'any', array: true },\n args: { obj: { type: 'object' } },\n variants: [{ argumentNames: ['obj'] }],\n description: 'Returns array of all values in $obj.',\n seeAlso: ['keys', 'entries', 'zipmap'],\n examples: [\n 'vals({})',\n 'vals({ x: 10, y: true, z: \"A string\" })',\n 'vals(object(\"x\", 10, \"y\", true, \"z\", \"A string\"))',\n ],\n },\n },\n\n 'entries': {\n evaluate: ([obj], sourceCodeInfo): Array<[string, unknown]> => {\n assertObj(obj, sourceCodeInfo)\n return Object.entries(obj)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'object',\n returns: { type: 'array' },\n args: { obj: { type: 'object' } },\n variants: [{ argumentNames: ['obj'] }],\n description: 'Returns nested array of all key - value pairs in $obj.',\n seeAlso: ['keys', 'vals', 'zipmap', 'find'],\n examples: [\n 'entries({})',\n 'entries({ x: 10, y: true, z: \"A string\" })',\n 'entries(object(\"x\", 10, \"y\", true, \"z\", \"A string\"))',\n ],\n },\n },\n\n 'find': {\n evaluate: ([obj, key], sourceCodeInfo): [string, unknown] | null => {\n assertObj(obj, sourceCodeInfo)\n assertString(key, sourceCodeInfo)\n if (collHasKey(obj, key))\n return [key, obj[key]]\n\n return null\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: ['array', 'null'] },\n args: {\n a: { type: 'object' },\n b: { type: 'string' },\n obj: { type: 'object' },\n key: { type: 'string' },\n },\n variants: [{ argumentNames: ['obj', 'key'] }],\n description: 'Returns entry (key-value pair) for $key, or `null` if $key not present in $obj.',\n seeAlso: ['get', 'contains?', 'entries', 'sequence.position', 'some'],\n examples: [\n '{ a: 1, \"b\": 2 } find \"a\"',\n 'find(object(\"a\", 1, \"b\", 2), \"b\")',\n 'find(object(\"a\", 1, \"b\", 2), \"c\")',\n ],\n },\n },\n\n 'dissoc': {\n evaluate: ([obj, key], sourceCodeInfo): Any => {\n assertObj(obj, sourceCodeInfo)\n assertString(key, sourceCodeInfo)\n const newObj = { ...obj }\n delete newObj[key]\n return newObj\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'object' },\n b: { type: 'string' },\n obj: { type: 'object' },\n key: { type: 'string' },\n },\n variants: [{ argumentNames: ['obj', 'key'] }],\n description: 'Return shallow copy of $obj with $key deleted.',\n seeAlso: ['assoc', 'select-keys'],\n examples: [\n '{ x: 10, y: 20 } dissoc \"y\"',\n 'dissoc({ x: 10, y: 20 }, \"x\")',\n 'dissoc({ x: 10 }, \"y\")',\n `\nlet o = { a: 5 };\ndissoc(o, \"a\");\no`,\n ],\n },\n },\n\n 'merge': {\n evaluate: (params, sourceCodeInfo): Any => {\n if (params.length === 0)\n return null\n\n const [first, ...rest] = params\n assertObj(first, sourceCodeInfo)\n\n return rest.reduce(\n (result: Obj, obj) => {\n assertObj(obj, sourceCodeInfo)\n return { ...result, ...obj }\n },\n { ...first },\n )\n },\n arity: { min: 0 },\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'object' },\n b: { type: 'object' },\n objs: { type: 'object', rest: true },\n },\n variants: [{ argumentNames: ['objs'] }],\n 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.`,\n seeAlso: ['merge-with', 'assoc'],\n examples: [\n '{ x: 10 } merge { y: 20 }',\n 'merge(object(\"x\", 10), object(\"y\", 20))',\n 'merge(object(\"x\", 10), object(\"x\", 15, \"y\", 20))',\n ],\n },\n },\n\n 'merge-with': {\n evaluate: (params: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n const first = params[0]\n const fn = params.at(-1)\n const rest = params.slice(1, -1)\n\n assertObj(first, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n return reduceSequential(\n rest,\n (result: Obj, obj) => {\n assertObj(obj, sourceCodeInfo)\n const entries = Object.entries(obj)\n return chain(\n reduceSequential(\n entries,\n (res: Obj, entry) => {\n const key = asString(entry[0], sourceCodeInfo)\n const val = toAny(entry[1])\n if (collHasKey(res, key)) {\n return chain(executeFunction(fn, [res[key], val], contextStack, sourceCodeInfo), (merged) => {\n res[key] = merged\n return res\n })\n }\n else {\n res[key] = val\n return res\n }\n },\n result,\n ),\n r => r,\n )\n },\n { ...first } satisfies Obj,\n )\n },\n arity: { min: 2 },\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n objs: { type: 'object', rest: true },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['objs', 'fun'] }],\n 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.`,\n seeAlso: ['merge'],\n examples: [\n 'merge-with(object(\"x\", 10), object(\"y\", 20), +)',\n 'merge-with(object(\"x\", 10), object(\"x\", 15, \"y\", 20), +)',\n 'merge-with({ x: 10 }, { x: 20 }, { x: 30 }, { x: 40 }, -)',\n ],\n hideOperatorForm: true,\n },\n },\n\n 'zipmap': {\n evaluate: ([keys, values], sourceCodeInfo): Any => {\n assertStringArray(keys, sourceCodeInfo)\n assertArray(values, sourceCodeInfo)\n\n const length = Math.min(keys.length, values.length)\n\n const result: Obj = {}\n\n for (let i = 0; i < length; i += 1) {\n const key = asString(keys[i], sourceCodeInfo)\n result[key] = toAny(values[i])\n }\n return result\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'array' },\n b: { type: 'array' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns a new object created by mapping $a to $b.',\n seeAlso: ['entries', 'keys', 'vals', 'sequence.interleave'],\n examples: [\n '[\"a\", \"b\", \"c\"] zipmap [1, 2, 3]',\n 'zipmap([\"a\", \"b\", \"c\"], [10, null, [1, 2, 3]])',\n 'zipmap([\"a\", \"b\", \"c\"], [1])',\n 'zipmap([], [10, null, [1, 2, 3]])',\n ],\n },\n },\n\n 'select-keys': {\n evaluate: ([obj, keys], sourceCodeInfo): Any => {\n assertStringArray(keys, sourceCodeInfo)\n assertObj(obj, sourceCodeInfo)\n\n return keys.reduce((result: Obj, key) => {\n if (collHasKey(obj, key))\n result[key] = toAny(obj[key])\n\n return result\n }, {})\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'object' },\n b: { type: 'array' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns an object containing only those entries in $a whose key is in $b.',\n seeAlso: ['dissoc', 'keys'],\n examples: [\n '{ a: 1, b: 2, c: 3 } select-keys [\"a\", \"b\"]',\n 'select-keys({ a: 1, b: 2, c: 3 }, [\"a\", \"b\"])',\n 'select-keys({ a: 1 }, [\"a\", \"b\"])',\n ],\n },\n },\n}\n","import { isDvalaFunction } from '../../typeGuards/dvalaFunction'\nimport { assertColl, isColl, isObj, isRegularExpression, isSeq } from '../../typeGuards/dvala'\nimport { assertNumber, isNumber } from '../../typeGuards/number'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { isGrid, isMatrix, isVector } from '../../typeGuards/annotatedArrays'\nimport { EPSILON } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\n\nexport const predicatesNormalExpression: BuiltinNormalExpressions = {\n 'function?': {\n evaluate: ([first]): boolean => isDvalaFunction(first),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a function, otherwise `false`.',\n seeAlso: ['string?', 'number?', 'boolean?', 'null?', 'array?', 'object?', 'regexp?'],\n examples: [\n 'function?(+)',\n 'function?(/)',\n 'function?((x, y) -> x + y)',\n 'function?(false)',\n 'function?(\"false\")',\n 'function?([1, 2, 3])',\n ],\n },\n },\n\n 'string?': {\n evaluate: ([first]): boolean => typeof first === 'string',\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a string, otherwise `false`.',\n seeAlso: ['blank?', 'number?', 'boolean?', 'null?', 'array?', 'object?', 'regexp?', 'function?', 'collection?', 'sequence?'],\n examples: [\n 'string?(\"\")',\n 'string?(\"A string\")',\n 'string?(true ? \"A string\" : false)',\n 'string?(false)',\n 'string?([1, 2, 3])',\n 'string?(100)',\n ],\n },\n },\n\n 'number?': {\n evaluate: ([first]): boolean => typeof first === 'number',\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a number, otherwise `false`.',\n seeAlso: ['integer?', 'zero?', 'pos?', 'neg?', 'finite?', 'number', 'string?', 'boolean?', 'null?', 'function?'],\n examples: [\n 'number?(0)',\n 'number?(2)',\n 'number?(-0.12)',\n 'number?(false)',\n 'number?([1, 2, 3])',\n 'number?(\"A string\")',\n ],\n },\n },\n\n 'integer?': {\n evaluate: ([first]): boolean => typeof first === 'number' && isNumber(first, { integer: true }),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is an integer, otherwise `false`.',\n seeAlso: ['number?', 'number', 'even?', 'odd?'],\n examples: [\n 'integer?(0)',\n 'integer?(-12)',\n 'integer?(42)',\n 'integer?(10.1)',\n 'integer?((x, y) -> x + y)',\n 'integer?(false)',\n 'integer?(\"false\")',\n 'integer?([1, 2, 3])',\n ],\n },\n },\n\n 'boolean?': {\n evaluate: ([first]): boolean => typeof first === 'boolean',\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a `boolean`, otherwise `false`.',\n seeAlso: ['true?', 'false?', 'boolean', 'string?', 'number?', 'null?', 'function?'],\n examples: [\n 'boolean?(true)',\n 'boolean?(false)',\n 'boolean?([1, 2, 3])',\n 'boolean?(0)',\n 'boolean?(\"A string\")',\n ],\n },\n },\n\n 'null?': {\n evaluate: ([first]): boolean => first === null || first === undefined,\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `null`, otherwise `false`.',\n seeAlso: ['empty?', 'not-empty?', 'string?', 'number?', 'boolean?', 'function?'],\n examples: [\n 'null?(null)',\n 'null?(false)',\n 'null?([1, 2, 3])',\n 'null?(0)',\n 'null?(\"A string\")',\n ],\n },\n },\n\n 'zero?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo, { finite: true })\n return Math.abs(value) < EPSILON\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `0`, otherwise `false`.',\n seeAlso: ['pos?', 'neg?', 'even?', 'number?'],\n examples: [\n 'zero?(0)',\n 'zero?(-0.0)',\n 'zero?(1)',\n 'zero?(0.1)',\n ],\n },\n },\n\n 'pos?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return first > 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is greater than `0`, otherwise `false`.',\n seeAlso: ['neg?', 'zero?', 'number?'],\n examples: [\n 'pos?(0)',\n 'pos?(-0.0)',\n 'pos?(1)',\n 'pos?(-0.1)',\n ],\n },\n },\n\n 'neg?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return first < 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is less than `0`, otherwise `false`.',\n seeAlso: ['pos?', 'zero?', 'number?'],\n examples: [\n 'neg?(0)',\n 'neg?(-0.0)',\n 'neg?(1)',\n 'neg?(-0.1)',\n ],\n },\n },\n\n 'even?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return first % 2 === 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is even, otherwise `false`.',\n seeAlso: ['odd?', 'integer?', 'zero?'],\n examples: [\n 'even?(0)',\n 'even?(-0.0)',\n 'even?(-1)',\n 'even?(2.1)',\n ],\n },\n },\n\n 'odd?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return isNumber(first, { integer: true }) && first % 2 !== 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is odd, otherwise `false`.',\n seeAlso: ['even?', 'integer?'],\n examples: [\n 'odd?(1.0)',\n 'odd?(1.001)',\n 'odd?(-1)',\n 'odd?(2.1)',\n ],\n },\n },\n\n 'array?': {\n evaluate: ([first]): boolean => {\n return Array.isArray(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is an array, otherwise `false`.',\n seeAlso: ['sequence?', 'collection?', 'object?', 'string?', 'vector?', 'matrix?', 'grid?', 'function?'],\n examples: [\n 'array?([])',\n 'array?([1, 2, 3])',\n 'array?(object(\"a\", 10))',\n 'array?(42)',\n 'array?(10.1)',\n 'array?((x, y) -> x + y)',\n ],\n },\n },\n\n 'collection?': {\n evaluate: ([first]): boolean => {\n return isColl(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a collection i.e. an array, an object or a string, otherwise `false`.',\n seeAlso: ['sequence?', 'array?', 'object?', 'string?'],\n examples: [\n 'collection?([])',\n 'collection?([1, 2, 3])',\n 'collection?(object(\"a\", 10))',\n 'collection?(\"Albert\")',\n 'collection?(42)',\n 'collection?(10.1)',\n 'collection?((x, y) -> x + y)',\n ],\n },\n },\n\n 'sequence?': {\n evaluate: ([first]): boolean => {\n return isSeq(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a sequence i.e. an array or a string, otherwise `false`.',\n seeAlso: ['collection?', 'array?', 'string?'],\n examples: [\n 'sequence?([])',\n 'sequence?([1, 2, 3])',\n 'sequence?(object(\"a\", 10))',\n 'sequence?(\"Albert\")',\n 'sequence?(42)',\n 'sequence?(10.1)',\n 'sequence?((x, y) -> x + y)',\n ],\n },\n },\n\n 'object?': {\n evaluate: ([first]): boolean => isObj(first),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is an object, otherwise `false`.',\n seeAlso: ['collection?', 'array?', 'string?', 'function?'],\n examples: [\n 'object?(object(\"a\", 10))',\n 'object?(42)',\n 'object?(10.1)',\n 'object?((x, y) -> x + y)',\n 'object?(#\"^start\")',\n 'object?(\"false\")',\n 'object?([1, 2, 3])',\n ],\n },\n },\n\n 'regexp?': {\n evaluate: ([value]): boolean => isRegularExpression(value),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a regexp, otherwise `false`.',\n seeAlso: ['regexp', 're-match', 'string?', 'function?'],\n examples: [\n 'regexp?(regexp(\"^start\"))',\n 'regexp?(#\"^start\")',\n 'regexp?(-12)',\n 'regexp?({})',\n 'regexp?(10.1)',\n 'regexp?((x, y) -> x + y)',\n 'regexp?(false)',\n 'regexp?(\"false\")',\n 'regexp?([1, 2, 3])',\n ],\n },\n },\n\n 'finite?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo)\n return Number.isFinite(value)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is finite, otherwise `false`.',\n seeAlso: ['positive-infinity?', 'negative-infinity?', 'number?'],\n examples: [\n 'finite?(1.0)',\n 'finite?(1 / 0)',\n 'finite?(-1 / 0)',\n ],\n },\n },\n\n 'positive-infinity?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo)\n return value === Number.POSITIVE_INFINITY\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x equals positive infinity, otherwise `false`.',\n seeAlso: ['negative-infinity?', 'finite?'],\n examples: [\n 'positive-infinity?(1.0)',\n 'positive-infinity?(1 / 0)',\n 'positive-infinity?(-1 / 0)',\n ],\n },\n },\n\n 'negative-infinity?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo)\n return value === Number.NEGATIVE_INFINITY\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x equals negative infinity, otherwise `false`.',\n seeAlso: ['positive-infinity?', 'finite?'],\n examples: [\n 'negative-infinity?(1.0)',\n 'negative-infinity?(1 / 0)',\n 'negative-infinity?(-1 / 0)',\n ],\n },\n },\n\n 'true?': {\n evaluate: ([value]): boolean => {\n return value === true\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `true`, otherwise `false`.',\n seeAlso: ['false?', 'boolean?', 'boolean'],\n examples: [\n 'true?(false)',\n 'true?(true)',\n 'true?(1)',\n 'true?(0)',\n ],\n },\n },\n\n 'false?': {\n evaluate: ([value]): boolean => {\n return value === false\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `true`, otherwise `false`.',\n seeAlso: ['true?', 'boolean?', 'boolean'],\n examples: [\n 'false?(false)',\n 'false?(true)',\n 'false?(1)',\n 'false?(0)',\n ],\n },\n },\n\n 'empty?': {\n evaluate: ([coll], sourceCodeInfo): boolean => {\n if (coll === null)\n return true\n\n assertColl(coll, sourceCodeInfo)\n if (typeof coll === 'string')\n return coll.length === 0\n\n if (Array.isArray(coll))\n return coll.length === 0\n\n return Object.keys(coll).length === 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: ['collection', 'string', 'null'] } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is empty or `null`, otherwise `false`.',\n seeAlso: ['not-empty?', 'collection.not-empty', 'null?', 'blank?', 'count'],\n examples: [\n 'empty?([])',\n 'empty?([1, 2, 3])',\n 'empty?({})',\n 'empty?({ a: 2 })',\n 'empty?(\"\")',\n 'empty?(\"Albert\")',\n 'empty?(null)',\n ],\n },\n },\n 'not-empty?': {\n evaluate: ([coll], sourceCodeInfo): boolean => {\n if (coll === null)\n return false\n\n assertColl(coll, sourceCodeInfo)\n if (typeof coll === 'string')\n return coll.length > 0\n\n if (Array.isArray(coll))\n return coll.length > 0\n\n return Object.keys(coll).length > 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: ['collection', 'string', 'null'] } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `false` if $x is empty or `null`, otherwise `true`.',\n seeAlso: ['empty?', 'collection.not-empty', 'null?'],\n examples: [\n 'not-empty?([])',\n 'not-empty?([1, 2, 3])',\n 'not-empty?({})',\n 'not-empty?({ a: 2 })',\n 'not-empty?(\"\")',\n 'not-empty?(\"Albert\")',\n 'not-empty?(null)',\n ],\n },\n },\n 'vector?': {\n evaluate: ([vector]): boolean => isVector(vector),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n description: 'Checks if a value is a `vector`. A `vector` is an array of `numbers`.',\n seeAlso: ['matrix?', 'grid?', 'array?'],\n returns: { type: 'boolean' },\n args: { value: { type: 'any', description: 'The value to check.' } },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'vector?(1)',\n 'vector?([1, 2, 3])',\n 'vector?([1, 2, \"3\"])',\n ],\n },\n },\n 'matrix?': {\n evaluate: ([matrix]): boolean => isMatrix(matrix),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n description: 'Checks if a value is a `matrix`. A `matrix` is an array of arrays of `numbers`.',\n seeAlso: ['vector?', 'grid?', 'array?'],\n returns: { type: 'boolean' },\n args: { value: { type: 'any', description: 'The value to check.' } },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'matrix?(1)',\n 'matrix?([1, 2, 3])',\n 'matrix?([[1, 2], [3, 4]])',\n 'matrix?([[1, 2], [3, \"4\"]])',\n 'matrix?([[1, 2], [3]])',\n ],\n },\n },\n 'grid?': {\n evaluate: ([table]): boolean => isGrid(table),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n description: 'Checks if a `value` is a `grid`. A `grid` is an `array` of `arrays` where all inner `arrays` have the same length.',\n seeAlso: ['vector?', 'matrix?', 'array?'],\n returns: { type: 'boolean' },\n args: { value: { type: 'any', description: 'The value to check.' } },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'grid?(\"1\")',\n 'grid?([\"1\", 2, 3])',\n 'grid?([[\"1\", 2], [3, 4]])',\n 'grid?([[\"1\", 2], [3, \"4\"]])',\n 'grid?([[\"1\", 2], [3]])',\n ],\n },\n },\n\n}\n","import { DvalaError } from '../../errors'\nimport type { RegularExpression } from '../../parser/types'\nimport { assertRegularExpression, assertStringOrRegularExpression, isRegularExpression } from '../../typeGuards/dvala'\nimport { assertString, isString } from '../../typeGuards/string'\nimport { toFixedArity } from '../../utils/arity'\nimport { REGEXP_SYMBOL } from '../../utils/symbols'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const regexpNormalExpression: BuiltinNormalExpressions = {\n 'regexp': {\n evaluate: ([sourceArg, flagsArg], sourceCodeInfo): RegularExpression => {\n assertString(sourceArg, sourceCodeInfo)\n const source = sourceArg || '(?:)'\n const flags = typeof flagsArg === 'string' ? flagsArg : ''\n\n try {\n // eslint-disable-next-line no-new\n new RegExp(source, flags) // Throws if invalid regexp\n }\n catch (e) {\n throw new DvalaError(`Invalid regular expression: ${source} ${flags}`, sourceCodeInfo)\n }\n return {\n [REGEXP_SYMBOL]: true,\n sourceCodeInfo,\n s: source,\n f: flags,\n }\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'regular-expression',\n returns: { type: 'regexp' },\n args: {\n pattern: { type: 'string' },\n flags: { type: 'string', description: 'Optional flags for the regular expression. Possible values are the same as Javascript RegExp takes.' },\n },\n variants: [\n { argumentNames: ['pattern'] },\n { argumentNames: ['pattern', 'flags'] },\n ],\n description: 'Creates a RegExp from $pattern and $flags.',\n examples: [\n 'regexp(\"^\\\\s*(.*)$\")',\n '#\"^\\\\s*(.*)$\"',\n 'regexp(\"albert\", \"ig\")',\n '#\"albert\"ig',\n ],\n seeAlso: ['-short-regexp', 're-match', 'replace', 'replace-all', 'regexp?'],\n hideOperatorForm: true,\n },\n },\n 're-match': {\n evaluate: ([text, regexp], sourceCodeInfo): string[] | null => {\n assertRegularExpression(regexp, sourceCodeInfo)\n if (!isString(text))\n return null\n\n const regExp = new RegExp(regexp.s, regexp.f)\n const match = regExp.exec(text)\n if (match)\n return [...match]\n\n return null\n },\n arity: toFixedArity(2),\n docs: {\n category: 'regular-expression',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'regexp' },\n b: { type: 'string' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: `Matches $b against regular expression $a.\nIf $b is a string and matches the regular expression, a \\`re-match\\`-array is returned, otherwise \\`null\\` is returned.`,\n seeAlso: ['regexp', 'replace', 'replace-all', '-short-regexp', 'regexp?'],\n examples: [\n 're-match(\" A string\", regexp(\"^\\\\\\\\s*(.*)$\"))',\n 're-match(\" A string\", #\"^\\\\s*(.*)$\")',\n 're-match(\"My name is Albert\", #\"albert\"i)',\n 're-match(\"My name is Ben\", #\"albert\"i)',\n 're-match(null, #\"albert\"i)',\n 're-match(1, #\"albert\"i)',\n 're-match({}, #\"albert\"i)',\n ],\n },\n },\n 'replace': {\n evaluate: ([str, regexp, value], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n assertStringOrRegularExpression(regexp, sourceCodeInfo)\n assertString(value, sourceCodeInfo)\n\n const matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, `${regexp.f}`) : regexp\n return str.replace(matcher, value)\n },\n arity: toFixedArity(3),\n docs: {\n category: 'regular-expression',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'string' },\n b: { type: ['regexp', 'string'] },\n x: { type: 'string' },\n },\n variants: [{ argumentNames: ['a', 'b', 'x'] }],\n description: 'Returns a new string with first match of regular expression $b replaced by $x.',\n seeAlso: ['replace-all', 'regexp', 're-match', '-short-regexp'],\n examples: [\n 'replace(\"Duck duck\", \"u\", \"i\")',\n 'replace(\"Duck duck\", #\"u\", \"i\")',\n 'replace(\"abcABC\", regexp(\"a\", \"i\"), \"-\")',\n 'replace(\"abcABC\", regexp(\"a\", \"gi\"), \"-\")',\n 'replace(\"abcABC\", #\"a\"i, \"-\")',\n 'replace(\"abcABC\", #\"a\"gi, \"-\")',\n ],\n },\n },\n 'replace-all': {\n evaluate: ([str, regexp, value], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n assertStringOrRegularExpression(regexp, sourceCodeInfo)\n assertString(value, sourceCodeInfo)\n const matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, `${regexp.f.includes('g') ? regexp.f : `${regexp.f}g`}`) : regexp\n return str.replaceAll(matcher, value)\n },\n arity: toFixedArity(3),\n docs: {\n category: 'regular-expression',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'string' },\n b: { type: ['regexp', 'string'] },\n x: { type: 'string' },\n },\n variants: [{ argumentNames: ['a', 'b', 'x'] }],\n description: 'Returns a new string with all matches of regular expression $b replaced by $x.',\n seeAlso: ['replace', 'regexp', 're-match', '-short-regexp'],\n examples: [\n 'replace-all(\"Duck duck\", \"u\", \"i\")',\n 'replace-all(\"Duck duck\", regexp(\"u\"), \"i\")',\n 'replace-all(\"abcABC\", regexp(\"a\", \"i\"), \"-\")',\n 'replace-all(\"abcABC\", regexp(\"a\", \"gi\"), \"-\")',\n 'replace-all(\"abcABC\", #\"a\"i, \"-\")',\n 'replace-all(\"abcABC\", #\"a\"gi, \"-\")',\n ],\n },\n },\n}\n","import { DvalaError } from '../../errors'\nimport type { Arr } from '../../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { assertStringOrRegularExpression, isObj } from '../../typeGuards/dvala'\nimport { assertNumber } from '../../typeGuards/number'\nimport { assertString, assertStringOrNumber } from '../../typeGuards/string'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nconst blankRegexp = /^\\s*$/\nexport const stringNormalExpression: BuiltinNormalExpressions = {\n 'str': {\n evaluate: (params: Arr) => {\n return params.reduce((result: string, param) => {\n const paramStr\n = param === undefined || param === null\n ? ''\n : isObj(param)\n ? JSON.stringify(param)\n : Array.isArray(param)\n ? JSON.stringify(param)\n : `${param}`\n return result + paramStr\n }, '')\n },\n arity: {},\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { values: { type: 'any', rest: true } },\n variants: [{ argumentNames: ['values'] }],\n description: 'Concatenats $values into one string. If `value` equals `null` empty string is returned.',\n seeAlso: ['++', 'join', 'string.template', 'string.string-repeat', 'number'],\n examples: [\n 'str(\"A string\", \", and another string\", \" ...and more\")',\n 'str(\"Just one string\")',\n 'str()',\n 'str(0, false, true, null, #\"^kalle\", [1, 2, 3], {a: \"a\"})',\n ],\n hideOperatorForm: true,\n },\n },\n\n 'number': {\n evaluate: ([str], sourceCodeInfo): number => {\n assertString(str, sourceCodeInfo)\n const number = Number(str)\n if (Number.isNaN(number))\n throw new DvalaError(`Could not convert '${str}' to a number.`, sourceCodeInfo)\n\n return number\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'number' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Parses $s to a number.',\n seeAlso: ['str', 'number?', 'integer?'],\n examples: [\n 'number(\"10\")',\n 'number(\"010\")',\n 'number(\"-1.01\")',\n ],\n },\n },\n\n 'lower-case': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.toLowerCase()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns $s converted to lower case.',\n seeAlso: ['upper-case', 'string.capitalize'],\n examples: [\n 'lower-case(\"Albert\")',\n 'lower-case(\"\")',\n ],\n },\n },\n\n 'upper-case': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.toUpperCase()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns $s converted to upper case.',\n seeAlso: ['lower-case', 'string.capitalize'],\n examples: [\n 'upper-case(\"Albert\")',\n 'upper-case(\"\")',\n ],\n },\n },\n\n 'trim': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.trim()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns a new string with leading and trailing whitespaces removed.',\n seeAlso: ['string.trim-left', 'string.trim-right', 'blank?'],\n examples: [\n 'trim(\" Albert \")',\n 'trim(\" \")',\n 'trim(\"\")',\n ],\n },\n },\n\n 'join': {\n evaluate: ([stringList, delimiter], sourceCodeInfo): string => {\n assertArray(stringList, sourceCodeInfo)\n stringList.forEach(str => assertStringOrNumber(str, sourceCodeInfo))\n assertString(delimiter, sourceCodeInfo)\n return stringList.join(delimiter)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: {\n a: { type: 'array' },\n b: { type: 'string' },\n arr: { type: 'array' },\n delimiter: { type: 'string' },\n },\n variants: [{ argumentNames: ['arr', 'delimiter'] }],\n description: 'Returns a new string by concatenating all of the elements in $arr, separated by $delimiter.',\n seeAlso: ['split', 'str', '++', 'sequence.interpose'],\n examples: [\n 'map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str) join \", \"',\n '([0, 1, 2, 3, 4, 5, 6, 7, 8, 9] map str) join \", \"',\n 'join([\"Albert\", 10], \", \")',\n 'join([\"Albert\", \"Mojir\"], \" \")',\n 'join(map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str), \", \")',\n ],\n },\n },\n\n 'split': {\n evaluate: ([str, stringOrRegExpValue, limit], sourceCodeInfo): string[] => {\n assertString(str, sourceCodeInfo)\n assertStringOrRegularExpression(stringOrRegExpValue, sourceCodeInfo)\n if (limit !== undefined)\n assertNumber(limit, sourceCodeInfo, { integer: true, nonNegative: true })\n\n const delimiter\n = typeof stringOrRegExpValue === 'string'\n ? stringOrRegExpValue\n : new RegExp(stringOrRegExpValue.s, stringOrRegExpValue.f)\n return str.split(delimiter, limit)\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: {\n a: { type: 'string' },\n b: { type: 'string' },\n s: { type: 'string' },\n delimiter: { type: 'string' },\n limit: { type: 'integer' },\n },\n variants: [\n { argumentNames: ['s', 'delimiter'] },\n { argumentNames: ['s', 'delimiter', 'limit'] },\n ],\n 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.',\n seeAlso: ['join', 'string.split-lines'],\n examples: [\n '\"Albert Mojir\" split \" \"',\n 'split(\"Albert Mojir\", \" \")',\n 'split(\"abcdefghijklmnopqrstuvw\", #\"[aoueiy]\")',\n 'split(\"0123456789\", \"\")',\n 'split(\"0123456789\", \"\", 5) map number',\n ],\n },\n },\n 'blank?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n if (value === null) {\n return true\n }\n assertString(value, sourceCodeInfo)\n return blankRegexp.test(value)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'boolean' },\n args: { s: { type: ['string', 'null'] } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns true if $s is null or only contains whitespace characters.',\n seeAlso: ['trim', 'empty?', 'string?'],\n examples: [\n 'blank?(\"\")',\n 'blank?(null)',\n 'blank?(\"\\n\")',\n 'blank?(\" \")',\n 'blank?(\".\")',\n ],\n },\n },\n}\n","import type { Any, Arr } from '../../interface'\nimport type {\n CompFunction,\n ConstantlyFunction,\n FunctionLike,\n} from '../../parser/types'\nimport { toAny } from '../../utils'\nimport { getArityFromFunction, toFixedArity } from '../../utils/arity'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { FUNCTION_SYMBOL } from '../../utils/symbols'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { assertFunctionLike } from '../../typeGuards/dvala'\n\nexport const functionalNormalExpression: BuiltinNormalExpressions = {\n '|>': {\n evaluate: ([value, func], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertFunctionLike(func, sourceCodeInfo)\n return executeFunction(func, [value], contextStack, sourceCodeInfo)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'functional',\n returns: { type: 'any' },\n args: {\n a: { type: 'any' },\n b: { type: 'function' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Takes a value $a and a function $b, and returns the result of applying $b to $a.',\n seeAlso: ['apply', 'comp'],\n examples: [\n `\n1 |> inc |> inc`,\n `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)`,\n ],\n },\n },\n 'apply': {\n evaluate: ([func, ...params]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertFunctionLike(func, sourceCodeInfo)\n const paramsLength = params.length\n const last = params[paramsLength - 1]\n assertArray(last, sourceCodeInfo)\n const applyArray = [...params.slice(0, -1), ...last]\n return executeFunction(func, applyArray, contextStack, sourceCodeInfo)\n },\n arity: { min: 2 },\n docs: {\n category: 'functional',\n returns: { type: 'any' },\n args: {\n a: { type: 'function' },\n b: { type: 'array' },\n fun: { type: 'function' },\n args: { type: 'array' },\n },\n variants: [{ argumentNames: ['fun', 'args'] }],\n description: 'Call supplied function $fun with specified arguments $args.',\n seeAlso: ['|>'],\n examples: [\n `\napply(+, [1, 2, 3])`,\n `\napply(\n (x, y) -> sqrt(x ^ 2 + y ^ 2),\n [3, 4]\n)`,\n `\n(x, y) -> sqrt(x ^ 2 + y ^ 2) apply [3, 4]`,\n ],\n },\n },\n\n 'identity': {\n evaluate: ([value]): Any => {\n return toAny(value)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'functional',\n returns: { type: 'any' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns $x.',\n seeAlso: ['constantly', 'functional.fnull'],\n examples: ['identity(1)', 'identity(\"Albert\")', 'identity({ a: 1 })', 'identity(null)'],\n },\n },\n\n 'comp': {\n evaluate: (params, sourceCodeInfo): CompFunction => {\n params.forEach(param => assertFunctionLike(param, sourceCodeInfo))\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Comp',\n params,\n arity: params.length > 0 ? getArityFromFunction(params.at(-1) as FunctionLike) : { min: 1, max: 1 },\n }\n },\n arity: {},\n docs: {\n category: 'functional',\n returns: { type: 'function' },\n args: {\n a: { type: 'function' },\n b: { type: 'function' },\n fns: { type: 'function', rest: true },\n },\n variants: [{ argumentNames: ['fns'] }],\n 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.`,\n seeAlso: ['|>', 'functional.juxt', 'functional.complement'],\n examples: [\n `\nlet negative-quotient = comp(-, /);\nnegative-quotient(9, 3)`,\n `\nlet x = { bar: { foo: 42 } };\ncomp(\"foo\", \"bar\")(x)`,\n ],\n },\n },\n\n 'constantly': {\n evaluate: ([value], sourceCodeInfo): ConstantlyFunction => {\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Constantly',\n value: toAny(value),\n arity: {},\n }\n },\n arity: toFixedArity(1),\n docs: {\n category: 'functional',\n returns: { type: 'function' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns a function that takes any number of arguments and always returns $x.',\n seeAlso: ['identity', 'functional.fnull'],\n examples: [\n `\nlet always-true = constantly(true);\nalways-true(9, 3)`,\n ],\n },\n },\n\n}\n","import { smartTrim } from '..'\nimport type { Argument, FunctionReference, TypedValue } from '../../../reference'\n\nexport function generateDocString(reference: FunctionReference): string {\n return smartTrim(`\n ${reference.title}\n\n ${reference.description\n .replace(/`(.+?)`/g, '$1')\n .replace(/\\$(\\w+)/g, '$1')\n .replace(/\\*\\*\\*(.+)\\*\\*\\*/g, '$1')\n .replace(/\\*\\*(.+)\\*\\*/g, '$1')\n }\n\n Signature:\n ${signature(reference).join('\\n ')}\n\n Arguments:\n ${argStrings(reference).join('\\n ')}\n\n Examples:\n${reference.examples.map(example => smartTrim(example, 4)).join('\\n\\n')}`)\n}\n\nfunction signature({ title, variants, args, returns, _isOperator }: FunctionReference): string[] {\n const functionForms = variants.map((variant) => {\n const form = ` ${title}(${variant.argumentNames.map((argName) => {\n let result = ''\n const arg = args[argName]!\n if (arg.rest) {\n result += '...'\n }\n result += argName\n return result\n }).join(', ')})`\n\n return `${form} -> ${type(returns)}`\n })\n\n const operatorForm = _isOperator ? ['', 'Operator:', ` a ${title} b -> ${type(returns)}`] : []\n\n return [\n ...functionForms,\n ...operatorForm,\n ]\n}\n\nfunction type(arg: Argument | TypedValue) {\n const argType = arg.type\n const types = Array.isArray(argType) ? argType : [argType]\n const typeString = types.join(' | ')\n return arg.array || arg.rest ? `Array<${typeString}>` : typeString\n}\n\nfunction argStrings(reference: FunctionReference): string[] {\n return Object.entries(reference.args).map(([argName, arg]) => `${argName}: ${type(arg)}`)\n}\n","import { assertNonEmptyVector, assertVector } from '../../typeGuards/annotatedArrays'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nfunction calcMedian(vector: number[]): number {\n const sorted = [...vector].sort((a, b) => a - b)\n const mid = Math.floor(sorted.length / 2)\n return sorted.length % 2 === 0\n ? (sorted[mid - 1]! + sorted[mid]!) / 2\n : sorted[mid]!\n}\n\nexport const vectorNormalExpression: BuiltinNormalExpressions = {\n sum: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc + val, 0)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to sum.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the **sum** of all elements in the `vector`. Returns `0` for an empty vector.',\n seeAlso: ['prod', 'mean', 'median', 'vector.moving-sum', 'vector.centered-moving-sum', 'vector.running-sum', 'vector.cumsum'],\n examples: [\n 'sum([1, 2, 3, 4, 5])',\n 'sum([1, -2, 3])',\n 'sum([])',\n ],\n },\n },\n\n prod: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc * val, 1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to multiply.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the **product** of all elements in the `vector`. Returns `1` for an empty vector.',\n seeAlso: ['sum', 'mean', 'median', 'vector.moving-prod', 'vector.centered-moving-prod', 'vector.running-prod', 'vector.cumprod'],\n examples: [\n 'prod([1, 2, 3, 4, 5])',\n 'prod([1, -2, 3])',\n 'prod([])',\n ],\n },\n },\n\n mean: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc + val, 0) / vector.length\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to calculate the mean of.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the arithmetic **mean** of all elements in the `vector`. Throws for an empty vector.',\n seeAlso: ['median', 'sum', 'prod', 'vector.moving-mean', 'vector.centered-moving-mean', 'vector.running-mean', 'vector.geometric-mean', 'vector.harmonic-mean', 'vector.rms', 'vector.mode'],\n examples: [\n 'mean([1, 2, 3, 4, 5])',\n 'mean([1, -2, 3])',\n ],\n },\n },\n\n median: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return calcMedian(vector)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to calculate the median of.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n 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.',\n seeAlso: ['mean', 'sum', 'prod', 'vector.moving-median', 'vector.centered-moving-median', 'vector.running-median', 'vector.mode', 'vector.quartiles', 'vector.percentile', 'vector.iqr', 'vector.medad'],\n examples: [\n 'median([1, 2, 3, 4, 5])',\n 'median([1, 2, 3, 4])',\n 'median([3, 1, 4, 1, 5])',\n ],\n },\n },\n}\n","import type { BuiltinNormalExpression, BuiltinNormalExpressions } from '../interface'\nimport type { Any } from '../../interface'\nimport type { FunctionReference } from '../../../reference'\nimport type { CoreNormalExpressionName } from '../../../reference/api'\n\n// Core categories - always available\nimport { assertionNormalExpression } from '../core/assertion'\nimport { bitwiseNormalExpression } from '../core/bitwise'\nimport { collectionNormalExpression } from '../core/collection'\nimport { arrayNormalExpression } from '../core/array'\nimport { sequenceNormalExpression } from '../core/sequence'\nimport { mathNormalExpression } from '../core/math'\nimport { miscNormalExpression } from '../core/misc'\nimport { objectNormalExpression } from '../core/object'\nimport { predicatesNormalExpression } from '../core/predicates'\nimport { regexpNormalExpression } from '../core/regexp'\nimport { stringNormalExpression } from '../core/string'\nimport { functionalNormalExpression } from '../core/functional'\nimport { getMetaNormalExpression } from '../core/meta'\nimport { vectorNormalExpression } from '../core/vector'\n\nconst normalExpressionReference: Record<string, FunctionReference> = {}\n\nexport function setNormalExpressionReference(reference: Record<CoreNormalExpressionName, FunctionReference>) {\n Object.assign(normalExpressionReference, reference)\n}\n\nconst expressions: BuiltinNormalExpressions = {\n // Core categories\n ...assertionNormalExpression,\n ...bitwiseNormalExpression,\n ...collectionNormalExpression,\n ...arrayNormalExpression,\n ...sequenceNormalExpression,\n ...mathNormalExpression,\n ...getMetaNormalExpression(normalExpressionReference),\n ...miscNormalExpression,\n ...objectNormalExpression,\n ...predicatesNormalExpression,\n ...regexpNormalExpression,\n ...stringNormalExpression,\n ...functionalNormalExpression,\n ...vectorNormalExpression,\n}\n\nObject.entries(expressions).forEach(([name, expression]) => {\n expression.name = name\n})\n\nexport const normalExpressions: BuiltinNormalExpressions = {\n ...expressions,\n}\n\nexport const normalExpressionTypes: Record<string, number> = {}\nexport const allNormalExpressions: BuiltinNormalExpression<Any>[] = []\n\nObject.entries(normalExpressions).forEach(([key, value], index) => {\n normalExpressionTypes[key] = index\n allNormalExpressions.push(value)\n})\n","import type { FunctionReference } from '../../../reference'\nimport { assertNonUndefined } from '../../typeGuards'\nimport { assertFunctionLike } from '../../typeGuards/dvala'\nimport { isDvalaFunction } from '../../typeGuards/dvalaFunction'\nimport { toFixedArity } from '../../utils/arity'\nimport { generateDocString } from '../../utils/docString/generateDocString'\nimport type { Arity, BuiltinNormalExpressions } from '../interface'\n\nexport function getMetaNormalExpression(normalExpressionReference: Record<string, FunctionReference>): BuiltinNormalExpressions {\n return {\n doc: {\n evaluate: ([fn], sourceCodeInfo): string => {\n assertNonUndefined(normalExpressionReference)\n assertFunctionLike(fn, sourceCodeInfo)\n if (!isDvalaFunction(fn)) {\n return ''\n }\n if (fn.functionType === 'Builtin') {\n const reference = normalExpressionReference[fn.name]\n return reference ? generateDocString(reference) : ''\n }\n if (fn.functionType === 'UserDefined' || fn.functionType === 'NativeJsFunction') {\n return fn.docString\n }\n return ''\n },\n arity: toFixedArity(1),\n docs: {\n category: 'meta',\n returns: { type: 'string' },\n args: { fun: { type: 'function' } },\n variants: [{ argumentNames: ['fun'] }],\n description: 'Returns documentation string of the $fun.',\n seeAlso: ['arity'],\n examples: [\n 'doc(+)',\n `\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)`,\n ],\n },\n },\n arity: {\n evaluate: ([fn], sourceCodeInfo): Arity => {\n assertFunctionLike(fn, sourceCodeInfo)\n return isDvalaFunction(fn) ? fn.arity : toFixedArity(1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'meta',\n returns: { type: 'object' },\n args: { fun: { type: 'function' } },\n variants: [{ argumentNames: ['fun'] }],\n 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.',\n seeAlso: ['doc'],\n examples: [\n 'arity(+)',\n 'arity(defined?)',\n `\nlet add = (x, y = 0) -> do\n x + y;\nend;\n\narity(add)`,\n `\nlet foo = (k, ...x) -> do\n k + x;\nend;\n arity(foo)`,\n ],\n },\n },\n }\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/dvala'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type AndNode = SpecialExpressionNode<[typeof specialExpressionTypes['&&'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'any',\n },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n c: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n 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.`,\n examples: [\n 'true && 1',\n '&&(1, 1)',\n '&&(3 > 2, \"string\")',\n '&&(3 < 2, \"string\")',\n '&&(true, true, true, true)',\n '&&(true, true, 0, true)',\n ],\n}\n\nexport const andSpecialExpression: BuiltinSpecialExpression<Any, AndNode> = {\n arity: {},\n docs,\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n let value: Any = true\n for (const param of params) {\n value = asAny(param, sourceCodeInfo)\n if (!value)\n break\n }\n return value\n },\n\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type CondNode = SpecialExpressionNode<[typeof specialExpressionTypes['cond'], [AstNode, AstNode][]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['cond cond-branch cond-branch ... end'],\n details: [\n ['cond-branch', 'case test then body', 'A branch of the cond expression.'],\n ['test', 'expression', 'The condition to test.'],\n ['body', 'expressions', 'The expressions to evaluate if the test is truthy.'],\n ],\n description: 'Used for branching. `cond-branches` are tested sequentially from the top. If no branch is tested truthy, `null` is returned.',\n examples: [\n `\ncond\n case false then write!(\"FALSE\")\n case true then write!(\"TRUE\")\nend`,\n `\ncond\n case false then write!(\"FALSE\")\n case null then write!(\"null\")\nend ?? write!(\"TRUE\")`,\n `\ncond\n case false then write!(\"FALSE\")\n case null then write!(\"null\")\nend ?? write!(\"TRUE\")`,\n ],\n}\n\nexport const condSpecialExpression: BuiltinSpecialExpression<Any, CondNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1].flat(), contextStack, builtin, evaluateNode),\n}\n","import type { JsFunction } from '../Dvala/Dvala'\nimport type { SpecialExpressionType } from '../builtin'\nimport type { Arity } from '../builtin/interface'\nimport type { specialExpressionTypes } from '../builtin/specialExpressionTypes'\nimport type { FunctionType, NodeType, NodeTypes } from '../constants/constants'\nimport type { Context } from '../evaluator/interface'\nimport type { Any, Arr, Coll } from '../interface'\nimport type { ReservedSymbol } from '../tokenizer/reservedNames'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport type { EFFECT_SYMBOL, FUNCTION_SYMBOL, REGEXP_SYMBOL } from '../utils/symbols'\n\nexport type EvaluatedFunction = [BindingTarget[], AstNode[], Context]\n\ninterface GenericDvalaFunction {\n [FUNCTION_SYMBOL]: true\n sourceCodeInfo?: SourceCodeInfo\n functionType: FunctionType\n arity: Arity\n}\n\nexport interface RegularExpression {\n [REGEXP_SYMBOL]: true\n sourceCodeInfo?: SourceCodeInfo\n s: string\n f: string\n}\n\nexport interface EffectRef {\n [EFFECT_SYMBOL]: true\n name: string // e.g. 'llm.complete'\n}\n\nexport interface NativeJsFunction extends GenericDvalaFunction {\n functionType: 'NativeJsFunction'\n name: string | undefined // name\n nativeFn: JsFunction\n docString: string // documentation string\n}\n\nexport interface UserDefinedFunction extends GenericDvalaFunction {\n functionType: 'UserDefined'\n name: string | undefined // name\n evaluatedfunction: EvaluatedFunction\n docString: string // documentation string\n}\n\nexport interface PartialFunction extends GenericDvalaFunction {\n functionType: 'Partial'\n function: FunctionLike\n params: Arr\n placeholders: number[] // indexes of the placeholders\n}\n\nexport interface CompFunction extends GenericDvalaFunction {\n functionType: 'Comp'\n params: Arr\n}\n\nexport interface ConstantlyFunction extends GenericDvalaFunction {\n functionType: 'Constantly'\n value: Any\n}\n\nexport interface JuxtFunction extends GenericDvalaFunction {\n functionType: 'Juxt'\n params: Arr\n}\n\nexport interface ComplementFunction extends GenericDvalaFunction {\n functionType: 'Complement'\n function: FunctionLike\n}\n\nexport interface EveryPredFunction extends GenericDvalaFunction {\n functionType: 'EveryPred'\n params: Arr\n}\n\nexport interface SomePredFunction extends GenericDvalaFunction {\n functionType: 'SomePred'\n params: Arr\n}\n\nexport interface FNullFunction extends GenericDvalaFunction {\n functionType: 'Fnull'\n function: FunctionLike\n params: Arr\n}\n\nexport interface NormalBuiltinFunction extends GenericDvalaFunction {\n functionType: 'Builtin'\n normalBuiltinSymbolType: number\n name: string\n}\n\nexport interface SpecialBuiltinFunction extends GenericDvalaFunction {\n functionType: 'SpecialBuiltin'\n specialBuiltinSymbolType:\n | typeof specialExpressionTypes['&&']\n | typeof specialExpressionTypes['||']\n | typeof specialExpressionTypes['array']\n | typeof specialExpressionTypes['object']\n | typeof specialExpressionTypes['defined?']\n | typeof specialExpressionTypes['recur']\n | typeof specialExpressionTypes['throw']\n | typeof specialExpressionTypes['??']\n}\n\nexport interface ModuleFunction extends GenericDvalaFunction {\n functionType: 'Module'\n moduleName: string\n functionName: string\n}\n\nexport type DvalaFunction =\n | NativeJsFunction\n | UserDefinedFunction\n | NormalBuiltinFunction\n | SpecialBuiltinFunction\n | ModuleFunction\n | PartialFunction\n | CompFunction\n | ConstantlyFunction\n | JuxtFunction\n | ComplementFunction\n | EveryPredFunction\n | SomePredFunction\n | FNullFunction\n\nexport type DvalaFunctionType = DvalaFunction['functionType']\n\nexport type FunctionLike = DvalaFunction | Coll | number\n\nexport type AstNode<T extends NodeType = NodeType, Payload = unknown> = [T, Payload] | [T, Payload, SourceCodeInfo]\n\nexport type ExpressionNode = NormalExpressionNode | SpecialExpressionNode | NumberNode | StringNode\n\nexport type SpreadNode = AstNode<typeof NodeTypes.Spread, AstNode> // Payload should be array or object depending on context\nexport type NumberNode = AstNode<typeof NodeTypes.Number, number>\nexport type StringNode = AstNode<typeof NodeTypes.String, string>\nexport type UserDefinedSymbolNode = AstNode<typeof NodeTypes.UserDefinedSymbol, string>\nexport type NormalBuiltinSymbolNode = AstNode<typeof NodeTypes.NormalBuiltinSymbol, number>\nexport type SpecialBuiltinSymbolNode = AstNode<typeof NodeTypes.SpecialBuiltinSymbol, SpecialExpressionType>\nexport type SymbolNode = UserDefinedSymbolNode | NormalBuiltinSymbolNode | SpecialBuiltinSymbolNode\nexport type ReservedSymbolNode = AstNode<typeof NodeTypes.ReservedSymbol, ReservedSymbol>\nexport type SpecialExpressionNode<T extends [SpecialExpressionType, ...unknown[]] = [SpecialExpressionType, ...unknown[]]> = AstNode<typeof NodeTypes.SpecialExpression, T> // [name, params]\n\nexport type NormalExpressionNodeWithName = AstNode<typeof NodeTypes.NormalExpression, [NormalBuiltinSymbolNode | UserDefinedSymbolNode, AstNode[]]> // [params, name]\nexport type NormalExpressionNodeExpression = AstNode<typeof NodeTypes.NormalExpression, [AstNode, AstNode[]]> // [name, node as function] node can be string number object or array\nexport type NormalExpressionNode = NormalExpressionNodeWithName | NormalExpressionNodeExpression\nexport const bindingTargetTypes = {\n symbol: 11,\n rest: 12,\n object: 13,\n array: 14,\n literal: 15,\n wildcard: 16,\n} as const\n\nexport type BindingTargetType = typeof bindingTargetTypes[keyof typeof bindingTargetTypes]\n\ntype GenericTarget<T extends BindingTargetType, Payload extends unknown[]> = [T, Payload] | [T, Payload, SourceCodeInfo]\n\nexport type SymbolBindingTarget = GenericTarget<typeof bindingTargetTypes.symbol, [SymbolNode, AstNode | undefined /* default value */]>\nexport type RestBindingTarget = GenericTarget<typeof bindingTargetTypes.rest, [string, AstNode | undefined /* default value */]>\nexport type ObjectBindingTarget = GenericTarget<typeof bindingTargetTypes.object, [Record<string, BindingTarget>, AstNode | undefined /* default value */]>\nexport type ArrayBindingTarget = GenericTarget<typeof bindingTargetTypes.array, [(BindingTarget | null)[], AstNode | undefined /* default value */]>\nexport type LiteralBindingTarget = GenericTarget<typeof bindingTargetTypes.literal, [AstNode /* literal expression */]>\nexport type WildcardBindingTarget = GenericTarget<typeof bindingTargetTypes.wildcard, []>\n\nexport type BindingTarget = SymbolBindingTarget | RestBindingTarget | ObjectBindingTarget | ArrayBindingTarget | LiteralBindingTarget | WildcardBindingTarget\n\nexport type BindingNode = AstNode<typeof NodeTypes.Binding, [BindingTarget, AstNode]> // [target, value]\n\ntype AstBody = AstNode[]\nexport interface Ast {\n body: AstBody // body\n hasDebugData: boolean\n}\n","import { DvalaError } from '../errors'\nimport type { Any } from '../interface'\nimport { type ArrayBindingTarget, type AstNode, type BindingTarget, type RestBindingTarget, type UserDefinedSymbolNode, bindingTargetTypes } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { assertUnknownRecord, isUnknownRecord } from '../typeGuards'\nimport { assertArray } from '../typeGuards/array'\nimport { asAny, assertAny } from '../typeGuards/dvala'\nimport type { MaybePromise } from '../utils/maybePromise'\nimport { chain, forEachSequential } from '../utils/maybePromise'\nimport { deepEqual } from '../utils'\n\nexport function walkDefaults(\n bindingTarget: BindingTarget,\n onDefault: (Node: AstNode) => void,\n): void {\n if (bindingTarget[0] === bindingTargetTypes.object) {\n Object.values(bindingTarget[1][0]).forEach((element) => {\n if (element[1][1]) {\n onDefault(element[1][1])\n }\n walkDefaults(element, onDefault)\n })\n }\n else if (bindingTarget[0] === bindingTargetTypes.array) {\n for (let index = 0; index < bindingTarget[1][0].length; index += 1) {\n const element = bindingTarget[1][0][index] ?? null\n if (element === null) {\n continue\n }\n if (element[1][1]) {\n onDefault(element[1][1])\n }\n walkDefaults(element, onDefault)\n }\n }\n // literal and wildcard have no defaults - nothing to walk\n}\n\nexport function evaluateBindingNodeValues(\n target: BindingTarget,\n value: Any,\n evaluate: (Node: AstNode) => MaybePromise<Any>,\n): MaybePromise<Record<string, Any>> {\n const sourceCodeInfo = target[2]\n const record: Record<string, Any> = {}\n return chain(createRecord(target, value, evaluate, sourceCodeInfo, record), () => record)\n}\n\nfunction createRecord(\n bindingTarget: BindingTarget,\n value: Any,\n evaluate: (Node: AstNode) => MaybePromise<Any>,\n sourceCodeInfo: SourceCodeInfo | undefined,\n record: Record<string, Any>,\n): MaybePromise<void> {\n if (bindingTarget[0] === bindingTargetTypes.object) {\n assertUnknownRecord(value, sourceCodeInfo)\n const capturedKeys = new Set<string>()\n let restElement: RestBindingTarget | undefined\n const entries = Object.entries(bindingTarget[1][0])\n\n return chain(\n forEachSequential(entries, ([key, element]) => {\n if (element[0] === bindingTargetTypes.rest) {\n restElement = element\n return\n }\n capturedKeys.add(key)\n const existingVal = value[key]\n const maybeVal: MaybePromise<Any> = existingVal !== undefined\n ? existingVal as Any\n : element[1][1]\n ? evaluate(element[1][1])\n : null\n return chain(maybeVal, (resolvedVal) => {\n const val = resolvedVal ?? null\n assertAny(val, sourceCodeInfo)\n return createRecord(element, val, evaluate, sourceCodeInfo, record)\n })\n }),\n () => {\n if (restElement) {\n const restValues = Object.entries(value)\n .filter(([key]) => !capturedKeys.has(key))\n .reduce((acc: Record<string, Any>, [key, val]) => {\n acc[key] = asAny(val)\n return acc\n }, {})\n\n record[restElement[1][0]] = restValues\n }\n },\n )\n }\n else if (bindingTarget[0] === bindingTargetTypes.array) {\n let restIndex: number | null = null\n assertArray(value, sourceCodeInfo)\n\n const elements: Array<{ element: BindingTarget, index: number }> = []\n for (let index = 0; index < bindingTarget[1][0].length; index += 1) {\n const element = bindingTarget[1][0][index] ?? null\n if (element === null) {\n continue\n }\n if (element[0] === bindingTargetTypes.rest) {\n restIndex = index\n break\n }\n elements.push({ element, index })\n }\n\n return chain(\n forEachSequential(elements, ({ element, index }) => {\n const existingVal = value[index]\n const maybeVal: MaybePromise<Any> = existingVal !== undefined\n ? existingVal as Any\n : element[1][1]\n ? evaluate(element[1][1])\n : null\n return chain(maybeVal, (resolvedVal) => {\n const val = resolvedVal ?? null\n assertAny(val, sourceCodeInfo)\n return createRecord(element, val, evaluate, sourceCodeInfo, record)\n })\n }),\n () => {\n if (restIndex !== null) {\n const restValues = value.slice(restIndex)\n const restElement = bindingTarget[1][0][restIndex]! as RestBindingTarget\n record[restElement[1][0]] = restValues\n }\n },\n )\n }\n else if (bindingTarget[0] === bindingTargetTypes.rest) {\n record[bindingTarget[1][0]] = asAny(value)\n }\n else {\n record[(bindingTarget[1][0] as UserDefinedSymbolNode)[1]] = asAny(value)\n }\n}\n\nexport function getAllBindingTargetNames(bindingTarget: BindingTarget): Record<string, true> {\n const names: Record<string, true> = {}\n getNamesFromBindingTarget(bindingTarget, names)\n return names\n}\n\nfunction getNamesFromBindingTarget(target: BindingTarget | null, names: Record<string, true>): void {\n if (target === null) {\n return\n }\n if (target[0] === bindingTargetTypes.array) {\n for (const element of target[1][0]) {\n getNamesFromBindingTarget(element, names)\n }\n }\n else if (target[0] === bindingTargetTypes.object) {\n for (const element of Object.values(target[1][0])) {\n getNamesFromBindingTarget(element, names)\n }\n }\n else if (target[0] === bindingTargetTypes.rest) {\n if (names[target[1][0]]) {\n throw new DvalaError(`Duplicate binding name: ${target[1][0]}`, target[2])\n }\n names[target[1][0]] = true\n }\n else if (target[0] === bindingTargetTypes.symbol) {\n if (names[target[1][0][1]]) {\n throw new DvalaError(`Duplicate binding name: ${target[1][0]}`, target[2])\n }\n names[target[1][0][1]] = true\n }\n // literal and wildcard bind no names - skip\n}\n\n/**\n * Non-throwing pattern matching. Returns bindings on match, null on mismatch.\n * Used by `switch` pattern matching.\n */\nexport function tryMatch(\n target: BindingTarget,\n value: Any,\n evaluate: (Node: AstNode) => MaybePromise<Any>,\n): MaybePromise<Record<string, Any> | null> {\n const record: Record<string, Any> = {}\n return chain(tryMatchRecord(target, value, evaluate, record), (matched) => {\n if (!matched)\n return null\n return record\n })\n}\n\nfunction tryMatchRecord(\n bindingTarget: BindingTarget,\n value: Any,\n evaluate: (Node: AstNode) => MaybePromise<Any>,\n record: Record<string, Any>,\n): MaybePromise<boolean> {\n // Wildcard: always matches, binds nothing\n if (bindingTarget[0] === bindingTargetTypes.wildcard) {\n return true\n }\n\n // Literal: compare with deepEqual\n else if (bindingTarget[0] === bindingTargetTypes.literal) {\n const literalNode = bindingTarget[1][0]\n return chain(evaluate(literalNode), (literalValue) => {\n return deepEqual(value, literalValue)\n })\n }\n\n // Symbol: always matches, binds value\n else if (bindingTarget[0] === bindingTargetTypes.symbol) {\n const symbolNode = bindingTarget[1][0] as UserDefinedSymbolNode\n const defaultNode = bindingTarget[1][1]\n if (value === undefined || value === null) {\n if (defaultNode) {\n return chain(evaluate(defaultNode), (defaultValue) => {\n record[symbolNode[1]] = asAny(defaultValue)\n return true\n })\n }\n record[symbolNode[1]] = value ?? null\n }\n else {\n record[symbolNode[1]] = asAny(value)\n }\n return true\n }\n\n // Object pattern\n else if (bindingTarget[0] === bindingTargetTypes.object) {\n if (!isUnknownRecord(value))\n return false\n\n const capturedKeys = new Set<string>()\n let restElement: RestBindingTarget | undefined\n const entries = Object.entries(bindingTarget[1][0])\n\n let result: MaybePromise<boolean> = true\n for (const [key, element] of entries) {\n result = chain(result, (matched) => {\n if (!matched)\n return false\n\n if (element[0] === bindingTargetTypes.rest) {\n restElement = element\n return true\n }\n\n capturedKeys.add(key)\n const existingVal = value[key]\n\n // For literal sub-patterns, missing key means no match\n if (existingVal === undefined && element[0] === bindingTargetTypes.literal) {\n return chain(evaluate(element[1][0]), (literalValue) => {\n return deepEqual(undefined, literalValue)\n })\n }\n\n const maybeVal: MaybePromise<Any> = existingVal !== undefined\n ? existingVal as Any\n : element[1] && element[1][1]\n ? evaluate(element[1][1])\n : null\n\n return chain(maybeVal, (resolvedVal) => {\n const val = resolvedVal ?? null\n return tryMatchRecord(element, val, evaluate, record)\n })\n })\n }\n\n return chain(result, (matched) => {\n if (!matched)\n return false\n if (restElement) {\n const restValues = Object.entries(value)\n .filter(([key]) => !capturedKeys.has(key))\n .reduce((acc: Record<string, Any>, [key, val]) => {\n acc[key] = asAny(val)\n return acc\n }, {})\n record[restElement[1][0]] = restValues\n }\n return true\n })\n }\n\n // Array pattern\n else {\n const arrayTarget = bindingTarget as ArrayBindingTarget\n if (!Array.isArray(value))\n return false\n\n const elements = arrayTarget[1][0]\n let restIndex: number | null = null\n\n // Find rest element index and check length constraints\n for (let i = 0; i < elements.length; i += 1) {\n const element = elements[i]!\n if (element !== null && element[0] === bindingTargetTypes.rest) {\n restIndex = i\n break\n }\n }\n\n // Without rest: array length must match exactly\n if (restIndex === null && value.length !== elements.length) {\n return false\n }\n // With rest: array must have at least the non-rest elements\n if (restIndex !== null && value.length < restIndex) {\n return false\n }\n\n let result: MaybePromise<boolean> = true\n for (let i = 0; i < elements.length; i += 1) {\n const element = elements[i]!\n if (element === null)\n continue // skipped position\n\n if (element[0] === bindingTargetTypes.rest) {\n // Rest collects remaining elements\n record[element[1][0]] = value.slice(i)\n break\n }\n\n const el = element\n result = chain(result, (matched) => {\n if (!matched)\n return false\n\n return tryMatchRecord(el, asAny(value[i]), evaluate, record)\n })\n }\n return result\n }\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, BindingTarget, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\nimport { getAllBindingTargetNames } from '../bindingNode'\nimport type { Context } from '../../evaluator/interface'\n\n// Each case: [pattern, body, guard?]\nexport type MatchCase = [BindingTarget, AstNode, AstNode | undefined]\nexport type MatchNode = SpecialExpressionNode<[typeof specialExpressionTypes['match'], AstNode, MatchCase[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['match value match-branch match-branch ... end'],\n details: [\n ['value', 'any', 'The value to match against patterns.'],\n ['match-branch', 'case pattern [when guard] then body', 'A branch of the match expression.'],\n ['pattern', 'pattern', 'A pattern to match: literal, variable, array destructuring, object destructuring, or wildcard (_).'],\n ['guard', 'expression', 'An optional guard expression that must be truthy for the match to succeed.'],\n ['body', 'expressions', 'The expressions to evaluate if the pattern matches.'],\n ],\n description: 'Pattern matching expression. Matches `value` against each `pattern` sequentially. If a pattern matches (and the optional `when` guard is truthy), the corresponding `body` is evaluated and its result returned. Bound variables from the pattern are available in the guard and body. If no pattern matches, `null` is returned.',\n examples: [\n `\nmatch 1\n case 1 then \"One\"\n case 2 then \"Two\"\nend`,\n `\nmatch [1, 2, 3]\n case [x] then \"one element\"\n case [x, y] then \"two elements\"\n case [x, ...xs] then \"first: \" ++ str(x) ++ \" rest: \" ++ str(xs)\nend`,\n `\nmatch { type: \"click\", x: 10, y: 20 }\n case { type: \"click\", x, y } then \"Click at \" ++ str(x) ++ \", \" ++ str(y)\n case { type: \"keydown\", key } then \"Key: \" ++ key\n case _ then \"unknown event\"\nend`,\n `\nmatch { role: \"admin\", name: \"Alice\" }\n case { role: \"admin\", name } then \"Admin: \" ++ name\n case { role, name } when role == \"user\" then \"User: \" ++ name\n case _ then \"Unknown role\"\nend`,\n ],\n}\n\nexport const matchSpecialExpression: BuiltinSpecialExpression<Any, MatchNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const result = new Set<string>()\n\n // The match value expression\n getUndefinedSymbols([node[1][1]], contextStack, builtin, evaluateNode).forEach(s => result.add(s))\n\n // Each case\n for (const [pattern, body, guard] of node[1][2]) {\n const newContext: Context = {}\n Object.assign(newContext, getAllBindingTargetNames(pattern))\n const caseContextStack = contextStack.create(newContext)\n\n if (guard) {\n getUndefinedSymbols([guard], caseContextStack, builtin, evaluateNode).forEach(s => result.add(s))\n }\n getUndefinedSymbols([body], caseContextStack, builtin, evaluateNode).forEach(s => result.add(s))\n }\n\n return result\n },\n}\n","import type { SpecialExpressionNode, SymbolNode } from '../../parser/types'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type DefinedNode = SpecialExpressionNode<[typeof specialExpressionTypes['defined?'], SymbolNode]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'boolean',\n },\n args: {\n symbol: { type: 'any' },\n },\n variants: [\n { argumentNames: ['symbol'] },\n ],\n 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.`,\n examples: [\n 'let x = 42; defined?(x)',\n 'defined?(x)',\n 'defined?(+)',\n ],\n}\n\nexport const definedSpecialExpression: BuiltinSpecialExpression<boolean, DefinedNode> = {\n arity: toFixedArity(1),\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols([node[1][1]], contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type DoNode = SpecialExpressionNode<[typeof specialExpressionTypes['block'], AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['do body end'],\n details: [\n ['body', 'expressions', 'The expressions to evaluate.'],\n ],\n description: 'Evaluates `body`. Resulting value is the value of the last expression.',\n examples: [\n `\ndo\n let a = 1 + 2 + 3 + 4;\n let b = -> $ * ( $ + 1 );\n b(a)\nend`,\n ],\n}\n\nexport const doSpecialExpression: BuiltinSpecialExpression<Any, DoNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n return getUndefinedSymbols(node[1][1], contextStack.create({}), builtin, evaluateNode)\n },\n}\n","import type { ContextStack } from '../../evaluator/ContextStack'\nimport type { Context, EvaluateNode } from '../../evaluator/interface'\nimport type { GetUndefinedSymbols, UndefinedSymbols } from '../../getUndefinedSymbols'\nimport type {\n DvalaFunction,\n SpecialExpressionNode,\n} from '../../parser/types'\nimport { addToSet } from '../../utils'\nimport { getAllBindingTargetNames, walkDefaults } from '../bindingNode'\nimport type { Builtin, BuiltinSpecialExpression } from '../interface'\nimport type { Function } from '../utils'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type LambdaNode = SpecialExpressionNode<[typeof specialExpressionTypes['0_lambda'], Function, string]>\n\nexport const lambdaSpecialExpression: BuiltinSpecialExpression<DvalaFunction, LambdaNode> = {\n arity: {},\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const fn = node[1][1]\n return getFunctionUnresolvedSymbols(fn, contextStack, getUndefinedSymbols, builtin, evaluateNode)\n },\n\n}\n\nfunction getFunctionUnresolvedSymbols(\n fn: Function,\n contextStack: ContextStack,\n getUndefinedSymbols: GetUndefinedSymbols,\n builtin: Builtin,\n evaluateNode: EvaluateNode,\n): UndefinedSymbols {\n const result = new Set<string>()\n const newContext: Context = { self: { value: null } }\n\n fn[0].forEach((arg) => {\n Object.assign(newContext, getAllBindingTargetNames(arg))\n\n walkDefaults(arg, (defaultNode) => {\n addToSet(result, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode))\n })\n })\n\n const newContextStack = contextStack.create(newContext)\n const overloadResult = getUndefinedSymbols(fn[1], newContextStack, builtin, evaluateNode)\n addToSet(result, overloadResult)\n return result\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type IfNode = SpecialExpressionNode<[typeof specialExpressionTypes['if'], [AstNode, AstNode, AstNode?]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['if test then true-expr else false-expr', 'if test then true-expr'],\n details: [\n ['test', 'expression', 'The condition to test.'],\n ['true-expr', 'expression', 'The expression to evaluate if the test is truthy.'],\n ['false-expr', 'expression', 'The expression to evaluate if the test is falsy.'],\n ],\n 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.',\n examples: [\n `\nif true then\n write!(\"TRUE\")\nelse\n write!(\"FALSE\")\nend`,\n 'if false then write!(\"TRUE\") else write!(\"FALSE\") end',\n 'if true then write!(\"TRUE\") end',\n 'if false then write!(\"TRUE\") end',\n ],\n}\n\nexport const ifSpecialExpression: BuiltinSpecialExpression<Any, IfNode> = {\n arity: { min: 2, max: 3 },\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) =>\n getUndefinedSymbols(node[1][1].filter(n => !!n), contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type UnlessNode = SpecialExpressionNode<[typeof specialExpressionTypes['unless'], [AstNode, AstNode, AstNode?]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['unless test then true-expr else false-expr end', 'unless test true-expr end'],\n details: [\n ['test', 'expression', 'The condition to test.'],\n ['true-expr', 'expression', 'The expressions to evaluate if the test is falsy.'],\n ['false-expr', 'expression', 'The expressions to evaluate if the test is truthy.'],\n ],\n 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.',\n examples: [\n `\nunless true then\n write!(\"TRUE\")\nelse\n write!(\"FALSE\")\nend`,\n 'unless false then write!(\"TRUE\") else write!(\"FALSE\") end',\n 'unless true then write!(\"TRUE\") end',\n 'unless false then write!(\"TRUE\") end',\n ],\n}\n\nexport const unlessSpecialExpression: BuiltinSpecialExpression<Any, UnlessNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) =>\n getUndefinedSymbols(node[1][1].filter(n => !!n), contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport { addToSet } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport { getAllBindingTargetNames, walkDefaults } from '../bindingNode'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type LetNode = SpecialExpressionNode<[typeof specialExpressionTypes['let'], BindingNode]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['let s = value;'],\n details: [\n ['s', 'symbol', 'The name of the variable to bind.'],\n ['value', 'any', 'The value to bind to the variable.'],\n ],\n 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.`,\n examples: [`\nlet a = 1 + 2 + 3 + 4;\nlet b = -> $ * ( $ + 1 );\nwrite!(\"a\", a, \"b\", b)`],\n}\n\nexport const letSpecialExpression: BuiltinSpecialExpression<Any, LetNode> = {\n arity: toFixedArity(0),\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const bindingNode = node[1][1]\n const target = bindingNode[1][0]\n const value = bindingNode[1][1]\n const bindingResult = getUndefinedSymbols([value], contextStack, builtin, evaluateNode)\n walkDefaults(target, (defaultNode) => {\n addToSet(bindingResult, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode))\n })\n contextStack.addValues(getAllBindingTargetNames(target), target[2])\n return bindingResult\n },\n}\n","import type { Context } from '../../evaluator/interface'\nimport type { Any } from '../../interface'\nimport type { AstNode, BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport { joinSets } from '../../utils'\nimport { getAllBindingTargetNames } from '../bindingNode'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type LoopNode = SpecialExpressionNode<[typeof specialExpressionTypes['loop'], BindingNode[], AstNode]> // bindings, body\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['loop (bindings) -> body'],\n details: [\n ['bindings', 'binding pairs', 'Comma-separated bindings with initial values, e.g. `n = 10, acc = 0`.'],\n ['body', 'expression', 'The expression to evaluate repeatedly. Use `recur` to loop back with new values.'],\n ],\n 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.`,\n examples: [\n `loop (n = 10, acc = 0) -> do\n if n == 0 then\n acc\n else\n recur(n - 1, acc + n)\n end\nend`,\n `loop (n = 5, acc = 1) -> do\n if n <= 1 then\n acc\n else\n recur(n - 1, acc * n)\n end\nend`,\n ],\n}\n\nexport const loopSpecialExpression: BuiltinSpecialExpression<Any, LoopNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const bindingNodes = node[1][1]\n\n const newContext = bindingNodes\n .reduce((context: Context, bindingNode) => {\n const names = getAllBindingTargetNames(bindingNode[1][0])\n\n Object.keys(names).forEach((name) => {\n context[name] = { value: true }\n })\n return context\n }, {})\n\n const bindingValueNodes = bindingNodes.map(bindingNode => bindingNode[1][1])\n const bindingsResult = getUndefinedSymbols(bindingValueNodes, contextStack, builtin, evaluateNode)\n const paramsResult = getUndefinedSymbols([node[1][2]], contextStack.create(newContext), builtin, evaluateNode)\n return joinSets(bindingsResult, paramsResult)\n },\n}\n","import type { GetUndefinedSymbols, UndefinedSymbols } from '../../getUndefinedSymbols'\nimport type { ContextStack } from '../../evaluator/ContextStack'\nimport type { Context, EvaluateNode } from '../../evaluator/interface'\nimport type { Any } from '../../interface'\nimport type { AstNode, BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport type { Builtin, BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport { getAllBindingTargetNames } from '../bindingNode'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\nimport { toFixedArity } from '../../utils/arity'\n\nexport type LoopBindingNode = [BindingNode, BindingNode[], AstNode?, AstNode?] // Binding, Let-Bindings, When, While\n\nexport type ForNode = SpecialExpressionNode<[typeof specialExpressionTypes['for'], LoopBindingNode[], AstNode]> // LoopBindings, body\nexport type DoSeqNode = SpecialExpressionNode<[typeof specialExpressionTypes['doseq'], LoopBindingNode[], AstNode]> // LoopBindings, body\n\ntype LoopNode = ForNode | DoSeqNode\n\nfunction analyze(\n loopNode: LoopNode,\n contextStack: ContextStack,\n getUndefinedSymbols: GetUndefinedSymbols,\n builtin: Builtin,\n evaluateNode: EvaluateNode,\n): UndefinedSymbols {\n const result = new Set<string>()\n const newContext: Context = {}\n const [, loopBindings, body] = loopNode[1]\n loopBindings.forEach((loopBindingNode) => {\n const [bindingNode, letBindings, whenNode, whileNode] = loopBindingNode\n const [target, value] = bindingNode[1]\n getUndefinedSymbols([value], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n Object.assign(newContext, getAllBindingTargetNames(target))\n if (letBindings) {\n letBindings.forEach((letBindingNode) => {\n const [letTarget, letValue] = letBindingNode[1]\n\n getUndefinedSymbols([letValue], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n Object.assign(newContext, getAllBindingTargetNames(letTarget))\n })\n }\n if (whenNode) {\n getUndefinedSymbols([whenNode], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n }\n if (whileNode) {\n getUndefinedSymbols([whileNode], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n }\n })\n getUndefinedSymbols([body], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n return result\n}\n\nconst forDocs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['for (...binding) -> body'],\n details: [\n ['binding', 'loop-var in collection [...let-binding] [where whereExpr] [while whileExp]', 'A for loop binding'],\n ['loop-var', 'symbol', 'The name of the loop variable.'],\n ['collection', 'any', 'The collection to iterate over.'],\n ['let-binding', 'let binding', 'A let binding to create a local variable.'],\n ['whereExpr', 'expression', 'An expression that must evaluate to truthy for the loop body to be executed.'],\n ['whileExp', 'expression', 'An expression that must evaluate to truthy for the loop to continue.'],\n ['body', 'expressions', 'The expressions to evaluate for each iteration of the loop.'],\n ],\n returns: {\n type: 'any',\n array: true,\n },\n description: 'Iterates over `bindings`, evaluates `body` for each `binding` and returns an `array` of results.',\n examples: [\n `\nfor (i in [1, 2, 3]) -> i * 2\n `,\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 `,\n ],\n}\n\nexport const forSpecialExpression: BuiltinSpecialExpression<Any, ForNode> = {\n arity: toFixedArity(1),\n docs: forDocs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => analyze(node, contextStack, getUndefinedSymbols, builtin, evaluateNode),\n}\n\nconst doseqDocs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['doseq (...binding) -> body'],\n details: [\n ['binding', 'loop-var in collection [...let-binding] [where whereExpr] [while whileExp]', 'A doseq loop binding'],\n ['loop-var', 'symbol', 'The name of the loop variable.'],\n ['collection', 'any', 'The collection to iterate over.'],\n ['let-binding', 'let binding', 'A let binding to create a local variable.'],\n ['whereExpr', 'expression', 'An expression that must evaluate to truthy for the loop body to be executed.'],\n ['whileExp', 'expression', 'An expression that must evaluate to truthy for the loop to continue.'],\n ['body', 'expressions', 'The expressions to evaluate for each iteration of the loop.'],\n ],\n returns: {\n type: 'null',\n },\n description: 'Iterates over `bindings`, evaluates `body` for each `binding` and returns `null`. This is useful for side effects.',\n examples: [\n `\ndoseq (i in [1, 2, 3]) -> write!(i * 2)\n `,\n ],\n}\n\nexport const doseqSpecialExpression: BuiltinSpecialExpression<null, DoSeqNode> = {\n arity: toFixedArity(1),\n docs: doseqDocs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => analyze(node, contextStack, getUndefinedSymbols, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/dvala'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type OrNode = SpecialExpressionNode<[typeof specialExpressionTypes['||'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'boolean',\n },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n c: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n 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.`,\n examples: [\n 'false || 1',\n '||(1, 1)',\n '||(3 > 2, \"string\")',\n '||(3 < 2, \"string\")',\n '||(false, false, false, true)',\n '||(1, 2, 3, 4)',\n ],\n}\n\nexport const orSpecialExpression: BuiltinSpecialExpression<Any, OrNode> = {\n arity: {},\n docs,\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n let value: Any = false\n for (const param of params) {\n value = asAny(param, sourceCodeInfo)\n if (value)\n break\n }\n return value\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/dvala'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type QqNode = SpecialExpressionNode<[typeof specialExpressionTypes['??'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'any',\n },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n c: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['a'] },\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n 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\\`.`,\n examples: [\n '1 ?? 2',\n 'null ?? 2',\n '??(null)',\n '??(null, \"default\")',\n '??(1, \"default\")',\n 'false ?? \"default\"',\n '??(null, null, 3)',\n ],\n}\n\nexport const qqSpecialExpression: BuiltinSpecialExpression<Any, QqNode> = {\n arity: { min: 1 },\n docs,\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n for (const param of params) {\n const value = asAny(param, sourceCodeInfo)\n if (value !== null) {\n return value\n }\n }\n return null\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import { RecurSignal } from '../../errors'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type RecurNode = SpecialExpressionNode<[typeof specialExpressionTypes['recur'], AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['recur(...recur-args)'],\n description: 'Recursevly calls enclosing function or loop with its evaluated `recur-args`.',\n examples: [\n `\nlet foo = (n) -> do\n write!(n);\n if not(zero?(n)) then\n recur(n - 1)\n end\nend;\nfoo(3)`,\n `\n(n -> do\n write!(n);\n if not(zero?(n)) then\n recur(n - 1)\n end\nend)(3)`,\n `\nloop (n = 3) -> do\n write!(n);\n if not(zero?(n)) then\n recur(n - 1)\n end\nend`,\n ],\n}\n\nexport const recurSpecialExpression: BuiltinSpecialExpression<null, RecurNode> = {\n arity: {},\n docs,\n evaluateAsNormalExpression: (params) => {\n throw new RecurSignal(params)\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) =>\n getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import { UserDefinedError } from '../../errors'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asString } from '../../typeGuards/string'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ThrowNode = SpecialExpressionNode<[typeof specialExpressionTypes['throw'], AstNode]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'never',\n },\n args: {\n expr: {\n type: 'any',\n },\n },\n variants: [\n { argumentNames: ['expr'] },\n ],\n description: 'Throws `UserDefinedError` with message set to $expr evaluated. $expr must evaluate to a string.',\n examples: [\n 'try throw(\"You shall not pass!\") catch(error) \"Error: \" ++ error.message end',\n 'try throw(slice(\"You shall not pass!\", 0, 3)) catch(error) \"Error: \" ++ error.message end',\n ],\n}\n\nexport const throwSpecialExpression: BuiltinSpecialExpression<null, ThrowNode> = {\n arity: toFixedArity(1),\n docs,\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n const message = asString(params[0], sourceCodeInfo, {\n nonEmpty: true,\n })\n throw new UserDefinedError(message, undefined)\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols([node[1][1]], contextStack, builtin, evaluateNode),\n}\n","import type { Context } from '../../evaluator/interface'\nimport type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode, SymbolNode } from '../../parser/types'\nimport { joinSets } from '../../utils'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type WithHandler = [AstNode, AstNode] // [effectExpr, handlerFn]\n\nexport type TryNode = SpecialExpressionNode<[typeof specialExpressionTypes['try'], AstNode, SymbolNode | undefined, AstNode | undefined, WithHandler[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: [\n 'try { try-body } catch { catch-body }',\n 'try { try-body } catch(error) { catch-body }',\n 'try { try-body } with { case effect then handler ... } end',\n 'try { try-body } with { case effect then handler ... } catch { catch-body }',\n 'try { try-body } with { case effect then handler ... } catch(error) { catch-body }',\n ],\n details: [\n ['try-body', 'expressions', 'The expressions to try.'],\n ['error', 'symbol', 'The error variable to bind.'],\n ['catch-body', 'expression', 'The expressions to evaluate if the try-body throws an error.'],\n ['effect', 'expression', 'An expression evaluating to an effect value.'],\n ['handler', 'expression', 'A function that handles the effect. Its return value resumes the perform call.'],\n ],\n description: 'Executes `try-body`. If that throws, the `catch-body` gets executed. '\n + 'Effect handlers can be installed via `with` to intercept `perform` calls. See examples for details.',\n examples: [\n `\ntry\n 2 / 4\ncatch\n \"Oops!\"\nend`,\n `\ntry\n foo()\ncatch(error)\n \"Error: \" ++ error.message\nend`,\n `\ntry\n foo()\ncatch\n 42\nend`,\n ],\n}\n\nexport const trySpecialExpression: BuiltinSpecialExpression<Any, TryNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const [, tryExpression, errorSymbol, catchExpression, withHandlers] = node[1]\n const tryResult = getUndefinedSymbols([tryExpression], contextStack, builtin, evaluateNode)\n\n let catchResult = new Set<string>()\n if (catchExpression) {\n const newContext: Context = errorSymbol\n ? {\n [errorSymbol[1]]: { value: true },\n }\n : {}\n catchResult = getUndefinedSymbols([catchExpression], contextStack.create(newContext), builtin, evaluateNode)\n }\n\n // Collect undefined symbols from with-handler expressions\n let withResult = new Set<string>()\n for (const [effectExpr, handlerFn] of withHandlers) {\n const effectResult = getUndefinedSymbols([effectExpr], contextStack, builtin, evaluateNode)\n const handlerResult = getUndefinedSymbols([handlerFn], contextStack, builtin, evaluateNode)\n withResult = joinSets(withResult, effectResult, handlerResult)\n }\n\n return joinSets(tryResult, catchResult, withResult)\n },\n}\n","import type { Any, Arr } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/dvala'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ArrayNode = SpecialExpressionNode<[typeof specialExpressionTypes['array'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'any',\n array: true,\n },\n args: {\n values: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['values'] },\n ],\n description: 'Makes new array from $values.',\n examples: [\n 'array(1, 2, 3)',\n 'array(array(null, false, true))',\n '[]',\n '[1, 2, 3]',\n '[1, 2, ...[3, 4, 5], 6]',\n '[[null, false, true]]',\n '[1, 2, 3][1]',\n ],\n hideOperatorForm: true,\n}\n\nexport const arraySpecialExpression: BuiltinSpecialExpression<Any, ArrayNode> = {\n arity: {},\n docs,\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n const result: Arr = []\n\n for (const param of params) {\n result.push(asAny(param, sourceCodeInfo))\n }\n\n return result\n },\n\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import type { EffectRef, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type EffectNode = SpecialExpressionNode<[typeof specialExpressionTypes['effect'], string]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: [\n 'effect(name)',\n ],\n details: [\n ['name', 'dotted identifier', 'The effect name, e.g. `llm.complete` or `dvala.log`.'],\n ],\n description: 'Returns the unique effect reference for the given name. '\n + 'Calling `effect` with the same name always returns the same reference. '\n + 'Effect references are first-class values that can be stored, passed, and compared with `==`.',\n examples: [\n 'effect(dvala.log)',\n '==(effect(llm.complete), effect(llm.complete))',\n ],\n}\n\nexport const effectSpecialExpression: BuiltinSpecialExpression<EffectRef, EffectNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: () => new Set<string>(),\n}\n","import type { Any, Obj } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { assertString } from '../../typeGuards/string'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ObjectNode = SpecialExpressionNode<[typeof specialExpressionTypes['object'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'object',\n },\n args: {\n kvps: {\n type: 'any',\n rest: true,\n description: 'key - value pairs, where key is a string',\n },\n },\n variants: [\n { argumentNames: ['kvps'] },\n ],\n description: 'Constructs a new object. Object members are created from the $kvps key-value pairs. Requires an even number of arguments.',\n examples: [\n 'object()',\n `\nlet default = {\n type: \"Person\",\n name: \"John Doe\",\n age: 42\n};\n\n{\n ...default,\n name: \"Lisa\"\n}`,\n 'object(\"x\", 10, \"y\", true, \"z\", \"A string\")',\n '{}',\n '{ a: 1, b: 2 }',\n ],\n hideOperatorForm: true,\n}\n\nexport const objectSpecialExpression: BuiltinSpecialExpression<Any, ObjectNode> = {\n arity: {},\n docs,\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n const result: Obj = {}\n\n for (let i = 0; i < params.length; i += 2) {\n const key = params[i]\n const value = params[i + 1]\n assertString(key, sourceCodeInfo)\n result[key] = value ?? null\n }\n\n return result\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import type { Arr } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { joinSets } from '../../utils'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ParallelNode = SpecialExpressionNode<[typeof specialExpressionTypes['parallel'], AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: [\n 'parallel(expr1, expr2, ...)',\n ],\n details: [\n ['expr1, expr2, ...', 'expressions', 'Expressions to evaluate concurrently. Typically `perform(...)` calls.'],\n ],\n description: 'Evaluates all branch expressions concurrently and returns an array of results in order. '\n + 'Each branch runs as an independent trampoline invocation. If any branch suspends, '\n + 'the entire `parallel` suspends with a composite blob. On resume, branches are resumed '\n + 'one at a time. Only available in async mode (`run()`). Requires at least one branch.',\n examples: [],\n}\n\nexport const parallelSpecialExpression: BuiltinSpecialExpression<Arr, ParallelNode> = {\n arity: { min: 1 },\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const branches = node[1][1] as AstNode[]\n const sets = branches.map(branch => getUndefinedSymbols([branch], contextStack, builtin, evaluateNode))\n return joinSets(...sets)\n },\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { joinSets } from '../../utils'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type PerformNode = SpecialExpressionNode<[typeof specialExpressionTypes['perform'], AstNode, AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: [\n 'perform(eff)',\n 'perform(eff, arg1)',\n 'perform(eff, arg1, arg2, ...)',\n ],\n details: [\n ['eff', 'expression', 'An expression evaluating to an effect value (from `effect(name)`).'],\n ['arg1, arg2, ...', 'expressions', 'Arguments passed to the effect handler.'],\n ],\n description: 'Invokes an effect. The nearest enclosing `try/with` handler matching the effect '\n + 'intercepts the call. The handler receives the arguments as an array and its return value '\n + 'becomes the result of `perform`. If no local handler matches, the effect is dispatched '\n + 'to the host.',\n examples: [\n `\ntry\n perform(effect(dvala.log), \"hello\")\nwith\n case effect(dvala.log) then ([msg]) -> msg\nend\n`,\n ],\n}\n\nexport const performSpecialExpression: BuiltinSpecialExpression<Any, PerformNode> = {\n arity: { min: 1 },\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const [, effectExpr, argExprs] = node[1]\n const effectResult = getUndefinedSymbols([effectExpr], contextStack, builtin, evaluateNode)\n const argsResult = getUndefinedSymbols(argExprs, contextStack, builtin, evaluateNode)\n return joinSets(effectResult, argsResult)\n },\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { joinSets } from '../../utils'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type RaceNode = SpecialExpressionNode<[typeof specialExpressionTypes['race'], AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: [\n 'race(expr1, expr2, ...)',\n ],\n details: [\n ['expr1, expr2, ...', 'expressions', 'Expressions to race concurrently. Typically `perform(...)` calls.'],\n ],\n description: 'Races all branch expressions concurrently. The first branch to complete wins — '\n + 'its value becomes the result. Losing branches are cancelled via AbortSignal. '\n + 'Errored branches are silently dropped. If all branches error, throws an aggregate error. '\n + 'If no branch completes but some suspend, the race suspends. On resume, the host provides '\n + 'the winner value directly. Only available in async mode (`run()`). Requires at least one branch.',\n examples: [],\n}\n\nexport const raceSpecialExpression: BuiltinSpecialExpression<Any, RaceNode> = {\n arity: { min: 1 },\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const branches = node[1][1] as AstNode[]\n const sets = branches.map(branch => getUndefinedSymbols([branch], contextStack, builtin, evaluateNode))\n return joinSets(...sets)\n },\n}\n","import type { Builtin } from './interface'\nimport { allNormalExpressions, normalExpressions } from './normalExpressions'\nimport { andSpecialExpression } from './specialExpressions/and'\nimport { condSpecialExpression } from './specialExpressions/cond'\nimport { matchSpecialExpression } from './specialExpressions/match'\nimport { definedSpecialExpression } from './specialExpressions/defined'\nimport { doSpecialExpression } from './specialExpressions/block'\nimport { lambdaSpecialExpression } from './specialExpressions/functions'\nimport { ifSpecialExpression } from './specialExpressions/if'\nimport { unlessSpecialExpression } from './specialExpressions/unless'\nimport { letSpecialExpression } from './specialExpressions/let'\nimport { loopSpecialExpression } from './specialExpressions/loop'\nimport { doseqSpecialExpression, forSpecialExpression } from './specialExpressions/loops'\nimport { orSpecialExpression } from './specialExpressions/or'\nimport { qqSpecialExpression } from './specialExpressions/qq'\nimport { recurSpecialExpression } from './specialExpressions/recur'\nimport { throwSpecialExpression } from './specialExpressions/throw'\nimport { trySpecialExpression } from './specialExpressions/try'\nimport { arraySpecialExpression } from './specialExpressions/array'\nimport { effectSpecialExpression } from './specialExpressions/effect'\nimport { objectSpecialExpression } from './specialExpressions/object'\nimport { importSpecialExpression } from './specialExpressions/import'\nimport { parallelSpecialExpression } from './specialExpressions/parallel'\nimport { performSpecialExpression } from './specialExpressions/perform'\nimport { raceSpecialExpression } from './specialExpressions/race'\nimport { specialExpressionTypes } from './specialExpressionTypes'\n\nexport const specialExpressions = [\n qqSpecialExpression,\n andSpecialExpression,\n orSpecialExpression,\n arraySpecialExpression,\n condSpecialExpression,\n definedSpecialExpression,\n doSpecialExpression,\n doseqSpecialExpression,\n lambdaSpecialExpression,\n forSpecialExpression,\n ifSpecialExpression,\n letSpecialExpression,\n loopSpecialExpression,\n objectSpecialExpression,\n recurSpecialExpression,\n matchSpecialExpression,\n throwSpecialExpression,\n trySpecialExpression,\n unlessSpecialExpression,\n importSpecialExpression,\n effectSpecialExpression,\n performSpecialExpression,\n parallelSpecialExpression,\n raceSpecialExpression,\n] as const\n\nexport type SpecialExpressions = typeof specialExpressions\nexport type SpecialExpression = SpecialExpressions[number]\nexport type SpecialExpressionName = keyof typeof specialExpressionTypes\nexport type CommonSpecialExpressionType = [\n | typeof specialExpressionTypes['??']\n | typeof specialExpressionTypes['&&']\n | typeof specialExpressionTypes['cond']\n | typeof specialExpressionTypes['match']\n | typeof specialExpressionTypes['defined?']\n | typeof specialExpressionTypes['block']\n | typeof specialExpressionTypes['if']\n | typeof specialExpressionTypes['unless']\n | typeof specialExpressionTypes['||']\n | typeof specialExpressionTypes['throw']\n | typeof specialExpressionTypes['array']\n | typeof specialExpressionTypes['object']\n | typeof specialExpressionTypes['effect']\n | typeof specialExpressionTypes['perform']\n | typeof specialExpressionTypes['parallel']\n | typeof specialExpressionTypes['race'],\n]\n\nexport type SpecialExpressionType = typeof specialExpressionTypes[SpecialExpressionName]\n\nexport const builtin: Builtin = {\n normalExpressions,\n specialExpressions,\n allNormalExpressions,\n}\n\nexport const normalExpressionKeys = Object.keys(normalExpressions)\nexport const specialExpressionKeys = Object.keys(specialExpressionTypes)\n","import type { Any } from '../../interface'\nimport type { SpecialExpressionNode } from '../../parser/types'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ImportNode = SpecialExpressionNode<[typeof specialExpressionTypes['import'], string]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n description: 'Imports all functions from a module as an object. Use destructuring to pick specific functions.',\n customVariants: [\n 'import(module-name)',\n ],\n returns: { type: 'object' },\n examples: [\n 'let v = import(vector); v.stdev([1, 2, 3, 4])',\n 'let { linspace } = import(vector); linspace(0, 10, 5)',\n 'let g = import(grid); g.row([[1, 2], [3, 4]], 0)',\n ],\n}\n\nexport const importSpecialExpression: BuiltinSpecialExpression<Any, ImportNode> = {\n arity: toFixedArity(1),\n docs,\n getUndefinedSymbols: () => new Set(),\n}\n","import type { Any } from '../interface'\n\nconst nonNumberReservedSymbolRecord = {\n true: true,\n false: false,\n null: null,\n do: null,\n else: null,\n case: null,\n each: null,\n in: null,\n when: null,\n while: null,\n catch: null,\n function: null,\n as: null,\n then: null,\n end: null,\n with: null,\n _: null,\n} as const satisfies Record<string, Any>\n\nconst phi = (1 + Math.sqrt(5)) / 2\nexport const numberReservedSymbolRecord = {\n 'E': Math.E,\n '-E': -Math.E,\n 'ε': Math.E,\n '-ε': -Math.E,\n 'PI': Math.PI,\n '-PI': -Math.PI,\n 'π': Math.PI,\n '-π': -Math.PI,\n 'PHI': phi,\n '-PHI': -phi,\n 'φ': phi,\n '-φ': -phi,\n 'POSITIVE_INFINITY': Number.POSITIVE_INFINITY,\n '∞': Number.POSITIVE_INFINITY,\n 'NEGATIVE_INFINITY': Number.NEGATIVE_INFINITY,\n '-∞': Number.NEGATIVE_INFINITY,\n 'MAX_SAFE_INTEGER': Number.MAX_SAFE_INTEGER,\n 'MIN_SAFE_INTEGER': Number.MIN_SAFE_INTEGER,\n 'MAX_VALUE': Number.MAX_VALUE,\n 'MIN_VALUE': Number.MIN_VALUE,\n 'NaN': Number.NaN,\n} as const satisfies Record<string, number>\n\nexport const reservedSymbolRecord = {\n ...nonNumberReservedSymbolRecord,\n ...numberReservedSymbolRecord,\n} as const\n\nexport type ReservedSymbol = keyof typeof reservedSymbolRecord\n\nexport function isReservedSymbol(symbol: string): symbol is keyof typeof reservedSymbolRecord {\n return symbol in reservedSymbolRecord\n}\n\nexport function isNumberReservedSymbol(symbol: string): symbol is keyof typeof numberReservedSymbolRecord {\n return symbol in numberReservedSymbolRecord\n}\n","/**\n * Shared types for the algebraic effects system.\n *\n * This module exists to break the circular dependency between `effects.ts`\n * (standalone functions) and `evaluator/trampoline.ts` (trampoline loop).\n * Both modules import types from here without creating a cycle.\n */\n\nimport type { Any } from '../interface'\nimport type { DvalaError } from '../errors'\nimport type { ContinuationStack } from './frames'\n\n// ---------------------------------------------------------------------------\n// Suspension blob — opaque serialized continuation\n// ---------------------------------------------------------------------------\n\n/**\n * Opaque string containing the serialized continuation stack.\n * Created by `suspend()`, consumed by `resume()`.\n * Internally it's JSON, but hosts should treat it as opaque.\n */\nexport type SuspensionBlob = string\n\n// ---------------------------------------------------------------------------\n// Effect handler types\n// ---------------------------------------------------------------------------\n\n/**\n * Context passed to a host effect handler.\n *\n * The handler must call exactly one of `resume` or `suspend`, exactly once.\n * Calling both, or calling either more than once, is a programming error.\n */\nexport interface EffectContext {\n /** Arguments from the Dvala `perform(eff, arg1, arg2, ...)` call. */\n args: Any[]\n\n /**\n * Aborted when: `race()` branch loses, runtime is disposed, or host cancels.\n * Combine with timeout: `AbortSignal.any([signal, AbortSignal.timeout(ms)])`\n */\n signal: AbortSignal\n\n /**\n * Resume the program with the given value (or a Promise that resolves to one).\n * The value becomes the result of the `perform(...)` expression in Dvala.\n */\n resume: (value: Any | Promise<Any>) => void\n\n /**\n * Suspend the program. The entire execution state is captured and returned\n * in `RunResult` as `{ type: 'suspended', continuation, meta }`.\n * `meta` is passed through to `RunResult.meta` for domain context\n * (e.g., assignee, deadline, priority).\n */\n suspend: (meta?: Any) => void\n}\n\n/** An async function that handles an effect by calling `resume` or `suspend`. */\nexport type EffectHandler = (ctx: EffectContext) => Promise<void>\n\n/** Map from effect name (e.g. `'llm.complete'`) to its handler. */\nexport type Handlers = Record<string, EffectHandler>\n\n// ---------------------------------------------------------------------------\n// Run result types\n// ---------------------------------------------------------------------------\n\n/**\n * The result of `run()` — always resolves, never rejects.\n * Errors are captured in the `error` variant.\n */\nexport type RunResult =\n | { type: 'completed', value: Any }\n | { type: 'suspended', blob: SuspensionBlob, meta?: Any }\n | { type: 'error', error: DvalaError }\n\n// ---------------------------------------------------------------------------\n// Suspension signal — used internally by the trampoline\n// ---------------------------------------------------------------------------\n\n/**\n * Thrown (as a promise rejection) by `suspend()` inside a host handler.\n * Caught by the effect trampoline loop — NOT by Dvala-level try/catch.\n */\nexport class SuspensionSignal {\n public readonly _brand = 'SuspensionSignal' as const\n constructor(\n /** The captured continuation stack at the point of suspension. */\n public readonly k: ContinuationStack,\n /** Optional domain metadata passed through to RunResult. */\n public readonly meta?: Any,\n ) {}\n}\n\nexport function isSuspensionSignal(value: unknown): value is SuspensionSignal {\n return value instanceof SuspensionSignal\n}\n","/**\n * EffectRef Interning\n *\n * Maintains a module-level intern map so that `getEffectRef('llm.complete')`\n * always returns the exact same `EffectRef` object. This guarantees reference\n * equality (`===`) for effect values created with the same name, which is\n * important for handler matching in `try/with` blocks.\n *\n * EffectRef values are serializable — they are stored as just their name string.\n * When a continuation is restored, the name is used to look up (or recreate)\n * the unique EffectRef in the new runtime.\n */\n\nimport type { EffectRef } from '../parser/types'\nimport { EFFECT_SYMBOL } from '../utils/symbols'\n\nconst internMap = new Map<string, EffectRef>()\n\n/**\n * Returns the unique EffectRef for the given name.\n * Calling with the same name always returns the same reference.\n *\n * @example\n * const a = getEffectRef('llm.complete')\n * const b = getEffectRef('llm.complete')\n * a === b // true\n */\nexport function getEffectRef(name: string): EffectRef {\n let ref = internMap.get(name)\n if (!ref) {\n ref = {\n [EFFECT_SYMBOL]: true,\n name,\n }\n internMap.set(name, ref)\n }\n return ref\n}\n\n/**\n * Clears the intern map. Primarily for testing.\n */\nexport function clearEffectRefInternMap(): void {\n internMap.clear()\n}\n","import type { SpecialExpression } from '../builtin'\nimport { builtin, normalExpressionKeys, specialExpressionKeys } from '../builtin'\nimport { allNormalExpressions } from '../builtin/normalExpressions'\nimport { specialExpressionTypes } from '../builtin/specialExpressionTypes'\nimport { DvalaError, UndefinedSymbolError } from '../errors'\nimport type { Any } from '../interface'\nimport type { ContextParams, JsFunction } from '../Dvala/Dvala'\nimport type { DvalaModule } from '../builtin/modules/interface'\nimport type { NativeJsFunction, NormalBuiltinFunction, SpecialBuiltinFunction, SymbolNode, UserDefinedSymbolNode } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asNonUndefined } from '../typeGuards'\nimport { isNormalBuiltinSymbolNode, isSpecialBuiltinSymbolNode } from '../typeGuards/astNode'\nimport { toAny } from '../utils'\nimport { FUNCTION_SYMBOL } from '../utils/symbols'\nimport type { Context, LookUpResult } from './interface'\nimport { isContextEntry } from './interface'\n\nexport type ContextStack = ContextStackImpl\n\nexport class ContextStackImpl {\n private _contexts: Context[]\n public globalContext: Context\n private values?: Record<string, unknown>\n private nativeJsFunctions?: Record<string, NativeJsFunction>\n private modules: Map<string, DvalaModule>\n private valueModules: Map<string, unknown>\n public pure: boolean\n constructor({\n contexts,\n values: hostValues,\n nativeJsFunctions,\n modules,\n valueModules,\n pure,\n }: {\n contexts: Context[]\n values?: Record<string, unknown>\n nativeJsFunctions?: Record<string, NativeJsFunction>\n modules?: Map<string, DvalaModule>\n valueModules?: Map<string, unknown>\n pure?: boolean\n }) {\n this.globalContext = asNonUndefined(contexts[0])\n this._contexts = contexts\n this.values = hostValues\n this.nativeJsFunctions = nativeJsFunctions\n this.modules = modules ?? new Map<string, DvalaModule>()\n this.valueModules = valueModules ?? new Map<string, unknown>()\n this.pure = pure ?? false\n }\n\n // -- Serialization support (Phase 4) --\n\n /** Get the raw context chain for serialization. */\n public getContextsRaw(): Context[] {\n return this._contexts\n }\n\n /** Get host values (plain bindings passed at creation). */\n public getHostValues(): Record<string, unknown> | undefined {\n return this.values\n }\n\n /**\n * Find the index of globalContext in the _contexts array.\n * Returns -1 if not found (should not happen in valid state).\n */\n public getGlobalContextIndex(): number {\n return this._contexts.indexOf(this.globalContext)\n }\n\n /**\n * Create a ContextStack from deserialized data.\n * `contexts` is the restored context chain (already resolved).\n * `globalContextIndex` identifies which element is the globalContext.\n * Host bindings (`values`, `nativeJsFunctions`, `modules`) come from resume options.\n */\n public static fromDeserialized(params: {\n contexts: Context[]\n globalContextIndex: number\n values?: Record<string, unknown>\n nativeJsFunctions?: Record<string, NativeJsFunction>\n modules?: Map<string, DvalaModule>\n pure: boolean\n }): ContextStackImpl {\n const cs = new ContextStackImpl({\n contexts: params.contexts,\n values: params.values,\n nativeJsFunctions: params.nativeJsFunctions,\n modules: params.modules,\n pure: params.pure,\n })\n if (params.globalContextIndex >= 0 && params.globalContextIndex < params.contexts.length) {\n cs.globalContext = params.contexts[params.globalContextIndex]!\n }\n return cs\n }\n\n /**\n * Replace the contexts array and globalContext. Used during deserialization\n * to fill in resolved context data after circular references are handled.\n */\n public setContextsFromDeserialized(contexts: Context[], globalContextIndex: number): void {\n this._contexts = contexts\n if (globalContextIndex >= 0 && globalContextIndex < contexts.length) {\n this.globalContext = contexts[globalContextIndex]!\n }\n }\n\n public getModule(name: string): DvalaModule | undefined {\n return this.modules.get(name)\n }\n\n public getValueModule(name: string): { value: unknown, found: boolean } {\n if (this.valueModules.has(name)) {\n return { value: this.valueModules.get(name), found: true }\n }\n return { value: undefined, found: false }\n }\n\n public registerValueModule(name: string, value: unknown): void {\n this.valueModules.set(name, value)\n }\n\n public create(context: Context): ContextStack {\n const globalContext = this.globalContext\n const contextStack = new ContextStackImpl({\n contexts: [context, ...this._contexts],\n values: this.values,\n nativeJsFunctions: this.nativeJsFunctions,\n modules: this.modules,\n valueModules: this.valueModules,\n pure: this.pure,\n })\n contextStack.globalContext = globalContext\n return contextStack\n }\n\n public new(context: Context): ContextStack {\n const contexts = [{}, context]\n\n return new ContextStackImpl({ contexts, modules: this.modules, valueModules: this.valueModules, pure: this.pure })\n }\n\n public addValues(values: Record<string, Any>, sourceCodeInfo: SourceCodeInfo | undefined) {\n const currentContext = this._contexts[0]!\n for (const [name, value] of Object.entries(values)) {\n if (currentContext[name]) {\n throw new DvalaError(`Cannot redefine value \"${name}\"`, sourceCodeInfo)\n }\n const shadowedName = getShadowedBuiltinName(name)\n if (shadowedName) {\n throw new DvalaError(`Cannot shadow ${shadowedName}`, sourceCodeInfo)\n }\n currentContext[name] = { value: toAny(value) }\n }\n }\n\n public getValue(name: string): unknown {\n for (const context of this._contexts) {\n const contextEntry = context[name]\n if (contextEntry)\n return contextEntry.value\n }\n\n const nativeJsFunction = this.nativeJsFunctions?.[name]\n if (nativeJsFunction)\n return nativeJsFunction\n\n return this.values?.[name]\n }\n\n public lookUp(node: UserDefinedSymbolNode): LookUpResult {\n const value = node[1]\n\n for (const context of this._contexts) {\n const contextEntry = context[value]\n if (contextEntry)\n return contextEntry\n }\n const hostValue = this.values?.[value]\n if (hostValue !== undefined) {\n return {\n value: toAny(hostValue),\n }\n }\n\n const nativeJsFunction = this.nativeJsFunctions?.[value]\n if (nativeJsFunction) {\n return {\n value: nativeJsFunction,\n }\n }\n\n return null\n }\n\n public evaluateSymbol(node: SymbolNode): Any {\n if (isSpecialBuiltinSymbolNode(node)) {\n const functionType = node[1]\n switch (functionType) {\n case specialExpressionTypes['&&']:\n case specialExpressionTypes['||']:\n case specialExpressionTypes.array:\n case specialExpressionTypes.object:\n case specialExpressionTypes['defined?']:\n case specialExpressionTypes.recur:\n case specialExpressionTypes.throw:\n case specialExpressionTypes['??']: {\n const specialExpression: SpecialExpression = asNonUndefined(builtin.specialExpressions[functionType], node[2])\n return {\n [FUNCTION_SYMBOL]: true,\n functionType: 'SpecialBuiltin',\n specialBuiltinSymbolType: functionType,\n sourceCodeInfo: node[2],\n arity: specialExpression.arity,\n } satisfies SpecialBuiltinFunction\n }\n default:\n throw new DvalaError(`Unknown special builtin symbol type: ${functionType}`, node[2])\n }\n }\n if (isNormalBuiltinSymbolNode(node)) {\n const type = node[1]\n const normalExpression = allNormalExpressions[type]!\n const name = normalExpression.name!\n return {\n [FUNCTION_SYMBOL]: true,\n functionType: 'Builtin',\n normalBuiltinSymbolType: type,\n sourceCodeInfo: node[2],\n arity: normalExpression.arity,\n name,\n } satisfies NormalBuiltinFunction\n }\n const lookUpResult = this.lookUp(node)\n\n if (isContextEntry(lookUpResult))\n return lookUpResult.value\n\n throw new UndefinedSymbolError(node[1], node[2])\n }\n}\n\nfunction getShadowedBuiltinName(name: string): string | null {\n if (specialExpressionKeys.includes(name))\n return `special expression \"${name}\"`\n if (normalExpressionKeys.includes(name))\n return `builtin function \"${name}\"`\n if (name === 'self')\n return `builtin value \"${name}\"`\n return null\n}\n\nfunction assertNotShadowingBuiltin(name: string): void {\n const shadowedName = getShadowedBuiltinName(name)\n if (shadowedName) {\n throw new DvalaError(`Cannot shadow ${shadowedName}`, undefined)\n }\n}\n\nexport function createContextStack(params: ContextParams = {}, modules?: Map<string, DvalaModule>, pure?: boolean): ContextStack {\n const globalContext = params.globalContext ?? {}\n // Contexts are checked from left to right\n const contexts = params.contexts ? [globalContext, ...params.contexts] : [globalContext]\n\n // Process bindings: separate plain values from JS functions\n let hostValues: Record<string, unknown> | undefined\n let nativeJsFunctions: Record<string, NativeJsFunction> | undefined\n\n if (params.bindings) {\n for (const [identifier, entry] of Object.entries(params.bindings)) {\n if (identifier.includes('.')) {\n throw new DvalaError(`Dots are not allowed in binding keys: \"${identifier}\"`, undefined)\n }\n\n const isFunction = typeof entry === 'function'\n\n if (isFunction) {\n const jsFunction: JsFunction = { fn: entry as (...args: any[]) => unknown }\n\n assertNotShadowingBuiltin(identifier)\n if (!nativeJsFunctions) {\n nativeJsFunctions = {}\n }\n nativeJsFunctions[identifier] = {\n functionType: 'NativeJsFunction',\n nativeFn: jsFunction,\n name: identifier,\n [FUNCTION_SYMBOL]: true,\n arity: jsFunction.arity ?? {},\n docString: jsFunction.docString ?? '',\n } satisfies NativeJsFunction\n }\n else {\n // Plain value binding\n assertNotShadowingBuiltin(identifier)\n if (!hostValues) {\n hostValues = {}\n }\n hostValues[identifier] = entry\n }\n }\n }\n\n const contextStack = new ContextStackImpl({\n contexts,\n values: hostValues,\n modules,\n nativeJsFunctions,\n pure,\n })\n return params.globalModuleScope ? contextStack : contextStack.create({})\n}\n","import type { Any, Arr } from '../interface'\nimport type { AstNode, FunctionLike } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isUnknownRecord } from '../typeGuards'\nimport type { MaybePromise } from '../utils/maybePromise'\nimport type { ContextStack } from './ContextStack'\n\ninterface ContextEntry { value: Any }\nexport type Context = Record<string, ContextEntry>\n\nexport type EvaluateNode = (node: AstNode, contextStack: ContextStack) => MaybePromise<Any>\nexport type ExecuteFunction = (fn: FunctionLike, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo) => MaybePromise<Any>\n\nexport type LookUpResult = ContextEntry | null\n\nexport function isContextEntry(value: unknown): value is ContextEntry {\n return isUnknownRecord(value) && value.value !== undefined\n}\n","/**\n * DvalaValue Serialization Contract\n *\n * Defines which runtime value types can be serialized to JSON and restored.\n * Used at suspension time to produce clear errors when non-serializable\n * values (e.g. NativeJsFunction) are found in the continuation stack.\n *\n * Serializable value types:\n * - Primitives: number, string, boolean, null\n * - Containers: array, object (if all contents are serializable)\n * - RegularExpression: stored as {s, f} string data\n * - UserDefinedFunction: {params, body, capturedEnv} — all plain data\n * - NormalBuiltinFunction: identified by normalBuiltinSymbolType (number)\n * - SpecialBuiltinFunction: identified by specialBuiltinSymbolType (number)\n * - ModuleFunction: identified by {moduleName, functionName}\n * - PartialFunction, CompFunction, ConstantlyFunction, JuxtFunction,\n * ComplementFunction, EveryPredFunction, SomePredFunction, FNullFunction:\n * serializable only if all inner values/functions are serializable\n * - EffectRef: stored as just the name string\n *\n * Non-serializable value types:\n * - NativeJsFunction: contains a live JS function reference.\n * These live in the global context and are re-injected from `bindings`\n * on resume — they must never appear in serialized continuation frames.\n */\n\nimport type { Any } from '../interface'\nimport { isDvalaFunction } from '../typeGuards/dvalaFunction'\nimport { isEffectRef, isRegularExpression } from '../typeGuards/dvala'\nimport type {\n DvalaFunction,\n} from '../parser/types'\n\n/**\n * Checks whether a Dvala runtime value is fully JSON-serializable.\n *\n * Returns `true` if the value can be serialized and later restored.\n * Returns `false` if any part of the value contains a NativeJsFunction\n * or other non-serializable reference.\n *\n * Uses a `Set` to track visited objects and avoid infinite loops from\n * circular references (which are themselves not serializable, but we\n * want to report NativeJsFunction as the problem, not stack overflow).\n */\nexport function isSerializable(value: Any, visited = new Set<object>()): boolean {\n // Primitives are always serializable\n if (value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return true\n }\n\n // Guard against circular references\n if (typeof value === 'object') {\n if (visited.has(value)) {\n return false\n }\n visited.add(value)\n }\n\n // RegularExpression — just string data {s, f}\n if (isRegularExpression(value)) {\n return true\n }\n\n // EffectRef — just a name string\n if (isEffectRef(value)) {\n return true\n }\n\n // DvalaFunction — check by functionType\n if (isDvalaFunction(value)) {\n return isDvalaFunctionSerializable(value, visited)\n }\n\n // Array — serializable if all elements are\n if (Array.isArray(value)) {\n return value.every(item => isSerializable(item as Any, visited))\n }\n\n // Plain object — serializable if all values are\n if (typeof value === 'object') {\n return Object.values(value).every(v => isSerializable(v as Any, visited))\n }\n\n // Anything else (shouldn't happen in well-typed code) is not serializable\n return false\n}\n\nfunction isDvalaFunctionSerializable(fn: DvalaFunction, visited: Set<object>): boolean {\n switch (fn.functionType) {\n // Always serializable — contain only primitive/index data\n case 'UserDefined':\n case 'Builtin':\n case 'SpecialBuiltin':\n case 'Module':\n return true\n\n // NativeJsFunction — never serializable\n case 'NativeJsFunction':\n return false\n\n // Conditionally serializable — check inner values/functions\n case 'Partial': {\n const partial = fn\n return isSerializable(partial.function as Any, visited)\n && partial.params.every(p => isSerializable(p as Any, visited))\n }\n\n case 'Comp': {\n const comp = fn\n return comp.params.every(p => isSerializable(p as Any, visited))\n }\n\n case 'Constantly': {\n const constantly = fn\n return isSerializable(constantly.value, visited)\n }\n\n case 'Juxt': {\n const juxt = fn\n return juxt.params.every(p => isSerializable(p as Any, visited))\n }\n\n case 'Complement': {\n const complement = fn\n return isSerializable(complement.function as Any, visited)\n }\n\n case 'EveryPred': {\n const everyPred = fn\n return everyPred.params.every(p => isSerializable(p as Any, visited))\n }\n\n case 'SomePred': {\n const somePred = fn\n return somePred.params.every(p => isSerializable(p as Any, visited))\n }\n\n case 'Fnull': {\n const fnull = fn\n return isSerializable(fnull.function as Any, visited)\n && fnull.params.every(p => isSerializable(p as Any, visited))\n }\n\n /* v8 ignore next 2 */\n default:\n return false\n }\n}\n\n/**\n * Describes why a value is not serializable.\n * Returns `null` if the value is serializable.\n * Returns a human-readable string describing the first non-serializable\n * component found.\n */\nexport function describeSerializationIssue(value: Any, path: string = 'value'): string | null {\n if (value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\n return null\n }\n\n if (isRegularExpression(value)) {\n return null\n }\n\n if (isEffectRef(value)) {\n return null\n }\n\n if (isDvalaFunction(value)) {\n if (value.functionType === 'NativeJsFunction') {\n return `${path} is a NativeJsFunction (${value.name ?? 'anonymous'}). NativeJsFunctions are not serializable — they are re-injected from bindings on resume.`\n }\n\n if (value.functionType === 'UserDefined' || value.functionType === 'Builtin' || value.functionType === 'SpecialBuiltin' || value.functionType === 'Module') {\n return null\n }\n\n // Check inner functions for compound function types\n if (value.functionType === 'Partial') {\n const partial = value\n const fnIssue = describeSerializationIssue(partial.function as Any, `${path}.function`)\n if (fnIssue)\n return fnIssue\n for (let i = 0; i < partial.params.length; i++) {\n const paramIssue = describeSerializationIssue(partial.params[i] as Any, `${path}.params[${i}]`)\n if (paramIssue)\n return paramIssue\n }\n return null\n }\n\n if (value.functionType === 'Comp') {\n const comp = value\n for (let i = 0; i < comp.params.length; i++) {\n const paramIssue = describeSerializationIssue(comp.params[i] as Any, `${path}.params[${i}]`)\n if (paramIssue)\n return paramIssue\n }\n return null\n }\n\n if (value.functionType === 'Complement') {\n const complement = value\n return describeSerializationIssue(complement.function as Any, `${path}.function`)\n }\n\n if (value.functionType === 'Constantly') {\n const constantly = value\n return describeSerializationIssue(constantly.value, `${path}.value`)\n }\n\n if (value.functionType === 'Juxt') {\n const juxt = value\n for (let i = 0; i < juxt.params.length; i++) {\n const paramIssue = describeSerializationIssue(juxt.params[i] as Any, `${path}.params[${i}]`)\n if (paramIssue)\n return paramIssue\n }\n return null\n }\n\n if (value.functionType === 'EveryPred') {\n const everyPred = value\n for (let i = 0; i < everyPred.params.length; i++) {\n const paramIssue = describeSerializationIssue(everyPred.params[i] as Any, `${path}.params[${i}]`)\n if (paramIssue)\n return paramIssue\n }\n return null\n }\n\n if (value.functionType === 'SomePred') {\n const somePred = value\n for (let i = 0; i < somePred.params.length; i++) {\n const paramIssue = describeSerializationIssue(somePred.params[i] as Any, `${path}.params[${i}]`)\n if (paramIssue)\n return paramIssue\n }\n return null\n }\n\n if (value.functionType === 'Fnull') {\n const fnull = value\n const fnIssue = describeSerializationIssue(fnull.function as Any, `${path}.function`)\n if (fnIssue)\n return fnIssue\n for (let i = 0; i < fnull.params.length; i++) {\n const paramIssue = describeSerializationIssue(fnull.params[i] as Any, `${path}.params[${i}]`)\n if (paramIssue)\n return paramIssue\n }\n return null\n }\n\n return `${path} has unknown function type ${value}`\n }\n\n if (Array.isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const issue = describeSerializationIssue(value[i] as Any, `${path}[${i}]`)\n if (issue)\n return issue\n }\n return null\n }\n\n if (typeof value === 'object') {\n for (const [key, v] of Object.entries(value)) {\n const issue = describeSerializationIssue(v as Any, `${path}.${key}`)\n if (issue)\n return issue\n }\n return null\n }\n\n return `${path} has unexpected type ${typeof value}`\n}\n","/**\n * Continuation stack serialization and deserialization.\n *\n * When a host handler calls `suspend(meta?)`, the trampoline captures the\n * continuation stack (an array of Frame objects). This module converts that\n * stack to/from a JSON string (the \"suspension blob\") that can be stored,\n * transferred, and later resumed in a new process.\n *\n * The main challenge is that Frame objects contain `ContextStack` class\n * instances (which hold lexical scope chains). These are not plain data\n * and may form circular references (e.g., a global context containing a\n * UserDefinedFunction whose captured env references the same global context).\n *\n * The serialization approach:\n * 1. Walk the frame tree and collect all unique ContextStack instances (by identity)\n * 2. Assign each a numeric ID\n * 3. Serialize ContextStacks separately as plain objects\n * 4. In the frame tree, replace ContextStack references with `{ __csRef: id }`\n * 5. First occurrence of each ContextStack gets `{ __csDef: id, ... }` in the\n * contextStacks array — circular refs just become `{ __csRef: id }`\n *\n * Deserialization reverses this:\n * 1. Parse the blob and create placeholder ContextStack instances\n * 2. Deep-resolve all `__csRef` markers back to real instances\n * 3. Fill in host bindings (values, nativeJsFunctions, modules) on each instance\n */\n\nimport { DvalaError } from '../errors'\nimport type { Any } from '../interface'\nimport type { NativeJsFunction } from '../parser/types'\nimport { isDvalaFunction } from '../typeGuards/dvalaFunction'\nimport type { DvalaModule } from '../builtin/modules/interface'\nimport { ContextStackImpl } from './ContextStack'\nimport type { Context } from './interface'\nimport type { ContinuationStack } from './frames'\nimport { describeSerializationIssue } from './serialization'\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nconst SUSPENSION_VERSION = 1\n\n// ---------------------------------------------------------------------------\n// Internal blob structure (what gets JSON-stringified)\n// ---------------------------------------------------------------------------\n\ninterface SerializedContextStack {\n id: number\n contexts: unknown[] // Context[] with nested ContextStacks replaced by refs\n globalContextIndex: number\n pure: boolean\n}\n\ninterface SuspensionBlobData {\n version: number\n contextStacks: SerializedContextStack[]\n k: unknown // ContinuationStack with ContextStacks replaced by refs\n meta?: Any\n}\n\n// Marker objects embedded in the serialized data\ninterface CSRef { __csRef: number }\n\nfunction isCSRef(value: unknown): value is CSRef {\n return value !== null\n && typeof value === 'object'\n && '__csRef' in value\n && typeof (value as CSRef).__csRef === 'number'\n}\n\n// ---------------------------------------------------------------------------\n// Serialize\n// ---------------------------------------------------------------------------\n\n/**\n * Serialize a continuation stack and optional metadata into an opaque JSON blob.\n *\n * Validates that all values are serializable (no NativeJsFunctions in frames).\n * Throws a descriptive `DvalaError` if non-serializable values are found.\n */\nexport function serializeSuspension(k: ContinuationStack, meta?: Any): string {\n // Phase 1: Collect all unique ContextStack instances\n const csMap = new Map<ContextStackImpl, number>()\n let nextId = 0\n\n function collectContextStacks(value: unknown): void {\n if (value instanceof ContextStackImpl) {\n if (csMap.has(value)) {\n return // Already visited — handles circular refs\n }\n csMap.set(value, nextId++)\n // Recurse into contexts to find nested ContextStacks (e.g., in UserDefinedFunction captured envs)\n for (const ctx of value.getContextsRaw()) {\n for (const entry of Object.values(ctx)) {\n collectContextStacks(entry.value)\n }\n }\n return\n }\n if (Array.isArray(value)) {\n for (const item of value) {\n collectContextStacks(item)\n }\n return\n }\n if (value !== null && typeof value === 'object') {\n for (const v of Object.values(value)) {\n collectContextStacks(v)\n }\n }\n }\n\n collectContextStacks(k)\n if (meta !== undefined) {\n collectContextStacks(meta)\n }\n\n // Phase 2: Serialize values, replacing ContextStacks with refs\n function serializeValue(value: unknown, path: string): unknown {\n if (value instanceof ContextStackImpl) {\n return { __csRef: csMap.get(value)! } satisfies CSRef\n }\n\n // Check for non-serializable function types\n if (isDvalaFunction(value as Any) && (value as { functionType: string }).functionType === 'NativeJsFunction') {\n const issue = describeSerializationIssue(value as Any, path)\n throw new DvalaError(\n `Cannot serialize continuation: ${issue ?? 'NativeJsFunction found in continuation stack'}`,\n undefined,\n )\n }\n\n if (Array.isArray(value)) {\n return value.map((item, i) => serializeValue(item, `${path}[${i}]`))\n }\n if (value !== null && typeof value === 'object') {\n const result: Record<string, unknown> = {}\n for (const [key, v] of Object.entries(value)) {\n result[key] = serializeValue(v, `${path}.${key}`)\n }\n return result\n }\n return value\n }\n\n // Serialize all collected ContextStacks\n const serializedContextStacks: SerializedContextStack[] = Array.from(csMap.entries()).map(\n ([cs, id]) => ({\n id,\n contexts: cs.getContextsRaw().map((ctx, ctxIdx) => {\n const serialized: Record<string, unknown> = {}\n for (const [name, entry] of Object.entries(ctx)) {\n serialized[name] = { value: serializeValue(entry.value, `cs[${id}].contexts[${ctxIdx}].${name}`) }\n }\n return serialized\n }),\n globalContextIndex: cs.getGlobalContextIndex(),\n pure: cs.pure,\n }),\n )\n\n // Serialize the continuation stack\n const serializedK = serializeValue(k, 'k')\n\n // Serialize meta\n const serializedMeta = meta !== undefined ? serializeValue(meta, 'meta') : undefined\n\n const blobData: SuspensionBlobData = {\n version: SUSPENSION_VERSION,\n contextStacks: serializedContextStacks,\n k: serializedK,\n ...(serializedMeta !== undefined ? { meta: serializedMeta as Any } : {}),\n }\n\n return JSON.stringify(blobData)\n}\n\n// ---------------------------------------------------------------------------\n// Deserialize\n// ---------------------------------------------------------------------------\n\n/** Options for re-injecting host bindings on resume. */\nexport interface DeserializeOptions {\n values?: Record<string, unknown>\n nativeJsFunctions?: Record<string, NativeJsFunction>\n modules?: Map<string, DvalaModule>\n}\n\n/**\n * Deserialize a suspension blob back into a continuation stack and metadata.\n *\n * Reconstructs `ContextStack` instances with fresh host bindings from `options`.\n * Handles circular references between ContextStacks and their contained values.\n */\nexport function deserializeSuspension(\n blob: string,\n options?: DeserializeOptions,\n): { k: ContinuationStack, meta?: Any } {\n let blobData: SuspensionBlobData\n try {\n blobData = JSON.parse(blob) as SuspensionBlobData\n }\n catch {\n throw new DvalaError('Invalid suspension blob: not valid JSON', undefined)\n }\n\n if (blobData.version !== SUSPENSION_VERSION) {\n throw new DvalaError(\n `Unsupported suspension blob version: ${blobData.version} (expected ${SUSPENSION_VERSION})`,\n undefined,\n )\n }\n\n // Phase 1: Create placeholder ContextStack instances for each serialized one.\n // Contexts are empty initially — filled in Phase 2 after all instances exist.\n const csMap = new Map<number, ContextStackImpl>()\n\n for (const scs of blobData.contextStacks) {\n const placeholderContexts = scs.contexts.map(() => {\n const ctx: Context = {}\n return ctx\n })\n const cs = ContextStackImpl.fromDeserialized({\n contexts: placeholderContexts,\n globalContextIndex: scs.globalContextIndex,\n values: options?.values,\n nativeJsFunctions: options?.nativeJsFunctions,\n modules: options?.modules,\n pure: scs.pure,\n })\n csMap.set(scs.id, cs)\n }\n\n // Phase 2: Deep-resolve all values, replacing __csRef markers with real instances\n function resolveValue(value: unknown): unknown {\n if (isCSRef(value)) {\n const cs = csMap.get(value.__csRef)\n if (!cs) {\n throw new DvalaError(`Invalid suspension blob: unknown context stack ref ${value.__csRef}`, undefined)\n }\n return cs\n }\n if (Array.isArray(value)) {\n return value.map(resolveValue)\n }\n if (value !== null && typeof value === 'object') {\n const result: Record<string, unknown> = {}\n for (const [key, v] of Object.entries(value)) {\n result[key] = resolveValue(v)\n }\n return result\n }\n return value\n }\n\n // Fill in contexts on each ContextStack\n for (const scs of blobData.contextStacks) {\n const cs = csMap.get(scs.id)!\n const resolvedContexts: Context[] = scs.contexts.map((serializedCtx) => {\n const ctx = serializedCtx as Record<string, { value: unknown }>\n const resolved: Context = {}\n for (const [name, entry] of Object.entries(ctx)) {\n resolved[name] = { value: resolveValue(entry.value) as Any }\n }\n return resolved\n })\n cs.setContextsFromDeserialized(resolvedContexts, scs.globalContextIndex)\n }\n\n // Resolve the continuation stack\n const resolvedK = resolveValue(blobData.k) as ContinuationStack\n\n // Resolve meta\n const resolvedMeta = blobData.meta !== undefined ? resolveValue(blobData.meta) as Any : undefined\n\n return { k: resolvedK, meta: resolvedMeta }\n}\n","/**\n * Standard effects — built-in effects with default implementations.\n *\n * These effects are always available without requiring explicit host handlers.\n * Host handlers can override them (host handlers take priority in the lookup order).\n *\n * Lookup order: local try/with → host handlers → standard effects → unhandled error\n *\n * Standard effects:\n * - `dvala.log` — sync: console.log(...args), resumes with null\n * - `dvala.now` — sync: Date.now()\n * - `dvala.random` — sync: Math.random()\n * - `dvala.sleep` — async: setTimeout(resolve, ms), resumes with null\n *\n * Sync effects work in both `runSync` and `run`.\n * Async effects (`dvala.sleep`) only work in `run` — `runSync` will throw\n * when a Promise surfaces.\n */\n\nimport type { Any, Arr } from '../interface'\nimport { DvalaError } from '../errors'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport type { ContinuationStack } from './frames'\nimport type { Step } from './step'\n\n// ---------------------------------------------------------------------------\n// Standard effect handler type\n// ---------------------------------------------------------------------------\n\n/**\n * A standard effect handler returns the next step directly.\n * Sync effects return `Step`, async effects return `Promise<Step>`.\n */\ntype StandardEffectHandler = (args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo) => Step | Promise<Step>\n\n// ---------------------------------------------------------------------------\n// Standard effect implementations\n// ---------------------------------------------------------------------------\n\nconst standardEffectHandlers: Record<string, StandardEffectHandler> = {\n /**\n * `dvala.log` — Log arguments to console.\n * Resumes with null (logging is a side effect with no meaningful return value).\n */\n 'dvala.log': (args: Arr, k: ContinuationStack): Step => {\n // eslint-disable-next-line no-console\n console.log(...args)\n return { type: 'Value', value: null, k }\n },\n\n /**\n * `dvala.now` — Current timestamp in milliseconds since epoch.\n * Equivalent to `Date.now()`.\n */\n 'dvala.now': (_args: Arr, k: ContinuationStack): Step => {\n return { type: 'Value', value: Date.now(), k }\n },\n\n /**\n * `dvala.random` — Random float in [0, 1).\n * Equivalent to `Math.random()`.\n */\n 'dvala.random': (_args: Arr, k: ContinuationStack): Step => {\n return { type: 'Value', value: Math.random(), k }\n },\n\n /**\n * `dvala.sleep` — Wait for a specified number of milliseconds.\n * Resumes with null after the delay.\n * Only works in `run()` (async) — `runSync()` will throw.\n */\n 'dvala.sleep': (args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo): Promise<Step> => {\n const ms = args[0] as Any\n if (typeof ms !== 'number' || ms < 0) {\n throw new DvalaError(`dvala.sleep requires a non-negative number argument, got ${typeof ms === 'number' ? ms : typeof ms}`, sourceCodeInfo)\n }\n return new Promise<Step>((resolve) => {\n setTimeout(() => resolve({ type: 'Value', value: null, k }), ms)\n })\n },\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/** All standard effect names. */\nexport const standardEffectNames: ReadonlySet<string> = new Set(Object.keys(standardEffectHandlers))\n\n/**\n * Look up a standard effect handler by name.\n * Returns undefined if the effect is not a standard effect.\n */\nexport function getStandardEffectHandler(effectName: string): StandardEffectHandler | undefined {\n return standardEffectHandlers[effectName]\n}\n","/**\n * Trampoline evaluator — explicit-stack evaluation engine.\n *\n * `stepNode(node, env, k)` maps an AST node to the next `Step`.\n * `applyFrame(frame, value, k)` processes a completed sub-result against a frame.\n * `tick(step)` processes one step and returns the next (or a Promise<Step> for async).\n * `runSyncTrampoline(step)` runs the trampoline synchronously to completion.\n * `runAsyncTrampoline(step)` runs the trampoline asynchronously to completion.\n *\n * Entry points:\n * - `evaluate(ast, contextStack)` — evaluate an AST (sync or async)\n * - `evaluateNode(node, contextStack)` — evaluate a single node (sync or async)\n *\n * Design principles:\n * - `stepNode` is always synchronous and returns `Step`.\n * - `applyFrame` may return `Step | Promise<Step>` when normal expressions\n * or compound function types produce async results.\n * - Normal built-in expressions are called directly with pre-evaluated args\n * (they may still use the old recursive `evaluateNode` internally for\n * higher-order callbacks — suspension through them is deferred).\n * - Binding utilities (`evaluateBindingNodeValues`, `tryMatch`) are called\n * with a recursive `evaluateNode` helper. This is acceptable for Phase 1.\n * - All state lives in frames (no JS closures) — enabling serialization later.\n */\n\nimport { builtin } from '../builtin'\nimport { evaluateBindingNodeValues, getAllBindingTargetNames, tryMatch } from '../builtin/bindingNode'\nimport type { LoopBindingNode } from '../builtin/specialExpressions/loops'\nimport type { MatchCase } from '../builtin/specialExpressions/match'\nimport { specialExpressionTypes } from '../builtin/specialExpressionTypes'\nimport { NodeTypes, getNodeTypeName } from '../constants/constants'\nimport { DvalaError, RecurSignal, UndefinedSymbolError, UserDefinedError } from '../errors'\nimport { getUndefinedSymbols } from '../getUndefinedSymbols'\nimport type { Any, Arr, Obj } from '../interface'\nimport type {\n Ast,\n AstNode,\n BindingNode,\n BindingTarget,\n CompFunction,\n DvalaFunction,\n EffectRef,\n EvaluatedFunction,\n EveryPredFunction,\n FNullFunction,\n FunctionLike,\n JuxtFunction,\n ModuleFunction,\n NativeJsFunction,\n NormalBuiltinFunction,\n NormalExpressionNode,\n NumberNode,\n PartialFunction,\n ReservedSymbolNode,\n SomePredFunction,\n SpecialBuiltinFunction,\n SpecialExpressionNode,\n StringNode,\n SymbolNode,\n UserDefinedFunction,\n UserDefinedSymbolNode,\n} from '../parser/types'\nimport { bindingTargetTypes } from '../parser/types'\nimport { reservedSymbolRecord } from '../tokenizer/reservedNames'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asNonUndefined, isUnknownRecord } from '../typeGuards'\nimport { annotate } from '../typeGuards/annotatedArrays'\nimport { isNormalBuiltinSymbolNode, isNormalExpressionNodeWithName, isSpreadNode, isUserDefinedSymbolNode } from '../typeGuards/astNode'\nimport { asAny, asFunctionLike, assertEffectRef, assertSeq, isAny, isEffectRef, isObj } from '../typeGuards/dvala'\nimport { isDvalaFunction } from '../typeGuards/dvalaFunction'\nimport { assertNumber, isNumber } from '../typeGuards/number'\nimport { assertString } from '../typeGuards/string'\nimport { toAny } from '../utils'\nimport { arityAcceptsMin, assertNumberOfParams, toFixedArity } from '../utils/arity'\nimport { valueToString } from '../utils/debug/debugTools'\nimport type { MaybePromise } from '../utils/maybePromise'\nimport { chain, forEachSequential, mapSequential, reduceSequential } from '../utils/maybePromise'\nimport { FUNCTION_SYMBOL } from '../utils/symbols'\nimport type { EffectHandler, Handlers, RunResult } from './effectTypes'\nimport { SuspensionSignal, isSuspensionSignal } from './effectTypes'\nimport type { ContextStack } from './ContextStack'\nimport { getEffectRef } from './effectRef'\nimport { serializeSuspension } from './suspension'\nimport { getStandardEffectHandler } from './standardEffects'\nimport type {\n AndFrame,\n ArrayBuildFrame,\n BindingDefaultFrame,\n CallFnFrame,\n CondFrame,\n ContinuationStack,\n DebugStepFrame,\n EffectResumeFrame,\n EvalArgsFrame,\n EvaluatedWithHandler,\n FnBodyFrame,\n ForLoopFrame,\n Frame,\n IfBranchFrame,\n LetBindFrame,\n LoopBindFrame,\n LoopIterateFrame,\n MatchFrame,\n NanCheckFrame,\n ObjectBuildFrame,\n OrFrame,\n ParallelResumeFrame,\n PerformArgsFrame,\n QqFrame,\n RecurFrame,\n SequenceFrame,\n ThrowFrame,\n TryCatchFrame,\n TryWithFrame,\n} from './frames'\nimport type { Context } from './interface'\nimport type { Step } from './step'\n\n// Re-export for external use\nexport type { Step }\n\n// ---------------------------------------------------------------------------\n// Recursive evaluateNode — used as a helper for normal expressions and\n// binding utilities until the full trampoline migration is complete.\n// ---------------------------------------------------------------------------\n\nfunction evaluateNodeRecursive(node: AstNode, contextStack: ContextStack): MaybePromise<Any> {\n switch (node[0]) {\n case NodeTypes.Number:\n return (node as NumberNode)[1]\n case NodeTypes.String:\n return (node as StringNode)[1]\n case NodeTypes.NormalBuiltinSymbol:\n case NodeTypes.SpecialBuiltinSymbol:\n case NodeTypes.UserDefinedSymbol:\n return contextStack.evaluateSymbol(node as SymbolNode)\n case NodeTypes.ReservedSymbol:\n return evaluateReservedSymbol(node as ReservedSymbolNode)\n case NodeTypes.NormalExpression: {\n const result = evaluateNormalExpressionRecursive(node as NormalExpressionNode, contextStack)\n return chain(result, (resolved) => {\n if (typeof resolved === 'number' && Number.isNaN(resolved)) {\n throw new DvalaError('Number is NaN', node[2])\n }\n return annotate(resolved)\n })\n }\n case NodeTypes.SpecialExpression: {\n // Route through the trampoline — special expressions are fully handled\n // by stepSpecialExpression and their corresponding frame types.\n // This replaces the old `.evaluate()` call on special expression objects.\n const initial: Step = { type: 'Eval', node, env: contextStack, k: [] }\n try {\n return annotate(runSyncTrampoline(initial))\n }\n catch (error) {\n if (error instanceof DvalaError && error.message.includes('Unexpected async operation')) {\n const freshInitial: Step = { type: 'Eval', node, env: contextStack, k: [] }\n return runAsyncTrampoline(freshInitial).then(r => annotate(r))\n }\n throw error\n }\n }\n /* v8 ignore next 2 */\n default:\n throw new DvalaError(`${getNodeTypeName(node[0])}-node cannot be evaluated`, node[2])\n }\n}\n\nfunction evaluateParamsRecursive(\n paramNodes: AstNode[],\n contextStack: ContextStack,\n): MaybePromise<{ params: Arr, placeholders: number[] }> {\n const params: Arr = []\n const placeholders: number[] = []\n const result = forEachSequential(paramNodes, (paramNode, index) => {\n if (isSpreadNode(paramNode)) {\n return chain(evaluateNodeRecursive(paramNode[1], contextStack), (spreadValue) => {\n if (Array.isArray(spreadValue)) {\n params.push(...spreadValue)\n }\n else {\n throw new DvalaError(`Spread operator requires an array, got ${valueToString(paramNode)}`, paramNode[2])\n }\n })\n }\n else if (paramNode[0] === NodeTypes.ReservedSymbol && paramNode[1] === '_') {\n placeholders.push(index)\n }\n else {\n return chain(evaluateNodeRecursive(paramNode, contextStack), (value) => {\n params.push(value)\n })\n }\n })\n return chain(result, () => ({ params, placeholders }))\n}\n\nfunction evaluateNormalExpressionRecursive(node: NormalExpressionNode, contextStack: ContextStack): MaybePromise<Any> {\n const sourceCodeInfo = node[2]\n return chain(evaluateParamsRecursive(node[1][1], contextStack), ({ params, placeholders }) => {\n if (isNormalExpressionNodeWithName(node)) {\n const nameSymbol = node[1][0]\n if (placeholders.length > 0) {\n const fn = evaluateNodeRecursive(nameSymbol, contextStack)\n return chain(fn, (resolvedFn) => {\n const partialFunction: PartialFunction = {\n [FUNCTION_SYMBOL]: true,\n function: asFunctionLike(resolvedFn, sourceCodeInfo),\n functionType: 'Partial',\n params,\n placeholders,\n sourceCodeInfo,\n arity: toFixedArity(placeholders.length),\n }\n return partialFunction\n })\n }\n if (isNormalBuiltinSymbolNode(nameSymbol)) {\n const type = nameSymbol[1]\n const normalExpression = builtin.allNormalExpressions[type]!\n if (contextStack.pure && normalExpression.pure === false) {\n throw new DvalaError(`Cannot call impure function '${normalExpression.name}' in pure mode`, node[2])\n }\n return normalExpression.evaluate(params, node[2], contextStack, { executeFunction: executeFunctionRecursive })\n }\n else {\n const fn = contextStack.getValue(nameSymbol[1])\n if (fn !== undefined) {\n return executeFunctionRecursive(asFunctionLike(fn, sourceCodeInfo), params, contextStack, sourceCodeInfo)\n }\n throw new UndefinedSymbolError(nameSymbol[1], node[2])\n }\n }\n else {\n const fnNode: AstNode = node[1][0]\n return chain(evaluateNodeRecursive(fnNode, contextStack), (resolvedFn) => {\n const fn = asFunctionLike(resolvedFn, sourceCodeInfo)\n if (placeholders.length > 0) {\n const partialFunction: PartialFunction = {\n [FUNCTION_SYMBOL]: true,\n function: fn,\n functionType: 'Partial',\n params,\n placeholders,\n sourceCodeInfo,\n arity: toFixedArity(placeholders.length),\n }\n return partialFunction\n }\n return executeFunctionRecursive(fn, params, contextStack, sourceCodeInfo)\n })\n }\n })\n}\n\nfunction executeFunctionRecursive(fn: FunctionLike, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n if (isDvalaFunction(fn)) {\n return executeDvalaFunctionRecursive(fn, params, contextStack, sourceCodeInfo)\n }\n if (Array.isArray(fn)) {\n return evaluateArrayAsFunction(fn, params, sourceCodeInfo)\n }\n if (isObj(fn)) {\n return evaluateObjectAsFunction(fn, params, sourceCodeInfo)\n }\n if (typeof fn === 'string') {\n return evaluateStringAsFunction(fn, params, sourceCodeInfo)\n }\n if (isNumber(fn)) {\n return evaluateNumberAsFunction(fn, params, sourceCodeInfo)\n }\n /* v8 ignore next 1 */\n throw new DvalaError('Unexpected function type', sourceCodeInfo)\n}\n\n/**\n * Execute a DvalaFunction recursively. This is the old-style executor\n * used as a fallback for normal expression callbacks.\n */\nfunction executeDvalaFunctionRecursive(fn: DvalaFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n switch (fn.functionType) {\n case 'UserDefined':\n return executeUserDefinedRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Partial':\n return executePartialRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Comp':\n return executeCompRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Constantly':\n return fn.value\n case 'Juxt':\n return executeJuxtRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Complement':\n return chain(executeFunctionRecursive(fn.function, params, contextStack, sourceCodeInfo), result => !result)\n case 'EveryPred':\n return executeEveryPredRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'SomePred':\n return executeSomePredRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Fnull':\n return executeFnullRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Builtin':\n return executeBuiltinRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'SpecialBuiltin':\n return executeSpecialBuiltinRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Module':\n return executeModuleRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'NativeJsFunction':\n return executeNativeJsFunctionRecursive(fn, params, contextStack, sourceCodeInfo)\n }\n}\n\nfunction executeUserDefinedRecursive(fn: UserDefinedFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n function setupAndExecute(currentParams: Arr): MaybePromise<Any> {\n if (!arityAcceptsMin(fn.arity, currentParams.length)) {\n throw new DvalaError(`Expected ${fn.arity} arguments, got ${currentParams.length}.`, sourceCodeInfo)\n }\n const evaluatedFunction = fn.evaluatedfunction\n const args = evaluatedFunction[0]\n const nbrOfNonRestArgs = args.filter(arg => arg[0] !== bindingTargetTypes.rest).length\n const newContextStack = contextStack.create(fn.evaluatedfunction[2])\n const newContext: Context = { self: { value: fn } }\n const rest: Arr = []\n let paramSetup: MaybePromise<void> = undefined as unknown as void\n for (let i = 0; i < currentParams.length; i += 1) {\n if (i < nbrOfNonRestArgs) {\n const paramIndex = i\n paramSetup = chain(paramSetup, () => {\n const param = toAny(currentParams[paramIndex])\n return chain(evaluateBindingNodeValues(args[paramIndex]!, param, node =>\n evaluateNodeRecursive(node, newContextStack.create(newContext))), (valueRecord) => {\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n })\n })\n }\n else {\n rest.push(toAny(currentParams[i]))\n }\n }\n let defaultSetup: MaybePromise<void> = undefined as unknown as void\n for (let i = currentParams.length; i < nbrOfNonRestArgs; i++) {\n const argIndex = i\n defaultSetup = chain(defaultSetup, () => {\n const arg = args[argIndex]!\n return chain(evaluateNodeRecursive(arg[1][1]!, contextStack.create(newContext)), (defaultValue) => {\n return chain(evaluateBindingNodeValues(arg, defaultValue, node =>\n evaluateNodeRecursive(node, contextStack.create(newContext))), (valueRecord) => {\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n })\n })\n })\n }\n return chain(paramSetup, () => chain(defaultSetup, () => {\n const restArgument = args.find(arg => arg[0] === bindingTargetTypes.rest)\n const restSetup: MaybePromise<void> = restArgument !== undefined\n ? chain(evaluateBindingNodeValues(restArgument, rest, node =>\n evaluateNodeRecursive(node, contextStack.create(newContext))), (valueRecord) => {\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n })\n : undefined as unknown as void\n return chain(restSetup, () => {\n const newContextStack2 = newContextStack.create(newContext)\n const bodyResult = reduceSequential(\n evaluatedFunction[1],\n (_acc, node) => evaluateNodeRecursive(node, newContextStack2),\n null as Any,\n )\n if (bodyResult instanceof Promise) {\n return bodyResult.catch((error: unknown) => {\n if (error instanceof RecurSignal) {\n return setupAndExecute(error.params)\n }\n throw error\n })\n }\n return bodyResult\n })\n }))\n }\n for (;;) {\n try {\n const result = setupAndExecute(params)\n return result\n }\n catch (error) {\n if (error instanceof RecurSignal) {\n params = error.params\n continue\n }\n throw error\n }\n }\n}\n\nfunction executePartialRecursive(fn: PartialFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const actualParams = [...fn.params]\n if (params.length !== fn.placeholders.length) {\n throw new DvalaError(`(partial) expects ${fn.placeholders.length} arguments, got ${params.length}.`, sourceCodeInfo)\n }\n const paramsCopy = [...params]\n for (const placeholderIndex of fn.placeholders) {\n actualParams.splice(placeholderIndex, 0, paramsCopy.shift())\n }\n return executeFunctionRecursive(fn.function, actualParams, contextStack, sourceCodeInfo)\n}\n\nfunction executeCompRecursive(fn: CompFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const { params: f } = fn\n if (f.length === 0) {\n if (params.length !== 1)\n throw new DvalaError(`(comp) expects one argument, got ${valueToString(params.length)}.`, sourceCodeInfo)\n return asAny(params[0], sourceCodeInfo)\n }\n let result: MaybePromise<Arr> = params\n for (let i = f.length - 1; i >= 0; i--) {\n const fun = f[i]!\n result = chain(result, currentParams =>\n chain(executeFunctionRecursive(asFunctionLike(fun, sourceCodeInfo), currentParams, contextStack, sourceCodeInfo), r => [r]))\n }\n return chain(result, finalArr => asAny(finalArr[0], sourceCodeInfo))\n}\n\nfunction executeJuxtRecursive(fn: JuxtFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n return mapSequential(fn.params, fun =>\n executeFunctionRecursive(asFunctionLike(fun, sourceCodeInfo), params, contextStack, sourceCodeInfo))\n}\n\nfunction executeEveryPredRecursive(fn: EveryPredFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const checks: Array<() => MaybePromise<Any>> = []\n for (const f of fn.params) {\n for (const param of params) {\n checks.push(() => executeFunctionRecursive(asFunctionLike(f, sourceCodeInfo), [param], contextStack, sourceCodeInfo))\n }\n }\n return reduceSequential(checks, (acc, check) => {\n if (!acc)\n return false\n return chain(check(), result => !!result)\n }, true as Any)\n}\n\nfunction executeSomePredRecursive(fn: SomePredFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const checks: Array<() => MaybePromise<Any>> = []\n for (const f of fn.params) {\n for (const param of params) {\n checks.push(() => executeFunctionRecursive(asFunctionLike(f, sourceCodeInfo), [param], contextStack, sourceCodeInfo))\n }\n }\n return reduceSequential(checks, (acc, check) => {\n if (acc)\n return true\n return chain(check(), result => !!result)\n }, false as Any)\n}\n\nfunction executeFnullRecursive(fn: FNullFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const fnulledParams = params.map((param, index) => (param === null ? toAny(fn.params[index]) : param))\n return executeFunctionRecursive(asFunctionLike(fn.function, sourceCodeInfo), fnulledParams, contextStack, sourceCodeInfo)\n}\n\nfunction executeBuiltinRecursive(fn: NormalBuiltinFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const normalExpression = asNonUndefined(builtin.allNormalExpressions[fn.normalBuiltinSymbolType], sourceCodeInfo)\n if (contextStack.pure && normalExpression.pure === false) {\n throw new DvalaError(`Cannot call impure function '${fn.name}' in pure mode`, sourceCodeInfo)\n }\n return normalExpression.evaluate(params, sourceCodeInfo, contextStack, { executeFunction: executeFunctionRecursive })\n}\n\nfunction executeSpecialBuiltinRecursive(fn: SpecialBuiltinFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const specialExpression = asNonUndefined(builtin.specialExpressions[fn.specialBuiltinSymbolType], sourceCodeInfo)\n if (specialExpression.evaluateAsNormalExpression) {\n return specialExpression.evaluateAsNormalExpression(params, sourceCodeInfo, contextStack, { executeFunction: executeFunctionRecursive })\n }\n throw new DvalaError(`Special builtin function ${fn.specialBuiltinSymbolType} is not supported as normal expression.`, sourceCodeInfo)\n}\n\nfunction executeModuleRecursive(fn: ModuleFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n const dvalaModule = contextStack.getModule(fn.moduleName)\n if (!dvalaModule) {\n throw new DvalaError(`Module '${fn.moduleName}' not found.`, sourceCodeInfo)\n }\n const expression = dvalaModule.functions[fn.functionName]\n if (!expression) {\n throw new DvalaError(`Function '${fn.functionName}' not found in module '${fn.moduleName}'.`, sourceCodeInfo)\n }\n if (contextStack.pure && expression.pure === false) {\n throw new DvalaError(`Cannot call impure function '${fn.functionName}' in pure mode`, sourceCodeInfo)\n }\n assertNumberOfParams(expression.arity, params.length, sourceCodeInfo)\n return expression.evaluate(params, sourceCodeInfo, contextStack, { executeFunction: executeFunctionRecursive })\n}\n\nfunction executeNativeJsFunctionRecursive(fn: NativeJsFunction, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n if (contextStack.pure && !fn.nativeFn.pure) {\n throw new DvalaError(`Cannot call impure native function '${fn.name}' in pure mode`, sourceCodeInfo)\n }\n try {\n const result = fn.nativeFn.fn(...params)\n if (result instanceof Promise) {\n return result.then(\n resolved => toAny(resolved),\n (error: unknown) => {\n const message = typeof error === 'string'\n ? error\n : isUnknownRecord(error) && typeof error.message === 'string'\n ? error.message\n : '<no message>'\n throw new DvalaError(`Native function threw: \"${message}\"`, sourceCodeInfo)\n },\n )\n }\n return toAny(result)\n }\n catch (error) {\n const message = typeof error === 'string'\n ? error\n : isUnknownRecord(error) && typeof error.message === 'string'\n ? error.message\n : '<no message>'\n throw new DvalaError(`Native function threw: \"${message}\"`, sourceCodeInfo)\n }\n}\n\n// ---------------------------------------------------------------------------\n// Value-as-function helpers (shared between trampoline and recursive paths)\n// ---------------------------------------------------------------------------\n\nfunction evaluateObjectAsFunction(fn: Obj, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n if (params.length !== 1)\n throw new DvalaError('Object as function requires one string parameter.', sourceCodeInfo)\n const key = params[0]\n assertString(key, sourceCodeInfo)\n return toAny(fn[key])\n}\n\nfunction evaluateArrayAsFunction(fn: Arr, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n if (params.length !== 1)\n throw new DvalaError('Array as function requires one non negative integer parameter.', sourceCodeInfo)\n const index = params[0]\n assertNumber(index, sourceCodeInfo, { integer: true, nonNegative: true })\n return toAny(fn[index])\n}\n\nfunction evaluateStringAsFunction(fn: string, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n if (params.length !== 1)\n throw new DvalaError('String as function requires one Obj parameter.', sourceCodeInfo)\n const param = toAny(params[0])\n if (isObj(param))\n return toAny((param)[fn])\n if (isNumber(param, { integer: true }))\n return toAny(fn[param])\n throw new DvalaError(\n `string as function expects Obj or integer parameter, got ${valueToString(param)}`,\n sourceCodeInfo,\n )\n}\n\nfunction evaluateNumberAsFunction(fn: number, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n assertNumber(fn, undefined, { integer: true })\n if (params.length !== 1)\n throw new DvalaError('Number as function requires one Arr parameter.', sourceCodeInfo)\n const param = params[0]\n assertSeq(param, sourceCodeInfo)\n return toAny(param[fn])\n}\n\n// ---------------------------------------------------------------------------\n// Reserved symbol evaluation\n// ---------------------------------------------------------------------------\n\nfunction evaluateReservedSymbol(node: ReservedSymbolNode): Any {\n const reservedName = node[1]\n if (!['true', 'false', 'null'].includes(reservedName)) {\n throw new DvalaError(`Reserved symbol ${reservedName} cannot be evaluated`, node[2])\n }\n const value = reservedSymbolRecord[reservedName]\n return asNonUndefined(value, node[2])\n}\n\n// ---------------------------------------------------------------------------\n// Lambda helper (closure capture) — used by stepSpecialExpression for lambda\n// ---------------------------------------------------------------------------\n\nfunction evaluateFunction(\n fn: [BindingTarget[], AstNode[], ...unknown[]],\n contextStack: ContextStack,\n): EvaluatedFunction {\n const functionContext: Context = {}\n const context = fn[0].reduce((ctx: Context, arg) => {\n Object.keys(getAllBindingTargetNames(arg)).forEach((name) => {\n ctx[name] = { value: null }\n })\n return ctx\n }, {})\n const undefinedSymbols = getUndefinedSymbols(fn[1], contextStack.new(context), builtin, evaluateNodeRecursive)\n undefinedSymbols.forEach((name) => {\n const value = contextStack.getValue(name)\n if (isAny(value)) {\n functionContext[name] = { value }\n }\n })\n return [fn[0], fn[1], functionContext]\n}\n\n// ---------------------------------------------------------------------------\n// stepNode — map an AST node to the next Step\n// ---------------------------------------------------------------------------\n\n/**\n * Given an AST node, its environment, and a continuation stack, return\n * the next Step for the trampoline to process.\n *\n * Leaf nodes (numbers, strings, symbols) immediately produce values.\n * Compound nodes (expressions) push frames and return sub-evaluations.\n */\nexport function stepNode(node: AstNode, env: ContextStack, k: ContinuationStack): Step | Promise<Step> {\n switch (node[0]) {\n case NodeTypes.Number:\n return { type: 'Value', value: (node as NumberNode)[1], k }\n case NodeTypes.String:\n return { type: 'Value', value: (node as StringNode)[1], k }\n case NodeTypes.NormalBuiltinSymbol:\n case NodeTypes.SpecialBuiltinSymbol:\n case NodeTypes.UserDefinedSymbol:\n return { type: 'Value', value: env.evaluateSymbol(node as SymbolNode), k }\n case NodeTypes.ReservedSymbol:\n return { type: 'Value', value: evaluateReservedSymbol(node as ReservedSymbolNode), k }\n case NodeTypes.NormalExpression:\n return stepNormalExpression(node as NormalExpressionNode, env, k)\n case NodeTypes.SpecialExpression:\n return stepSpecialExpression(node as SpecialExpressionNode, env, k)\n /* v8 ignore next 2 */\n default:\n throw new DvalaError(`${getNodeTypeName(node[0])}-node cannot be evaluated`, node[2])\n }\n}\n\n// ---------------------------------------------------------------------------\n// stepNormalExpression — start evaluating a function call's arguments\n// ---------------------------------------------------------------------------\n\n/**\n * Normal expressions: evaluate arguments left-to-right, then dispatch.\n * Push EvalArgsFrame + NanCheckFrame, then start evaluating the first arg.\n */\nfunction stepNormalExpression(node: NormalExpressionNode, env: ContextStack, k: ContinuationStack): Step | Promise<Step> {\n const argNodes = node[1][1]\n const sourceCodeInfo = node[2]\n\n // NaN guard wraps the final result\n const nanFrame: NanCheckFrame = { type: 'NanCheck', sourceCodeInfo }\n\n // Argument evaluator frame\n const evalArgsFrame: EvalArgsFrame = {\n type: 'EvalArgs',\n node,\n index: 0,\n params: [],\n placeholders: [],\n env,\n sourceCodeInfo,\n }\n\n // Find the first real argument to evaluate (skip leading placeholders)\n let startIndex = 0\n while (startIndex < argNodes.length) {\n const arg = argNodes[startIndex]!\n if (arg[0] === NodeTypes.ReservedSymbol && arg[1] === '_') {\n evalArgsFrame.placeholders.push(evalArgsFrame.params.length)\n startIndex++\n }\n else {\n break\n }\n }\n evalArgsFrame.index = startIndex\n\n if (startIndex >= argNodes.length) {\n // No real args to evaluate — dispatch immediately\n return dispatchCall(evalArgsFrame, [nanFrame, ...k])\n }\n\n // Start evaluating the first real argument\n const firstArg = argNodes[startIndex]!\n const newK: ContinuationStack = [evalArgsFrame, nanFrame, ...k]\n if (isSpreadNode(firstArg)) {\n return { type: 'Eval', node: firstArg[1], env, k: newK }\n }\n return { type: 'Eval', node: firstArg, env, k: newK }\n}\n\n// ---------------------------------------------------------------------------\n// stepSpecialExpression — push frame for a special expression\n// ---------------------------------------------------------------------------\n\n/**\n * Special expressions: push a frame appropriate to the expression type\n * and return an EvalStep for the first sub-expression.\n */\nfunction stepSpecialExpression(node: SpecialExpressionNode, env: ContextStack, k: ContinuationStack): Step | Promise<Step> {\n const sourceCodeInfo = node[2]\n const type = node[1][0]\n\n switch (type) {\n // --- if / unless ---\n case specialExpressionTypes.if:\n case specialExpressionTypes.unless: {\n const [conditionNode, thenNode, elseNode] = node[1][1] as [AstNode, AstNode, AstNode?]\n const frame: IfBranchFrame = {\n type: 'IfBranch',\n thenNode,\n elseNode,\n inverted: type === specialExpressionTypes.unless,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: conditionNode, env, k: [frame, ...k] }\n }\n\n // --- && (and) ---\n case specialExpressionTypes['&&']: {\n const nodes = node[1][1] as AstNode[]\n if (nodes.length === 0) {\n return { type: 'Value', value: true, k }\n }\n const frame: AndFrame = {\n type: 'And',\n nodes,\n index: 1,\n env,\n sourceCodeInfo,\n }\n if (nodes.length === 1) {\n return { type: 'Eval', node: nodes[0]!, env, k }\n }\n return { type: 'Eval', node: nodes[0]!, env, k: [frame, ...k] }\n }\n\n // --- || (or) ---\n case specialExpressionTypes['||']: {\n const nodes = node[1][1] as AstNode[]\n if (nodes.length === 0) {\n return { type: 'Value', value: false, k }\n }\n const frame: OrFrame = {\n type: 'Or',\n nodes,\n index: 1,\n env,\n sourceCodeInfo,\n }\n if (nodes.length === 1) {\n return { type: 'Eval', node: nodes[0]!, env, k }\n }\n return { type: 'Eval', node: nodes[0]!, env, k: [frame, ...k] }\n }\n\n // --- ?? (nullish coalescing) ---\n case specialExpressionTypes['??']: {\n const nodes = node[1][1] as AstNode[]\n if (nodes.length === 0) {\n return { type: 'Value', value: null, k }\n }\n // Check if the first node is an undefined user symbol\n const firstNode = nodes[0]!\n if (isUserDefinedSymbolNode(firstNode) && env.lookUp(firstNode) === null) {\n // Undefined symbol — treat as null, skip to next\n if (nodes.length === 1) {\n return { type: 'Value', value: null, k }\n }\n const frame: QqFrame = {\n type: 'Qq',\n nodes,\n index: 2,\n env,\n sourceCodeInfo,\n }\n const nextNode = nodes[1]!\n if (isUserDefinedSymbolNode(nextNode) && env.lookUp(nextNode) === null) {\n // Also undefined — continue skipping\n return skipUndefinedQq(frame, k)\n }\n if (nodes.length === 2) {\n return { type: 'Eval', node: nextNode, env, k }\n }\n return { type: 'Eval', node: nextNode, env, k: [frame, ...k] }\n }\n const frame: QqFrame = {\n type: 'Qq',\n nodes,\n index: 1,\n env,\n sourceCodeInfo,\n }\n if (nodes.length === 1) {\n return { type: 'Eval', node: firstNode, env, k }\n }\n return { type: 'Eval', node: firstNode, env, k: [frame, ...k] }\n }\n\n // --- cond ---\n case specialExpressionTypes.cond: {\n const cases = node[1][1] as [AstNode, AstNode][]\n if (cases.length === 0) {\n return { type: 'Value', value: null, k }\n }\n const frame: CondFrame = {\n type: 'Cond',\n phase: 'test',\n cases,\n index: 0,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: cases[0]![0], env, k: [frame, ...k] }\n }\n\n // --- match ---\n case specialExpressionTypes.match: {\n const matchValueNode = node[1][1] as AstNode\n const cases = node[1][2] as MatchCase[]\n const frame: MatchFrame = {\n type: 'Match',\n phase: 'matchValue',\n matchValue: null,\n cases,\n index: 0,\n bindings: {},\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: matchValueNode, env, k: [frame, ...k] }\n }\n\n // --- block (do...end) ---\n case specialExpressionTypes.block: {\n const nodes = node[1][1] as AstNode[]\n const newContext: Context = {}\n const newEnv = env.create(newContext)\n if (nodes.length === 0) {\n return { type: 'Value', value: null, k }\n }\n if (nodes.length === 1) {\n return { type: 'Eval', node: nodes[0]!, env: newEnv, k }\n }\n const frame: SequenceFrame = {\n type: 'Sequence',\n nodes,\n index: 1,\n env: newEnv,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: nodes[0]!, env: newEnv, k: [frame, ...k] }\n }\n\n // --- let ---\n case specialExpressionTypes.let: {\n const bindingNode = node[1][1] as BindingNode\n const target = bindingNode[1][0]\n const valueNode = bindingNode[1][1]\n const frame: LetBindFrame = {\n type: 'LetBind',\n target,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: valueNode, env, k: [frame, ...k] }\n }\n\n // --- loop ---\n case specialExpressionTypes.loop: {\n const bindingNodes = node[1][1] as BindingNode[]\n const body = node[1][2] as AstNode\n if (bindingNodes.length === 0) {\n // No bindings — just evaluate the body with an empty context\n const newContext: Context = {}\n const frame: LoopIterateFrame = {\n type: 'LoopIterate',\n bindingNodes,\n bindingContext: newContext,\n body,\n env: env.create(newContext),\n sourceCodeInfo,\n }\n return { type: 'Eval', node: body, env: env.create(newContext), k: [frame, ...k] }\n }\n // Start evaluating the first binding's value\n const frame: LoopBindFrame = {\n type: 'LoopBind',\n phase: 'value',\n bindingNodes,\n index: 0,\n context: {},\n body,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: bindingNodes[0]![1][1], env, k: [frame, ...k] }\n }\n\n // --- for / doseq ---\n case specialExpressionTypes.for:\n case specialExpressionTypes.doseq: {\n const loopBindings = node[1][1] as LoopBindingNode[]\n const body = node[1][2] as AstNode\n const returnResult = type === specialExpressionTypes.for\n if (loopBindings.length === 0) {\n return { type: 'Value', value: returnResult ? [] : null, k }\n }\n const context: Context = {}\n const newEnv = env.create(context)\n const frame: ForLoopFrame = {\n type: 'ForLoop',\n returnResult,\n bindingNodes: loopBindings,\n body,\n result: [],\n phase: 'evalCollection',\n bindingLevel: 0,\n levelStates: [],\n context,\n env: newEnv,\n sourceCodeInfo,\n }\n // Evaluate the first binding's collection expression\n const firstBinding = loopBindings[0]!\n const collectionNode = firstBinding[0][1][1] // bindingNode → [target, valueNode]\n return { type: 'Eval', node: collectionNode, env: newEnv, k: [frame, ...k] }\n }\n\n // --- try ---\n case specialExpressionTypes.try: {\n const tryExpression = node[1][1] as AstNode\n const errorSymbol = node[1][2] as SymbolNode | undefined\n const catchExpression = node[1][3] as AstNode | undefined\n const withHandlerNodes = node[1][4] as [AstNode, AstNode][] | undefined\n\n // Push effect handler frame if with-handlers exist\n if (withHandlerNodes && withHandlerNodes.length > 0) {\n // Eagerly evaluate effect expressions using recursive evaluator.\n // Effect expressions are always simple (effect(name) or variable refs),\n // so synchronous evaluation is safe.\n const evaluatedHandlers: EvaluatedWithHandler[] = withHandlerNodes.map(([effectExpr, handlerNode]) => ({\n effectRef: evaluateNodeRecursive(effectExpr, env) as Any,\n handlerNode,\n }))\n const withFrame: TryWithFrame = {\n type: 'TryWith',\n handlers: evaluatedHandlers,\n env,\n sourceCodeInfo,\n }\n if (catchExpression) {\n const catchFrame: TryCatchFrame = {\n type: 'TryCatch',\n errorSymbol: errorSymbol ? (errorSymbol as UserDefinedSymbolNode)[1] : null,\n catchNode: catchExpression,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: tryExpression, env, k: [withFrame, catchFrame, ...k] }\n }\n return { type: 'Eval', node: tryExpression, env, k: [withFrame, ...k] }\n }\n\n // No with-handlers — just try/catch\n if (catchExpression) {\n const frame: TryCatchFrame = {\n type: 'TryCatch',\n errorSymbol: errorSymbol ? (errorSymbol as UserDefinedSymbolNode)[1] : null,\n catchNode: catchExpression,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: tryExpression, env, k: [frame, ...k] }\n }\n // No catch, no with — just evaluate the body\n return { type: 'Eval', node: tryExpression, env, k }\n }\n\n // --- throw ---\n case specialExpressionTypes.throw: {\n const throwExpr = node[1][1] as AstNode\n const frame: ThrowFrame = {\n type: 'Throw',\n sourceCodeInfo,\n }\n return { type: 'Eval', node: throwExpr, env, k: [frame, ...k] }\n }\n\n // --- recur ---\n case specialExpressionTypes.recur: {\n const nodes = node[1][1] as AstNode[]\n if (nodes.length === 0) {\n return handleRecur([], k, sourceCodeInfo)\n }\n const frame: RecurFrame = {\n type: 'Recur',\n nodes,\n index: 1,\n params: [],\n env,\n sourceCodeInfo,\n }\n if (nodes.length === 1) {\n // Only one param — evaluate it, then recur\n const singleFrame: RecurFrame = { ...frame, index: 1 }\n return { type: 'Eval', node: nodes[0]!, env, k: [singleFrame, ...k] }\n }\n return { type: 'Eval', node: nodes[0]!, env, k: [frame, ...k] }\n }\n\n // --- array ---\n case specialExpressionTypes.array: {\n const nodes = node[1][1] as AstNode[]\n if (nodes.length === 0) {\n return { type: 'Value', value: [], k }\n }\n const firstNode = nodes[0]!\n const isFirstSpread = isSpreadNode(firstNode)\n const frame: ArrayBuildFrame = {\n type: 'ArrayBuild',\n nodes,\n index: 0,\n result: [],\n isSpread: isFirstSpread,\n env,\n sourceCodeInfo,\n }\n return {\n type: 'Eval',\n node: isFirstSpread ? firstNode[1] : firstNode,\n env,\n k: [frame, ...k],\n }\n }\n\n // --- object ---\n case specialExpressionTypes.object: {\n const nodes = node[1][1] as AstNode[]\n if (nodes.length === 0) {\n return { type: 'Value', value: {}, k }\n }\n const firstNode = nodes[0]!\n const isFirstSpread = isSpreadNode(firstNode)\n const frame: ObjectBuildFrame = {\n type: 'ObjectBuild',\n nodes,\n index: 0,\n result: {},\n currentKey: null,\n isSpread: isFirstSpread,\n env,\n sourceCodeInfo,\n }\n return {\n type: 'Eval',\n node: isFirstSpread ? firstNode[1] : firstNode,\n env,\n k: [frame, ...k],\n }\n }\n\n // --- lambda (fn / ->) ---\n case specialExpressionTypes['0_lambda']: {\n const fn = node[1][1] as [BindingTarget[], AstNode[], ...unknown[]]\n const docString = (node[1][2] ?? '') as string\n const evaluatedFunc = evaluateFunction(fn, env)\n const min = evaluatedFunc[0].filter(arg => arg[0] !== bindingTargetTypes.rest && arg[1][1] === undefined).length\n const max = evaluatedFunc[0].some(arg => arg[0] === bindingTargetTypes.rest) ? undefined : evaluatedFunc[0].length\n const arity = { min: min > 0 ? min : undefined, max }\n const dvalaFunction: DvalaFunction = {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo: node[2],\n functionType: 'UserDefined',\n name: undefined,\n evaluatedfunction: evaluatedFunc,\n arity,\n docString,\n }\n return { type: 'Value', value: dvalaFunction, k }\n }\n\n // --- defined? ---\n case specialExpressionTypes['defined?']: {\n const symbolNode = node[1][1] as SymbolNode\n if (!isUserDefinedSymbolNode(symbolNode)) {\n return { type: 'Value', value: true, k }\n }\n const lookUpResult = env.lookUp(symbolNode)\n return { type: 'Value', value: lookUpResult !== null, k }\n }\n\n // --- import ---\n case specialExpressionTypes.import: {\n const moduleName = node[1][1] as string\n // Check for value modules first (file modules from bundles)\n const valueModule = env.getValueModule(moduleName)\n if (valueModule.found) {\n return { type: 'Value', value: valueModule.value as Any, k }\n }\n // Fall back to builtin modules\n const dvalaModule = env.getModule(moduleName)\n if (!dvalaModule) {\n throw new DvalaError(`Unknown module: '${moduleName}'`, sourceCodeInfo)\n }\n const result: Record<string, ModuleFunction> = {}\n for (const [functionName, expression] of Object.entries(dvalaModule.functions)) {\n result[functionName] = {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Module',\n moduleName,\n functionName,\n arity: expression.arity,\n }\n }\n return { type: 'Value', value: result, k }\n }\n\n // --- effect ---\n case specialExpressionTypes.effect: {\n const effectName = node[1][1] as string\n return { type: 'Value', value: getEffectRef(effectName), k }\n }\n\n // --- perform ---\n case specialExpressionTypes.perform: {\n const effectExpr = node[1][1] as AstNode\n const argExprs = node[1][2] as AstNode[]\n const allNodes = [effectExpr, ...argExprs]\n if (allNodes.length === 1) {\n // Only the effect expression, no args — evaluate effect then dispatch\n const frame: PerformArgsFrame = {\n type: 'PerformArgs',\n argNodes: allNodes,\n index: 1,\n params: [],\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: allNodes[0]!, env, k: [frame, ...k] }\n }\n const frame: PerformArgsFrame = {\n type: 'PerformArgs',\n argNodes: allNodes,\n index: 1,\n params: [],\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: allNodes[0]!, env, k: [frame, ...k] }\n }\n\n // --- parallel ---\n case specialExpressionTypes.parallel: {\n const branches = node[1][1] as AstNode[]\n return { type: 'Parallel', branches, env, k }\n }\n\n // --- race ---\n case specialExpressionTypes.race: {\n const branches = node[1][1] as AstNode[]\n return { type: 'Race', branches, env, k }\n }\n\n /* v8 ignore next 2 */\n default:\n throw new DvalaError(`Unknown special expression type: ${type}`, sourceCodeInfo)\n }\n}\n\n// ---------------------------------------------------------------------------\n// dispatchCall — dispatch a function call after args are evaluated\n// ---------------------------------------------------------------------------\n\n/**\n * After all arguments are collected in an EvalArgsFrame, determine what\n * to call and return the next Step.\n */\nfunction dispatchCall(frame: EvalArgsFrame, k: ContinuationStack): Step | Promise<Step> {\n const { node, params, placeholders, env, sourceCodeInfo } = frame\n\n if (isNormalExpressionNodeWithName(node)) {\n const nameSymbol = node[1][0]\n\n // --- Partial application ---\n if (placeholders.length > 0) {\n const fn = env.evaluateSymbol(nameSymbol)\n const partialFunction: PartialFunction = {\n [FUNCTION_SYMBOL]: true,\n function: asFunctionLike(fn, sourceCodeInfo),\n functionType: 'Partial',\n params,\n placeholders,\n sourceCodeInfo,\n arity: toFixedArity(placeholders.length),\n }\n return { type: 'Value', value: partialFunction, k }\n }\n\n // --- Named builtin ---\n if (isNormalBuiltinSymbolNode(nameSymbol)) {\n const builtinType = nameSymbol[1]\n const normalExpression = builtin.allNormalExpressions[builtinType]!\n if (env.pure && normalExpression.pure === false) {\n throw new DvalaError(`Cannot call impure function '${normalExpression.name}' in pure mode`, sourceCodeInfo)\n }\n // Call the normal expression directly — it may use executeFunction internally\n const result = normalExpression.evaluate(params, sourceCodeInfo, env, { executeFunction: executeFunctionRecursive })\n return wrapMaybePromiseAsStep(result, k)\n }\n\n // --- Named user-defined ---\n const fn = env.getValue(nameSymbol[1])\n if (fn !== undefined) {\n return dispatchFunction(asFunctionLike(fn, sourceCodeInfo), params, placeholders, env, sourceCodeInfo, k)\n }\n throw new UndefinedSymbolError(nameSymbol[1], sourceCodeInfo)\n }\n else {\n // --- Anonymous function expression ---\n // The function expression is the first payload element; need to evaluate it\n const fnNode: AstNode = node[1][0]\n const callFrame: CallFnFrame = {\n type: 'CallFn',\n params,\n placeholders,\n env,\n sourceCodeInfo,\n }\n return { type: 'Eval', node: fnNode, env, k: [callFrame, ...k] }\n }\n}\n\n/**\n * Dispatch a resolved function value with pre-evaluated parameters.\n */\nfunction dispatchFunction(fn: FunctionLike, params: Arr, placeholders: number[], env: ContextStack, sourceCodeInfo: SourceCodeInfo | undefined, k: ContinuationStack): Step | Promise<Step> {\n if (placeholders.length > 0) {\n const partialFunction: PartialFunction = {\n [FUNCTION_SYMBOL]: true,\n function: fn,\n functionType: 'Partial',\n params,\n placeholders,\n sourceCodeInfo,\n arity: toFixedArity(placeholders.length),\n }\n return { type: 'Value', value: partialFunction, k }\n }\n\n if (isDvalaFunction(fn)) {\n return dispatchDvalaFunction(fn, params, env, sourceCodeInfo, k)\n }\n\n // Non-function callables: arrays, objects, strings, numbers\n if (Array.isArray(fn)) {\n return { type: 'Value', value: evaluateArrayAsFunction(fn, params, sourceCodeInfo), k }\n }\n if (isObj(fn)) {\n return { type: 'Value', value: evaluateObjectAsFunction(fn, params, sourceCodeInfo), k }\n }\n if (typeof fn === 'string') {\n return { type: 'Value', value: evaluateStringAsFunction(fn, params, sourceCodeInfo), k }\n }\n if (isNumber(fn)) {\n return { type: 'Value', value: evaluateNumberAsFunction(fn, params, sourceCodeInfo), k }\n }\n /* v8 ignore next 1 */\n throw new DvalaError('Unexpected function type', sourceCodeInfo)\n}\n\n/**\n * Dispatch a DvalaFunction. User-defined functions are set up with frames;\n * compound function types (Comp, Juxt, etc.) use the recursive executor.\n */\nfunction dispatchDvalaFunction(fn: DvalaFunction, params: Arr, env: ContextStack, sourceCodeInfo: SourceCodeInfo | undefined, k: ContinuationStack): Step | Promise<Step> {\n switch (fn.functionType) {\n case 'UserDefined': {\n return setupUserDefinedCall(fn, params, env, sourceCodeInfo, k)\n }\n // Compound function types: use recursive execution for now\n // (they involve internal iteration that would need its own frame types)\n case 'Partial':\n case 'Comp':\n case 'Constantly':\n case 'Juxt':\n case 'Complement':\n case 'EveryPred':\n case 'SomePred':\n case 'Fnull':\n case 'Builtin':\n case 'SpecialBuiltin':\n case 'Module':\n case 'NativeJsFunction': {\n const result = executeDvalaFunctionRecursive(fn, params, env, sourceCodeInfo)\n return wrapMaybePromiseAsStep(result, k)\n }\n }\n}\n\n/**\n * Set up a user-defined function call: bind params, push FnBodyFrame.\n *\n * For Phase 1, parameter binding (including destructuring defaults) is done\n * synchronously via evaluateBindingNodeValues with the recursive evaluator.\n * This will be converted to use frames in a later phase.\n */\nfunction setupUserDefinedCall(fn: UserDefinedFunction, params: Arr, env: ContextStack, sourceCodeInfo: SourceCodeInfo | undefined, k: ContinuationStack): Step | Promise<Step> {\n if (!arityAcceptsMin(fn.arity, params.length)) {\n throw new DvalaError(`Expected ${fn.arity} arguments, got ${params.length}.`, sourceCodeInfo)\n }\n const evaluatedFunc = fn.evaluatedfunction\n const args = evaluatedFunc[0]\n const nbrOfNonRestArgs = args.filter(arg => arg[0] !== bindingTargetTypes.rest).length\n const newContextStack = env.create(fn.evaluatedfunction[2])\n const newContext: Context = { self: { value: fn } }\n const rest: Arr = []\n\n // Bind non-rest params synchronously\n for (let i = 0; i < params.length; i += 1) {\n if (i < nbrOfNonRestArgs) {\n const param = toAny(params[i])\n const valueRecord = evaluateBindingNodeValues(args[i]!, param, n =>\n evaluateNodeRecursive(n, newContextStack.create(newContext)))\n if (valueRecord instanceof Promise) {\n // Fall back to recursive execution for async binding\n const result = executeUserDefinedRecursive(fn, params, env, sourceCodeInfo)\n return wrapMaybePromiseAsStep(result, k)\n }\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n }\n else {\n rest.push(toAny(params[i]))\n }\n }\n\n // Handle default values for optional params\n for (let i = params.length; i < nbrOfNonRestArgs; i++) {\n const arg = args[i]!\n const defaultValue = evaluateNodeRecursive(arg[1][1]!, newContextStack.create(newContext))\n if (defaultValue instanceof Promise) {\n const result = executeUserDefinedRecursive(fn, params, env, sourceCodeInfo)\n return wrapMaybePromiseAsStep(result, k)\n }\n const valueRecord = evaluateBindingNodeValues(arg, defaultValue, n =>\n evaluateNodeRecursive(n, newContextStack.create(newContext)))\n if (valueRecord instanceof Promise) {\n const result = executeUserDefinedRecursive(fn, params, env, sourceCodeInfo)\n return wrapMaybePromiseAsStep(result, k)\n }\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n }\n\n // Handle rest argument\n const restArgument = args.find(arg => arg[0] === bindingTargetTypes.rest)\n if (restArgument) {\n const valueRecord = evaluateBindingNodeValues(restArgument, rest, n =>\n evaluateNodeRecursive(n, newContextStack.create(newContext)))\n if (valueRecord instanceof Promise) {\n const result = executeUserDefinedRecursive(fn, params, env, sourceCodeInfo)\n return wrapMaybePromiseAsStep(result, k)\n }\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n }\n\n // Evaluate the body as a sequence\n const bodyNodes = evaluatedFunc[1]\n const bodyEnv = newContextStack.create(newContext)\n\n if (bodyNodes.length === 0) {\n return { type: 'Value', value: null, k }\n }\n\n const fnBodyFrame: FnBodyFrame = {\n type: 'FnBody',\n fn,\n bodyIndex: 1,\n env: bodyEnv,\n outerEnv: env,\n sourceCodeInfo,\n }\n\n if (bodyNodes.length === 1) {\n return { type: 'Eval', node: bodyNodes[0]!, env: bodyEnv, k: [fnBodyFrame, ...k] }\n }\n\n return { type: 'Eval', node: bodyNodes[0]!, env: bodyEnv, k: [fnBodyFrame, ...k] }\n}\n\n// ---------------------------------------------------------------------------\n// applyFrame — process a completed sub-result against a frame\n// ---------------------------------------------------------------------------\n\n/**\n * Given a completed sub-expression value and the top frame from the\n * continuation stack, determine the next Step.\n */\nexport function applyFrame(frame: Frame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n switch (frame.type) {\n case 'Sequence':\n return applySequence(frame, value, k)\n case 'IfBranch':\n return applyIfBranch(frame, value, k)\n case 'Cond':\n return applyCond(frame, value, k)\n case 'Match':\n return applyMatch(frame, value, k)\n case 'And':\n return applyAnd(frame, value, k)\n case 'Or':\n return applyOr(frame, value, k)\n case 'Qq':\n return applyQq(frame, value, k)\n case 'ArrayBuild':\n return applyArrayBuild(frame, value, k)\n case 'ObjectBuild':\n return applyObjectBuild(frame, value, k)\n case 'LetBind':\n return applyLetBind(frame, value, k)\n case 'LoopBind':\n return applyLoopBind(frame, value, k)\n case 'LoopIterate':\n return applyLoopIterate(frame, value, k)\n case 'ForLoop':\n return applyForLoop(frame, value, k)\n case 'Throw':\n return applyThrow(frame, value, k)\n case 'Recur':\n return applyRecur(frame, value, k)\n case 'PerformArgs':\n return applyPerformArgs(frame, value, k)\n case 'TryCatch':\n return applyTryCatch(value, k)\n case 'TryWith':\n return applyTryWith(value, k)\n case 'EffectResume':\n return applyEffectResume(frame, value, k)\n case 'ParallelResume':\n return applyParallelResume(frame, value, k)\n case 'EvalArgs':\n return applyEvalArgs(frame, value, k)\n case 'CallFn':\n return applyCallFn(frame, value, k)\n case 'FnBody':\n return applyFnBody(frame, value, k)\n case 'BindingDefault':\n return applyBindingDefault(frame, value, k)\n case 'NanCheck':\n return applyNanCheck(frame, value, k)\n case 'DebugStep':\n return applyDebugStep(frame, value, k)\n /* v8 ignore next 2 */\n default: {\n const _exhaustive: never = frame\n throw new DvalaError(`Unhandled frame type: ${(_exhaustive as Frame).type}`, undefined)\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Frame apply handlers\n// ---------------------------------------------------------------------------\n\nfunction applySequence(frame: SequenceFrame, _value: Any, k: ContinuationStack): Step {\n const { nodes, index, env } = frame\n if (index >= nodes.length) {\n // All nodes evaluated — return the last value\n return { type: 'Value', value: _value, k }\n }\n // More nodes to evaluate\n const newFrame: SequenceFrame = { ...frame, index: index + 1 }\n if (index === nodes.length - 1) {\n // Last node — no need for frame\n return { type: 'Eval', node: nodes[index]!, env, k }\n }\n return { type: 'Eval', node: nodes[index]!, env, k: [newFrame, ...k] }\n}\n\nfunction applyIfBranch(frame: IfBranchFrame, value: Any, k: ContinuationStack): Step {\n const { thenNode, elseNode, inverted, env } = frame\n const condition = inverted ? !value : value\n if (condition) {\n return { type: 'Eval', node: thenNode, env, k }\n }\n if (elseNode) {\n return { type: 'Eval', node: elseNode, env, k }\n }\n return { type: 'Value', value: null, k }\n}\n\nfunction applyCond(frame: CondFrame, value: Any, k: ContinuationStack): Step {\n const { cases, index, env } = frame\n\n if (frame.phase === 'test') {\n if (value) {\n // Test is truthy — evaluate the body\n return { type: 'Eval', node: cases[index]![1], env, k }\n }\n // Test is falsy — try next case\n const nextIndex = index + 1\n if (nextIndex >= cases.length) {\n return { type: 'Value', value: null, k }\n }\n const newFrame: CondFrame = { ...frame, index: nextIndex }\n return { type: 'Eval', node: cases[nextIndex]![0], env, k: [newFrame, ...k] }\n }\n\n // phase === 'body' — body has been evaluated\n return { type: 'Value', value, k }\n}\n\nfunction applyMatch(frame: MatchFrame, value: Any, k: ContinuationStack): Step {\n const { cases, env } = frame\n\n if (frame.phase === 'matchValue') {\n // matchValue has been evaluated — start processing cases\n const matchValue = value\n return processMatchCase({ ...frame, matchValue, phase: 'guard' }, k)\n }\n\n if (frame.phase === 'guard') {\n // Guard was evaluated\n if (!value) {\n // Guard failed — try next case\n const newFrame: MatchFrame = { ...frame, index: frame.index + 1, bindings: {} }\n return processMatchCase(newFrame, k)\n }\n // Guard passed — evaluate body\n const context: Context = {}\n for (const [name, val] of Object.entries(frame.bindings)) {\n context[name] = { value: val }\n }\n const newEnv = env.create(context)\n return { type: 'Eval', node: cases[frame.index]![1], env: newEnv, k }\n }\n\n // phase === 'body' — body has been evaluated\n return { type: 'Value', value, k }\n}\n\n/**\n * Process match cases starting from `frame.index`.\n * Uses recursive tryMatch with evaluateNodeRecursive for pattern matching.\n */\nfunction processMatchCase(frame: MatchFrame, k: ContinuationStack): Step {\n const { matchValue, cases, index, env, sourceCodeInfo } = frame\n\n for (let i = index; i < cases.length; i++) {\n const [pattern, body, guard] = cases[i]!\n const bindings = tryMatch(pattern, matchValue, n => evaluateNodeRecursive(n, env))\n\n if (bindings instanceof Promise) {\n // Async tryMatch — fall back to recursive evaluation\n // This handles the case where pattern matching involves async operations\n throw new DvalaError('Async pattern matching not supported in trampoline yet', sourceCodeInfo)\n }\n\n if (bindings === null) {\n continue // Pattern didn't match — try next case\n }\n\n // Pattern matched\n if (guard) {\n // Need to evaluate guard with bindings in scope\n const context: Context = {}\n for (const [name, val] of Object.entries(bindings)) {\n context[name] = { value: val }\n }\n const guardEnv = env.create(context)\n const guardFrame: MatchFrame = { ...frame, phase: 'guard', index: i, bindings }\n return { type: 'Eval', node: guard, env: guardEnv, k: [guardFrame, ...k] }\n }\n\n // No guard — evaluate body directly\n const context: Context = {}\n for (const [name, val] of Object.entries(bindings)) {\n context[name] = { value: val }\n }\n const bodyEnv = env.create(context)\n return { type: 'Eval', node: body, env: bodyEnv, k }\n }\n\n // No case matched\n return { type: 'Value', value: null, k }\n}\n\nfunction applyAnd(frame: AndFrame, value: Any, k: ContinuationStack): Step {\n if (!value) {\n return { type: 'Value', value, k }\n }\n const { nodes, index, env } = frame\n if (index >= nodes.length) {\n return { type: 'Value', value, k }\n }\n if (index === nodes.length - 1) {\n // Last node — no need for frame\n return { type: 'Eval', node: nodes[index]!, env, k }\n }\n const newFrame: AndFrame = { ...frame, index: index + 1 }\n return { type: 'Eval', node: nodes[index]!, env, k: [newFrame, ...k] }\n}\n\nfunction applyOr(frame: OrFrame, value: Any, k: ContinuationStack): Step {\n if (value) {\n return { type: 'Value', value, k }\n }\n const { nodes, index, env } = frame\n if (index >= nodes.length) {\n return { type: 'Value', value, k }\n }\n if (index === nodes.length - 1) {\n return { type: 'Eval', node: nodes[index]!, env, k }\n }\n const newFrame: OrFrame = { ...frame, index: index + 1 }\n return { type: 'Eval', node: nodes[index]!, env, k: [newFrame, ...k] }\n}\n\nfunction applyQq(frame: QqFrame, value: Any, k: ContinuationStack): Step {\n // If value is non-null, we found our result\n if (value !== null) {\n return { type: 'Value', value, k }\n }\n return advanceQq(frame, k)\n}\n\n/** Advance ?? to the next node, skipping undefined user symbols. */\nfunction advanceQq(frame: QqFrame, k: ContinuationStack): Step {\n const { nodes, env } = frame\n let { index } = frame\n\n // Skip undefined user symbols\n while (index < nodes.length) {\n const node = nodes[index]!\n if (isUserDefinedSymbolNode(node) && env.lookUp(node) === null) {\n index++\n continue\n }\n break\n }\n\n if (index >= nodes.length) {\n return { type: 'Value', value: null, k }\n }\n\n if (index === nodes.length - 1) {\n // Last node — no need for frame\n return { type: 'Eval', node: nodes[index]!, env, k }\n }\n\n const newFrame: QqFrame = { ...frame, index: index + 1 }\n return { type: 'Eval', node: nodes[index]!, env, k: [newFrame, ...k] }\n}\n\n/** Skip undefined user symbols in ?? until we find one to evaluate. */\nfunction skipUndefinedQq(frame: QqFrame, k: ContinuationStack): Step {\n return advanceQq(frame, k)\n}\n\nfunction applyArrayBuild(frame: ArrayBuildFrame, value: Any, k: ContinuationStack): Step {\n const { nodes, result, env, sourceCodeInfo } = frame\n\n // Process the completed value\n if (frame.isSpread) {\n if (!Array.isArray(value)) {\n throw new DvalaError('Spread value is not an array', sourceCodeInfo)\n }\n result.push(...value)\n }\n else {\n result.push(value)\n }\n\n // Advance to next element\n const nextIndex = frame.index + 1\n if (nextIndex >= nodes.length) {\n return { type: 'Value', value: result, k }\n }\n\n const nextNode = nodes[nextIndex]!\n const isNextSpread = isSpreadNode(nextNode)\n const newFrame: ArrayBuildFrame = { ...frame, index: nextIndex, isSpread: isNextSpread }\n return {\n type: 'Eval',\n node: isNextSpread ? nextNode[1] : nextNode,\n env,\n k: [newFrame, ...k],\n }\n}\n\nfunction applyObjectBuild(frame: ObjectBuildFrame, value: Any, k: ContinuationStack): Step {\n const { nodes, result, env, sourceCodeInfo } = frame\n\n if (frame.isSpread) {\n // Spread value should be an object\n if (!isUnknownRecord(value)) {\n throw new DvalaError('Spread value is not an object', sourceCodeInfo)\n }\n Object.assign(result, value)\n // Advance to next entry\n const nextIndex = frame.index + 1\n if (nextIndex >= nodes.length) {\n return { type: 'Value', value: result, k }\n }\n const nextNode = nodes[nextIndex]!\n const isNextSpread = isSpreadNode(nextNode)\n const newFrame: ObjectBuildFrame = { ...frame, index: nextIndex, currentKey: null, isSpread: isNextSpread }\n return {\n type: 'Eval',\n node: isNextSpread ? nextNode[1] : nextNode,\n env,\n k: [newFrame, ...k],\n }\n }\n\n if (frame.currentKey === null) {\n // We just evaluated a key expression\n assertString(value, sourceCodeInfo)\n const valueNode = nodes[frame.index + 1]\n if (valueNode === undefined) {\n throw new DvalaError('Missing value for key', sourceCodeInfo)\n }\n const newFrame: ObjectBuildFrame = { ...frame, currentKey: value }\n return { type: 'Eval', node: valueNode, env, k: [newFrame, ...k] }\n }\n else {\n // We just evaluated a value expression\n result[frame.currentKey] = value\n // Advance to next key-value pair\n const nextIndex = frame.index + 2\n if (nextIndex >= nodes.length) {\n return { type: 'Value', value: result, k }\n }\n const nextNode = nodes[nextIndex]!\n const isNextSpread = isSpreadNode(nextNode)\n const newFrame: ObjectBuildFrame = { ...frame, index: nextIndex, currentKey: null, isSpread: isNextSpread }\n return {\n type: 'Eval',\n node: isNextSpread ? nextNode[1] : nextNode,\n env,\n k: [newFrame, ...k],\n }\n }\n}\n\nfunction applyLetBind(frame: LetBindFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n const { target, env, sourceCodeInfo } = frame\n\n // Process the binding using the recursive helper\n const bindingResult = evaluateBindingNodeValues(target, value, n => evaluateNodeRecursive(n, env))\n return chain(bindingResult, (br) => {\n env.addValues(br, sourceCodeInfo)\n return { type: 'Value' as const, value, k }\n })\n}\n\nfunction applyLoopBind(frame: LoopBindFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n const { bindingNodes, index, context, body, env, sourceCodeInfo } = frame\n\n // Value for the current binding has been evaluated\n const bindingNode = bindingNodes[index]!\n const target = bindingNode[1][0]\n\n const valueRecord = evaluateBindingNodeValues(target, value, n => evaluateNodeRecursive(n, env.create(context)))\n return chain(valueRecord, (vr) => {\n Object.entries(vr).forEach(([name, val]) => {\n context[name] = { value: val }\n })\n\n // Move to next binding\n const nextIndex = index + 1\n if (nextIndex >= bindingNodes.length) {\n // All bindings done — set up the loop iteration\n const loopEnv = env.create(context)\n const iterateFrame: LoopIterateFrame = {\n type: 'LoopIterate',\n bindingNodes,\n bindingContext: context,\n body,\n env: loopEnv,\n sourceCodeInfo,\n }\n return { type: 'Eval' as const, node: body, env: loopEnv, k: [iterateFrame, ...k] }\n }\n\n // Evaluate next binding's value expression (in context with previous bindings)\n const newFrame: LoopBindFrame = { ...frame, index: nextIndex }\n return { type: 'Eval' as const, node: bindingNodes[nextIndex]![1][1], env: env.create(context), k: [newFrame, ...k] }\n })\n}\n\nfunction applyLoopIterate(_frame: LoopIterateFrame, value: Any, k: ContinuationStack): Step {\n // Body has been evaluated successfully — return the value\n // (recur is handled by the RecurFrame, which will pop back to this frame)\n return { type: 'Value', value, k }\n}\n\nfunction applyForLoop(frame: ForLoopFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n const { returnResult, bindingNodes, result, env, sourceCodeInfo, context } = frame\n const { asColl, isSeq } = getCollectionUtils()\n\n switch (frame.phase) {\n case 'evalCollection': {\n // A collection expression has been evaluated\n const coll = asColl(value, sourceCodeInfo)\n const seq = isSeq(coll) ? coll : Object.entries(coll as Obj)\n\n if ((seq as Arr).length === 0) {\n // Empty collection — abort this level\n return handleForAbort(frame, k)\n }\n\n // Store collection for this level\n const levelStates = [...frame.levelStates]\n levelStates[frame.bindingLevel] = { collection: seq as Arr, index: 0 }\n\n // Process the first element's binding\n const binding = bindingNodes[frame.bindingLevel]!\n const targetNode = binding[0][1][0]\n const element = (seq as Arr)[0]\n\n const elValue = asAny(element, sourceCodeInfo)\n const valueRecord = evaluateBindingNodeValues(targetNode, elValue, n => evaluateNodeRecursive(n, env))\n return chain(valueRecord, (vr) => {\n Object.entries(vr).forEach(([name, val]) => {\n context[name] = { value: val }\n })\n\n // Process let-bindings if any\n const letBindings = binding[1]\n if (letBindings.length > 0) {\n return processForLetBindings(frame, levelStates, letBindings, 0, k)\n }\n\n // Process when-guard if any\n return processForGuards(frame, levelStates, k)\n })\n }\n\n case 'evalLet': {\n // A let-binding value has been evaluated; handled via recursive fallback\n // (processForLetBindings handles this inline)\n /* v8 ignore next 1 */\n throw new DvalaError('ForLoop evalLet should not reach applyFrame', sourceCodeInfo)\n }\n\n case 'evalWhen': {\n // When-guard has been evaluated\n if (!value) {\n // When-guard failed — advance to next element\n return advanceForElement(frame, k)\n }\n // Check while-guard\n const binding = bindingNodes[frame.bindingLevel]!\n const whileNode = binding[3]\n if (whileNode) {\n const newFrame: ForLoopFrame = { ...frame, phase: 'evalWhile' }\n return { type: 'Eval', node: whileNode, env, k: [newFrame, ...k] }\n }\n return processForNextLevel(frame, k)\n }\n\n case 'evalWhile': {\n if (!value) {\n // While-guard failed — skip remaining elements at this level\n const levelStates = [...frame.levelStates]\n levelStates[frame.bindingLevel] = {\n ...levelStates[frame.bindingLevel]!,\n index: Number.POSITIVE_INFINITY,\n }\n return advanceForElement({ ...frame, levelStates }, k)\n }\n return processForNextLevel(frame, k)\n }\n\n case 'evalBody': {\n // Body has been evaluated\n if (returnResult) {\n result.push(value)\n }\n // Advance innermost binding to next element\n return advanceForElement(frame, k)\n }\n\n /* v8 ignore next 2 */\n case 'evalElement':\n throw new DvalaError(`Unexpected ForLoop phase: ${frame.phase}`, sourceCodeInfo)\n }\n\n /* v8 ignore next 1 */\n return { type: 'Value', value: null, k }\n}\n\n/** Handle for-loop abort: no more elements at the outermost level. */\nfunction handleForAbort(frame: ForLoopFrame, k: ContinuationStack): Step {\n return { type: 'Value', value: frame.returnResult ? frame.result : null, k }\n}\n\n/** Advance to the next element at the current binding level. */\nfunction advanceForElement(frame: ForLoopFrame, k: ContinuationStack): Step | Promise<Step> {\n const { bindingNodes, env, sourceCodeInfo, context } = frame\n const levelStates = [...frame.levelStates]\n const bindingLevel = frame.bindingLevel\n\n // Advance the innermost level\n const currentLevel = bindingLevel\n const currentState = levelStates[currentLevel]!\n const nextElementIndex = currentState.index + 1\n\n if (nextElementIndex >= currentState.collection.length) {\n // No more elements at this level — back up\n if (currentLevel === 0) {\n return handleForAbort(frame, k)\n }\n // Move to next element of the parent level\n return advanceForElement({ ...frame, bindingLevel: currentLevel - 1 }, k)\n }\n\n // Process next element at current level\n levelStates[currentLevel] = { ...currentState, index: nextElementIndex }\n const binding = bindingNodes[currentLevel]!\n const targetNode = binding[0][1][0]\n const element = currentState.collection[nextElementIndex]\n const elValue = asAny(element, sourceCodeInfo)\n\n const valueRecord = evaluateBindingNodeValues(targetNode, elValue, n => evaluateNodeRecursive(n, env))\n return chain(valueRecord, (vr) => {\n Object.entries(vr).forEach(([name, val]) => {\n context[name] = { value: val }\n })\n\n // Process let-bindings\n const letBindings = binding[1]\n if (letBindings.length > 0) {\n return processForLetBindings({ ...frame, levelStates, bindingLevel: currentLevel }, levelStates, letBindings, 0, k)\n }\n\n return processForGuards({ ...frame, levelStates, bindingLevel: currentLevel }, levelStates, k)\n })\n}\n\n/** Process let-bindings at the current for-loop level. */\nfunction processForLetBindings(frame: ForLoopFrame, levelStates: ForLoopFrame['levelStates'], letBindings: BindingNode[], letIndex: number, k: ContinuationStack): Step | Promise<Step> {\n const { env, context } = frame\n\n let result: MaybePromise<void> = undefined as unknown as void\n for (let i = letIndex; i < letBindings.length; i++) {\n const bindingIndex = i\n result = chain(result, () => {\n const bindingNode = letBindings[bindingIndex]!\n const [target, bindingValue] = bindingNode[1]\n const val = evaluateNodeRecursive(bindingValue, env)\n return chain(val, (v) => {\n const valueRecord = evaluateBindingNodeValues(target, v, n => evaluateNodeRecursive(n, env))\n return chain(valueRecord, (vr) => {\n Object.entries(vr).forEach(([name, value]) => {\n context[name] = { value }\n })\n })\n })\n })\n }\n\n return chain(result, () => processForGuards({ ...frame, levelStates }, levelStates, k))\n}\n\n/** Process when/while guards at the current level. */\nfunction processForGuards(frame: ForLoopFrame, levelStates: ForLoopFrame['levelStates'], k: ContinuationStack): Step {\n const { bindingNodes, env } = frame\n const binding = bindingNodes[frame.bindingLevel]!\n const whenNode = binding[2]\n const whileNode = binding[3]\n\n if (whenNode) {\n const newFrame: ForLoopFrame = { ...frame, levelStates, phase: 'evalWhen' }\n return { type: 'Eval', node: whenNode, env, k: [newFrame, ...k] }\n }\n\n if (whileNode) {\n const newFrame: ForLoopFrame = { ...frame, levelStates, phase: 'evalWhile' }\n return { type: 'Eval', node: whileNode, env, k: [newFrame, ...k] }\n }\n\n return processForNextLevel({ ...frame, levelStates }, k)\n}\n\n/** After guards pass, either go deeper (more binding levels) or evaluate body. */\nfunction processForNextLevel(frame: ForLoopFrame, k: ContinuationStack): Step {\n const { bindingNodes, body, env } = frame\n const nextLevel = frame.bindingLevel + 1\n\n if (nextLevel < bindingNodes.length) {\n // Go deeper — evaluate the next level's collection\n const binding = bindingNodes[nextLevel]!\n const collectionNode = binding[0][1][1]\n const newFrame: ForLoopFrame = {\n ...frame,\n phase: 'evalCollection',\n bindingLevel: nextLevel,\n }\n return { type: 'Eval', node: collectionNode, env, k: [newFrame, ...k] }\n }\n\n // All levels bound — evaluate the body\n const newFrame: ForLoopFrame = { ...frame, phase: 'evalBody' }\n return { type: 'Eval', node: body, env, k: [newFrame, ...k] }\n}\n\n/**\n * Search the continuation stack for the nearest TryCatchFrame.\n * If found, evaluate the catch body with the error bound (if errorSymbol is set).\n * If not found, re-throw the error.\n */\nfunction unwindToTryCatch(error: unknown, k: ContinuationStack): Step {\n for (let i = 0; i < k.length; i++) {\n const f = k[i]!\n if (f.type === 'TryCatch') {\n const { errorSymbol, catchNode, env } = f\n const catchContext: Context = errorSymbol\n ? { [errorSymbol]: { value: error as Any } }\n : {}\n const remainingK = k.slice(i + 1)\n return { type: 'Eval', node: catchNode, env: env.create(catchContext), k: remainingK }\n }\n }\n // No TryCatchFrame found — re-throw the error\n throw error\n}\n\nfunction applyThrow(frame: ThrowFrame, value: Any, k: ContinuationStack): Step {\n assertString(value, frame.sourceCodeInfo, { nonEmpty: true })\n const error = new UserDefinedError(value, frame.sourceCodeInfo)\n return unwindToTryCatch(error, k)\n}\n\nfunction applyRecur(frame: RecurFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n const { nodes, index, params, env } = frame\n params.push(value)\n\n if (index >= nodes.length) {\n // All recur params collected — handle recur via continuation stack\n return handleRecur(params, k, frame.sourceCodeInfo)\n }\n\n // Evaluate next param\n const newFrame: RecurFrame = { ...frame, index: index + 1 }\n return { type: 'Eval', node: nodes[index]!, env, k: [newFrame, ...k] }\n}\n\n/**\n * Handle recur by searching the continuation stack for the nearest\n * LoopIterateFrame or FnBodyFrame, rebinding parameters, and restarting.\n * This replaces the exception-based RecurSignal approach from the recursive\n * evaluator with proper continuation-based control flow.\n */\nfunction handleRecur(params: Arr, k: ContinuationStack, sourceCodeInfo: SourceCodeInfo | undefined): Step | Promise<Step> {\n for (let i = 0; i < k.length; i++) {\n const frame = k[i]!\n\n if (frame.type === 'LoopIterate') {\n // Found loop frame — rebind variables and re-evaluate body\n const { bindingNodes, bindingContext, body, env } = frame\n const remainingK = k.slice(i + 1)\n\n if (params.length !== bindingNodes.length) {\n throw new DvalaError(\n `recur expected ${bindingNodes.length} parameters, got ${params.length}`,\n sourceCodeInfo,\n )\n }\n\n const rebindAll: MaybePromise<void> = forEachSequential(\n bindingNodes,\n (bindingNode, j) => {\n const target = bindingNode[1][0]\n const param = toAny(params[j])\n return chain(\n evaluateBindingNodeValues(target, param, n => evaluateNodeRecursive(n, env)),\n (valueRecord) => {\n Object.entries(valueRecord).forEach(([name, val]) => {\n bindingContext[name] = { value: val }\n })\n },\n )\n },\n )\n\n return chain(rebindAll, () => {\n // After serialization/deserialization, env's innermost context and\n // bindingContext may be separate copies. Sync them by copying the\n // updated bindings into the env's innermost context.\n const envContexts = env.getContextsRaw()\n const innermostContext = envContexts[0]!\n if (innermostContext !== bindingContext) {\n for (const [name, entry] of Object.entries(bindingContext)) {\n innermostContext[name] = entry\n }\n }\n\n // Push fresh LoopIterateFrame and re-evaluate body\n const newIterateFrame: LoopIterateFrame = {\n type: 'LoopIterate',\n bindingNodes,\n bindingContext,\n body,\n env,\n sourceCodeInfo: frame.sourceCodeInfo,\n }\n return { type: 'Eval' as const, node: body, env, k: [newIterateFrame, ...remainingK] }\n })\n }\n\n if (frame.type === 'FnBody') {\n // Found function body frame — restart with new params\n const { fn, outerEnv } = frame\n const remainingK = k.slice(i + 1)\n return setupUserDefinedCall(fn, params, outerEnv, frame.sourceCodeInfo, remainingK)\n }\n }\n\n throw new DvalaError('recur called outside of loop or function body', sourceCodeInfo)\n}\n\nfunction applyTryCatch(_value: Any, k: ContinuationStack): Step {\n // Try body completed successfully — the catch frame is discarded.\n // The value propagates up past the TryCatchFrame.\n return { type: 'Value', value: _value, k }\n}\n\nfunction applyTryWith(_value: Any, k: ContinuationStack): Step {\n // Try body completed successfully — the with frame is discarded.\n // The value propagates up past the TryWithFrame.\n return { type: 'Value', value: _value, k }\n}\n\nfunction applyEffectResume(frame: EffectResumeFrame, value: Any, _k: ContinuationStack): Step {\n // The handler returned a value. Replace the continuation with resumeK\n // (the original continuation from the perform call site, with TryWithFrame\n // still on the stack for subsequent performs).\n // The _k (handler's remaining outer_k) is discarded — resumeK already\n // includes the full original continuation.\n return { type: 'Value', value, k: frame.resumeK }\n}\n\n/**\n * Convert a ParallelResumeFrame into a ParallelResumeStep.\n *\n * The value is the resume value from the host for the first suspended branch.\n * The actual resumption logic happens in `tick()` → `handleParallelResume()`\n * which has access to `handlers` and `signal`.\n */\nfunction applyParallelResume(frame: ParallelResumeFrame, value: Any, k: ContinuationStack): Step {\n return {\n type: 'ParallelResume',\n value,\n branchCount: frame.branchCount,\n completedBranches: frame.completedBranches,\n suspendedBranches: frame.suspendedBranches,\n k,\n }\n}\n\nfunction applyPerformArgs(frame: PerformArgsFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n const { argNodes, index, params, env } = frame\n params.push(value)\n\n if (index >= argNodes.length) {\n // All values collected — first is the effect ref, rest are args\n const effectRef = params[0]!\n assertEffectRef(effectRef, frame.sourceCodeInfo)\n const args = params.slice(1)\n // Produce a PerformStep — let the trampoline dispatch it\n return { type: 'Perform', effect: effectRef, args, k }\n }\n\n // Evaluate next arg\n const newFrame: PerformArgsFrame = { ...frame, index: index + 1 }\n return { type: 'Eval', node: argNodes[index]!, env, k: [newFrame, ...k] }\n}\n\n/**\n * Dispatch a Perform step by searching the continuation stack for a matching\n * TryWithFrame. If found, evaluate the handler and use its return value as the\n * result of the perform call. If not found, throw an unhandled effect error.\n *\n * Handler semantics (per P&P / Dvala contract):\n * - Handler receives the perform args as an array: `([arg1, arg2]) -> ...`\n * - Handler's return value IS the resume value — no explicit resume needed\n * - Handlers run OUTSIDE the try/with scope — the TryWithFrame is removed\n * from the handler's error/effect path. An EffectResumeFrame bridges the\n * handler's return value back to the original continuation.\n * - The handler function's environment is the one captured at the with-clause,\n * NOT the environment at the perform call site\n *\n * Continuation structure:\n * Original k: [...body_k, TryWithFrame(i), TryCatchFrame?(i+1), ...outer_k]\n * Handler's k: [EffectResumeFrame{resumeK=k}, ...outer_k]\n * When handler returns V: EffectResumeFrame replaces k with original k,\n * so V flows through body_k with TryWithFrame still on stack.\n */\nfunction dispatchPerform(effect: EffectRef, args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo, handlers?: Handlers, signal?: AbortSignal): Step | Promise<Step> {\n for (let i = 0; i < k.length; i++) {\n const frame = k[i]!\n if (frame.type === 'TryWith') {\n // Search this frame's handlers for a matching effect\n for (const handler of frame.handlers) {\n if (isEffectRef(handler.effectRef) && handler.effectRef.name === effect.name) {\n // Found a match!\n // resumeK = original k — handler's return value resumes here\n // (TryWithFrame stays on the stack for subsequent performs)\n const resumeK = k\n\n // Determine outer_k — skip TryWithFrame and any adjacent TryCatchFrame\n // from the same try/with/catch block, so errors and effects from the\n // handler propagate upward past the current try block.\n let skipEnd = i + 1\n if (skipEnd < k.length && k[skipEnd]!.type === 'TryCatch') {\n skipEnd++ // also skip the TryCatchFrame from the same block\n }\n const outerK = k.slice(skipEnd)\n\n // Handler's continuation: EffectResumeFrame bridges back to resumeK\n const effectResumeFrame: EffectResumeFrame = {\n type: 'EffectResume',\n resumeK,\n sourceCodeInfo,\n }\n const handlerK: ContinuationStack = [effectResumeFrame, ...outerK]\n\n // Evaluate the handler fn expression using recursive evaluator.\n // Handler expressions are always simple (lambda or variable refs).\n const handlerFn = evaluateNodeRecursive(handler.handlerNode, frame.env) as Any\n const fnLike = asFunctionLike(handlerFn, frame.sourceCodeInfo)\n // Call the handler with args as an array\n return dispatchFunction(fnLike, [args], [], frame.env, sourceCodeInfo, handlerK)\n }\n }\n }\n }\n\n // No matching local handler found — dispatch to host handler if available.\n const hostHandler = handlers?.[effect.name]\n if (hostHandler) {\n return dispatchHostHandler(hostHandler, args, k, signal, sourceCodeInfo)\n }\n\n // No host handler — check standard effects (dvala.log, dvala.now, etc.).\n const standardHandler = getStandardEffectHandler(effect.name)\n if (standardHandler) {\n return standardHandler(args, k, sourceCodeInfo)\n }\n\n // No handler at all — unhandled effect.\n throw new DvalaError(`Unhandled effect: '${effect.name}'`, sourceCodeInfo)\n}\n\n/**\n * Dispatch an effect to a host-provided JavaScript handler.\n *\n * Creates an `EffectContext` with `resume` and `suspend` callbacks, then\n * calls the handler and returns a `Promise<Step>` that resolves when the\n * handler calls one of those callbacks:\n *\n * - `resume(value)` — resolves with a `ValueStep` that continues evaluation\n * at the `perform` call site with the provided value and the original `k`.\n * If `value` is a `Promise`, it's awaited first.\n * - `suspend(meta?)` — rejects with a `SuspensionSignal` carrying the\n * continuation `k` and optional metadata. The effect trampoline loop\n * catches this and returns `RunResult.suspended`.\n *\n * Host handler errors are treated as Dvala-level errors — they're fed to\n * `unwindToTryCatch` so that Dvala `try/catch` blocks can intercept them.\n */\nfunction dispatchHostHandler(\n handler: EffectHandler,\n args: Arr,\n k: ContinuationStack,\n signal: AbortSignal | undefined,\n sourceCodeInfo: SourceCodeInfo | undefined,\n): Promise<Step> {\n const effectSignal = signal ?? new AbortController().signal\n\n return new Promise<Step>((resolve, reject) => {\n let settled = false\n\n const ctx = {\n args: Array.from(args) as Any[],\n signal: effectSignal,\n resume: (value: Any | Promise<Any>) => {\n if (settled) {\n throw new DvalaError('Effect handler called resume() more than once or after suspend()', sourceCodeInfo)\n }\n settled = true\n\n if (value instanceof Promise) {\n value.then(\n (v) => {\n resolve({ type: 'Value', value: v, k })\n },\n (e) => {\n // The promise-value rejected — treat as a Dvala-level error\n // so try/catch in the Dvala program can handle it.\n try {\n resolve(unwindToTryCatch(e instanceof Error ? new DvalaError(e, sourceCodeInfo) : new DvalaError(`${e}`, sourceCodeInfo), k))\n }\n catch (unwoundError) {\n reject(unwoundError)\n }\n },\n )\n }\n else {\n resolve({ type: 'Value', value, k })\n }\n },\n suspend: (meta?: Any) => {\n if (settled) {\n throw new DvalaError('Effect handler called suspend() more than once or after resume()', sourceCodeInfo)\n }\n settled = true\n reject(new SuspensionSignal(k, meta))\n },\n }\n\n handler(ctx).catch((e) => {\n if (settled) {\n // Handler already resolved via resume/suspend — ignore late errors\n return\n }\n settled = true\n if (isSuspensionSignal(e)) {\n reject(e)\n }\n else {\n // Handler itself threw — treat as a Dvala-level error.\n try {\n resolve(unwindToTryCatch(e instanceof Error ? new DvalaError(e, sourceCodeInfo) : new DvalaError(`${e}`, sourceCodeInfo), k))\n }\n catch (unwoundError) {\n reject(unwoundError)\n }\n }\n })\n })\n}\n\n// ---------------------------------------------------------------------------\n// Parallel & Race — concurrent branch execution\n// ---------------------------------------------------------------------------\n\n/**\n * Throw a SuspensionSignal. Factored out to a helper so ESLint's\n * `only-throw-literal` rule can be suppressed in one place.\n */\nfunction throwSuspension(k: ContinuationStack, meta?: Any): never {\n // eslint-disable-next-line ts/no-throw-literal -- SuspensionSignal is a signaling mechanism, not an error\n throw new SuspensionSignal(k, meta)\n}\n\n/**\n * Run a single trampoline branch to completion with effect handler support.\n *\n * This is the core building block for `parallel` and `race`. Each branch\n * runs as an independent trampoline invocation through `runEffectLoop`,\n * producing a `RunResult` that is either `completed`, `suspended`, or `error`.\n *\n * The branch receives the same `handlers` and the given `signal`, allowing\n * the caller to cancel branches via AbortController.\n */\nasync function runBranch(\n node: AstNode,\n env: ContextStack,\n handlers: Handlers | undefined,\n signal: AbortSignal,\n): Promise<RunResult> {\n const initial: Step = { type: 'Eval', node, env, k: [] }\n return runEffectLoop(initial, handlers, signal)\n}\n\n/**\n * Execute a `parallel(...)` expression.\n *\n * Runs all branch expressions concurrently as independent trampoline\n * invocations using `Promise.allSettled`. Results are collected in order.\n *\n * Outcome:\n * - All branches complete → return `ValueStep` with array of results\n * - Any branch suspends → throw `SuspensionSignal` with a `ParallelResumeFrame`\n * on the outer continuation. The host can resume branches one at a time.\n * - Any branch errors → throw the first error (other branches still complete\n * but errors take priority)\n */\nasync function executeParallelBranches(\n branches: AstNode[],\n env: ContextStack,\n k: ContinuationStack,\n handlers: Handlers | undefined,\n signal: AbortSignal | undefined,\n): Promise<Step> {\n const effectSignal = signal ?? new AbortController().signal\n\n // Run all branches concurrently\n const branchPromises = branches.map(branch =>\n runBranch(branch, env, handlers, effectSignal),\n )\n const results = await Promise.allSettled(branchPromises)\n\n // Collect outcomes\n const completedBranches: Array<{ index: number, value: Any }> = []\n const suspendedBranches: Array<{ index: number, blob: string, meta?: Any }> = []\n const errors: DvalaError[] = []\n\n for (let i = 0; i < results.length; i++) {\n const result = results[i]!\n if (result.status === 'rejected') {\n // runEffectLoop should never reject, but handle defensively\n errors.push(new DvalaError(`${result.reason}`, undefined))\n }\n else {\n const r = result.value\n switch (r.type) {\n case 'completed':\n completedBranches.push({ index: i, value: r.value })\n break\n case 'suspended':\n suspendedBranches.push({ index: i, blob: r.blob, meta: r.meta })\n break\n case 'error':\n errors.push(r.error)\n break\n }\n }\n }\n\n // If any branch errored, throw the first error\n if (errors.length > 0) {\n throw errors[0]!\n }\n\n // If any branch suspended, build a composite suspension\n if (suspendedBranches.length > 0) {\n // Build a ParallelResumeFrame on the outer continuation\n const parallelResumeFrame: ParallelResumeFrame = {\n type: 'ParallelResume',\n branchCount: branches.length,\n completedBranches,\n suspendedBranches: suspendedBranches.slice(1), // remaining after the first\n }\n const resumeK: ContinuationStack = [parallelResumeFrame, ...k]\n\n // Throw SuspensionSignal with the first suspended branch's meta\n const firstSuspended = suspendedBranches[0]!\n return throwSuspension(resumeK, firstSuspended.meta)\n }\n\n // All branches completed — build the result array in original order\n const resultArray: Any[] = Array.from({ length: branches.length })\n for (const { index, value } of completedBranches) {\n resultArray[index] = value\n }\n return { type: 'Value', value: resultArray, k }\n}\n\n/**\n * Execute a `race(...)` expression.\n *\n * Runs all branch expressions concurrently. The first branch to complete\n * wins — its value becomes the result. Losing branches are cancelled via\n * per-branch AbortControllers.\n *\n * Branch outcome priority: completed > suspended > errored.\n * - First completed branch wins immediately.\n * - Errored branches are silently dropped.\n * - If no branch completes but some suspend, the race suspends with only\n * the outer continuation. The host provides the winner value directly.\n * - If all branches error, throw an aggregate error.\n */\nasync function executeRaceBranches(\n branches: AstNode[],\n env: ContextStack,\n k: ContinuationStack,\n handlers: Handlers | undefined,\n signal: AbortSignal | undefined,\n): Promise<Step> {\n const parentSignal = signal ?? new AbortController().signal\n\n // Each branch gets its own AbortController so losers can be cancelled\n const branchControllers = branches.map(() => new AbortController())\n\n // Link: if parent signal aborts, abort all branches\n const onParentAbort = () => {\n for (const ctrl of branchControllers) {\n ctrl.abort(parentSignal.reason)\n }\n }\n parentSignal.addEventListener('abort', onParentAbort, { once: true })\n\n try {\n // Track the first branch to complete (temporal order, not positional)\n let winnerIndex = -1\n let winnerValue: Any = null\n\n // Run all branches concurrently, tracking completion order\n const branchPromises = branches.map(async (branch, i) => {\n const branchSignal = branchControllers[i]!.signal\n const result = await runBranch(branch, env, handlers, branchSignal)\n\n // First branch to complete wins (JavaScript is single-threaded,\n // so the first resolved promise's continuation runs first)\n if (result.type === 'completed' && winnerIndex < 0) {\n winnerIndex = i\n winnerValue = result.value\n // Cancel all other branches\n for (let j = 0; j < branchControllers.length; j++) {\n if (j !== i) {\n branchControllers[j]!.abort('race: branch lost')\n }\n }\n }\n return result\n })\n\n // Wait for all branches to settle (even cancelled ones)\n const results = await Promise.allSettled(branchPromises)\n\n // If we have a winner, return it\n if (winnerIndex >= 0) {\n return { type: 'Value', value: winnerValue, k }\n }\n\n // No completed branch — collect suspended and errored\n const suspendedMetas: Any[] = []\n const errors: DvalaError[] = []\n\n for (let i = 0; i < results.length; i++) {\n const result = results[i]!\n if (result.status === 'rejected') {\n errors.push(new DvalaError(`${result.reason}`, undefined))\n }\n else {\n const r = result.value\n switch (r.type) {\n case 'suspended':\n suspendedMetas.push(r.meta ?? null)\n break\n case 'error':\n errors.push(r.error)\n break\n /* v8 ignore next 3 */\n case 'completed':\n // Already handled via winnerIndex above\n break\n }\n }\n }\n\n // If some branches suspended, the race suspends\n if (suspendedMetas.length > 0) {\n // Race suspension: only outer k, host provides winner value directly\n // Meta contains all branch metas so host knows who is waiting\n const raceMeta: Any = { type: 'race', branches: suspendedMetas }\n throwSuspension(k, raceMeta)\n }\n\n // All branches errored — throw aggregate error\n const messages = errors.map(e => e.message).join('; ')\n throw new DvalaError(`race: all branches failed: ${messages}`, undefined)\n }\n finally {\n parentSignal.removeEventListener('abort', onParentAbort)\n }\n}\n\n/**\n * Handle a `ParallelResume` step — resume the first suspended branch.\n *\n * Called from `tick()` when a `ParallelResumeFrame` produces a\n * `ParallelResumeStep`. The value is the host's resume value for the\n * first pending suspended branch.\n *\n * Logic:\n * 1. The `completedBranches` already has the branches that completed before.\n * 2. The `value` is for the branch that was exposed to the host (the one\n * whose meta was in the SuspensionSignal). We DON'T re-run any blob —\n * the host has already decided the value.\n * 3. If more branches are suspended, throw another SuspensionSignal.\n * 4. If all branches are now done, build the result array.\n */\nfunction handleParallelResume(\n step: Step & { type: 'ParallelResume' },\n _handlers: Handlers | undefined,\n _signal: AbortSignal | undefined,\n): Step {\n const { value, branchCount, completedBranches, suspendedBranches, k } = step\n\n // The first suspended branch (whose meta was exposed) is now completed\n // We need to know its index — it was removed from suspendedBranches\n // and its index can be derived from what's missing.\n // Actually, looking at how we build this: the first suspended branch\n // was kept OUT of suspendedBranches (slice(1)), and its meta was used\n // in the SuspensionSignal. But we need its index!\n //\n // Let me reconsider: we need to track which branch index the host resume\n // value is for. The index is determined by what's NOT in completedBranches\n // or suspendedBranches.\n //\n // Better approach: store the current branch index explicitly.\n // Since we're in the middle of implementing, let me find the missing index.\n const completedIndices = new Set(completedBranches.map(b => b.index))\n const suspendedIndices = new Set(suspendedBranches.map(b => b.index))\n let currentBranchIndex = -1\n for (let i = 0; i < branchCount; i++) {\n if (!completedIndices.has(i) && !suspendedIndices.has(i)) {\n currentBranchIndex = i\n break\n }\n }\n\n // Add the just-resumed branch to completed\n const updatedCompleted = [...completedBranches, { index: currentBranchIndex, value }]\n\n // If more branches are suspended, suspend again with next one's meta\n if (suspendedBranches.length > 0) {\n const nextSuspended = suspendedBranches[0]!\n const remaining = suspendedBranches.slice(1)\n\n const parallelResumeFrame: ParallelResumeFrame = {\n type: 'ParallelResume',\n branchCount,\n completedBranches: updatedCompleted,\n suspendedBranches: remaining,\n }\n const resumeK: ContinuationStack = [parallelResumeFrame, ...k]\n return throwSuspension(resumeK, nextSuspended.meta)\n }\n\n // All branches now completed — build the result array in original order\n const resultArray: Any[] = Array.from({ length: branchCount })\n for (const { index, value: v } of updatedCompleted) {\n resultArray[index] = v\n }\n return { type: 'Value', value: resultArray, k }\n}\n\nfunction applyEvalArgs(frame: EvalArgsFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n const { node, params, placeholders, env } = frame\n const argNodes = node[1][1]\n const currentArgNode = argNodes[frame.index]!\n\n // Process the completed value\n if (isSpreadNode(currentArgNode)) {\n if (!Array.isArray(value)) {\n throw new DvalaError(`Spread operator requires an array, got ${valueToString(value)}`, currentArgNode[2])\n }\n params.push(...value)\n }\n else {\n params.push(value)\n }\n\n // Find the next real argument (skip placeholders)\n let nextIndex = frame.index + 1\n while (nextIndex < argNodes.length) {\n const nextArg = argNodes[nextIndex]!\n if (nextArg[0] === NodeTypes.ReservedSymbol && nextArg[1] === '_') {\n placeholders.push(params.length)\n nextIndex++\n }\n else {\n break\n }\n }\n\n if (nextIndex >= argNodes.length) {\n // All args evaluated — dispatch the call\n return dispatchCall({ ...frame, index: nextIndex }, k)\n }\n\n // Evaluate next argument\n const newFrame: EvalArgsFrame = { ...frame, index: nextIndex }\n const nextArg = argNodes[nextIndex]!\n if (isSpreadNode(nextArg)) {\n return { type: 'Eval', node: nextArg[1], env, k: [newFrame, ...k] }\n }\n return { type: 'Eval', node: nextArg, env, k: [newFrame, ...k] }\n}\n\nfunction applyCallFn(frame: CallFnFrame, value: Any, k: ContinuationStack): Step | Promise<Step> {\n // `value` is the resolved function value\n const fn = asFunctionLike(value, frame.sourceCodeInfo)\n return dispatchFunction(fn, frame.params, frame.placeholders, frame.env, frame.sourceCodeInfo, k)\n}\n\nfunction applyFnBody(frame: FnBodyFrame, value: Any, k: ContinuationStack): Step {\n const { fn, bodyIndex, env } = frame\n const bodyNodes = fn.evaluatedfunction[1]\n\n if (bodyIndex >= bodyNodes.length) {\n // All body nodes evaluated — return the result\n return { type: 'Value', value, k }\n }\n\n // More body nodes to evaluate.\n // The FnBodyFrame is always pushed — even for the last body node — because\n // `handleRecur` walks the continuation stack looking for it. When recur fires\n // inside the last expression, handleRecur finds this frame, slices the stack\n // at that point, and calls setupUserDefinedCall with the remaining stack.\n // This replaces the old FnBodyFrame rather than growing the stack — achieving\n // proper tail call elimination.\n const newFrame: FnBodyFrame = { ...frame, bodyIndex: bodyIndex + 1 }\n return { type: 'Eval', node: bodyNodes[bodyIndex]!, env, k: [newFrame, ...k] }\n}\n\nfunction applyBindingDefault(frame: BindingDefaultFrame, value: Any, k: ContinuationStack): Step {\n // Default value has been evaluated — continue binding processing\n // For Phase 1, this is handled by the recursive evaluateBindingNodeValues\n // This frame type will be fully utilized in later phases.\n const { target, record, env, sourceCodeInfo } = frame\n const valueRecord = evaluateBindingNodeValues(target, value, n => evaluateNodeRecursive(n, env))\n if (valueRecord instanceof Promise) {\n throw new DvalaError('Async binding default evaluation not supported in trampoline yet', sourceCodeInfo)\n }\n Object.assign(record, valueRecord)\n return { type: 'Value', value, k }\n}\n\nfunction applyNanCheck(frame: NanCheckFrame, value: Any, k: ContinuationStack): Step {\n if (typeof value === 'number' && Number.isNaN(value)) {\n throw new DvalaError('Number is NaN', frame.sourceCodeInfo)\n }\n return { type: 'Value', value: annotate(value), k }\n}\n\n// ---------------------------------------------------------------------------\n// Debug step handling\n// ---------------------------------------------------------------------------\n\n/**\n * Extract all visible bindings from a ContextStack as a flat record.\n * Iterates from outermost to innermost scope so that inner bindings\n * shadow outer ones, matching Dvala scoping semantics.\n */\nexport function extractBindings(env: ContextStack): Record<string, Any> {\n const result: Record<string, Any> = {}\n // Include host values (plain bindings passed at creation)\n const hostValues = env.getHostValues()\n if (hostValues) {\n for (const [name, value] of Object.entries(hostValues)) {\n result[name] = value as Any\n }\n }\n const contexts = env.getContextsRaw()\n // Outer scopes first, inner override\n for (let i = contexts.length - 1; i >= 0; i--) {\n for (const [name, entry] of Object.entries(contexts[i]!)) {\n result[name] = entry.value\n }\n }\n return result\n}\n\n/**\n * Apply a DebugStepFrame.\n *\n * Phase 'awaitValue': The compound expression just evaluated to `value`.\n * Build step info and produce a PerformStep for `dvala.debug.step`.\n * Push self (in 'awaitPerform' phase) onto k so that when the debug\n * perform completes, the value flows through correctly.\n *\n * Phase 'awaitPerform': The debug perform completed (handler resumed or\n * suspension was resumed). Pass the value through to the next frame.\n * For normal stepping, the debugger resumes with the original value.\n * For `rerunFrom`, the debugger resumes with an alternate value.\n */\nfunction applyDebugStep(frame: DebugStepFrame, value: Any, k: ContinuationStack): Step {\n if (frame.phase === 'awaitValue') {\n // Build step info from source code info and evaluation result\n const stepInfo: Obj = {\n expression: frame.sourceCodeInfo?.code ?? '',\n value,\n location: frame.sourceCodeInfo\n ? { line: frame.sourceCodeInfo.position.line, column: frame.sourceCodeInfo.position.column }\n : { line: 0, column: 0 },\n env: extractBindings(frame.env),\n }\n\n // Push awaitPerform phase frame, then produce PerformStep\n const awaitFrame: DebugStepFrame = {\n type: 'DebugStep',\n phase: 'awaitPerform',\n sourceCodeInfo: frame.sourceCodeInfo,\n env: frame.env,\n }\n const debugEffect = getEffectRef('dvala.debug.step')\n return { type: 'Perform', effect: debugEffect, args: [stepInfo as Any], k: [awaitFrame, ...k] }\n }\n\n // phase === 'awaitPerform': pass through the value\n return { type: 'Value', value, k }\n}\n\n// ---------------------------------------------------------------------------\n// Utility functions\n// ---------------------------------------------------------------------------\n\n/**\n * Wrap a MaybePromise<Any> result into a Step or Promise<Step>.\n * If the result is a value, return a ValueStep immediately.\n * If it's a Promise, return a Promise<Step> that resolves to a ValueStep.\n * The trampoline loop handles the async case: runSyncTrampoline throws,\n * runAsyncTrampoline awaits.\n */\nfunction wrapMaybePromiseAsStep(result: MaybePromise<Any>, k: ContinuationStack): Step | Promise<Step> {\n if (result instanceof Promise) {\n return result.then(\n value => ({ type: 'Value' as const, value, k }),\n error => unwindToTryCatch(error, k),\n )\n }\n return { type: 'Value', value: result, k }\n}\n\n/** Lazy-load collection utilities to avoid circular imports. */\nfunction getCollectionUtils(): { asColl: (v: Any, s?: SourceCodeInfo) => Any, isSeq: (v: Any) => boolean } {\n return {\n asColl: (v: Any, s?: SourceCodeInfo) => {\n if (typeof v === 'string' || Array.isArray(v) || isObj(v)) {\n return v\n }\n throw new DvalaError(`Expected collection, got ${valueToString(v)}`, s)\n },\n isSeq: (v: Any) => typeof v === 'string' || Array.isArray(v),\n }\n}\n\n// ---------------------------------------------------------------------------\n// Trampoline loop — tick, runSyncTrampoline, runAsyncTrampoline\n// ---------------------------------------------------------------------------\n\n/**\n * Process one step of the trampoline. Returns the next step, or a\n * Promise<Step> when an async operation (e.g., native JS function) is\n * encountered.\n *\n * - `Value` with empty `k`: the program is done (terminal state).\n * - `Value` with non-empty `k`: pop the top frame and apply it.\n * - `Eval`: evaluate an AST node via `stepNode` (always synchronous).\n * - `Apply`: apply a frame to a value (may return Promise<Step>).\n * - `Perform`: effect dispatch — local (try/with) first, then host handlers.\n *\n * When `handlers` and `signal` are provided (from `run()`), host handlers are\n * available as a fallback for effects not matched by any local `try/with`.\n */\nexport function tick(step: Step, handlers?: Handlers, signal?: AbortSignal): Step | Promise<Step> {\n try {\n switch (step.type) {\n case 'Value': {\n if (step.k.length === 0) {\n return step // Terminal state — program is complete\n }\n const [frame, ...rest] = step.k\n return applyFrame(frame!, step.value, rest)\n }\n case 'Eval':\n return stepNode(step.node, step.env, step.k)\n case 'Apply':\n return applyFrame(step.frame, step.value, step.k)\n case 'Perform':\n return dispatchPerform(step.effect, step.args, step.k, undefined, handlers, signal)\n case 'Parallel':\n return executeParallelBranches(step.branches, step.env, step.k, handlers, signal)\n case 'Race':\n return executeRaceBranches(step.branches, step.env, step.k, handlers, signal)\n case 'ParallelResume':\n return handleParallelResume(step, handlers, signal)\n }\n }\n catch (error) {\n // SuspensionSignal must propagate out of tick to the effect trampoline loop\n // (runEffectLoop). Never let unwindToTryCatch intercept it.\n if (isSuspensionSignal(error)) {\n // eslint-disable-next-line ts/no-throw-literal -- SuspensionSignal is a signaling mechanism, not an error\n throw error\n }\n // Search the continuation stack for a TryCatchFrame to handle the error.\n // This handles both explicit throw() and runtime errors (e.g., type errors).\n return unwindToTryCatch(error, step.k)\n }\n}\n\n/**\n * Run the trampoline synchronously to completion.\n * Throws if any step produces a Promise (i.e., an async operation was\n * encountered in a synchronous context).\n */\nexport function runSyncTrampoline(initial: Step): Any {\n let step: Step | Promise<Step> = initial\n for (;;) {\n if (step instanceof Promise) {\n throw new DvalaError('Unexpected async operation in synchronous context. Use async.run() for async operations.', undefined)\n }\n if (step.type === 'Value' && step.k.length === 0) {\n return step.value\n }\n step = tick(step)\n }\n}\n\n/**\n * Run the trampoline asynchronously to completion.\n * Awaits any Promise<Step> that surfaces from async operations.\n */\nexport async function runAsyncTrampoline(initial: Step): Promise<Any> {\n let step: Step | Promise<Step> = initial\n for (;;) {\n if (step instanceof Promise) {\n step = await step\n }\n if (step.type === 'Value' && step.k.length === 0) {\n return step.value\n }\n step = tick(step)\n }\n}\n\n// ---------------------------------------------------------------------------\n// Public entry points — evaluate an AST or a single node\n// ---------------------------------------------------------------------------\n\n/**\n * Build the initial Step for evaluating an AST (sequence of top-level nodes).\n */\nfunction buildInitialStep(nodes: AstNode[], env: ContextStack): Step {\n if (nodes.length === 0) {\n return { type: 'Value', value: null, k: [] }\n }\n if (nodes.length === 1) {\n return { type: 'Eval', node: nodes[0]!, env, k: [] }\n }\n const sequenceFrame: SequenceFrame = {\n type: 'Sequence',\n nodes,\n index: 1,\n env,\n }\n return { type: 'Eval', node: nodes[0]!, env, k: [sequenceFrame] }\n}\n\n/**\n * Evaluate an AST using the trampoline.\n * Returns the final value synchronously, or a Promise if async operations\n * are involved (e.g., native JS functions returning Promises).\n */\nexport function evaluate(ast: Ast, contextStack: ContextStack): MaybePromise<Any> {\n const initial = buildInitialStep(ast.body, contextStack)\n // Try synchronous first; if a Promise surfaces, switch to async\n try {\n return runSyncTrampoline(initial)\n }\n catch (error) {\n if (error instanceof DvalaError && error.message.includes('Unexpected async operation')) {\n // An async operation was encountered — re-run with the async trampoline.\n // We must rebuild the initial step since the sync attempt may have\n // partially mutated frames.\n const freshInitial = buildInitialStep(ast.body, contextStack)\n return runAsyncTrampoline(freshInitial)\n }\n throw error\n }\n}\n\n/**\n * Evaluate an AST using the async trampoline directly.\n * Use this when the caller knows that async operations may be involved\n * (e.g., from Dvala.async.run) to avoid the sync-first-then-retry pattern\n * which can cause side effects to be executed twice.\n */\nexport function evaluateAsync(ast: Ast, contextStack: ContextStack): Promise<Any> {\n const initial = buildInitialStep(ast.body, contextStack)\n return runAsyncTrampoline(initial)\n}\n\n/**\n * Evaluate a single AST node using the trampoline.\n * Used as the `evaluateNode` callback passed to `getUndefinedSymbols`\n * and other utilities.\n */\nexport function evaluateNode(node: AstNode, contextStack: ContextStack): MaybePromise<Any> {\n const initial: Step = { type: 'Eval', node, env: contextStack, k: [] }\n try {\n return runSyncTrampoline(initial)\n }\n catch (error) {\n if (error instanceof DvalaError && error.message.includes('Unexpected async operation')) {\n const freshInitial: Step = { type: 'Eval', node, env: contextStack, k: [] }\n return runAsyncTrampoline(freshInitial)\n }\n throw error\n }\n}\n\n// ---------------------------------------------------------------------------\n// Effect trampoline — async loop with host handler support\n// ---------------------------------------------------------------------------\n\n/**\n * Evaluate an AST with full effect handler support.\n *\n * Uses the async trampoline loop, passing `handlers` and `signal` to `tick`\n * so that `dispatchPerform` can fall back to host handlers when no local\n * `try/with` matches.\n *\n * Always resolves — never rejects. All errors are captured in\n * `RunResult.error`. Suspension is signaled via `RunResult.suspended`.\n *\n * The `AbortController` is created internally per `run()` call. The signal\n * is passed to every host handler. Used for `race()` cancellation (Phase 6)\n * and host-side timeouts.\n */\nexport async function evaluateWithEffects(\n ast: Ast,\n contextStack: ContextStack,\n handlers?: Handlers,\n): Promise<RunResult> {\n const abortController = new AbortController()\n const signal = abortController.signal\n const initial = buildInitialStep(ast.body, contextStack)\n\n return runEffectLoop(initial, handlers, signal)\n}\n\n/**\n * Resume a suspended continuation with a value.\n *\n * Re-enters the trampoline with `{ type: 'Value', value, k }` where `k` is\n * the deserialized continuation stack. Host handlers and signal are provided\n * fresh for this run.\n */\nexport async function resumeWithEffects(\n k: ContinuationStack,\n value: Any,\n handlers?: Handlers,\n): Promise<RunResult> {\n const abortController = new AbortController()\n const signal = abortController.signal\n const initial: Step = { type: 'Value', value, k }\n\n return runEffectLoop(initial, handlers, signal)\n}\n\n/**\n * Shared effect trampoline loop used by both `evaluateWithEffects` and\n * `resumeWithEffects`. Runs the trampoline to completion, suspension, or error.\n *\n * When `handlers` includes a `dvala.debug.step` handler, the loop enters\n * debug mode: before evaluating compound nodes (NormalExpression,\n * SpecialExpression) that have source code info, a `DebugStepFrame` is\n * pushed onto the continuation stack. This causes each compound expression\n * to fire a `perform(dvala.debug.step, stepInfo)` after evaluation,\n * enabling the time-travel debugger.\n */\nasync function runEffectLoop(\n initial: Step,\n handlers: Handlers | undefined,\n signal: AbortSignal,\n): Promise<RunResult> {\n const debugMode = handlers != null && 'dvala.debug.step' in handlers\n\n try {\n let step: Step | Promise<Step> = initial\n for (;;) {\n if (step instanceof Promise) {\n step = await step\n }\n if (step.type === 'Value' && step.k.length === 0) {\n return { type: 'completed', value: step.value }\n }\n\n // Debug mode: inject DebugStepFrame for compound nodes with source info\n if (debugMode && step.type === 'Eval' && step.node[2]) {\n const nodeType = step.node[0]\n if (nodeType === NodeTypes.NormalExpression || nodeType === NodeTypes.SpecialExpression) {\n const debugFrame: DebugStepFrame = {\n type: 'DebugStep',\n phase: 'awaitValue',\n sourceCodeInfo: step.node[2],\n env: step.env,\n }\n step = { ...step, k: [debugFrame, ...step.k] }\n }\n }\n\n step = tick(step, handlers, signal)\n }\n }\n catch (error) {\n if (isSuspensionSignal(error)) {\n const blob = serializeSuspension(error.k, error.meta)\n return { type: 'suspended', blob, meta: error.meta }\n }\n if (error instanceof DvalaError) {\n return { type: 'error', error }\n }\n return { type: 'error', error: new DvalaError(`${error}`, undefined) }\n }\n}\n","import { DvalaError } from '../errors'\n\nconst binaryOperators = [\n '^', // exponentiation\n\n '*', // multiplication\n '/', // division\n '%', // remainder\n\n '+', // addition\n '-', // subtraction\n\n '<<', // left shift\n '>>', // signed right shift\n '>>>', // unsigned right shift\n\n '++', // string concatenation\n\n '<', // less than\n '<=', // less than or equal\n '≤', // less than or equal\n '>', // greater than\n '>=', // greater than or equal\n '≥', // greater than or equal\n\n '==', // equal\n '!=', // not equal\n '!=', // not equal\n\n '&', // bitwise AND\n 'xor', // bitwise XOR\n '|', // bitwise OR\n\n '&&', // logical AND\n '||', // logical OR\n '??', // nullish coalescing\n\n '|>', // pipe\n] as const\n\nconst otherOperators = [\n '?', // conditional operator\n ':', // conditional operator\n '->', // lambda\n '...', // rest\n '.', // property accessor\n ',', // item separator\n '=', // assignment\n ':', // property assignment\n ';', // statement terminator\n] as const\n\nconst symbolicOperators = [\n ...binaryOperators,\n ...otherOperators,\n] as const\n\nconst nonFunctionOperators = [\n 'comment',\n 'cond',\n 'defined?',\n 'block',\n 'doseq',\n 'if',\n 'let',\n 'loop',\n 'recur',\n 'throw',\n 'try',\n 'unless',\n 'while',\n]\n\nconst nonFunctionOperatorSet = new Set(nonFunctionOperators)\nexport function isFunctionOperator(operator: string): boolean {\n return !nonFunctionOperatorSet.has(operator)\n}\n\nexport type SymbolicBinaryOperator = typeof binaryOperators[number]\nexport type SymbolicOperator = typeof symbolicOperators[number]\n\nconst binaryOperatorSet = new Set(binaryOperators)\nexport function isBinaryOperator(operator: string): operator is SymbolicBinaryOperator {\n return binaryOperatorSet.has(operator as SymbolicBinaryOperator)\n}\nexport function assertBinaryOperator(operator: string): asserts operator is SymbolicBinaryOperator {\n if (!isBinaryOperator(operator)) {\n throw new DvalaError(`Expected symbolic binary operator, got ${operator}`, undefined)\n }\n}\nexport function asBinaryOperator(operator: string): SymbolicBinaryOperator {\n assertBinaryOperator(operator)\n return operator\n}\n\nconst symbolicOperatorSet = new Set(symbolicOperators)\nexport function isSymbolicOperator(operator: string): operator is SymbolicOperator {\n return symbolicOperatorSet.has(operator as SymbolicOperator)\n}\nexport function assertSymbolicOperator(operator: string): asserts operator is SymbolicOperator {\n if (!isSymbolicOperator(operator)) {\n throw new DvalaError(`Expected symbolic operator, got ${operator}`, undefined)\n }\n}\nexport function asSymbolicOperator(operator: string): SymbolicOperator {\n assertSymbolicOperator(operator)\n return operator\n}\n","import { isSymbolicOperator } from './operators'\nimport type { BasePrefixedNumberToken, DocStringToken, ErrorToken, LBraceToken, LBracketToken, LParenToken, MultiLineCommentToken, NumberToken, OperatorToken, RBraceToken, RBracketToken, RParenToken, RegexpShorthandToken, ReservedSymbolToken, SingleLineCommentToken, StringToken, SymbolToken, Token, TokenDescriptor, WhitespaceToken } from './token'\nimport type { ReservedSymbol } from './reservedNames'\nimport { reservedSymbolRecord } from './reservedNames'\n\ntype Tokenizer<T extends Token> = (input: string, position: number) => TokenDescriptor<T | ErrorToken>\n\nconst illegalSymbolCharacters = [\n '(',\n ')',\n '[',\n ']',\n '{',\n '}',\n '\\'',\n '\"',\n '`',\n ',',\n '.',\n ';',\n ' ',\n '\\n',\n '\\r',\n '\\t',\n]\nconst illegalFirstSymbolCharacters = [\n '0',\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n ...illegalSymbolCharacters,\n]\nconst illegalSymbolCharacterSet = new Set(illegalSymbolCharacters)\nconst illegalFirstSymbolCharacterSet = new Set(illegalFirstSymbolCharacters)\n\nconst whitespaceRegExp = /\\s/\n\nexport const NO_MATCH: TokenDescriptor<never> = [0]\n\nconst tokenizeLParen: Tokenizer<LParenToken> = (input, position) =>\n tokenizeToken('LParen', '(', input, position)\nconst tokenizeRParen: Tokenizer<RParenToken> = (input, position) =>\n tokenizeToken('RParen', ')', input, position)\nconst tokenizeLBracket: Tokenizer<LBracketToken> = (input, position) =>\n tokenizeToken('LBracket', '[', input, position)\nconst tokenizeRBracket: Tokenizer<RBracketToken> = (input, position) =>\n tokenizeToken('RBracket', ']', input, position)\nconst tokenizeLBrace: Tokenizer<LBraceToken> = (input, position) =>\n tokenizeToken('LBrace', '{', input, position)\nconst tokenizeRBrace: Tokenizer<RBraceToken> = (input, position) =>\n tokenizeToken('RBrace', '}', input, position)\n\nexport const tokenizeDocString: Tokenizer<DocStringToken> = (input, position) => {\n if (input[position] !== '\"' || input[position + 1] !== '\"' || input[position + 2] !== '\"')\n return NO_MATCH\n\n let value = '\"\"\"'\n let length = 3\n let char = input[position + length]\n let nextThreeChars = input.slice(position + length, position + length + 3)\n let escaping = false\n while (char && (nextThreeChars !== '\"\"\"' || escaping)) {\n length += 1\n if (escaping) {\n escaping = false\n value += char\n }\n else {\n if (char === '\\\\') {\n escaping = true\n }\n value += char\n }\n char = input[position + length]\n nextThreeChars = input.slice(position + length, position + length + 3)\n }\n if (!char) {\n return [length, ['Error', value, undefined, `Unclosed doc string at position ${position}`]]\n }\n value += '\"\"\"' // closing quote\n return [length + 3, ['DocString', value]]\n}\n\nconst tokenizeString: Tokenizer<StringToken> = (input, position) => {\n if (input[position] !== '\"')\n return NO_MATCH\n\n let value = '\"'\n let length = 1\n let char = input[position + length]\n let escaping = false\n while (char && (char !== '\"' || escaping)) {\n length += 1\n if (escaping) {\n escaping = false\n value += char\n }\n else {\n if (char === '\\\\') {\n escaping = true\n }\n value += char\n }\n char = input[position + length]\n }\n if (!char) {\n return [length, ['Error', value, undefined, `Unclosed string at position ${position}`]]\n }\n value += '\"' // closing quote\n return [length + 1, ['string', value]]\n}\n\nconst tokenizeRegexpShorthand: Tokenizer<RegexpShorthandToken> = (input, position) => {\n if (input[position] !== '#')\n return NO_MATCH\n\n const [stringLength, token] = tokenizeString(input, position + 1)\n if (!token)\n return NO_MATCH\n\n if (token[0] === 'Error') {\n const errorToken: ErrorToken = ['Error', `#${token[1]}`, undefined, `Unclosed regexp at position ${position}`]\n return [stringLength + 1, errorToken]\n }\n\n position += stringLength + 1\n let length = stringLength + 1\n\n let options = ''\n while (input[position] === 'g' || input[position] === 'i') {\n options += input[position]!\n length += 1\n position += 1\n if (options.includes(input[position]!)) {\n return [length, ['Error', `#${token[1]}${options}`, undefined, `Duplicated regexp option \"${input[position]}\"`]]\n }\n }\n\n return [length, ['RegexpShorthand', `#${token[1]}${options}`]]\n}\n\nfunction tokenizeToken<T extends Token>(\n type: T[0],\n value: string,\n input: string,\n position: number,\n): TokenDescriptor<T> {\n if (value === input.slice(position, position + value.length))\n return [value.length, [type, value] as T]\n else\n return NO_MATCH\n}\n\nconst tokenizeWhitespace: Tokenizer<WhitespaceToken> = (input, position) => {\n let char = input[position]\n if (!char || !whitespaceRegExp.test(char)) {\n return NO_MATCH\n }\n let value = char\n position += 1\n char = input[position]\n while (char && whitespaceRegExp.test(char)) {\n value += char\n position += 1\n char = input[position]\n }\n return [value.length, ['Whitespace', value]]\n}\n\nconst decimalNumberRegExp = /\\d/\nconst octalNumberRegExp = /[0-7]/\nconst hexNumberRegExp = /[0-9a-f]/i\nconst binaryNumberRegExp = /[01]/\nconst postNumberRegExp = /[\\s)\\]}(,;]/\n\nexport const tokenizeNumber: Tokenizer<NumberToken> = (input, position) => {\n let i: number\n const negate = input[position] === '-'\n const plusPrefix = input[position] === '+'\n const start = negate || plusPrefix ? position + 1 : position\n let hasDecimalPoint = false\n let hasExponent = false\n for (i = start; i < input.length; i += 1) {\n const char = input[i] as string\n\n if (char === '_') {\n if (!decimalNumberRegExp.test(input[i - 1]!) || !decimalNumberRegExp.test(input[i + 1]!)) {\n if (i === start) {\n return NO_MATCH\n }\n return [i - position + 1, ['Error', input.substring(position, i + 1), undefined, `Invalid number format at position ${i + 1}`]]\n }\n }\n\n else if (char === '.') {\n if (i === start) {\n return NO_MATCH\n }\n if (hasDecimalPoint || hasExponent) {\n return [i - position + 1, ['Error', input.substring(position, i + 1), undefined, `Invalid number format at position ${i + 1}`]]\n }\n hasDecimalPoint = true\n }\n\n else if (char === 'e' || char === 'E') {\n if (i === start) {\n return NO_MATCH\n }\n\n if (hasExponent) {\n return [i - position + 1, ['Error', input.substring(position, i + 1), undefined, `Invalid number format at position ${i + 1}`]]\n }\n\n if (input[i - 1] === '.' || input[i - 1] === '+' || input[i - 1] === '-') {\n return [i - position + 1, ['Error', input.substring(position, i + 1), undefined, `Invalid number format at position ${i + 1}`]]\n }\n\n if (input[i + 1] === '+' || input[i + 1] === '-') {\n i += 1\n }\n\n hasExponent = true\n }\n\n else if (!decimalNumberRegExp.test(char)) {\n break\n }\n }\n\n if ((negate || plusPrefix) && i === start) {\n return NO_MATCH\n }\n\n const length = i - position\n if (length === 0) {\n return NO_MATCH\n }\n\n const nextChar = input[i]\n if (nextChar && nextChar !== ':' && !postNumberRegExp.test(nextChar)) {\n return [i - position + 1, ['Error', input.substring(position, i + 1), undefined, `Invalid number format at position ${i + 1}`]]\n }\n\n return [length, ['Number', input.substring(position, i)]]\n}\n\nexport const tokenizeBasePrefixedNumber: Tokenizer<BasePrefixedNumberToken> = (input, position) => {\n if (input[position] !== '0') {\n return NO_MATCH\n }\n\n const baseChar = input[position + 1]\n\n const type = baseChar === 'b' || baseChar === 'B'\n ? 'binary'\n : baseChar === 'o' || baseChar === 'O'\n ? 'octal'\n : baseChar === 'x' || baseChar === 'X'\n ? 'hex'\n : null\n\n if (type === null) {\n return NO_MATCH\n }\n\n let i: number\n for (i = position + 2; i < input.length; i += 1) {\n const char = input[i] as string\n if (type === 'binary' && !binaryNumberRegExp.test(char)) {\n break\n }\n if (type === 'octal' && !octalNumberRegExp.test(char)) {\n break\n }\n if (type === 'hex' && !hexNumberRegExp.test(char)) {\n break\n }\n }\n\n const length = i - position\n if (length <= 2) {\n return NO_MATCH\n }\n\n const nextChar = input[i]\n if (nextChar && !postNumberRegExp.test(nextChar)) {\n return NO_MATCH\n }\n\n return [length, ['BasePrefixedNumber', input.substring(position, i)]]\n}\n\nexport const tokenizeSymbol: Tokenizer<SymbolToken> = (input, position) => {\n let value = input[position]!\n\n if (value === '\\'') {\n let length = 1\n let char = input[position + length]\n let escaping = false\n while (char !== '\\'' || escaping) {\n if (char === undefined)\n return [length, ['Error', value, undefined, `Unclosed quoted symbol at position ${position}`]]\n\n length += 1\n if (escaping) {\n escaping = false\n value += char\n }\n else {\n if (char === '\\\\') {\n escaping = true\n }\n value += char\n }\n char = input[position + length]\n }\n value += '\\'' // closing quote\n return [length + 1, ['Symbol', value]]\n }\n\n if (!illegalFirstSymbolCharacterSet.has(value)) {\n const initialPosition = position\n position += 1\n let char = input[position]\n\n while (char && !illegalSymbolCharacterSet.has(char)) {\n value += char\n position += 1\n char = input[position]\n }\n\n // : can be used as symbol character, but it must not be the last character\n return value.endsWith(':')\n ? [position - initialPosition - 1, ['Symbol', value.slice(0, -1)]]\n : [position - initialPosition, ['Symbol', value]]\n }\n\n return NO_MATCH\n}\n\nexport const tokenizeReservedSymbolToken: Tokenizer<ReservedSymbolToken> = (input, position) => {\n const symbolMeta = tokenizeSymbol(input, position)\n if (symbolMeta[0] === 0 || !symbolMeta[1]) {\n return NO_MATCH\n }\n let symbolName = symbolMeta[1][1]\n symbolName = symbolName.startsWith('\\'') ? symbolName.slice(1, symbolName.length - 1) : symbolName\n\n const info = reservedSymbolRecord[symbolName as ReservedSymbol]\n if (info === undefined) {\n return NO_MATCH\n }\n return [symbolMeta[0], ['ReservedSymbol', symbolName as ReservedSymbol]]\n}\n\nexport const tokenizeOperator: Tokenizer<OperatorToken> = (input, position) => {\n const threeChars = input.slice(position, position + 3)\n if (position + 2 < input.length && isSymbolicOperator(threeChars)) {\n return [3, ['Operator', threeChars]]\n }\n\n const twoChars = input.slice(position, position + 2)\n if (position + 1 < input.length && isSymbolicOperator(twoChars)) {\n return [2, ['Operator', twoChars]]\n }\n\n const oneChar = input[position] ?? ''\n if (isSymbolicOperator(oneChar)) {\n return [1, ['Operator', oneChar]]\n }\n return NO_MATCH\n}\n\nexport const tokenizeMultiLineComment: Tokenizer<MultiLineCommentToken> = (input, position) => {\n if (input[position] === '/' && input[position + 1] === '*') {\n let length = 2\n let value = '/*'\n while ((input[position + length] !== '*' || input[position + length + 1] !== '/') && position + length + 1 < input.length) {\n value += input[position + length]\n length += 1\n }\n if (position + length + 1 >= input.length) {\n return [length, ['Error', value, undefined, `Unclosed multi-line comment at position ${position}`]]\n }\n value += '*/'\n length += 2\n\n return [length, ['MultiLineComment', value]]\n }\n return NO_MATCH\n}\n\nexport const tokenizeShebang: Tokenizer<SingleLineCommentToken> = (input, position) => {\n if (input[position] === '#' && input[position + 1] === '!') {\n let length = 2\n let value = '#!'\n while (input[position + length] !== '\\n' && position + length < input.length) {\n value += input[position + length]\n length += 1\n }\n\n return [length, ['SingleLineComment', value]]\n }\n return NO_MATCH\n}\n\nexport const tokenizeSingleLineComment: Tokenizer<SingleLineCommentToken> = (input, position) => {\n if (input[position] === '/' && input[position + 1] === '/') {\n let length = 2\n let value = '//'\n while (input[position + length] !== '\\n' && position + length < input.length) {\n value += input[position + length]\n length += 1\n }\n\n return [length, ['SingleLineComment', value]]\n }\n return NO_MATCH\n}\n\n// All tokenizers, order matters!\nexport const tokenizers = [\n tokenizeWhitespace,\n tokenizeMultiLineComment,\n tokenizeSingleLineComment,\n tokenizeReservedSymbolToken,\n tokenizeLParen,\n tokenizeRParen,\n tokenizeLBracket,\n tokenizeRBracket,\n tokenizeLBrace,\n tokenizeRBrace,\n tokenizeDocString,\n tokenizeString,\n tokenizeRegexpShorthand,\n tokenizeBasePrefixedNumber,\n tokenizeNumber,\n tokenizeOperator,\n tokenizeSymbol,\n] as const satisfies Tokenizer<Token>[]\n","import type { FilePathParams } from '../Dvala/Dvala'\nimport { tokenizeShebang, tokenizers } from './tokenizers'\nimport type { SourceCodeInfo, Token, TokenDescriptor } from './token'\n\nexport interface TokenStream {\n tokens: Token[]\n hasDebugData: boolean\n filePath?: string\n}\n\nexport function tokenize(input: string, debug: boolean, filePath: FilePathParams['filePath']): TokenStream {\n let position = 0\n const tokenStream: TokenStream = {\n tokens: [],\n filePath,\n hasDebugData: debug,\n }\n\n while (position < input.length) {\n const sourceCodeInfo: SourceCodeInfo | undefined = debug\n ? createSourceCodeInfo(input, position, filePath)\n : undefined\n\n const tokenDescriptor = getCurrentToken(input, position)\n\n const [count, token] = tokenDescriptor\n\n position += count\n if (token) {\n if (sourceCodeInfo) {\n token[2] = sourceCodeInfo\n }\n\n tokenStream.tokens.push(token)\n }\n }\n\n return tokenStream\n}\n\nfunction getSourceCodeLine(input: string, lineNbr: number): string {\n return input.split(/\\r\\n|\\r|\\n/)[lineNbr] as string\n}\n\nfunction createSourceCodeInfo(input: string, position: number, filePath?: string): SourceCodeInfo {\n const lines = input.substring(0, position + 1).split(/\\r\\n|\\r|\\n/)\n const lastLine = lines[lines.length - 1] as string\n\n const code = getSourceCodeLine(input, lines.length - 1)\n const line = lines.length\n const column = lastLine.length\n return {\n code,\n position: {\n line,\n column,\n },\n filePath,\n }\n}\n\nfunction getCurrentToken(input: string, position: number): TokenDescriptor<Token> {\n const initialPosition = position\n\n if (position === 0) {\n const [nbrOfCharacters, token] = tokenizeShebang(input, position)\n position += nbrOfCharacters\n if (nbrOfCharacters > 0) {\n return [position - initialPosition, token]\n }\n }\n\n for (const tokenizer of tokenizers) {\n const [nbrOfCharacters, token] = tokenizer(input, position)\n position += nbrOfCharacters\n if (nbrOfCharacters === 0) {\n continue\n }\n\n return [position - initialPosition, token]\n }\n return [1, ['Error', input[initialPosition], undefined, 'Unrecognized character']] as TokenDescriptor<Token>\n}\n","import { DvalaError } from '../errors'\nimport type { ReservedSymbol } from './reservedNames'\nimport { type SymbolicBinaryOperator, type SymbolicOperator, isBinaryOperator } from './operators'\n\nexport const tokenTypes = [\n 'LBrace',\n 'LBracket',\n 'RBrace',\n 'RBracket',\n 'LParen',\n 'RParen',\n 'BasePrefixedNumber',\n 'DocString',\n 'Error',\n 'MultiLineComment',\n 'Number',\n 'Operator',\n 'RegexpShorthand',\n 'ReservedSymbol',\n 'SingleLineComment',\n 'Shebang',\n 'string',\n 'Symbol',\n 'Whitespace',\n] as const\n\nexport type TokenType = typeof tokenTypes[number]\n\ntype GenericToken<T extends TokenType, V extends string = string> = [T, V] | [T, V, SourceCodeInfo]\n\nexport type ErrorToken = ['Error', string, SourceCodeInfo | undefined, string]\n\nexport type LBraceToken = GenericToken<'LBrace', '{'>\nexport type LBracketToken = GenericToken<'LBracket', '['>\nexport type LParenToken = GenericToken<'LParen', '('>\nexport type RBraceToken = GenericToken<'RBrace', '}'>\nexport type RBracketToken = GenericToken<'RBracket', ']'>\nexport type RParenToken = GenericToken<'RParen', ')'>\n\nexport type BasePrefixedNumberToken = GenericToken<'BasePrefixedNumber'>\nexport type MultiLineCommentToken = GenericToken<'MultiLineComment'>\nexport type NumberToken = GenericToken<'Number'>\nexport type OperatorToken<T extends SymbolicOperator = SymbolicOperator> = GenericToken<'Operator', T>\nexport type RegexpShorthandToken = GenericToken<'RegexpShorthand'>\nexport type ReservedSymbolToken<T extends ReservedSymbol = ReservedSymbol> = GenericToken<'ReservedSymbol', T>\nexport type SingleLineCommentToken = GenericToken<'SingleLineComment'>\nexport type ShebangToken = GenericToken<'Shebang'>\nexport type StringToken = GenericToken<'string'>\nexport type DocStringToken = GenericToken<'DocString'>\nexport type SymbolToken<T extends string = string> = GenericToken<'Symbol', T>\nexport type WhitespaceToken = GenericToken<'Whitespace'>\n\nexport type Token =\n | LBraceToken\n | LBracketToken\n | LParenToken\n | RBraceToken\n | RBracketToken\n | RParenToken\n | BasePrefixedNumberToken\n | DocStringToken\n | ErrorToken\n | MultiLineCommentToken\n | NumberToken\n | OperatorToken\n | RegexpShorthandToken\n | ReservedSymbolToken\n | SingleLineCommentToken\n | ShebangToken\n | StringToken\n | SymbolToken\n | WhitespaceToken\n\nexport type TokenDescriptor<T extends Token> = [length: number, token?: T]\n\nexport interface SourceCodeInfo {\n position: {\n line: number\n column: number\n }\n code: string\n filePath?: string\n}\n\nexport function isSymbolToken<T extends string>(token: Token | undefined | undefined, symbolName?: T): token is SymbolToken<T> {\n if (token?.[0] !== 'Symbol') {\n return false\n }\n if (symbolName && token[1] !== symbolName) {\n return false\n }\n return true\n}\n\nexport function assertSymbolToken<T extends string>(token: Token | undefined | undefined, symbolName?: T): asserts token is SymbolToken<T> {\n if (!isSymbolToken(token, symbolName)) {\n throwUnexpectedToken('Symbol', undefined, token)\n }\n}\nexport function asSymbolToken<T extends string>(token: Token | undefined | undefined, symbolName?: T): SymbolToken<T> {\n assertSymbolToken(token, symbolName)\n return token\n}\n\nexport function isReservedSymbolToken<T extends ReservedSymbol>(token: Token | undefined | undefined, symbolName?: T): token is ReservedSymbolToken<T> {\n if (token?.[0] !== 'ReservedSymbol') {\n return false\n }\n if (symbolName && token[1] !== symbolName) {\n return false\n }\n return true\n}\nexport function assertReservedSymbolToken<T extends ReservedSymbol>(token: Token | undefined | undefined, symbolName?: T): asserts token is ReservedSymbolToken<T> {\n if (!isReservedSymbolToken(token, symbolName)) {\n throwUnexpectedToken('ReservedSymbol', symbolName, token)\n }\n}\nexport function asReservedSymbolToken<T extends ReservedSymbol>(token: Token | undefined | undefined, symbolName?: T): ReservedSymbolToken<T> {\n assertReservedSymbolToken(token, symbolName)\n return token\n}\n\nexport function isShebangToken(token: Token | undefined): token is SingleLineCommentToken {\n return token?.[0] === 'Shebang'\n}\n\nexport function isSingleLineCommentToken(token: Token | undefined): token is SingleLineCommentToken {\n return token?.[0] === 'SingleLineComment'\n}\n\nexport function isMultiLineCommentToken(token: Token | undefined): token is MultiLineCommentToken {\n return token?.[0] === 'MultiLineComment'\n}\n\nexport function isOperatorToken<T extends SymbolicOperator>(token: Token | undefined | undefined, operatorName?: T): token is OperatorToken<T> {\n if (token?.[0] !== 'Operator') {\n return false\n }\n if (operatorName && token[1] !== operatorName) {\n return false\n }\n return true\n}\nexport function assertOperatorToken<T extends SymbolicOperator>(token: Token | undefined | undefined, operatorName?: T): asserts token is OperatorToken<T> {\n if (!isOperatorToken(token, operatorName)) {\n throwUnexpectedToken('Operator', operatorName, token)\n }\n}\nexport function asOperatorToken<T extends SymbolicOperator>(token: Token | undefined | undefined, operatorName?: T): OperatorToken<T> {\n assertOperatorToken(token, operatorName)\n return token\n}\n\nexport function isWhitespaceToken(token: Token | undefined): token is WhitespaceToken {\n return token?.[0] === 'Whitespace'\n}\nexport function assertWhitespaceToken(token: Token | undefined): asserts token is WhitespaceToken {\n if (!isWhitespaceToken(token)) {\n throwUnexpectedToken('Whitespace', undefined, token)\n }\n}\nexport function asWhitespaceToken(token: Token | undefined): WhitespaceToken {\n assertWhitespaceToken(token)\n return token\n}\n\nexport function isNumberToken(token: Token | undefined): token is NumberToken {\n return token?.[0] === 'Number'\n}\nexport function assertNumberToken(token: Token | undefined): asserts token is NumberToken {\n if (!isNumberToken(token)) {\n throwUnexpectedToken('Number', undefined, token)\n }\n}\nexport function asNumberToken(token: Token | undefined): NumberToken {\n assertNumberToken(token)\n return token\n}\n\nexport function isBasePrefixedNumberToken(token: Token | undefined): token is BasePrefixedNumberToken {\n return token?.[0] === 'BasePrefixedNumber'\n}\nexport function assertBasePrefixedNumberToken(token: Token | undefined): asserts token is BasePrefixedNumberToken {\n if (!isBasePrefixedNumberToken(token)) {\n throwUnexpectedToken('BasePrefixedNumber', undefined, token)\n }\n}\nexport function asBasePrefixedNumberToken(token: Token | undefined): BasePrefixedNumberToken {\n assertBasePrefixedNumberToken(token)\n return token\n}\n\nexport function isLParenToken(token: Token | undefined): token is LParenToken {\n return token?.[0] === 'LParen'\n}\nexport function assertLParenToken(token: Token | undefined): asserts token is LParenToken {\n if (!isLParenToken(token)) {\n throwUnexpectedToken('LParen', undefined, token)\n }\n}\nexport function asLParenToken(token: Token | undefined): LParenToken {\n assertLParenToken(token)\n return token\n}\n\nexport function isRParenToken(token: Token | undefined): token is RParenToken {\n return token?.[0] === 'RParen'\n}\nexport function assertRParenToken(token: Token | undefined): asserts token is RParenToken {\n if (!isRParenToken(token)) {\n throwUnexpectedToken('RParen', undefined, token)\n }\n}\nexport function asRParenToken(token: Token | undefined): RParenToken {\n assertRParenToken(token)\n return token\n}\n\nexport function isLBracketToken(token: Token | undefined): token is LBracketToken {\n return token?.[0] === 'LBracket'\n}\nexport function assertLBracketToken(token: Token | undefined): asserts token is LBracketToken {\n if (!isLBracketToken(token)) {\n throwUnexpectedToken('LBracket', undefined, token)\n }\n}\nexport function asLBracketToken(token: Token | undefined): LBracketToken {\n assertLBracketToken(token)\n return token\n}\n\nexport function isRBracketToken(token: Token | undefined): token is RBracketToken {\n return token?.[0] === 'RBracket'\n}\nexport function assertRBracketToken(token: Token | undefined): asserts token is RBracketToken {\n if (!isRBracketToken(token)) {\n throwUnexpectedToken('RBracket', undefined, token)\n }\n}\nexport function asRBracketToken(token: Token | undefined): RBracketToken {\n assertRBracketToken(token)\n return token\n}\n\nexport function isLBraceToken(token: Token | undefined): token is LBraceToken {\n return token?.[0] === 'LBrace'\n}\nexport function assertLBraceToken(token: Token | undefined): asserts token is LBraceToken {\n if (!isLBraceToken(token)) {\n throwUnexpectedToken('LBrace', undefined, token)\n }\n}\nexport function asLBraceToken(token: Token | undefined): LBraceToken {\n assertLBraceToken(token)\n return token\n}\n\nexport function isRBraceToken(token: Token | undefined): token is RBraceToken {\n return token?.[0] === 'RBrace'\n}\nexport function assertRBraceToken(token: Token | undefined): asserts token is RBraceToken {\n if (!isRBraceToken(token)) {\n throwUnexpectedToken('RBrace', undefined, token)\n }\n}\nexport function asRBraceToken(token: Token | undefined): RBraceToken {\n assertRBraceToken(token)\n return token\n}\n\nexport function isStringToken(token: Token | undefined): token is StringToken {\n return token?.[0] === 'string'\n}\nexport function assertStringToken(token: Token | undefined): asserts token is StringToken {\n if (!isStringToken(token)) {\n throwUnexpectedToken('string', undefined, token)\n }\n}\nexport function asStringToken(token: Token | undefined): StringToken {\n assertStringToken(token)\n return token\n}\n\nexport function isDocStringToken(token: Token | undefined): token is DocStringToken {\n return token?.[0] === 'DocString'\n}\n\nexport function isRegexpShorthandToken(token: Token | undefined): token is RegexpShorthandToken {\n return token?.[0] === 'RegexpShorthand'\n}\nexport function assertRegexpShorthandToken(token: Token | undefined): asserts token is RegexpShorthandToken {\n if (!isRegexpShorthandToken(token)) {\n throwUnexpectedToken('RegexpShorthand', undefined, token)\n }\n}\nexport function asRegexpShorthandToken(token: Token | undefined): RegexpShorthandToken {\n assertRegexpShorthandToken(token)\n return token\n}\n\nexport function isA_BinaryOperatorToken(token: Token | undefined): token is OperatorToken<SymbolicBinaryOperator> {\n return token?.[0] === 'Operator' && isBinaryOperator(token[1])\n}\nexport function assertA_BinaryOperatorToken(token: Token | undefined): asserts token is OperatorToken<SymbolicBinaryOperator> {\n if (!isA_BinaryOperatorToken(token)) {\n throwUnexpectedToken('Operator', undefined, token)\n }\n}\nexport function asA_BinaryOperatorToken(token: Token | undefined): OperatorToken<SymbolicBinaryOperator> {\n assertA_BinaryOperatorToken(token)\n return token\n}\n\nfunction throwUnexpectedToken(expected: TokenType, expectedValue: string | undefined, actual: Token | undefined): never {\n const actualOutput = actual ? `${actual[0]} '${actual[1]}'` : 'end of input'\n throw new DvalaError(`Unexpected token: ${actualOutput}, expected ${expected}${expectedValue ? ` '${expectedValue}'` : ''}`, actual?.[2])\n}\n","import type { TokenStream } from './tokenize'\nimport { isMultiLineCommentToken, isShebangToken, isSingleLineCommentToken, isWhitespaceToken } from './token'\n\nexport function minifyTokenStream(tokenStream: TokenStream, { removeWhiteSpace }: { removeWhiteSpace: boolean }): TokenStream {\n const tokens = tokenStream.tokens\n .filter((token) => {\n if (isSingleLineCommentToken(token)\n || isMultiLineCommentToken(token)\n || isShebangToken(token)\n || (removeWhiteSpace && isWhitespaceToken(token))) {\n return false\n }\n return true\n })\n\n return { ...tokenStream, tokens }\n}\n","import { normalExpressionKeys, specialExpressionKeys } from '../builtin'\nimport type { ContextParams, Dvala } from '../Dvala/Dvala'\nimport { reservedSymbolRecord } from '../tokenizer/reservedNames'\n\ntype AutoCompleteSuggestion = {\n program: string\n position: number\n}\n\nconst dvalaCommands = new Set([...normalExpressionKeys, ...specialExpressionKeys, ...Object.keys(reservedSymbolRecord)])\n\n// TODO: replace with get suggestions function\nexport class AutoCompleter {\n private prefixProgram: string = ''\n private suffixProgram: string = ''\n private searchString: string = ''\n private suggestions: string[] = []\n private suggestionIndex: null | number = null\n\n constructor(public readonly originalProgram: string, public readonly originalPosition: number, dvala: Dvala, params: ContextParams) {\n const partialProgram = this.originalProgram.slice(0, this.originalPosition)\n const tokenStream = dvala.tokenize(partialProgram)\n\n const lastToken = tokenStream.tokens.at(-1)\n if (!lastToken) {\n return\n }\n\n if (lastToken[0] === 'Error') {\n return\n }\n\n this.searchString = lastToken[1]\n this.prefixProgram = this.originalProgram.slice(0, this.originalPosition - this.searchString.length)\n this.suffixProgram = this.originalProgram.slice(this.prefixProgram.length + this.searchString.length)\n this.originalProgram.slice(this.prefixProgram.length + this.searchString.length)\n this.suggestions = this.generateSuggestions(params)\n }\n\n public getNextSuggestion(): AutoCompleteSuggestion | null {\n return this.getAutoCompleteSuggestionResult(this.getNextSuggestionSymbol())\n }\n\n public getPreviousSuggestion(): AutoCompleteSuggestion | null {\n return this.getAutoCompleteSuggestionResult(this.getPreviousSuggestionSymbol())\n }\n\n private getAutoCompleteSuggestionResult(suggestion: string | null): AutoCompleteSuggestion | null {\n if (suggestion === null) {\n return null\n }\n\n return {\n program: this.prefixProgram + suggestion + this.suffixProgram,\n position: this.prefixProgram.length + suggestion.length,\n }\n }\n\n private getNextSuggestionSymbol(): string | null {\n if (this.suggestions.length === 0) {\n return null\n }\n\n if (this.suggestionIndex === null) {\n this.suggestionIndex = 0\n }\n else {\n this.suggestionIndex += 1\n if (this.suggestionIndex >= this.suggestions.length) {\n this.suggestionIndex = 0\n }\n }\n\n return this.suggestions[this.suggestionIndex]!\n }\n\n private getPreviousSuggestionSymbol(): string | null {\n if (this.suggestions.length === 0) {\n return null\n }\n\n if (this.suggestionIndex === null) {\n this.suggestionIndex = this.suggestions.length - 1\n }\n else {\n this.suggestionIndex -= 1\n if (this.suggestionIndex < 0) {\n this.suggestionIndex = this.suggestions.length - 1\n }\n }\n\n return this.suggestions[this.suggestionIndex]!\n }\n\n public getSuggestions(): string[] {\n return [...this.suggestions]\n }\n\n public getSearchString(): string {\n return this.searchString\n }\n\n private generateSuggestions(params: ContextParams): string[] {\n const blacklist = new Set<string>(['0_defn', '0_lambda'])\n\n const startsWithCaseSensitive = this.generateWithPredicate(params, suggestion =>\n !blacklist.has(suggestion) && suggestion.startsWith(this.searchString))\n startsWithCaseSensitive.forEach(suggestion => blacklist.add(suggestion))\n\n const startsWithCaseInsensitive = this.generateWithPredicate(params, suggestion =>\n !blacklist.has(suggestion) && suggestion.toLowerCase().startsWith(this.searchString.toLowerCase()))\n startsWithCaseInsensitive.forEach(suggestion => blacklist.add(suggestion))\n\n const includesCaseSensitive = this.generateWithPredicate(params, suggestion =>\n !blacklist.has(suggestion) && suggestion.includes(this.searchString))\n includesCaseSensitive.forEach(suggestion => blacklist.add(suggestion))\n\n const includesCaseInsensitive = this.generateWithPredicate(params, suggestion =>\n !blacklist.has(suggestion) && suggestion.includes(this.searchString.toLowerCase()))\n includesCaseInsensitive.forEach(suggestion => blacklist.add(suggestion))\n\n return [...startsWithCaseSensitive, ...startsWithCaseInsensitive, ...includesCaseSensitive, ...includesCaseInsensitive]\n }\n\n private generateWithPredicate(params: ContextParams, shouldInclude: (suggestion: string) => boolean): string[] {\n const suggestions = new Set<string>()\n\n dvalaCommands.forEach((suggestion) => {\n if (shouldInclude(suggestion)) {\n suggestions.add(suggestion)\n }\n })\n\n Object.keys(params.globalContext ?? {})\n .filter(shouldInclude)\n .forEach(suggestion => suggestions.add(suggestion))\n\n params.contexts?.forEach((context) => {\n Object.keys(context)\n .filter(shouldInclude)\n .forEach(suggestion => suggestions.add(suggestion))\n })\n\n Object.keys(params.bindings ?? {})\n .filter(shouldInclude)\n .forEach(suggestion => suggestions.add(suggestion))\n\n return [...suggestions].sort((a, b) => a.localeCompare(b))\n }\n}\n","/**\n * A bundle produced by the bundler. Contains the main program source\n * with file imports rewritten to canonical module names, plus an ordered\n * array of file module sources keyed by canonical name.\n *\n * The bundle is pure JSON — fully serializable and portable\n * (e.g., build on a server, run in a browser).\n */\nexport interface DvalaBundle {\n /** The main program source, with file imports rewritten to bare symbols. */\n program: string\n /** Ordered array of [canonicalName, source] pairs. Dependencies come before dependents. */\n fileModules: [string, string][]\n}\n\nexport function isDvalaBundle(value: unknown): value is DvalaBundle {\n return (\n typeof value === 'object'\n && value !== null\n && typeof (value as DvalaBundle).program === 'string'\n && Array.isArray((value as DvalaBundle).fileModules)\n )\n}\n","import type { NormalExpressionName } from '../../reference/api'\nimport type { SpecialExpressionName } from '../builtin'\nimport { allNormalExpressions, normalExpressionTypes } from '../builtin/normalExpressions'\nimport type { AndNode } from '../builtin/specialExpressions/and'\nimport { specialExpressionTypes } from '../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../constants/constants'\nimport { DvalaError } from '../errors'\nimport type { OperatorToken, SourceCodeInfo } from '../tokenizer/token'\nimport { isOperatorToken, isReservedSymbolToken } from '../tokenizer/token'\nimport { isNormalBuiltinSymbolNode, isUserDefinedSymbolNode } from '../typeGuards/astNode'\nimport { assertNumberOfParams } from '../utils/arity'\nimport type { AstNode, BindingTarget, NormalBuiltinSymbolNode, NormalExpressionNodeWithName, SymbolNode, UserDefinedSymbolNode } from './types'\nimport type { ParserContext } from './ParserContext'\n\nexport const exponentiationPrecedence = 12\nexport const binaryFunctionalOperatorPrecedence = 3\nexport const conditionalOperatorPrecedence = 1\n\nexport function withSourceCodeInfo<T extends AstNode | BindingTarget>(node: T, sourceCodeInfo: SourceCodeInfo | undefined): T {\n if (sourceCodeInfo) {\n node[2] = sourceCodeInfo\n }\n return node\n}\n\nexport function stringToSymbolNode(value: string, sourceCodeInfo: SourceCodeInfo | undefined): SymbolNode {\n if (specialExpressionTypes[value as SpecialExpressionName] !== undefined && value !== 'fn' && value !== 'defn') {\n return withSourceCodeInfo([NodeTypes.SpecialBuiltinSymbol, specialExpressionTypes[value as SpecialExpressionName]], sourceCodeInfo) satisfies SymbolNode\n }\n if (normalExpressionTypes[value as NormalExpressionName] !== undefined) {\n return withSourceCodeInfo([NodeTypes.NormalBuiltinSymbol, normalExpressionTypes[value as NormalExpressionName] as number], sourceCodeInfo) satisfies SymbolNode\n }\n return withSourceCodeInfo([NodeTypes.UserDefinedSymbol, value], sourceCodeInfo) satisfies SymbolNode\n}\n\nexport function stringFromQuotedSymbol(value: string): string {\n return value.substring(1, value.length - 1)\n .replace(\n /(\\\\{2})|(\\\\')|\\\\(.)/g,\n (\n _,\n backslash: string,\n singleQuote: string,\n normalChar: string,\n ) => {\n if (backslash) {\n return '\\\\'\n }\n if (singleQuote) {\n return '\\''\n }\n return `\\\\${normalChar}`\n },\n )\n}\n\n// Reverse lookup tables for getting symbol names from builtin types\nconst normalExpressionNames: string[] = Object.entries(normalExpressionTypes).reduce((acc, [name, index]) => {\n acc[index] = name\n return acc\n}, [] as string[])\n\nconst specialExpressionNames: string[] = Object.entries(specialExpressionTypes).reduce((acc, [name, index]) => {\n acc[index] = name\n return acc\n}, [] as string[])\n\n/**\n * Extract the symbol name from any symbol node type.\n * UserDefinedSymbolNode: node[1] is the string name\n * NormalBuiltinSymbolNode: node[1] is an index, need reverse lookup\n * SpecialBuiltinSymbolNode: node[1] is an index, need reverse lookup\n */\nexport function getSymbolName(symbol: SymbolNode): string {\n if (isUserDefinedSymbolNode(symbol)) {\n return symbol[1]\n }\n if (isNormalBuiltinSymbolNode(symbol)) {\n return normalExpressionNames[symbol[1]]!\n }\n // SpecialBuiltinSymbolNode\n return specialExpressionNames[symbol[1]]!\n}\n\nexport function createNamedNormalExpressionNode(symbolNode: NormalBuiltinSymbolNode | UserDefinedSymbolNode, params: AstNode[], sourceCodeInfo: SourceCodeInfo | undefined): NormalExpressionNodeWithName {\n const node: NormalExpressionNodeWithName = withSourceCodeInfo([NodeTypes.NormalExpression, [symbolNode, params]], sourceCodeInfo)\n\n if (isNormalBuiltinSymbolNode(symbolNode)) {\n assertNumberOfParams(allNormalExpressions[symbolNode[1]]!.arity, node[1][1].length, sourceCodeInfo)\n }\n\n return node\n}\n\nexport function isAtExpressionEnd(ctx: ParserContext): boolean {\n if (ctx.isAtEnd()) {\n return true\n }\n const token = ctx.tryPeek()\n if (isOperatorToken(token)) {\n return [';', ',', ':'].includes(token[1])\n }\n if (isReservedSymbolToken(token)) {\n return ['else', 'when', 'while', 'case', 'catch', 'let', 'then', 'end', 'do'].includes(token[1])\n }\n return false\n}\n\nexport function fromBinaryOperatorToNode(operator: OperatorToken, symbolNode: SymbolNode, left: AstNode, right: AstNode, sourceCodeInfo: SourceCodeInfo | undefined): AstNode {\n const operatorName = operator[1]\n\n switch (operatorName) {\n case '^': // exponentiation\n case '*':\n case '/':\n case '%':\n case '+':\n case '-':\n case '<<':\n case '>>':\n case '>>>':\n case '++':\n case '<':\n case '<=':\n case '≤':\n case '>':\n case '>=':\n case '≥':\n case '==':\n case '!=':\n case '&':\n case 'xor':\n case '|':\n case '|>':\n return createNamedNormalExpressionNode(symbolNode as NormalBuiltinSymbolNode, [left, right], sourceCodeInfo)\n case '&&':\n case '||':\n case '??':\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes[operatorName], [left, right]]] as AndNode, sourceCodeInfo)\n /* v8 ignore next 11 */\n case '.':\n case ';':\n case ':':\n case '=':\n case ',':\n case '->':\n case '...':\n case '?':\n throw new DvalaError(`Unknown binary operator: ${operatorName}`, sourceCodeInfo)\n default:\n throw new DvalaError(`Unknown binary operator: ${operatorName satisfies never}`, sourceCodeInfo)\n }\n}\n","import { DvalaError } from '../errors'\nimport type { SourceCodeInfo, Token } from '../tokenizer/token'\nimport type { TokenStream } from '../tokenizer/tokenize'\nimport type { AstNode } from './types'\n\nexport class ParserContext {\n private readonly tokens: Token[]\n private position: number\n private storedPosition: number = 0\n public parseExpression!: (precedence?: number) => AstNode\n\n constructor(tokenStream: TokenStream) {\n this.tokens = tokenStream.tokens\n this.position = 0\n }\n\n public advance(): void {\n this.position += 1\n }\n\n public tryPeek(): Token | undefined {\n return this.tokens[this.position]\n }\n\n public peek(): Token {\n const token = this.tokens[this.position]\n if (!token) {\n const lastToken = this.tokens.at(-1)\n /* v8 ignore next */\n const sourceCodeInfo = lastToken ? lastToken[2] : undefined\n throw new DvalaError('Unexpected end of input', sourceCodeInfo)\n }\n return token\n }\n\n public isAtEnd(): boolean {\n return this.position >= this.tokens.length\n }\n\n // TODO rename to getSourceCodeInfo\n public peekSourceCodeInfo(): SourceCodeInfo | undefined {\n const currentToken = this.tryPeek()\n return currentToken ? currentToken[2] : this.tokens.at(-1)?.[2]\n }\n\n public storePosition(): number {\n return this.storedPosition = this.position\n }\n\n public restorePosition(): void {\n this.position = this.storedPosition\n }\n\n public peekAhead(count: number): Token | undefined {\n return this.tokens[this.position + count]\n }\n\n public getPosition(): number {\n return this.position\n }\n\n public getTokenAt(pos: number): Token | undefined {\n return this.tokens[pos]\n }\n\n // Add methods for token management, error handling, etc.\n}\n","import { DvalaError } from '../errors'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport type { SymbolicBinaryOperator } from '../tokenizer/operators'\nimport { exponentiationPrecedence } from './helpers'\n\nexport function getPrecedence(operatorSign: SymbolicBinaryOperator, sourceCodeInfo: SourceCodeInfo | undefined): number {\n switch (operatorSign) {\n case '^': // exponentiation\n return exponentiationPrecedence\n\n case '*': // multiplication\n case '/': // division\n case '%': // remainder\n return 11\n\n case '+': // addition\n case '-': // subtraction\n return 10\n\n case '<<': // left shift\n case '>>': // signed right shift\n case '>>>': // unsigned right shift\n return 9\n\n case '++': // string concatenation\n return 8\n\n case '<': // less than\n case '<=': // less than or equal\n case '≤': // less than or equal\n case '>': // greater than\n case '>=': // greater than or equal\n case '≥': // greater than or equal\n return 7\n\n case '==': // equal\n case '!=': // not equal\n return 6\n\n case '&': // bitwise AND\n case 'xor': // bitwise XOR\n case '|': // bitwise OR\n return 5\n\n case '&&': // logical AND\n case '||': // logical OR\n case '??': // nullish coalescing\n return 4\n\n // leave room for binaryFunctionalOperatorPrecedence = 3\n\n case '|>': // pipe\n return 2\n\n // leave room for conditionalOperatorPrecedence = 1\n\n /* v8 ignore next 2 */\n default:\n throw new DvalaError(`Unknown binary operator: ${operatorSign satisfies never}`, sourceCodeInfo)\n }\n}\n","import { isOperatorToken, isReservedSymbolToken } from '../../tokenizer/token'\nimport type { AstNode } from '../types'\nimport { DvalaError } from '../../errors'\nimport { NodeTypes } from '../../constants/constants'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport type { DoNode } from '../../builtin/specialExpressions/block'\nimport type { ParserContext } from '../ParserContext'\nimport { withSourceCodeInfo } from '../helpers'\n\ntype ImplicitBlockEnd = 'end' | 'else' | 'catch' | 'case' | 'with'\n\nexport function parseImplicitBlock(ctx: ParserContext, ends: ImplicitBlockEnd[]): AstNode {\n const nodes: AstNode[] = []\n while (!ctx.isAtEnd() && !isImplicitBlockEnd(ctx, ends)) {\n if (isOperatorToken(ctx.tryPeek(), ';')) {\n ctx.advance()\n }\n else {\n nodes.push(ctx.parseExpression())\n }\n }\n assertImplicitBlockEnd(ctx, ends)\n\n if (nodes.length === 0) {\n throw new DvalaError('Expected expression', ctx.peekSourceCodeInfo())\n }\n\n return nodes.length === 1\n ? nodes[0]!\n : withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.block, nodes]], ctx.peekSourceCodeInfo()) satisfies DoNode\n}\n\nfunction assertImplicitBlockEnd(ctx: ParserContext, ends: ImplicitBlockEnd[]): void {\n if (!isImplicitBlockEnd(ctx, ends)) {\n throw new DvalaError(`Expected ${ends.map(e => e[1]).join(' or ')}`, ctx.peekSourceCodeInfo())\n }\n}\n\nfunction isImplicitBlockEnd(ctx: ParserContext, ends: ImplicitBlockEnd[]): boolean {\n for (const end of ends) {\n if (isReservedSymbolToken(ctx.tryPeek(), end)) {\n return true\n }\n }\n return false\n}\n","import { NodeTypes } from '../../constants/constants'\nimport type { StringNode } from '../types'\nimport type { StringToken } from '../../tokenizer/token'\nimport { withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\n\nexport function parseString(ctx: ParserContext, token: StringToken): StringNode {\n ctx.advance()\n const value = token[1].substring(1, token[1].length - 1)\n .replace(\n /(\\\\{2})|(\\\\\")|(\\\\n)|(\\\\t)|(\\\\r)|(\\\\b)|(\\\\f)|\\\\(.)/g,\n (\n _,\n backslash: string,\n doubleQuote: string,\n newline: string,\n tab: string,\n carriageReturn: string,\n backspace: string,\n formFeed: string,\n normalChar: string,\n ) => {\n // If it's a double escape (\\\\x), return \\x\n if (backslash) {\n return '\\\\'\n }\n // If it's a special character (\\n, \\t, \\r, \\b, \\f), return the special character\n else if (newline) {\n return '\\n'\n }\n else if (tab) {\n return '\\t'\n }\n else if (carriageReturn) {\n return '\\r'\n }\n else if (backspace) {\n return '\\b'\n }\n else if (formFeed) {\n return '\\f'\n }\n else if (doubleQuote) {\n return '\"'\n }\n return normalChar\n },\n )\n\n return withSourceCodeInfo([NodeTypes.String, value], token[2]) satisfies StringNode\n}\n","import type { DoNode } from '../../builtin/specialExpressions/block'\nimport { DvalaError } from '../../errors'\nimport type { StringToken } from '../../tokenizer/token'\nimport { asReservedSymbolToken, assertOperatorToken, assertReservedSymbolToken, isDocStringToken, isOperatorToken, isReservedSymbolToken } from '../../tokenizer/token'\nimport { smartTrim } from '../../utils'\nimport type { AstNode } from '../types'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../../constants/constants'\nimport type { ParserContext } from '../ParserContext'\nimport { withSourceCodeInfo } from '../helpers'\nimport { parseString } from './parseString'\n\nexport function parseDo(ctx: ParserContext, allowDocString = false): [DoNode, string] {\n const token = asReservedSymbolToken(ctx.tryPeek(), 'do')\n ctx.advance()\n let docString: string = ''\n if (allowDocString && isDocStringToken(ctx.tryPeek())) {\n docString = parseDocString(ctx)\n if (!ctx.isAtEnd() && !isReservedSymbolToken(ctx.tryPeek(), 'end')) {\n assertOperatorToken(ctx.tryPeek(), ';')\n ctx.advance()\n }\n }\n\n const expressions: AstNode[] = []\n while (!ctx.isAtEnd() && !isReservedSymbolToken(ctx.tryPeek(), 'end')) {\n expressions.push(ctx.parseExpression())\n if (isOperatorToken(ctx.tryPeek(), ';')) {\n ctx.advance()\n }\n else if (!isReservedSymbolToken(ctx.tryPeek(), 'end')) {\n throw new DvalaError('Expected end', ctx.peekSourceCodeInfo())\n }\n }\n assertReservedSymbolToken(ctx.tryPeek(), 'end')\n ctx.advance()\n return [\n withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.block, expressions]], token[2]) satisfies DoNode,\n docString,\n ]\n}\n\nfunction parseDocString(ctx: ParserContext): string {\n const token = ctx.peek()\n const stringToken: StringToken = token[2] ? ['string', token[1].slice(2, -2), token[2]] : ['string', token[1].slice(2, -2)]\n const stringNode = parseString(ctx, stringToken)\n return smartTrim(stringNode[1]) // Extract the string value from the StringNode\n}\n","import { DvalaError } from '../../errors'\nimport type { NormalBuiltinSymbolNode, SpecialBuiltinSymbolNode, SymbolNode } from '../types'\nimport { isSymbolToken } from '../../tokenizer/token'\nimport { stringFromQuotedSymbol, stringToSymbolNode } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\n\nexport function parseSymbol(ctx: ParserContext): SymbolNode | NormalBuiltinSymbolNode | SpecialBuiltinSymbolNode {\n const token = ctx.peek()\n ctx.advance()\n if (!isSymbolToken(token)) {\n throw new DvalaError(`Expected symbol token, got ${token[0]}`, token[2])\n }\n if (token[1][0] === '\\'') {\n return stringToSymbolNode(stringFromQuotedSymbol(token[1]), token[2])\n }\n else {\n return stringToSymbolNode(token[1], token[2])\n }\n}\n","import { NodeTypes } from '../../constants/constants'\nimport type { NumberNode } from '../types'\nimport { withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\n\nexport function parseNumber(ctx: ParserContext): NumberNode {\n const token = ctx.peek()\n ctx.advance()\n\n const value = token[1]\n const negative = value[0] === '-'\n const numberString = (negative ? value.substring(1) : value).replace(/_/g, '')\n return withSourceCodeInfo([NodeTypes.Number, negative ? -Number(numberString) : Number(numberString)], token[2]) satisfies NumberNode\n}\n","import { DvalaError } from '../../errors'\nimport type { AstNode, BindingTarget } from '../types'\nimport { bindingTargetTypes } from '../types'\nimport { type Token, assertOperatorToken, isBasePrefixedNumberToken, isLBraceToken, isLBracketToken, isNumberToken, isOperatorToken, isRBraceToken, isRBracketToken, isReservedSymbolToken, isStringToken, isSymbolToken } from '../../tokenizer/token'\nimport { asUserDefinedSymbolNode, isUserDefinedSymbolNode } from '../../typeGuards/astNode'\nimport { getSymbolName, withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\nimport { NodeTypes } from '../../constants/constants'\nimport { parseSymbol } from './parseSymbol'\nimport { parseString } from './parseString'\nimport { parseNumber } from './parseNumber'\n\nexport interface ParseBindingTargetOptions {\n requireDefaultValue?: true\n noRest?: true\n allowLiteralPatterns?: true\n}\n\nexport function parseBindingTarget(ctx: ParserContext, { requireDefaultValue, noRest, allowLiteralPatterns }: ParseBindingTargetOptions = {}): BindingTarget {\n const firstToken = ctx.tryPeek()\n\n // Wildcard _ (only in pattern matching context)\n if (allowLiteralPatterns && isReservedSymbolToken(firstToken, '_')) {\n ctx.advance()\n return withSourceCodeInfo([bindingTargetTypes.wildcard, []], firstToken[2])\n }\n\n // Literal patterns: number, string, true, false, null (only in pattern matching context)\n if (allowLiteralPatterns && isLiteralToken(firstToken)) {\n if (isNumberToken(firstToken) || isBasePrefixedNumberToken(firstToken)) {\n const node = parseNumber(ctx)\n return withSourceCodeInfo([bindingTargetTypes.literal, [node]], firstToken[2])\n }\n if (isStringToken(firstToken)) {\n const node = parseString(ctx, firstToken)\n return withSourceCodeInfo([bindingTargetTypes.literal, [node]], firstToken[2])\n }\n if (isReservedSymbolToken(firstToken, 'true')) {\n ctx.advance()\n const node: AstNode = withSourceCodeInfo([NodeTypes.ReservedSymbol, 'true'], firstToken[2])\n return withSourceCodeInfo([bindingTargetTypes.literal, [node]], firstToken[2])\n }\n if (isReservedSymbolToken(firstToken, 'false')) {\n ctx.advance()\n const node: AstNode = withSourceCodeInfo([NodeTypes.ReservedSymbol, 'false'], firstToken[2])\n return withSourceCodeInfo([bindingTargetTypes.literal, [node]], firstToken[2])\n }\n if (isReservedSymbolToken(firstToken, 'null')) {\n ctx.advance()\n const node: AstNode = withSourceCodeInfo([NodeTypes.ReservedSymbol, 'null'], firstToken[2])\n return withSourceCodeInfo([bindingTargetTypes.literal, [node]], firstToken[2])\n }\n }\n\n // Symbol\n if (isSymbolToken(firstToken)) {\n const symbol = parseSymbol(ctx)\n if (!isUserDefinedSymbolNode(symbol)) {\n throw new DvalaError('Expected user defined symbol', firstToken[2])\n }\n\n const defaultValue = parseOptionalDefaulValue(ctx)\n if (requireDefaultValue && !defaultValue) {\n throw new DvalaError('Expected assignment', ctx.peekSourceCodeInfo())\n }\n\n return withSourceCodeInfo([bindingTargetTypes.symbol, [symbol, defaultValue]], firstToken[2])\n }\n\n // Rest\n if (isOperatorToken(firstToken, '...')) {\n if (noRest) {\n throw new DvalaError('Rest element not allowed', firstToken[2])\n }\n ctx.advance()\n const symbol = asUserDefinedSymbolNode(parseSymbol(ctx))\n if (isOperatorToken(ctx.tryPeek(), '=')) {\n throw new DvalaError('Rest argument can not have default value', ctx.peekSourceCodeInfo())\n }\n return withSourceCodeInfo([bindingTargetTypes.rest, [symbol[1], undefined]], firstToken[2])\n }\n\n // Array\n if (isLBracketToken(firstToken)) {\n ctx.advance()\n const elements: (BindingTarget | null)[] = []\n let token = ctx.peek()\n\n let rest = false\n while (!isRBracketToken(token)) {\n if (rest) {\n throw new DvalaError('Rest argument must be last', token[2])\n }\n if (isOperatorToken(token, ',')) {\n elements.push(null)\n ctx.advance()\n token = ctx.peek()\n continue\n }\n\n const target = parseBindingTarget(ctx, { allowLiteralPatterns })\n\n if (target[0] === bindingTargetTypes.rest) {\n rest = true\n }\n\n elements.push(target)\n token = ctx.peek()\n\n if (!isRBracketToken(token)) {\n assertOperatorToken(token, ',')\n ctx.advance()\n }\n token = ctx.peek()\n }\n ctx.advance()\n\n const defaultValue = parseOptionalDefaulValue(ctx)\n if (requireDefaultValue && !defaultValue) {\n throw new DvalaError('Expected assignment', ctx.peekSourceCodeInfo())\n }\n\n return withSourceCodeInfo([bindingTargetTypes.array, [elements, defaultValue]], firstToken[2])\n }\n\n // Object\n if (isLBraceToken(firstToken)) {\n ctx.advance()\n const elements: Record<string, BindingTarget> = {}\n let token = ctx.peek()\n let rest = false\n while (!isRBraceToken(token)) {\n if (rest) {\n throw new DvalaError('Rest argument must be last', token[2])\n }\n if (isOperatorToken(token, '...')) {\n rest = true\n ctx.advance()\n }\n // Parse the key symbol - can be any symbol type (including builtins) when using 'as' alias\n const keySymbol = parseSymbol(ctx)\n const keyName = getSymbolName(keySymbol)\n token = ctx.peek()\n if (isReservedSymbolToken(token, 'as')) {\n if (rest) {\n throw new DvalaError('Rest argument can not have alias', token[2])\n }\n ctx.advance()\n const name = asUserDefinedSymbolNode(parseSymbol(ctx))\n if (elements[name[1]]) {\n throw new DvalaError(`Duplicate binding name: ${name}`, token[2])\n }\n elements[keyName] = withSourceCodeInfo([bindingTargetTypes.symbol, [name, parseOptionalDefaulValue(ctx)]], firstToken[2])\n }\n else if (isRBraceToken(token) || isOperatorToken(token, ',') || isOperatorToken(token, '=')) {\n // Without 'as' alias, the key becomes the binding name - must be user-defined symbol\n const key = asUserDefinedSymbolNode(keySymbol, keySymbol[2])\n if (elements[key[1]]) {\n throw new DvalaError(`Duplicate binding name: ${key}`, token[2])\n }\n if (rest && isOperatorToken(ctx.tryPeek(), '=')) {\n throw new DvalaError('Rest argument can not have default value', ctx.peekSourceCodeInfo())\n }\n\n elements[key[1]] = rest\n ? withSourceCodeInfo([bindingTargetTypes.rest, [key[1], parseOptionalDefaulValue(ctx)]], firstToken[2])\n : withSourceCodeInfo([bindingTargetTypes.symbol, [key, parseOptionalDefaulValue(ctx)]], firstToken[2])\n }\n else if (isOperatorToken(token, ':')) {\n ctx.advance()\n token = ctx.peek()\n if (allowLiteralPatterns) {\n // In pattern matching context, allow literals, nested objects/arrays, and variable bindings after ':'\n if (!isLBraceToken(token) && !isLBracketToken(token) && !isLiteralToken(token)) {\n throw new DvalaError('Expected literal, object or array pattern', token[2])\n }\n }\n else {\n if (!isLBraceToken(token) && !isLBracketToken(token)) {\n throw new DvalaError('Expected object or array', token[2])\n }\n }\n elements[keyName] = parseBindingTarget(ctx, { allowLiteralPatterns })\n }\n\n if (!isRBraceToken(ctx.peek())) {\n assertOperatorToken(ctx.peek(), ',')\n ctx.advance()\n }\n token = ctx.peek()\n }\n ctx.advance()\n token = ctx.peek()\n\n const defaultValue = parseOptionalDefaulValue(ctx)\n if (requireDefaultValue && !defaultValue) {\n throw new DvalaError('Expected assignment', token[2])\n }\n\n return withSourceCodeInfo([bindingTargetTypes.object, [elements, defaultValue]], firstToken[2])\n }\n\n throw new DvalaError('Expected symbol', ctx.peekSourceCodeInfo())\n}\n\nfunction parseOptionalDefaulValue(ctx: ParserContext): AstNode | undefined {\n if (isOperatorToken(ctx.tryPeek(), '=')) {\n ctx.advance()\n return ctx.parseExpression()\n }\n return undefined\n}\n\nfunction isLiteralToken(token: Token | undefined): boolean {\n return isNumberToken(token)\n || isBasePrefixedNumberToken(token)\n || isStringToken(token)\n || isReservedSymbolToken(token, 'true')\n || isReservedSymbolToken(token, 'false')\n || isReservedSymbolToken(token, 'null')\n}\n","import type { LetNode } from '../../builtin/specialExpressions/let'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../../constants/constants'\nimport type { BindingNode } from '../types'\nimport type { SymbolToken } from '../../tokenizer/token'\nimport { withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\nimport { parseBindingTarget } from './parseBindingTarget'\n\nexport function parseLet(ctx: ParserContext, token: SymbolToken): LetNode {\n ctx.advance()\n\n const target = parseBindingTarget(ctx, { requireDefaultValue: true, noRest: true })\n\n const value = target[1][1]!\n target[1][1] = undefined\n\n const bindingTarget: BindingNode = withSourceCodeInfo([NodeTypes.Binding, [target, value]], token[2])\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.let, bindingTarget]], token[2]) satisfies LetNode\n}\n","import { getAllBindingTargetNames } from '../../builtin/bindingNode'\nimport type { DoSeqNode, ForNode, LoopBindingNode } from '../../builtin/specialExpressions/loops'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../../constants/constants'\nimport { DvalaError } from '../../errors'\nimport type { AstNode, BindingNode } from '../types'\nimport { bindingTargetTypes } from '../types'\nimport type { SymbolToken, Token } from '../../tokenizer/token'\nimport { asSymbolToken, assertLParenToken, assertOperatorToken, assertRParenToken, assertReservedSymbolToken, isOperatorToken, isRParenToken, isReservedSymbolToken, isSymbolToken } from '../../tokenizer/token'\nimport { asUserDefinedSymbolNode } from '../../typeGuards/astNode'\nimport { withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\nimport { parseLet } from './parseLet'\nimport { parseSymbol } from './parseSymbol'\n\ntype InternalLoopBindingDelimiter = 'let' | 'when' | 'while'\n\nexport function parseForOrDoseq(ctx: ParserContext, firstToken: SymbolToken): ForNode | DoSeqNode {\n const isDoseq = firstToken[1] === 'doseq'\n ctx.advance()\n\n assertLParenToken(ctx.tryPeek())\n ctx.advance()\n\n const forLoopBindings: LoopBindingNode[] = []\n\n while (!ctx.isAtEnd() && !isRParenToken(ctx.tryPeek())) {\n const loopBinding = parseForLoopBinding(ctx)\n const existingBoundNames = forLoopBindings.flatMap(b => Object.keys(getAllBindingTargetNames(b[0][1][0])))\n const newBoundNames = getAllBindingTargetNames(loopBinding[0][1][0])\n if (Object.keys(newBoundNames).some(n => existingBoundNames.includes(n))) {\n throw new DvalaError('Duplicate binding', loopBinding[0][2])\n }\n forLoopBindings.push(loopBinding)\n if (isOperatorToken(ctx.tryPeek(), ',')) {\n ctx.advance()\n }\n }\n\n assertRParenToken(ctx.tryPeek())\n ctx.advance()\n\n assertOperatorToken(ctx.tryPeek(), '->')\n ctx.advance()\n\n const expression = ctx.parseExpression()\n\n return isDoseq\n ? withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.doseq, forLoopBindings, expression]], firstToken[2]) satisfies DoSeqNode\n : withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.for, forLoopBindings, expression]], firstToken[2]) satisfies ForNode\n}\n\nfunction parseForLoopBinding(ctx: ParserContext): LoopBindingNode {\n const bindingNode = parseBinding(ctx)\n\n const modifiers: Array<'&let' | '&when' | '&while'> = []\n let token = ctx.peek()\n\n assertInternalLoopBindingDelimiter(token, ['let', 'when', 'while'])\n\n const letBindings: BindingNode[] = []\n if (token[1] === 'let') {\n modifiers.push('&let')\n while (isSymbolToken(token, 'let')) {\n const letNode = parseLet(ctx, token)\n const existingBoundNames = letBindings.flatMap(b => Object.keys(getAllBindingTargetNames(b[1][0])))\n const newBoundNames = Object.keys(getAllBindingTargetNames(letNode[1][1][1][0]))\n if (newBoundNames.some(n => existingBoundNames.includes(n))) {\n throw new DvalaError('Duplicate binding', letNode[1][1][2])\n }\n\n letBindings.push(letNode[1][1])\n token = ctx.peek()\n assertInternalLoopBindingDelimiter(token, ['let', 'when', 'while'])\n token = ctx.peek()\n }\n }\n\n let whenNode: AstNode | undefined\n let whileNode: AstNode | undefined\n while (\n isReservedSymbolToken(token, 'when')\n || isReservedSymbolToken(token, 'while')\n ) {\n ctx.advance()\n\n if (token[1] === 'when') {\n modifiers.push('&when')\n whenNode = ctx.parseExpression()\n }\n else {\n modifiers.push('&while')\n whileNode = ctx.parseExpression()\n }\n token = ctx.peek()\n\n const symbols: ('when' | 'while')[] = modifiers.includes('&when') && modifiers.includes('&while')\n ? []\n : modifiers.includes('&when')\n ? ['while']\n : ['when']\n\n assertInternalLoopBindingDelimiter(token, symbols)\n token = ctx.peek()\n }\n\n assertInternalLoopBindingDelimiter(token, [])\n\n return [bindingNode, letBindings, whenNode, whileNode] satisfies LoopBindingNode\n}\n\nfunction parseBinding(ctx: ParserContext): BindingNode {\n const firstToken = asSymbolToken(ctx.tryPeek())\n const name = asUserDefinedSymbolNode(parseSymbol(ctx))\n\n assertReservedSymbolToken(ctx.tryPeek(), 'in')\n ctx.advance()\n\n const value = ctx.parseExpression()\n\n const node: BindingNode = withSourceCodeInfo(\n [\n NodeTypes.Binding,\n [\n withSourceCodeInfo([bindingTargetTypes.symbol, [name, undefined]], firstToken[2]),\n value,\n ],\n ],\n firstToken[2],\n )\n return node\n}\n\nfunction assertInternalLoopBindingDelimiter(token: Token, symbols: InternalLoopBindingDelimiter[]): void {\n if (!isInternalLoopBindingDelimiter(token, symbols)) {\n const symbolsString = `${[...symbols, ','].map(symbol => `\"${symbol}\"`).join(', ')} or \")\"`\n throw new DvalaError(`Expected symbol ${symbolsString}`, token[2])\n }\n}\n\nfunction isInternalLoopBindingDelimiter(token: Token, symbols: InternalLoopBindingDelimiter[]): boolean {\n // end of loop binding\n if (isOperatorToken(token, ',') || isRParenToken(token)) {\n return true\n }\n for (const symbol of symbols) {\n if (symbol === 'let' && isSymbolToken(token, 'let')) {\n return true\n }\n if (['when', 'while'].includes(symbol) && isReservedSymbolToken(token, symbol as 'when' | 'while')) {\n return true\n }\n }\n return false\n}\n","import { NodeTypes } from '../../constants/constants'\nimport type { NumberNode, ReservedSymbolNode } from '../types'\nimport { isNumberReservedSymbol, numberReservedSymbolRecord } from '../../tokenizer/reservedNames'\nimport { asReservedSymbolToken } from '../../tokenizer/token'\nimport { withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\n\nexport function parseReservedSymbol(ctx: ParserContext): ReservedSymbolNode | NumberNode {\n const token = asReservedSymbolToken(ctx.tryPeek())\n ctx.advance()\n\n const symbol = token[1]\n if (isNumberReservedSymbol(symbol)) {\n return withSourceCodeInfo([NodeTypes.Number, numberReservedSymbolRecord[symbol]], token[2]) satisfies NumberNode\n }\n return withSourceCodeInfo([NodeTypes.ReservedSymbol, token[1]], token[2]) satisfies ReservedSymbolNode\n}\n","import type { LambdaNode } from '../../builtin/specialExpressions/functions'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../../constants/constants'\nimport { DvalaError } from '../../errors'\nimport type { AstNode, BindingTarget } from '../types'\nimport { bindingTargetTypes } from '../types'\nimport { assertLParenToken, isLParenToken, isOperatorToken, isRParenToken, isReservedSymbolToken, isSymbolToken } from '../../tokenizer/token'\nimport { withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\nimport { parseBindingTarget } from './parseBindingTarget'\nimport { parseDo } from './parseDo'\nimport { parseSymbol } from './parseSymbol'\n\nconst placeholderRegexp = /^\\$([1-9]\\d?)?$/\nconst maxShorthandLambdaArity = 20\n\nexport function parseLambdaFunction(ctx: ParserContext): LambdaNode | null {\n const firstToken = ctx.peek()\n\n if (isLParenToken(firstToken)\n && isSymbolToken(ctx.peekAhead(1))\n && isOperatorToken(ctx.peekAhead(2), '->')) {\n return null\n }\n\n try {\n const functionArguments = parseFunctionArguments(ctx)\n\n if (!isOperatorToken(ctx.peek(), '->')) {\n return null\n }\n ctx.advance()\n let nodes: AstNode[] | undefined\n let docString = ''\n if (isReservedSymbolToken(ctx.peek(), 'do')) {\n const parsedDo = parseDo(ctx, true)\n docString = parsedDo[1]\n nodes = parsedDo[0][1][1]\n }\n else {\n nodes = [ctx.parseExpression()]\n }\n\n return withSourceCodeInfo([\n NodeTypes.SpecialExpression,\n [\n specialExpressionTypes['0_lambda'],\n [\n functionArguments,\n nodes,\n ],\n docString,\n ],\n ], firstToken[2]) satisfies LambdaNode\n }\n catch {\n return null\n }\n}\n\nfunction parseFunctionArguments(ctx: ParserContext): BindingTarget[] {\n const firstToken = ctx.peek()\n if (isSymbolToken(firstToken)) {\n return [withSourceCodeInfo([bindingTargetTypes.symbol, [parseSymbol(ctx), undefined]], firstToken[2])]\n }\n\n assertLParenToken(firstToken)\n ctx.advance()\n\n let rest = false\n let defaults = false\n const functionArguments: BindingTarget[] = []\n while (!ctx.isAtEnd() && !isRParenToken(ctx.peek()) && !isSymbolToken(ctx.peek(), 'let')) {\n if (rest) {\n throw new DvalaError('Rest argument must be last', ctx.peekSourceCodeInfo())\n }\n const bindingTarget = parseBindingTarget(ctx)\n if (bindingTarget[1][1] !== undefined) {\n defaults = true\n }\n if (bindingTarget[0] === bindingTargetTypes.rest) {\n rest = true\n }\n if (defaults && !bindingTarget[1][1]) {\n throw new DvalaError('Default arguments must be last', ctx.peekSourceCodeInfo())\n }\n functionArguments.push(bindingTarget)\n\n if (!isOperatorToken(ctx.peek(), ',') && !isRParenToken(ctx.peek()) && !isSymbolToken(ctx.peek(), 'let')) {\n throw new DvalaError('Expected comma or closing parenthesis', ctx.peekSourceCodeInfo())\n }\n if (isOperatorToken(ctx.peek(), ',')) {\n ctx.advance()\n }\n }\n\n if (!isRParenToken(ctx.peek())) {\n throw new DvalaError('Expected closing parenthesis', ctx.peekSourceCodeInfo())\n }\n\n ctx.advance()\n\n return functionArguments\n}\nexport function parseShorthandLambdaFunction(ctx: ParserContext): LambdaNode {\n const firstToken = ctx.peek()\n ctx.advance()\n // TODO, do not like this...\n const startPos = ctx.getPosition()\n\n let nodes: AstNode[] | undefined\n let docString = ''\n if (isReservedSymbolToken(ctx.peek(), 'do')) {\n const parsedDo = parseDo(ctx, true)\n docString = parsedDo[1]\n nodes = parsedDo[0][1][1]\n }\n else {\n nodes = [ctx.parseExpression()]\n }\n\n const endPos = ctx.getPosition() - 1\n\n let arity = 0\n let dollar1: 'NOT_SET' | 'WITH_1' | 'NAKED' = 'NOT_SET' // referring to argument bindings. $ = NAKED, $1, $2, $3, etc = WITH_1\n for (let pos = startPos; pos <= endPos; pos += 1) {\n const token = ctx.getTokenAt(pos)!\n if (isSymbolToken(token)) {\n const match = placeholderRegexp.exec(token[1])\n if (match) {\n const number = match[1] ?? '1'\n if (number === '1') {\n const mixedPercent1 = (!match[1] && dollar1 === 'WITH_1') || (match[1] && dollar1 === 'NAKED')\n if (mixedPercent1)\n throw new DvalaError('Please make up your mind, either use $ or $1', firstToken[2])\n\n dollar1 = match[1] ? 'WITH_1' : 'NAKED'\n }\n\n arity = Math.max(arity, Number(number))\n if (arity > maxShorthandLambdaArity)\n throw new DvalaError('Can\\'t specify more than 20 arguments', firstToken[2])\n }\n }\n }\n\n const functionArguments: BindingTarget[] = []\n\n for (let i = 1; i <= arity; i += 1) {\n if (i === 1 && dollar1 === 'NAKED') {\n functionArguments.push(withSourceCodeInfo([bindingTargetTypes.symbol, [[NodeTypes.UserDefinedSymbol, '$'], undefined]], firstToken[2]))\n }\n else {\n functionArguments.push(withSourceCodeInfo([bindingTargetTypes.symbol, [[NodeTypes.UserDefinedSymbol, `$${i}`], undefined]], firstToken[2]))\n }\n }\n\n const node: LambdaNode = withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes['0_lambda'], [\n functionArguments,\n nodes,\n ], docString]], firstToken[2])\n\n return node\n}\n","import type { SpecialExpression, SpecialExpressionType } from '../../builtin'\nimport { builtin } from '../../builtin'\nimport type { AndNode } from '../../builtin/specialExpressions/and'\nimport type { ArrayNode } from '../../builtin/specialExpressions/array'\nimport type { DefinedNode } from '../../builtin/specialExpressions/defined'\nimport type { EffectNode } from '../../builtin/specialExpressions/effect'\nimport type { ImportNode } from '../../builtin/specialExpressions/import'\nimport type { ObjectNode } from '../../builtin/specialExpressions/object'\nimport type { OrNode } from '../../builtin/specialExpressions/or'\nimport type { ParallelNode } from '../../builtin/specialExpressions/parallel'\nimport type { PerformNode } from '../../builtin/specialExpressions/perform'\nimport type { RaceNode } from '../../builtin/specialExpressions/race'\nimport type { QqNode } from '../../builtin/specialExpressions/qq'\nimport type { RecurNode } from '../../builtin/specialExpressions/recur'\nimport type { ThrowNode } from '../../builtin/specialExpressions/throw'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../../constants/constants'\nimport { DvalaError } from '../../errors'\nimport type { AstNode, NormalExpressionNodeExpression, SymbolNode } from '../types'\nimport { isOperatorToken, isRParenToken, isSymbolToken } from '../../tokenizer/token'\nimport { isNormalBuiltinSymbolNode, isSpecialBuiltinSymbolNode, isUserDefinedSymbolNode } from '../../typeGuards/astNode'\nimport { assertNumberOfParams } from '../../utils/arity'\nimport { createNamedNormalExpressionNode, withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\n\nexport function parseFunctionCall(ctx: ParserContext, symbol: AstNode): AstNode {\n ctx.advance()\n\n // Handle effect(dotted.name) — custom parsing for dotted identifier argument\n if (isSpecialBuiltinSymbolNode(symbol) && symbol[1] === specialExpressionTypes.effect) {\n return parseEffectArgs(ctx, symbol)\n }\n\n const params: AstNode[] = []\n while (!ctx.isAtEnd() && !isRParenToken(ctx.tryPeek())) {\n if (isOperatorToken(ctx.tryPeek(), '...')) {\n ctx.advance()\n params.push(withSourceCodeInfo([NodeTypes.Spread, ctx.parseExpression()], ctx.peekSourceCodeInfo()))\n }\n else {\n params.push(ctx.parseExpression())\n }\n const nextToken = ctx.tryPeek()\n if (!isOperatorToken(nextToken, ',') && !isRParenToken(nextToken)) {\n throw new DvalaError('Expected comma or closing parenthesis', ctx.tryPeek()?.[2])\n }\n if (isOperatorToken(nextToken, ',')) {\n ctx.advance()\n }\n }\n if (!isRParenToken(ctx.tryPeek())) {\n throw new DvalaError('Expected closing parenthesis', ctx.peekSourceCodeInfo())\n }\n ctx.advance()\n\n if (isSpecialBuiltinSymbolNode(symbol)) { // Named function\n const specialExpressionType = symbol[1]\n\n // Handle import specially — extract module name as a string from the symbol argument\n if (specialExpressionType === specialExpressionTypes.import) {\n if (params.length !== 1) {\n throw new DvalaError(`import expects exactly 1 argument, got ${params.length}`, symbol[2])\n }\n const param = params[0]!\n if (!isUserDefinedSymbolNode(param)) {\n throw new DvalaError('import expects a module name (symbol), got a non-symbol argument', param[2] ?? symbol[2])\n }\n const moduleName = param[1]\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionType, moduleName]], symbol[2]) satisfies ImportNode\n }\n\n const type = specialExpressionType as Exclude<\n SpecialExpressionType,\n | typeof specialExpressionTypes.for\n | typeof specialExpressionTypes.if\n | typeof specialExpressionTypes.unless\n | typeof specialExpressionTypes.cond\n | typeof specialExpressionTypes.match\n | typeof specialExpressionTypes.let\n | typeof specialExpressionTypes.block\n | typeof specialExpressionTypes.loop\n | typeof specialExpressionTypes.try\n | typeof specialExpressionTypes.doseq\n | typeof specialExpressionTypes.import\n | typeof specialExpressionTypes.effect\n >\n const specialExpression: SpecialExpression = builtin.specialExpressions[type]\n assertNumberOfParams(specialExpression.arity, params.length, symbol[2])\n switch (type) {\n case specialExpressionTypes['||']:\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, params]], symbol[2]) satisfies OrNode\n case specialExpressionTypes['&&']:\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, params]], symbol[2]) satisfies AndNode\n case specialExpressionTypes.recur:\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, params]], symbol[2]) satisfies RecurNode\n case specialExpressionTypes.array:\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, params]], symbol[2]) satisfies ArrayNode\n case specialExpressionTypes.object:\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, params]], symbol[2]) satisfies ObjectNode\n case specialExpressionTypes['??']:\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, params]], symbol[2]) satisfies QqNode\n case specialExpressionTypes['defined?']: {\n const [param] = params\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, param as SymbolNode]], symbol[2]) satisfies DefinedNode\n }\n case specialExpressionTypes.throw: {\n const [param] = params\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, param!]], symbol[2]) satisfies ThrowNode\n }\n case specialExpressionTypes.perform: {\n const [effectExpr, ...argExprs] = params\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, effectExpr!, argExprs]], symbol[2]) satisfies PerformNode\n }\n case specialExpressionTypes.parallel:\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, params]], symbol[2]) satisfies ParallelNode\n case specialExpressionTypes.race:\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [type, params]], symbol[2]) satisfies RaceNode\n case specialExpressionTypes['0_lambda']:\n throw new DvalaError(`${type} is not allowed`, symbol[2])\n /* v8 ignore next 2 */\n default:\n throw new DvalaError(`Unknown special expression: ${type satisfies never}`, symbol[2])\n }\n }\n else if (isNormalBuiltinSymbolNode(symbol) || isUserDefinedSymbolNode(symbol)) {\n return createNamedNormalExpressionNode(symbol, params, symbol[2])\n }\n\n else {\n return withSourceCodeInfo([NodeTypes.NormalExpression, [symbol, params]], symbol[2]) satisfies NormalExpressionNodeExpression\n }\n}\n\n/**\n * Parse the argument to `effect(...)` — a dotted identifier like `llm.complete`\n * or `com.myco.human.approve`. Consumes symbol tokens separated by `.` and\n * builds the full name string.\n */\nfunction parseEffectArgs(ctx: ParserContext, symbol: AstNode): EffectNode {\n const sourceCodeInfo = symbol[2]\n const firstToken = ctx.peek()\n if (!isSymbolToken(firstToken)) {\n throw new DvalaError('effect expects a dotted name identifier', firstToken[2])\n }\n let name = firstToken[1]\n ctx.advance()\n while (isOperatorToken(ctx.tryPeek(), '.')) {\n ctx.advance() // skip dot\n const nextToken = ctx.peek()\n if (!isSymbolToken(nextToken)) {\n throw new DvalaError('Expected identifier after dot in effect name', nextToken[2])\n }\n name += `.${nextToken[1]}`\n ctx.advance()\n }\n if (!isRParenToken(ctx.tryPeek())) {\n throw new DvalaError('Expected closing parenthesis after effect name', ctx.peekSourceCodeInfo())\n }\n ctx.advance()\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.effect, name]], sourceCodeInfo) satisfies EffectNode\n}\n","import type { ObjectNode } from '../../builtin/specialExpressions/object'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../../constants/constants'\nimport { DvalaError } from '../../errors'\nimport { asLBraceToken, assertOperatorToken, assertRBraceToken, assertRBracketToken, isLBracketToken, isOperatorToken, isRBraceToken, isStringToken, isSymbolToken } from '../../tokenizer/token'\nimport type { AstNode } from '../types'\nimport { stringFromQuotedSymbol, withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\nimport { parseString } from './parseString'\n\nexport function parseObject(ctx: ParserContext): ObjectNode {\n const\n firstToken = asLBraceToken(ctx.tryPeek())\n ctx.advance()\n const params: AstNode[] = []\n while (!ctx.isAtEnd() && !isRBraceToken(ctx.tryPeek())) {\n if (isOperatorToken(ctx.tryPeek(), '...')) {\n ctx.advance()\n params.push(withSourceCodeInfo([NodeTypes.Spread, ctx.parseExpression()], ctx.peekSourceCodeInfo()))\n }\n else {\n const token = ctx.tryPeek()\n if (isStringToken(token)) {\n const stringNode = parseString(ctx, token)\n params.push(withSourceCodeInfo([NodeTypes.String, stringNode[1]], token[2]))\n }\n else if (isSymbolToken(token)) {\n const value = token[1].startsWith('\\'')\n ? stringFromQuotedSymbol(token[1])\n : token[1]\n params.push(withSourceCodeInfo([NodeTypes.String, value], token[2]))\n ctx.advance()\n }\n else if (isLBracketToken(token)) {\n ctx.advance()\n params.push(ctx.parseExpression())\n assertRBracketToken(ctx.tryPeek())\n ctx.advance()\n }\n else {\n throw new DvalaError('Expected key to be a symbol or a string', ctx.peekSourceCodeInfo())\n }\n\n assertOperatorToken(ctx.tryPeek(), ':')\n ctx.advance()\n\n params.push(ctx.parseExpression())\n }\n const nextToken = ctx.tryPeek()\n if (!isOperatorToken(nextToken, ',') && !isRBraceToken(nextToken)) {\n throw new DvalaError('Expected comma or closing brace', ctx.peekSourceCodeInfo())\n }\n\n if (isOperatorToken(nextToken, ',')) {\n ctx.advance()\n }\n }\n\n assertRBraceToken(ctx.tryPeek())\n ctx.advance()\n\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.object, params]], firstToken[2])\n}\n","import type { NormalExpressionName } from '../../../reference/api'\nimport type { SpecialExpressionName } from '../../builtin'\nimport { normalExpressionTypes } from '../../builtin/normalExpressions'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../../constants/constants'\nimport { DvalaError } from '../../errors'\nimport type { AstNode, NormalBuiltinSymbolNode, NormalExpressionNodeExpression, SpecialBuiltinSymbolNode, StringNode } from '../types'\nimport { isBinaryOperator } from '../../tokenizer/operators'\nimport type { SourceCodeInfo, StringToken, TokenType } from '../../tokenizer/token'\nimport { isLBraceToken, isLBracketToken, isLParenToken, isOperatorToken, isRBracketToken, isRParenToken, isSymbolToken } from '../../tokenizer/token'\nimport { withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\nimport { parseRegexpShorthand } from './parseRegexpShorthand'\nimport { parseReservedSymbol } from './parseReservedSymbol'\nimport { parseString } from './parseString'\nimport { parseSymbol } from './parseSymbol'\nimport { parseArray } from './parseArray'\nimport { parseLambdaFunction, parseShorthandLambdaFunction } from './parseFunction'\nimport { parseFunctionCall } from './parseFunctionCall'\nimport { parseNumber } from './parseNumber'\nimport { parseObject } from './parseObject'\n\nexport function parseOperand(ctx: ParserContext): AstNode {\n let operand: AstNode = parseOperandPart(ctx)\n let token = ctx.tryPeek()\n\n while (isOperatorToken(token, '.') || isLBracketToken(token) || isLParenToken(token)) {\n if (token[1] === '.') {\n ctx.advance()\n const symbolToken = ctx.tryPeek()\n if (!isSymbolToken(symbolToken)) {\n throw new DvalaError('Expected symbol', ctx.peekSourceCodeInfo())\n }\n const stringNode: StringNode = withSourceCodeInfo([NodeTypes.String, symbolToken[1]], symbolToken[2])\n operand = createAccessorNode(operand, stringNode, token[2])\n ctx.advance()\n token = ctx.tryPeek()\n }\n else if (isLBracketToken(token)) {\n ctx.advance()\n const expression = ctx.parseExpression()\n if (!isRBracketToken(ctx.tryPeek())) {\n throw new DvalaError('Expected closing bracket', ctx.peekSourceCodeInfo())\n }\n operand = createAccessorNode(operand, expression, token[2])\n ctx.advance()\n token = ctx.tryPeek()\n }\n else if (isLParenToken(token)) {\n operand = parseFunctionCall(ctx, operand)\n token = ctx.tryPeek()\n }\n }\n return operand\n}\n\nfunction parseOperandPart(ctx: ParserContext): AstNode {\n const token = ctx.peek()\n\n // Parentheses\n if (isLParenToken(token)) {\n ctx.storePosition()\n const lamdaFunction = parseLambdaFunction(ctx)\n if (lamdaFunction) {\n return lamdaFunction\n }\n ctx.restorePosition()\n ctx.advance()\n const expression = ctx.parseExpression()\n if (!isRParenToken(ctx.peek())) {\n throw new DvalaError('Expected closing parenthesis', ctx.peekSourceCodeInfo())\n }\n ctx.advance()\n return expression\n }\n\n else if (isOperatorToken(token)) {\n const operatorName = token[1]\n if (isBinaryOperator(operatorName)) {\n ctx.advance()\n if (specialExpressionTypes[operatorName as SpecialExpressionName] !== undefined) {\n return withSourceCodeInfo([NodeTypes.SpecialBuiltinSymbol, specialExpressionTypes[operatorName as SpecialExpressionName]], token[2]) satisfies SpecialBuiltinSymbolNode\n }\n return withSourceCodeInfo([NodeTypes.NormalBuiltinSymbol, normalExpressionTypes[operatorName as NormalExpressionName] as number], token[2]) satisfies NormalBuiltinSymbolNode\n }\n\n if (operatorName === '->') {\n return parseShorthandLambdaFunction(ctx)\n }\n else {\n throw new DvalaError(`Illegal operator: ${operatorName}`, token[2])\n }\n }\n\n // Object litteral, e.g. {a: 1, b: 2}\n if (isLBraceToken(token)) {\n return parseObject(ctx)\n }\n\n // Array litteral, e.g. [1, 2]\n if (isLBracketToken(token)) {\n return parseArray(ctx)\n }\n\n const tokenType = token[0] as Exclude<\n TokenType,\n | 'Operator' // Handled above\n | 'LParen' // Handled above\n | 'LBrace' // Handled above\n | 'LBracket' // Handled above\n\n | 'RParen' // Illegal token\n | 'RBrace' // Illegal token\n | 'RBracket' // Illegal token\n\n | 'MultiLineComment' // Should have been removed\n | 'SingleLineComment' // Should have been removed\n | 'Whitespace' // Should have been removed\n >\n switch (tokenType) {\n case 'Number':\n case 'BasePrefixedNumber':\n return parseNumber(ctx)\n case 'string':\n return parseString(ctx, token as StringToken)\n case 'Symbol': {\n ctx.storePosition()\n const lamdaFunction = parseLambdaFunction(ctx)\n if (lamdaFunction) {\n return lamdaFunction\n }\n ctx.restorePosition()\n return parseSymbol(ctx)\n }\n case 'ReservedSymbol':\n return parseReservedSymbol(ctx)\n case 'RegexpShorthand':\n return parseRegexpShorthand(ctx)\n\n default:\n throw new DvalaError(`Unknown token type: ${tokenType}`, token[2])\n }\n}\n\nfunction createAccessorNode(left: AstNode, right: AstNode, sourceCodeInfo: SourceCodeInfo | undefined): NormalExpressionNodeExpression {\n return withSourceCodeInfo([NodeTypes.NormalExpression, [[NodeTypes.NormalBuiltinSymbol, normalExpressionTypes.get], [left, right]]], sourceCodeInfo)\n}\n","import type { ArrayNode } from '../../builtin/specialExpressions/array'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../../constants/constants'\nimport { DvalaError } from '../../errors'\nimport { asLBracketToken, assertRBracketToken, isOperatorToken, isRBracketToken } from '../../tokenizer/token'\nimport type { AstNode } from '../types'\nimport { withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\n\nexport function parseArray(ctx: ParserContext): ArrayNode {\n const firstToken = asLBracketToken(ctx.tryPeek())\n ctx.advance()\n const params: AstNode[] = []\n while (!ctx.isAtEnd() && !isRBracketToken(ctx.tryPeek())) {\n if (isOperatorToken(ctx.tryPeek(), '...')) {\n ctx.advance()\n params.push(withSourceCodeInfo([NodeTypes.Spread, ctx.parseExpression()], ctx.peekSourceCodeInfo()))\n }\n else {\n params.push(ctx.parseExpression())\n }\n const nextToken = ctx.tryPeek()\n if (!isOperatorToken(nextToken, ',') && !isRBracketToken(nextToken)) {\n throw new DvalaError('Expected comma or closing parenthesis', ctx.peekSourceCodeInfo())\n }\n if (isOperatorToken(nextToken, ',')) {\n ctx.advance()\n }\n }\n\n assertRBracketToken(ctx.tryPeek())\n ctx.advance()\n\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.array, params]], firstToken[2])\n}\n","import { normalExpressionTypes } from '../../builtin/normalExpressions'\nimport { NodeTypes } from '../../constants/constants'\nimport type { NormalExpressionNodeWithName, StringNode } from '../types'\nimport { withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\n\nexport function parseRegexpShorthand(ctx: ParserContext): NormalExpressionNodeWithName {\n const token = ctx.peek()\n ctx.advance()\n\n const endStringPosition = token[1].lastIndexOf('\"')\n const regexpString = token[1].substring(2, endStringPosition)\n const optionsString = token[1].substring(endStringPosition + 1)\n const stringNode: StringNode = withSourceCodeInfo([NodeTypes.String, regexpString], token[2]) satisfies StringNode\n\n const optionsNode: StringNode = withSourceCodeInfo([NodeTypes.String, optionsString], token[2]) satisfies StringNode\n\n const node: NormalExpressionNodeWithName = withSourceCodeInfo([\n NodeTypes.NormalExpression,\n [\n withSourceCodeInfo([NodeTypes.NormalBuiltinSymbol, normalExpressionTypes.regexp as number], token[2]),\n [stringNode, optionsNode],\n ],\n ], token[2])\n\n return node\n}\n","import type { SpecialExpressionName } from '../../builtin'\nimport { normalExpressionTypes } from '../../builtin/normalExpressions'\nimport type { IfNode } from '../../builtin/specialExpressions/if'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../../constants/constants'\nimport { DvalaError } from '../../errors'\nimport { isFunctionOperator } from '../../tokenizer/operators'\nimport { isA_BinaryOperatorToken, isOperatorToken, isReservedSymbolToken, isSymbolToken } from '../../tokenizer/token'\nimport type { TokenStream } from '../../tokenizer/tokenize'\nimport { isSpecialBuiltinSymbolNode } from '../../typeGuards/astNode'\nimport { binaryFunctionalOperatorPrecedence, conditionalOperatorPrecedence, createNamedNormalExpressionNode, exponentiationPrecedence, fromBinaryOperatorToNode, isAtExpressionEnd, withSourceCodeInfo } from '../helpers'\nimport { ParserContext } from '../ParserContext'\nimport type { AstNode, SymbolNode } from '../types'\nimport { getPrecedence } from '../getPrecedence'\nimport { parseCond } from './parseCond'\nimport { parseDo } from './parseDo'\nimport { parseForOrDoseq } from './parseForOrDoseq'\nimport { parseIfOrUnless } from './parseIfOrUnless'\nimport { parseLet } from './parseLet'\nimport { parseLoop } from './parseLoop'\nimport { parseOperand } from './parseOperand'\nimport { parseMatch } from './parseMatch'\nimport { parseSymbol } from './parseSymbol'\nimport { parseTry } from './parseTry'\n\nexport function createParserContext(tokenStream: TokenStream): ParserContext {\n const ctx = new ParserContext(tokenStream)\n ctx.parseExpression = (precedence = 0) => parseExpression(ctx, precedence)\n return ctx\n}\n\nexport function parseExpression(ctx: ParserContext, precedence = 0): AstNode {\n const token = ctx.tryPeek()\n\n let left: AstNode\n\n if (isSymbolToken(token)) {\n switch (token[1]) {\n case 'let':\n return parseLet(ctx, token)\n case 'if':\n case 'unless':\n left = parseIfOrUnless(ctx, token)\n break\n case 'cond':\n left = parseCond(ctx, token)\n break\n case 'match':\n left = parseMatch(ctx, token)\n break\n case 'for':\n case 'doseq':\n left = parseForOrDoseq(ctx, token)\n break\n case 'loop':\n left = parseLoop(ctx, token)\n break\n case 'try':\n left = parseTry(ctx, token)\n break\n }\n }\n else if (isReservedSymbolToken(token, 'do')) {\n left = parseDo(ctx)[0]\n }\n\n left ||= parseOperand(ctx)\n let operator = ctx.tryPeek()\n\n while (!isAtExpressionEnd(ctx)) {\n if (isA_BinaryOperatorToken(operator)) {\n const name = operator[1]\n const newPrecedece = getPrecedence(name, operator[2])\n if (\n newPrecedece <= precedence\n // ^ (exponentiation) is right associative\n && !(newPrecedece === exponentiationPrecedence && precedence === exponentiationPrecedence)) {\n break\n }\n const symbol: SymbolNode = specialExpressionTypes[name as SpecialExpressionName]\n ? withSourceCodeInfo([NodeTypes.SpecialBuiltinSymbol, specialExpressionTypes[name as SpecialExpressionName]], operator[2])\n : withSourceCodeInfo([NodeTypes.NormalBuiltinSymbol, normalExpressionTypes[name]!], operator[2])\n ctx.advance()\n const right = parseExpression(ctx, newPrecedece)\n left = fromBinaryOperatorToNode(operator, symbol, left, right, operator[2])\n }\n else if (isSymbolToken(operator)) {\n if (!isFunctionOperator(operator[1])) {\n break\n }\n const newPrecedence = binaryFunctionalOperatorPrecedence\n if (newPrecedence <= precedence) {\n break\n }\n const operatorSymbol = parseSymbol(ctx)\n const right = parseExpression(ctx, newPrecedence)\n if (isSpecialBuiltinSymbolNode(operatorSymbol)) {\n throw new DvalaError('Special expressions are not allowed in binary functional operators', operatorSymbol[2])\n }\n left = createNamedNormalExpressionNode(operatorSymbol, [left, right], operator[2])\n }\n else if (operator?.[1] === '?') {\n if (conditionalOperatorPrecedence <= precedence) {\n break\n }\n ctx.advance()\n const trueNode = parseExpression(ctx)\n if (!isOperatorToken(ctx.tryPeek(), ':')) {\n throw new DvalaError('Expected :', ctx.peekSourceCodeInfo())\n }\n ctx.advance()\n const falseNode = parseExpression(ctx)\n left = withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.if, [left, trueNode, falseNode]]], left[2]) satisfies IfNode\n }\n else {\n break\n }\n\n operator = ctx.tryPeek()\n }\n\n return left\n}\n","import type { IfNode } from '../../builtin/specialExpressions/if'\nimport type { UnlessNode } from '../../builtin/specialExpressions/unless'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../../constants/constants'\nimport type { SymbolToken } from '../../tokenizer/token'\nimport { assertReservedSymbolToken, isReservedSymbolToken } from '../../tokenizer/token'\nimport type { AstNode } from '../types'\nimport { withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\nimport { parseImplicitBlock } from './parseImplicitBlock'\n\nexport function parseIfOrUnless(ctx: ParserContext, token: SymbolToken): IfNode | UnlessNode {\n const isUnless = token[1] === 'unless'\n ctx.advance()\n const condition = ctx.parseExpression()\n assertReservedSymbolToken(ctx.tryPeek(), 'then')\n ctx.advance()\n const thenExpression = parseImplicitBlock(ctx, ['else', 'end'])\n\n let elseExpression: AstNode | undefined\n if (isReservedSymbolToken(ctx.tryPeek(), 'else')) {\n ctx.advance()\n elseExpression = parseImplicitBlock(ctx, ['end'])\n }\n\n ctx.advance()\n\n return isUnless\n ? withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.unless, [condition, thenExpression, elseExpression]]], token[2]) satisfies UnlessNode\n : withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.if, [condition, thenExpression, elseExpression]]], token[2]) satisfies IfNode\n}\n","import type { CondNode } from '../../builtin/specialExpressions/cond'\nimport { type SymbolToken, assertReservedSymbolToken, isReservedSymbolToken } from '../../tokenizer/token'\nimport type { AstNode } from '../types'\nimport { NodeTypes } from '../../constants/constants'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport type { ParserContext } from '../ParserContext'\nimport { withSourceCodeInfo } from '../helpers'\nimport { parseImplicitBlock } from './parseImplicitBlock'\n\nexport function parseCond(ctx: ParserContext, token: SymbolToken): CondNode {\n ctx.advance()\n\n const params: [AstNode, AstNode][] = []\n\n while (!ctx.isAtEnd() && !isReservedSymbolToken(ctx.tryPeek(), 'end')) {\n assertReservedSymbolToken(ctx.tryPeek(), 'case')\n ctx.advance()\n const caseExpression = ctx.parseExpression()\n assertReservedSymbolToken(ctx.tryPeek(), 'then')\n ctx.advance()\n const thenExpression = parseImplicitBlock(ctx, ['case', 'end'])\n\n params.push([caseExpression, thenExpression])\n if (isReservedSymbolToken(ctx.tryPeek(), 'end')) {\n break\n }\n }\n\n assertReservedSymbolToken(ctx.tryPeek())\n ctx.advance()\n\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.cond, params]], token[2]) satisfies CondNode\n}\n","import type { MatchCase, MatchNode } from '../../builtin/specialExpressions/match'\nimport { type SymbolToken, assertReservedSymbolToken, isReservedSymbolToken } from '../../tokenizer/token'\nimport { NodeTypes } from '../../constants/constants'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport type { ParserContext } from '../ParserContext'\nimport { withSourceCodeInfo } from '../helpers'\nimport { parseImplicitBlock } from './parseImplicitBlock'\nimport { parseBindingTarget } from './parseBindingTarget'\n\nexport function parseMatch(ctx: ParserContext, token: SymbolToken): MatchNode {\n ctx.advance()\n const valueExpression = ctx.parseExpression()\n const params: MatchCase[] = []\n\n while (!ctx.isAtEnd() && !isReservedSymbolToken(ctx.tryPeek(), 'end')) {\n assertReservedSymbolToken(ctx.tryPeek(), 'case')\n ctx.advance()\n\n // Parse pattern instead of expression\n const pattern = parseBindingTarget(ctx, { allowLiteralPatterns: true })\n\n // Check for optional guard: `when <expression>`\n let guard\n if (isReservedSymbolToken(ctx.tryPeek(), 'when')) {\n ctx.advance()\n guard = ctx.parseExpression()\n }\n\n assertReservedSymbolToken(ctx.tryPeek(), 'then')\n ctx.advance()\n const thenExpression = parseImplicitBlock(ctx, ['case', 'end'])\n\n params.push([pattern, thenExpression, guard])\n if (isReservedSymbolToken(ctx.tryPeek(), 'end')) {\n break\n }\n }\n\n assertReservedSymbolToken(ctx.tryPeek(), 'end')\n ctx.advance()\n\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.match, valueExpression, params]], token[2]) satisfies MatchNode\n}\n","import type { LoopNode } from '../../builtin/specialExpressions/loop'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../../constants/constants'\nimport { DvalaError } from '../../errors'\nimport type { BindingNode } from '../types'\nimport type { SymbolToken } from '../../tokenizer/token'\nimport { assertLParenToken, assertOperatorToken, assertRParenToken, isOperatorToken, isRParenToken } from '../../tokenizer/token'\nimport { withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\nimport { parseBindingTarget } from './parseBindingTarget'\n\nexport function parseLoop(ctx: ParserContext, firstToken: SymbolToken): LoopNode {\n ctx.advance()\n\n assertLParenToken(ctx.tryPeek())\n ctx.advance()\n\n const bindingNodes: BindingNode[] = []\n let token = ctx.tryPeek()\n while (!ctx.isAtEnd() && !isRParenToken(token)) {\n const target = parseBindingTarget(ctx, { requireDefaultValue: true, noRest: true })\n const value = target[1][1]!\n target[1][1] = undefined\n\n bindingNodes.push(withSourceCodeInfo([NodeTypes.Binding, [target, value]], target[2]) satisfies BindingNode)\n\n if (isOperatorToken(ctx.tryPeek(), ',')) {\n ctx.advance()\n }\n token = ctx.tryPeek()\n }\n if (bindingNodes.length === 0) {\n throw new DvalaError('Expected binding', ctx.peekSourceCodeInfo())\n }\n\n assertRParenToken(token)\n ctx.advance()\n\n assertOperatorToken(ctx.tryPeek(), '->')\n ctx.advance()\n\n const expression = ctx.parseExpression()\n\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.loop, bindingNodes, expression]], firstToken[2]) satisfies LoopNode\n}\n","import type { TryNode, WithHandler } from '../../builtin/specialExpressions/try'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../../constants/constants'\nimport type { AstNode, SymbolNode } from '../types'\nimport type { SymbolToken } from '../../tokenizer/token'\nimport { assertRParenToken, assertReservedSymbolToken, isLParenToken, isReservedSymbolToken } from '../../tokenizer/token'\nimport { withSourceCodeInfo } from '../helpers'\nimport type { ParserContext } from '../ParserContext'\nimport { parseImplicitBlock } from './parseImplicitBlock'\nimport { parseSymbol } from './parseSymbol'\n\nexport function parseTry(ctx: ParserContext, token: SymbolToken): TryNode {\n ctx.advance()\n\n // Parse the try body — it ends at 'with', 'catch', or 'end' (only 'end' when neither with nor catch)\n const tryExpression = parseImplicitBlock(ctx, ['with', 'catch'])\n\n // Parse optional with-handlers\n const withHandlers: WithHandler[] = []\n if (isReservedSymbolToken(ctx.tryPeek(), 'with')) {\n ctx.advance()\n while (!ctx.isAtEnd() && !isReservedSymbolToken(ctx.tryPeek(), 'end') && !isReservedSymbolToken(ctx.tryPeek(), 'catch')) {\n assertReservedSymbolToken(ctx.tryPeek(), 'case')\n ctx.advance()\n const effectExpr = ctx.parseExpression()\n assertReservedSymbolToken(ctx.tryPeek(), 'then')\n ctx.advance()\n const handlerFn = parseImplicitBlock(ctx, ['case', 'catch', 'end'])\n withHandlers.push([effectExpr, handlerFn])\n }\n }\n\n // Parse optional catch clause\n let errorSymbol: SymbolNode | undefined\n let catchExpression: AstNode | undefined\n if (isReservedSymbolToken(ctx.tryPeek(), 'catch')) {\n ctx.advance()\n\n if (isLParenToken(ctx.tryPeek())) {\n ctx.advance()\n errorSymbol = parseSymbol(ctx)\n assertRParenToken(ctx.tryPeek())\n ctx.advance()\n }\n\n catchExpression = parseImplicitBlock(ctx, ['end'])\n }\n\n assertReservedSymbolToken(ctx.tryPeek(), 'end')\n ctx.advance()\n\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.try, tryExpression, errorSymbol, catchExpression, withHandlers]], token[2]) satisfies TryNode\n}\n","import type { TokenStream } from '../tokenizer/tokenize'\nimport { DvalaError } from '../errors'\nimport { isOperatorToken } from '../tokenizer/token'\nimport type { AstNode } from './types'\nimport { createParserContext, parseExpression } from './subParsers/parseExpression'\n\nexport { createParserContext, parseExpression }\n\nexport function parse(tokenStream: TokenStream): AstNode[] {\n tokenStream.tokens.forEach((token) => {\n if (token[0] === 'Error') {\n throw new DvalaError(token[3], token[2])\n }\n })\n\n const nodes: AstNode[] = []\n\n const ctx = createParserContext(tokenStream)\n\n while (!ctx.isAtEnd()) {\n nodes.push(parseExpression(ctx, 0))\n if (isOperatorToken(ctx.tryPeek(), ';')) {\n ctx.advance()\n }\n else {\n if (!ctx.isAtEnd()) {\n throw new DvalaError('Expected ;', ctx.peekSourceCodeInfo())\n }\n }\n }\n\n return nodes\n}\n","import type { Ast } from '../parser/types'\nimport { toNonNegativeInteger } from '../utils'\nimport { valueToString } from '../utils/debug/debugTools'\n\ninterface CacheEntry {\n key: string\n value: Ast\n nextEntry: CacheEntry | undefined\n}\n\nexport class Cache {\n private cache: Record<string, CacheEntry> = {}\n private firstEntry: CacheEntry | undefined = undefined\n private lastEntry: CacheEntry | undefined = undefined\n private _size = 0\n private maxSize: number | null\n constructor(maxSize: number | null) {\n this.maxSize = maxSize === null ? null : toNonNegativeInteger(maxSize)\n if (typeof this.maxSize === 'number' && this.maxSize < 1)\n throw new Error(`1 is the minimum maxSize, got ${valueToString(maxSize)}`)\n }\n\n public getContent(): Record<string, Ast> {\n return Object.entries(this.cache).reduce((result: Record<string, Ast>, [key, entry]) => {\n result[key] = entry.value\n return result\n }, {})\n }\n\n public get size(): number {\n return this._size\n }\n\n public get(key: string): Ast | undefined {\n return this.cache[key]?.value\n }\n\n public clear(): void {\n this.cache = {}\n this.firstEntry = undefined\n this.lastEntry = undefined\n this._size = 0\n }\n\n public has(key: string): boolean {\n return !!this.cache[key]\n }\n\n public set(key: string, value: Ast): void {\n if (this.has(key))\n throw new Error(`AstCache - key already present: ${key}`)\n\n const newEntry: CacheEntry = { value, nextEntry: undefined, key }\n\n this.cache[key] = newEntry\n this._size += 1\n\n if (this.lastEntry)\n this.lastEntry.nextEntry = newEntry\n\n this.lastEntry = newEntry\n\n if (!this.firstEntry)\n this.firstEntry = this.lastEntry\n\n while (this.maxSize !== null && this.size > this.maxSize)\n this.dropFirstEntry()\n }\n\n private dropFirstEntry(): void {\n const firstEntry = this.firstEntry as CacheEntry\n delete this.cache[firstEntry.key]\n this._size -= 1\n this.firstEntry = firstEntry.nextEntry\n }\n}\n","import { getUndefinedSymbols } from '../getUndefinedSymbols'\nimport { evaluate, evaluateAsync, evaluateNode } from '../evaluator/trampoline'\nimport { createContextStack } from '../evaluator/ContextStack'\nimport type { Context } from '../evaluator/interface'\nimport type { Any, Obj } from '../interface'\nimport type { Ast, DvalaFunction } from '../parser/types'\nimport { tokenize } from '../tokenizer/tokenize'\nimport type { TokenStream } from '../tokenizer/tokenize'\nimport { minifyTokenStream } from '../tokenizer/minifyTokenStream'\nimport { transformSymbolTokens } from '../transformer'\nimport { untokenize } from '../untokenizer'\nimport { builtin } from '../builtin'\nimport { AutoCompleter } from '../AutoCompleter/AutoCompleter'\nimport type { Arity } from '../builtin/interface'\nimport type { DvalaModule } from '../builtin/modules/interface'\nimport { isDvalaBundle } from '../bundler/interface'\nimport type { DvalaBundle } from '../bundler/interface'\nimport type { MaybePromise } from '../utils/maybePromise'\n\nimport { parse } from '../parser'\nimport { Cache } from './Cache'\n\nexport interface DvalaRuntimeInfo {\n astCache: Cache | null\n astCacheSize: number | null\n debug: boolean\n}\n\nexport interface JsFunction {\n fn: (...args: any[]) => unknown\n arity?: Arity\n pure?: boolean\n docString?: string\n}\n\nexport interface ContextParams {\n globalContext?: Context\n contexts?: Context[]\n bindings?: Record<string, unknown>\n globalModuleScope?: boolean\n}\n\nexport interface MinifyParams {\n minify?: boolean\n}\n\nexport interface FilePathParams {\n filePath?: string\n}\n\nexport interface PureParams {\n pure?: boolean\n}\n\ninterface DvalaConfig {\n initialCache?: Record<string, Ast>\n astCacheSize?: number | null\n debug?: boolean\n modules?: DvalaModule[]\n}\n\nexport class Dvala {\n private astCache: Cache | null\n private astCacheSize: number | null\n private debug: boolean\n private modules: Map<string, DvalaModule>\n\n constructor(config: DvalaConfig = {}) {\n this.debug = config.debug ?? false\n this.astCacheSize = config.astCacheSize ?? null\n if (this.astCacheSize) {\n this.astCache = new Cache(this.astCacheSize)\n const initialCache = config.initialCache ?? {}\n for (const cacheEntry of Object.keys(initialCache))\n this.astCache.set(cacheEntry, initialCache[cacheEntry] as Ast)\n }\n else {\n this.astCache = null\n }\n const nsList = config.modules ?? []\n this.modules = new Map(nsList.map(ns => [ns.name, ns]))\n }\n\n public getRuntimeInfo(): DvalaRuntimeInfo {\n return {\n astCacheSize: this.astCacheSize,\n astCache: this.astCache,\n debug: this.debug,\n }\n }\n\n public readonly async = {\n run: async (programOrBundle: string | DvalaBundle, params: ContextParams & FilePathParams & PureParams = {}): Promise<unknown> => {\n if (isDvalaBundle(programOrBundle)) {\n return this.runBundle(programOrBundle, params)\n }\n const ast = this.generateAst(programOrBundle, params)\n return this.evaluateAsync(ast, params)\n },\n apply: async (fn: DvalaFunction, fnParams: unknown[], params: ContextParams & PureParams = {}): Promise<unknown> => {\n return this.apply(fn, fnParams, params)\n },\n }\n\n public run(programOrBundle: string | DvalaBundle, params: ContextParams & FilePathParams & PureParams = {}): unknown {\n if (isDvalaBundle(programOrBundle)) {\n return this.runBundle(programOrBundle, params)\n }\n const ast = this.generateAst(programOrBundle, params)\n const result = this.evaluate(ast, params)\n if (result instanceof Promise) {\n throw new TypeError('Unexpected async result in synchronous run(). Use dvala.async.run() for async operations.')\n }\n return result\n }\n\n private runBundle(bundle: DvalaBundle, params: ContextParams & FilePathParams & PureParams = {}): unknown {\n const contextStack = createContextStack(params, this.modules, params.pure)\n\n // Evaluate file modules in dependency order and register as value modules.\n // Each file module is evaluated in its own scope so local bindings don't leak.\n // File modules are always evaluated in pure mode to ensure deterministic,\n // side-effect-free initialization regardless of the caller's pure setting.\n const savedPure = contextStack.pure\n contextStack.pure = true\n for (const [name, source] of bundle.fileModules) {\n const ast = this.generateAst(source, params)\n const moduleContextStack = contextStack.create({})\n const result = evaluate(ast, moduleContextStack)\n\n // TODO: When async functions in file modules are able to mark themselves as pure and\n // are returning a Promise, uncomment the following check, and make sure a test is verifying the behaviour.\n // if (result instanceof Promise) {\n // throw new TypeError('Unexpected async result in synchronous runBundle(). Use dvala.async.run() for async operations.')\n // }\n contextStack.registerValueModule(name, result)\n }\n contextStack.pure = savedPure\n\n // Parse and evaluate the main program\n const ast = this.generateAst(bundle.program, params)\n const result = evaluate(ast, contextStack)\n if (result instanceof Promise) {\n throw new TypeError('Unexpected async result in synchronous runBundle(). Use dvala.async.run() for async operations.')\n }\n return result\n }\n\n public getUndefinedSymbols(programOrAst: string | Ast, params: ContextParams = {}): Set<string> {\n const ast = typeof programOrAst === 'string' ? this.generateAst(programOrAst, params) : programOrAst\n const contextStack = createContextStack(params, this.modules)\n return getUndefinedSymbols(ast, contextStack, builtin, evaluateNode)\n }\n\n public tokenize(program: string, tokenizeParams: FilePathParams & MinifyParams = {}): TokenStream {\n const tokenStream = tokenize(program, this.debug, tokenizeParams.filePath)\n return tokenizeParams.minify ? minifyTokenStream(tokenStream, { removeWhiteSpace: false }) : tokenStream\n }\n\n public parse(tokenStream: TokenStream): Ast {\n tokenStream = minifyTokenStream(tokenStream, { removeWhiteSpace: true })\n const ast: Ast = {\n body: [],\n hasDebugData: tokenStream.hasDebugData,\n }\n\n ast.body = parse(tokenStream)\n\n return ast\n }\n\n private evaluate(ast: Ast, params: ContextParams & PureParams): MaybePromise<Any> {\n const contextStack = createContextStack(params, this.modules, params.pure)\n return evaluate(ast, contextStack)\n }\n\n private evaluateAsync(ast: Ast, params: ContextParams & PureParams): Promise<Any> {\n const contextStack = createContextStack(params, this.modules, params.pure)\n return evaluateAsync(ast, contextStack)\n }\n\n public transformSymbols(tokenStream: TokenStream, transformer: (symbol: string) => string): TokenStream {\n return transformSymbolTokens(tokenStream, transformer)\n }\n\n public untokenize(tokenStream: TokenStream): string {\n return untokenize(tokenStream)\n }\n\n public apply(fn: DvalaFunction, fnParams: unknown[], params: ContextParams & PureParams = {}): MaybePromise<Any> {\n const fnName = 'FN_2eb7b316_471c_5bfa_90cb_d3dfd9164a59'\n const program = this.generateApplyFunctionCall(fnName, fnParams)\n\n const ast = this.generateAst(program, params)\n\n const hostValues: Obj = fnParams.reduce(\n (result: Obj, param, index) => {\n result[`${fnName}_${index}`] = param\n return result\n },\n { [fnName]: fn },\n )\n\n params.bindings = { ...params.bindings, ...hostValues }\n\n return this.evaluate(ast, params)\n }\n\n private generateApplyFunctionCall(fnName: string, fnParams: unknown[]) {\n const paramsString: string = fnParams\n .map((_, index) => {\n return `${fnName}_${index}`\n })\n .join(', ')\n return `${fnName}(${paramsString})`\n }\n\n private generateAst(program: string, params: ContextParams & FilePathParams): Ast {\n if (this.astCache) {\n const cachedAst = this.astCache.get(program)\n if (cachedAst)\n return cachedAst\n }\n const tokenStream = this.tokenize(program, {\n filePath: params.filePath,\n })\n const ast: Ast = this.parse(tokenStream)\n this.astCache?.set(program, ast)\n return ast\n }\n\n public getAutoCompleter(program: string, position: number, params: ContextParams = {}): AutoCompleter {\n return new AutoCompleter(program, position, this, params)\n }\n}\n","import type { TokenStream } from '../tokenizer/tokenize'\nimport { isSymbolToken } from '../tokenizer/token'\n\nexport function transformSymbolTokens(tokenStram: TokenStream, transformer: (symbol: string) => string): TokenStream {\n return {\n ...tokenStram,\n tokens: tokenStram.tokens.map(token => isSymbolToken(token)\n ? [token[0], transformer(token[1])]\n : token),\n }\n}\n","import type { TokenStream } from '../tokenizer/tokenize'\n\nexport function untokenize(tokenStream: TokenStream): string {\n return tokenStream.tokens.reduce((acc: string, token) => {\n return `${acc}${token[1]}`\n }, '')\n}\n","import type { FunctionDocs } from '../../interface'\n\nexport const moduleDocs: Record<string, FunctionDocs> = {\n 'assert!=': {\n category: 'assertion',\n description: 'If $a is the same as $b it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n a: {\n type: 'any',\n },\n b: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n {\n argumentNames: [\n 'a',\n 'b',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert!= } = import(assertion);\\ntry assert!=(0, 0, \"Expected different values\") catch (e) e.message end',\n 'let { assert!= } = import(assertion);\\ntry assert!=(0, 0) catch (e) e.message end',\n 'let { assert!= } = import(assertion);\\ntry 0 assert!= 0 catch (e) e.message end',\n 'let { assert!= } = import(assertion);\\ntry assert!=(0, 1) catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert='],\n hideOperatorForm: true,\n },\n 'assert=': {\n category: 'assertion',\n description: 'If $a is not structural equal to $b it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n a: {\n type: 'any',\n },\n b: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n {\n argumentNames: [\n 'a',\n 'b',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert= } = import(assertion);\\ntry assert=({ \"a\": 1 }, { \"a\": 2 }, \"Expected equal values\") catch (e) e.message end',\n 'let { assert= } = import(assertion);\\ntry assert=({ \"a\": 1 }, { \"a\": 2 }) catch (e) e.message end',\n 'let { assert= } = import(assertion);\\ntry assert=({ \"a\": 1 }, { \"a\": 1 }) catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert!='],\n hideOperatorForm: true,\n },\n 'assert-gt': {\n category: 'assertion',\n description: 'If $a is not greater than $b it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n a: {\n type: 'any',\n },\n b: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n {\n argumentNames: [\n 'a',\n 'b',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-gt } = import(assertion);\\ntry assert-gt(0, 1, \"Expected greater value\") catch (e) e.message end',\n 'let { assert-gt } = import(assertion);\\ntry assert-gt(0, 0) catch (e) e.message end',\n 'let { assert-gt } = import(assertion);\\ntry assert-gt(1, 0) catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-lt', 'assertion.assert-gte', 'assertion.assert-lte'],\n hideOperatorForm: true,\n },\n 'assert-lt': {\n category: 'assertion',\n description: 'If $a is not less than $b it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n a: {\n type: 'any',\n },\n b: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n {\n argumentNames: [\n 'a',\n 'b',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-lt } = import(assertion);\\ntry assert-lt(1, 0, \"Expected smaller value value\") catch (e) e.message end',\n 'let { assert-lt } = import(assertion);\\ntry assert-lt(1, 1) catch (e) e.message end',\n 'let { assert-lt } = import(assertion);\\ntry assert-lt(0, 1) catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-gt', 'assertion.assert-lte', 'assertion.assert-gte'],\n hideOperatorForm: true,\n },\n 'assert-gte': {\n category: 'assertion',\n description: 'If $a is less than $b it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n a: {\n type: 'any',\n },\n b: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n {\n argumentNames: [\n 'a',\n 'b',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-gte } = import(assertion);\\ntry assert-gte(0, 1, \"Expected greater value\") catch (e) e.message end',\n 'let { assert-gte } = import(assertion);\\ntry assert-gte(0, 1) catch (e) e.message end',\n 'let { assert-gte } = import(assertion);\\ntry assert-gte(1, 1) catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-lte', 'assertion.assert-gt', 'assertion.assert-lt'],\n hideOperatorForm: true,\n },\n 'assert-lte': {\n category: 'assertion',\n description: 'If $a is grater than $b it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n a: {\n type: 'any',\n },\n b: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n {\n argumentNames: [\n 'a',\n 'b',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-lte } = import(assertion);\\ntry assert-lte(1, 0, \"Expected smaller value value\") catch (e) e.message end',\n 'let { assert-lte } = import(assertion);\\ntry assert-lte(1, 0) catch (e) e.message end',\n 'let { assert-lte } = import(assertion);\\ntry assert-lte(1, 1) catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-gte', 'assertion.assert-lt', 'assertion.assert-gt'],\n hideOperatorForm: true,\n },\n 'assert-true': {\n category: 'assertion',\n description: 'If $value is not `true` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-true } = import(assertion);\\ntry assert-true(false, \"Expected true\") catch (e) e.message end',\n 'let { assert-true } = import(assertion);\\ntry assert-true(false) catch (e) e.message end',\n 'let { assert-true } = import(assertion);\\ntry assert-true(true) catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-false', 'assertion.assert-truthy', 'assertion.assert-falsy', 'assert', 'assertion.assert-boolean'],\n hideOperatorForm: true,\n },\n 'assert-false': {\n category: 'assertion',\n description: 'If $value is not `false` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-false } = import(assertion);\\ntry assert-false(true, \"Expected false\") catch (e) e.message end',\n 'let { assert-false } = import(assertion);\\ntry assert-false(true) catch (e) e.message end',\n 'let { assert-false } = import(assertion);\\ntry assert-false(false) catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-true', 'assertion.assert-falsy', 'assertion.assert-truthy', 'assertion.assert-boolean'],\n hideOperatorForm: true,\n },\n 'assert-truthy': {\n category: 'assertion',\n description: 'If $value is not `truthy` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-truthy } = import(assertion);\\ntry assert-truthy(false, \"Expected truthy\") catch (e) e.message end',\n 'let { assert-truthy } = import(assertion);\\ntry assert-truthy(false) catch (e) e.message end',\n 'let { assert-truthy } = import(assertion);\\ntry assert-truthy(0) catch (e) e.message end',\n 'let { assert-truthy } = import(assertion);\\ntry assert-truthy(null) catch (e) e.message end',\n 'let { assert-truthy } = import(assertion);\\ntry assert-truthy(\"\") catch (e) e.message end',\n 'let { assert-truthy } = import(assertion);\\ntry assert-truthy(true) catch (e) e.message end',\n 'let { assert-truthy } = import(assertion);\\ntry assert-truthy(1) catch (e) e.message end',\n 'let { assert-truthy } = import(assertion);\\ntry assert-truthy(\"x\") catch (e) e.message end',\n 'let { assert-truthy } = import(assertion);\\ntry assert-truthy([]) catch (e) e.message end',\n 'let { assert-truthy } = import(assertion);\\ntry assert-truthy(nd) catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-falsy', 'assertion.assert-true', 'assertion.assert-false', 'assert', 'assertion.assert-null'],\n hideOperatorForm: true,\n },\n 'assert-falsy': {\n category: 'assertion',\n description: 'If $value is not `falsy` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-falsy } = import(assertion);\\ntry assert-falsy(true, \"Expected falsy\") catch (e) e.message end',\n 'let { assert-falsy } = import(assertion);\\ntry assert-falsy(\"x\") catch (e) e.message end',\n 'let { assert-falsy } = import(assertion);\\ntry assert-falsy([]) catch (e) e.message end',\n 'let { assert-falsy } = import(assertion);\\ntry assert-falsy(nd) catch (e) e.message end',\n 'let { assert-falsy } = import(assertion);\\ntry assert-falsy(1) catch (e) e.message end',\n 'let { assert-falsy } = import(assertion);\\ntry assert-falsy(false) catch (e) e.message end',\n 'let { assert-falsy } = import(assertion);\\ntry assert-falsy(0) catch (e) e.message end',\n 'let { assert-falsy } = import(assertion);\\ntry assert-falsy(null) catch (e) e.message end',\n 'let { assert-falsy } = import(assertion);\\ntry assert-falsy(\"\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-truthy', 'assertion.assert-false', 'assertion.assert-true', 'assertion.assert-null'],\n hideOperatorForm: true,\n },\n 'assert-null': {\n category: 'assertion',\n description: 'If $value is not `null` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-null } = import(assertion);\\ntry assert-null(null) catch (e) e.message end',\n 'let { assert-null } = import(assertion);\\ntry assert-null(true, \"Expected null\") catch (e) e.message end',\n 'let { assert-null } = import(assertion);\\ntry assert-null(\"x\") catch (e) e.message end',\n 'let { assert-null } = import(assertion);\\ntry assert-null([]) catch (e) e.message end',\n 'let { assert-null } = import(assertion);\\ntry assert-null(nd) catch (e) e.message end',\n 'let { assert-null } = import(assertion);\\ntry assert-null(1) catch (e) e.message end',\n 'let { assert-null } = import(assertion);\\ntry assert-null(false) catch (e) e.message end',\n 'let { assert-null } = import(assertion);\\ntry assert-null(0) catch (e) e.message end',\n 'let { assert-null } = import(assertion);\\ntry assert-null(\"\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-truthy', 'assertion.assert-falsy'],\n hideOperatorForm: true,\n },\n 'assert-throws': {\n category: 'assertion',\n description: 'If $fun does not throw, it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n fun: {\n type: 'function',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'fun',\n ],\n },\n {\n argumentNames: [\n 'fun',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-throws } = import(assertion);\\nassert-throws(-> throw(\"Error\"))',\n 'let { assert-throws } = import(assertion);\\ntry assert-throws(-> identity(\"Error\")) catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-throws-error', 'assertion.assert-not-throws'],\n hideOperatorForm: true,\n },\n 'assert-throws-error': {\n category: 'assertion',\n description: 'If $fun does not throw $error-message, it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n 'fun': {\n type: 'function',\n },\n 'error-message': {\n type: 'string',\n },\n 'message': {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n 'error-message',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'error-message',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-throws-error } = import(assertion);\\ntry assert-throws-error(-> throw(\"Error\"), \"Error\") catch (e) e.message end',\n 'let { assert-throws-error } = import(assertion);\\ntry assert-throws-error(-> identity(\"Error\"), \"Error\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-throws', 'assertion.assert-not-throws'],\n hideOperatorForm: true,\n },\n 'assert-not-throws': {\n category: 'assertion',\n description: 'If $fun throws, it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n fun: {\n type: 'function',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'fun',\n ],\n },\n {\n argumentNames: [\n 'fun',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-not-throws } = import(assertion);\\ntry assert-not-throws(-> identity(\"Error\")) catch (e) e.message end',\n 'let { assert-not-throws } = import(assertion);\\ntry assert-not-throws(-> throw(\"Error\")) catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-throws', 'assertion.assert-throws-error'],\n hideOperatorForm: true,\n },\n 'assert-array': {\n category: 'assertion',\n description: 'If $value is not an `array` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-array } = import(assertion);\\ntry assert-array([1, 2, 3]) catch (e) e.message end',\n 'let { assert-array } = import(assertion);\\ntry assert-array(\"string\") catch (e) e.message end',\n 'let { assert-array } = import(assertion);\\ntry assert-array(42, \"Expected an array\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-object', 'assertion.assert-collection', 'assertion.assert-sequence'],\n hideOperatorForm: true,\n },\n 'assert-boolean': {\n category: 'assertion',\n description: 'If $value is not a `boolean` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-boolean } = import(assertion);\\ntry assert-boolean(true) catch (e) e.message end',\n 'let { assert-boolean } = import(assertion);\\ntry assert-boolean(false) catch (e) e.message end',\n 'let { assert-boolean } = import(assertion);\\ntry assert-boolean(1, \"Expected a boolean\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-true', 'assertion.assert-false', 'assertion.assert-number', 'assertion.assert-string'],\n hideOperatorForm: true,\n },\n 'assert-collection': {\n category: 'assertion',\n description: 'If $value is not a `collection` (array, object, or string) it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-collection } = import(assertion);\\ntry assert-collection([1, 2]) catch (e) e.message end',\n 'let { assert-collection } = import(assertion);\\ntry assert-collection({ a: 1 }) catch (e) e.message end',\n 'let { assert-collection } = import(assertion);\\ntry assert-collection(\"hello\") catch (e) e.message end',\n 'let { assert-collection } = import(assertion);\\ntry assert-collection(42, \"Expected a collection\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-sequence', 'assertion.assert-array', 'assertion.assert-object'],\n hideOperatorForm: true,\n },\n 'assert-function': {\n category: 'assertion',\n description: 'If $value is not a `function` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-function } = import(assertion);\\ntry assert-function(-> $ + 1) catch (e) e.message end',\n 'let { assert-function } = import(assertion);\\ntry assert-function(42, \"Expected a function\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-number', 'assertion.assert-string'],\n hideOperatorForm: true,\n },\n 'assert-grid': {\n category: 'assertion',\n description: 'If $value is not a `grid` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-grid } = import(assertion);\\ntry assert-grid([[1, 2], [3, 4]]) catch (e) e.message end',\n 'let { assert-grid } = import(assertion);\\ntry assert-grid([1, 2], \"Expected a grid\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-matrix', 'assertion.assert-vector'],\n hideOperatorForm: true,\n },\n 'assert-integer': {\n category: 'assertion',\n description: 'If $value is not an `integer` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-integer } = import(assertion);\\ntry assert-integer(42) catch (e) e.message end',\n 'let { assert-integer } = import(assertion);\\ntry assert-integer(3.14, \"Expected an integer\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-number'],\n hideOperatorForm: true,\n },\n 'assert-matrix': {\n category: 'assertion',\n description: 'If $value is not a `matrix` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-matrix } = import(assertion);\\ntry assert-matrix([[1, 2], [3, 4]]) catch (e) e.message end',\n 'let { assert-matrix } = import(assertion);\\ntry assert-matrix([1, 2], \"Expected a matrix\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-vector', 'assertion.assert-grid'],\n hideOperatorForm: true,\n },\n 'assert-number': {\n category: 'assertion',\n description: 'If $value is not a `number` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-number } = import(assertion);\\ntry assert-number(42) catch (e) e.message end',\n 'let { assert-number } = import(assertion);\\ntry assert-number(\"hello\", \"Expected a number\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-integer', 'assertion.assert-boolean', 'assertion.assert-string', 'assertion.assert-function'],\n hideOperatorForm: true,\n },\n 'assert-object': {\n category: 'assertion',\n description: 'If $value is not an `object` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-object } = import(assertion);\\ntry assert-object({ a: 1 }) catch (e) e.message end',\n 'let { assert-object } = import(assertion);\\ntry assert-object([1, 2], \"Expected an object\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-array', 'assertion.assert-collection'],\n hideOperatorForm: true,\n },\n 'assert-regexp': {\n category: 'assertion',\n description: 'If $value is not a `regexp` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-regexp } = import(assertion);\\ntry assert-regexp(#\"^start\") catch (e) e.message end',\n 'let { assert-regexp } = import(assertion);\\ntry assert-regexp(\"hello\", \"Expected a regexp\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-string'],\n hideOperatorForm: true,\n },\n 'assert-sequence': {\n category: 'assertion',\n description: 'If $value is not a `sequence` (array or string) it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-sequence } = import(assertion);\\ntry assert-sequence([1, 2]) catch (e) e.message end',\n 'let { assert-sequence } = import(assertion);\\ntry assert-sequence(\"hello\") catch (e) e.message end',\n 'let { assert-sequence } = import(assertion);\\ntry assert-sequence({ a: 1 }, \"Expected a sequence\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-collection', 'assertion.assert-array'],\n hideOperatorForm: true,\n },\n 'assert-string': {\n category: 'assertion',\n description: 'If $value is not a `string` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-string } = import(assertion);\\ntry assert-string(\"hello\") catch (e) e.message end',\n 'let { assert-string } = import(assertion);\\ntry assert-string(42, \"Expected a string\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-number', 'assertion.assert-boolean', 'assertion.assert-regexp', 'assertion.assert-function'],\n hideOperatorForm: true,\n },\n 'assert-vector': {\n category: 'assertion',\n description: 'If $value is not a `vector` it throws `AssertionError`.',\n returns: {\n type: 'null',\n },\n args: {\n value: {\n type: 'any',\n },\n message: {\n type: 'string',\n },\n },\n variants: [\n {\n argumentNames: [\n 'value',\n ],\n },\n {\n argumentNames: [\n 'value',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-vector } = import(assertion);\\ntry assert-vector([1, 2, 3]) catch (e) e.message end',\n 'let { assert-vector } = import(assertion);\\ntry assert-vector([\"a\", \"b\"], \"Expected a vector\") catch (e) e.message end',\n ],\n seeAlso: ['assertion.assert-matrix', 'assertion.assert-grid'],\n hideOperatorForm: true,\n },\n}\n","import type { DvalaError } from '../../../errors'\nimport { AssertionError } from '../../../errors'\nimport { compare, deepEqual } from '../../../utils'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport { asAny, assertFunctionLike, isColl, isObj, isRegularExpression, isSeq } from '../../../typeGuards/dvala'\nimport { isDvalaFunction } from '../../../typeGuards/dvalaFunction'\nimport { isNumber } from '../../../typeGuards/number'\nimport { assertString, assertStringOrNumber } from '../../../typeGuards/string'\nimport { isGrid, isMatrix, isVector } from '../../../typeGuards/annotatedArrays'\nimport { chain, tryCatch } from '../../../utils/maybePromise'\nimport type { MaybePromise } from '../../../utils/maybePromise'\nimport type { DvalaModule } from '../interface'\nimport { moduleDocs } from './docs'\n\nconst assertNormalExpression: BuiltinNormalExpressions = {\n 'assert=': {\n evaluate: ([first, second, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (!deepEqual(asAny(first, sourceCodeInfo), asAny(second, sourceCodeInfo), sourceCodeInfo)) {\n throw new AssertionError(\n `Expected ${JSON.stringify(first, null, 2)} to deep equal ${JSON.stringify(second, null, 2)}.${message}`,\n sourceCodeInfo,\n )\n }\n return null\n },\n arity: { min: 2, max: 3 },\n },\n 'assert!=': {\n evaluate: ([first, second, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (deepEqual(asAny(first, sourceCodeInfo), asAny(second, sourceCodeInfo), sourceCodeInfo)) {\n throw new AssertionError(\n `Expected ${JSON.stringify(first)} not to deep equal ${JSON.stringify(second)}.${message}`,\n sourceCodeInfo,\n )\n }\n return null\n },\n arity: { min: 2, max: 3 },\n },\n 'assert-gt': {\n evaluate: ([first, second, message], sourceCodeInfo): null => {\n assertStringOrNumber(first, sourceCodeInfo)\n assertStringOrNumber(second, sourceCodeInfo)\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (compare(first, second, sourceCodeInfo) <= 0)\n throw new AssertionError(`Expected ${first} to be grater than ${second}.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 2, max: 3 },\n },\n 'assert-gte': {\n evaluate: ([first, second, message], sourceCodeInfo): null => {\n assertStringOrNumber(first, sourceCodeInfo)\n assertStringOrNumber(second, sourceCodeInfo)\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (compare(first, second, sourceCodeInfo) < 0)\n throw new AssertionError(`Expected ${first} to be grater than or equal to ${second}.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 2, max: 3 },\n },\n 'assert-lt': {\n evaluate: ([first, second, message], sourceCodeInfo): null => {\n assertStringOrNumber(first, sourceCodeInfo)\n assertStringOrNumber(second, sourceCodeInfo)\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (compare(first, second, sourceCodeInfo) >= 0)\n throw new AssertionError(`Expected ${first} to be less than ${second}.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 2, max: 3 },\n },\n 'assert-lte': {\n evaluate: ([first, second, message], sourceCodeInfo): null => {\n assertStringOrNumber(first, sourceCodeInfo)\n assertStringOrNumber(second, sourceCodeInfo)\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (compare(first, second, sourceCodeInfo) > 0)\n throw new AssertionError(`Expected ${first} to be less than or equal to ${second}.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 2, max: 3 },\n },\n 'assert-true': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (first !== true)\n throw new AssertionError(`Expected ${first} to be true.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-false': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (first !== false)\n throw new AssertionError(`Expected ${first} to be false.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-truthy': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (!first)\n throw new AssertionError(`Expected ${first} to be truthy.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-falsy': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (first)\n throw new AssertionError(`Expected ${first} to be falsy.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-null': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (first !== null)\n throw new AssertionError(`Expected ${first} to be null.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-throws': {\n evaluate: ([func, message], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<null> => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n assertFunctionLike(func, sourceCodeInfo)\n return tryCatch(\n () => chain(executeFunction(func, [], contextStack, sourceCodeInfo), () => {\n throw new AssertionError(`Expected function to throw.${message}`, sourceCodeInfo)\n }),\n () => null,\n )\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-throws-error': {\n evaluate: ([func, throwMessage, message], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<null> => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n assertString(throwMessage, sourceCodeInfo)\n assertFunctionLike(func, sourceCodeInfo)\n return tryCatch(\n () => chain(executeFunction(func, [], contextStack, sourceCodeInfo), () => {\n throw new AssertionError(`Expected function to throw \"${throwMessage}\".${message}`, sourceCodeInfo)\n }),\n (error) => {\n const errorMessage = (error as DvalaError).shortMessage\n if (errorMessage !== throwMessage) {\n throw new AssertionError(\n `Expected function to throw \"${throwMessage}\", but thrown \"${errorMessage}\".${message}`,\n sourceCodeInfo,\n )\n }\n return null\n },\n )\n },\n arity: { min: 2, max: 3 },\n },\n 'assert-not-throws': {\n evaluate: ([func, message], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<null> => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n assertFunctionLike(func, sourceCodeInfo)\n return tryCatch(\n () => chain(executeFunction(func, [], contextStack, sourceCodeInfo), () => null),\n () => {\n throw new AssertionError(`Expected function not to throw.${message}`, sourceCodeInfo)\n },\n )\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-array': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (!Array.isArray(first))\n throw new AssertionError(`Expected ${JSON.stringify(first)} to be an array.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-boolean': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (typeof first !== 'boolean')\n throw new AssertionError(`Expected ${JSON.stringify(first)} to be a boolean.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-collection': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (!isColl(first))\n throw new AssertionError(`Expected ${JSON.stringify(first)} to be a collection.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-function': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (!isDvalaFunction(first))\n throw new AssertionError(`Expected ${JSON.stringify(first)} to be a function.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-grid': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (!isGrid(first))\n throw new AssertionError(`Expected ${JSON.stringify(first)} to be a grid.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-integer': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (typeof first !== 'number' || !isNumber(first, { integer: true }))\n throw new AssertionError(`Expected ${JSON.stringify(first)} to be an integer.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-matrix': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (!isMatrix(first))\n throw new AssertionError(`Expected ${JSON.stringify(first)} to be a matrix.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-number': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (typeof first !== 'number')\n throw new AssertionError(`Expected ${JSON.stringify(first)} to be a number.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-object': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (!isObj(first))\n throw new AssertionError(`Expected ${JSON.stringify(first)} to be an object.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-regexp': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (!isRegularExpression(first))\n throw new AssertionError(`Expected ${JSON.stringify(first)} to be a regexp.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-sequence': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (!isSeq(first))\n throw new AssertionError(`Expected ${JSON.stringify(first)} to be a sequence.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-string': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (typeof first !== 'string')\n throw new AssertionError(`Expected ${JSON.stringify(first)} to be a string.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n 'assert-vector': {\n evaluate: ([first, message], sourceCodeInfo): null => {\n if (message !== undefined) {\n assertString(message, sourceCodeInfo)\n message = ` ${message}`\n }\n message ??= ''\n if (!isVector(first))\n throw new AssertionError(`Expected ${JSON.stringify(first)} to be a vector.${message}`, sourceCodeInfo)\n\n return null\n },\n arity: { min: 1, max: 2 },\n },\n}\n\nfor (const [key, docs] of Object.entries(moduleDocs)) {\n if (assertNormalExpression[key])\n assertNormalExpression[key].docs = docs\n}\n\nexport const assertModule: DvalaModule = {\n name: 'assertion',\n functions: assertNormalExpression,\n}\n","import type { FunctionDocs } from '../../interface'\n\nexport const moduleDocs: Record<string, FunctionDocs> = {\n 'cell-every?': {\n category: 'grid',\n 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.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'function',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { cell-every? } = import(grid);\\ncell-every?([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], string?)',\n 'let { cell-every? } = import(grid);\\ncell-every?([\\n [\"Albert\", \"father\"],\\n [\"Nina\", \"mother\"],\\n [\"Kian\", \"son\"],\\n], string?)',\n 'let { cell-every? } = import(grid);\\ncell-every?([\\n [1, 2],\\n [3, 4],\\n], string?)',\n ],\n seeAlso: ['collection.every?', 'grid.some?', 'grid.every-row?', 'grid.every-col?'],\n },\n 'some?': {\n category: 'grid',\n 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.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'function',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { some? } = import(grid);\\nsome?([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], string?)',\n 'let { some? } = import(grid);\\nsome?([\\n [\"Albert\", \"father\"],\\n [\"Nina\", \"mother\"],\\n [\"Kian\", \"son\"],\\n], string?)',\n 'let { some? } = import(grid);\\nsome?([\\n [1, 2],\\n [3, 4],\\n], string?)',\n ],\n seeAlso: ['collection.any?', 'grid.cell-every?', 'grid.some-row?', 'grid.some-col?'],\n },\n 'every-row?': {\n category: 'grid',\n 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.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'function',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { every-row? } = import(grid);\\nevery-row?([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], -> string?($[0]))',\n 'let { every-row? } = import(grid);\\nevery-row?([\\n [\"Albert\", \"father\"],\\n [\"Nina\", \"mother\"],\\n [\"Kian\", \"son\"],\\n], -> string?($[0]))',\n 'let { every-row? } = import(grid);\\nevery-row?([\\n [1, 2],\\n [3, 4],\\n], -> string?($[0]))',\n ],\n seeAlso: ['grid.some-row?', 'grid.every-col?', 'grid.cell-every?'],\n },\n 'some-row?': {\n category: 'grid',\n 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.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'function',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { some-row? } = import(grid);\\nsome-row?([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], -> $ contains? \"Albert\")',\n 'let { some-row? } = import(grid);\\nsome-row?([\\n [\"Albert\", \"father\"],\\n [\"Nina\", \"mother\"],\\n [\"Kian\", \"son\"],\\n], -> $ contains? \"Albert\")',\n 'let { some-row? } = import(grid);\\nsome-row?([\\n [1, 2],\\n [3, 4],\\n], -> $ contains? \"Albert\")',\n ],\n seeAlso: ['grid.every-row?', 'grid.some-col?', 'grid.some?'],\n },\n 'every-col?': {\n category: 'grid',\n 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.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'function',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { every-col? } = import(grid);\\nevery-col?([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], -> string?($[0]))',\n 'let { every-col? } = import(grid);\\nevery-col?([\\n [\"Albert\", \"father\"],\\n [\"Nina\", \"mother\"],\\n [\"Kian\", \"son\"],\\n], -> string?($[0]))',\n 'let { every-col? } = import(grid);\\nevery-col?([\\n [1, 2],\\n [3, 4],\\n], -> string?($[0]))',\n ],\n seeAlso: ['grid.some-col?', 'grid.every-row?', 'grid.cell-every?'],\n },\n 'some-col?': {\n category: 'grid',\n 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.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'function',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { some-col? } = import(grid);\\nsome-col?([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], -> $ contains? \"Albert\")',\n 'let { some-col? } = import(grid);\\nsome-col?([\\n [\"Albert\", \"father\"],\\n [\"Nina\", \"mother\"],\\n [\"Kian\", \"son\"],\\n], -> $ contains? \"Albert\")',\n 'let { some-col? } = import(grid);\\nsome-col?([\\n [1, 2],\\n [3, 4],\\n], -> $ contains? \"Albert\")',\n ],\n seeAlso: ['grid.every-col?', 'grid.some-row?', 'grid.some?'],\n },\n 'row': {\n category: 'grid',\n description: 'Returns the row at index $a in the grid $b.',\n returns: {\n type: 'any',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'number',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { row } = import(grid);\\nrow([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], 0)',\n 'let { row } = import(grid);\\nrow([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], 1)',\n 'let { row } = import(grid);\\nrow([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], 2)',\n ],\n seeAlso: ['grid.col', 'grid.shape'],\n },\n 'col': {\n category: 'grid',\n description: 'Returns the column at index $a in the grid $b.',\n returns: {\n type: 'any',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'number',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { col } = import(grid);\\ncol([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], 0)',\n 'let { col } = import(grid);\\ncol([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], 1)',\n 'let { col } = import(grid);\\ncol([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], 2)',\n ],\n seeAlso: ['grid.row', 'grid.shape'],\n },\n 'shape': {\n category: 'grid',\n 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.',\n returns: {\n type: 'vector',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to get the shape of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n ],\n },\n ],\n examples: [\n 'let { shape } = import(grid);\\nshape([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n])',\n 'let { shape } = import(grid);\\nshape([\\n [\"Albert\", \"father\"],\\n [\"Nina\", \"mother\"],\\n [\"Kian\", \"son\"],\\n])',\n 'let { shape } = import(grid);\\nshape([\\n [1, 2],\\n [3, 4],\\n])',\n ],\n seeAlso: ['grid.row', 'grid.col', 'grid.reshape'],\n },\n 'fill': {\n category: 'grid',\n description: 'Creates a grid of the specified size, filled with the specified value.',\n returns: {\n type: 'grid',\n },\n args: {\n rows: {\n type: 'integer',\n description: 'The number of rows in the grid.',\n },\n cols: {\n type: 'integer',\n description: 'The number of columns in the grid.',\n },\n value: {\n type: 'any',\n description: 'The value to fill the grid with.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'rows',\n 'cols',\n 'value',\n ],\n },\n ],\n examples: [\n 'let { fill } = import(grid);\\nfill(2, 3, 0)',\n 'let { fill } = import(grid);\\nfill(2, 3, \"x\")',\n ],\n seeAlso: ['grid.generate', 'grid.from-array'],\n },\n 'generate': {\n category: 'grid',\n description: 'Generates a grid of the specified size, where each element is generated by the provided function.',\n returns: {\n type: 'grid',\n },\n args: {\n rows: {\n type: 'number',\n description: 'The number of rows in the grid.',\n },\n cols: {\n type: 'number',\n description: 'The number of columns in the grid.',\n },\n fn: {\n type: 'function',\n description: 'The function to generate the grid. It takes two arguments: the row index and the column index.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'rows',\n 'cols',\n 'fn',\n ],\n },\n ],\n examples: [\n 'let { generate } = import(grid);\\ngenerate(3, 3, (i, j) -> i + j)',\n ],\n seeAlso: ['grid.fill', 'grid.from-array'],\n },\n 'reshape': {\n category: 'grid',\n 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.',\n returns: {\n type: 'grid',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'number',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { reshape } = import(grid);\\nreshape([\\n [\"Albert\", \"father\"],\\n [\"Nina\", \"mother\"],\\n [\"Kian\", \"son\"],\\n], 2)',\n ],\n seeAlso: ['grid.shape', 'grid.from-array'],\n },\n 'transpose': {\n category: 'grid',\n description: 'Transposes the grid `g`, swapping its rows and columns.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to transpose.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n ],\n },\n ],\n examples: [\n 'let { transpose } = import(grid);\\ntranspose([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n])',\n 'let { transpose } = import(grid);\\ntranspose([\\n [\"Albert\", \"father\"],\\n [\"Nina\", \"mother\"],\\n [\"Kian\", \"son\"],\\n])',\n 'let { transpose } = import(grid);\\ntranspose([\\n [1, 2],\\n [3, 4],\\n])',\n ],\n seeAlso: ['grid.flip-h', 'grid.flip-v', 'grid.rotate'],\n },\n 'flip-h': {\n category: 'grid',\n description: 'Flips the grid `g` horizontally.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to flip horizontally.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n ],\n },\n ],\n examples: [\n 'let { flip-h } = import(grid);\\nflip-h([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n])',\n 'let { flip-h } = import(grid);\\nflip-h([\\n [\"Albert\", \"father\"],\\n [\"Nina\", \"mother\"],\\n [\"Kian\", \"son\"],\\n])',\n 'let { flip-h } = import(grid);\\nflip-h([\\n [1, 2],\\n [3, 4],\\n])',\n ],\n seeAlso: ['grid.flip-v', 'grid.transpose', 'grid.rotate'],\n },\n 'flip-v': {\n category: 'grid',\n description: 'Flips the grid `g` vertically.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to flip vertically.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n ],\n },\n ],\n examples: [\n 'let { flip-v } = import(grid);\\nflip-v([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n])',\n 'let { flip-v } = import(grid);\\nflip-v([\\n [\"Albert\", \"father\"],\\n [\"Nina\", \"mother\"],\\n [\"Kian\", \"son\"],\\n])',\n 'let { flip-v } = import(grid);\\nflip-v([\\n [1, 2],\\n [3, 4],\\n])',\n ],\n seeAlso: ['grid.flip-h', 'grid.transpose', 'grid.rotate'],\n },\n 'rotate': {\n category: 'grid',\n 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.',\n returns: {\n type: 'grid',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { rotate } = import(grid);\\nrotate([\\n [1, 2],\\n [3, 4],\\n], 1)',\n 'let { rotate } = import(grid);\\nrotate([\\n [1, 2],\\n [3, 4],\\n], 2)',\n 'let { rotate } = import(grid);\\nrotate([\\n [1, 2],\\n [3, 4],\\n], 3)',\n 'let { rotate } = import(grid);\\nrotate([\\n [1, 2],\\n [3, 4],\\n], 4)',\n 'let { rotate } = import(grid);\\nrotate([\\n [1, 2],\\n [3, 4],\\n], -1)',\n 'let { rotate } = import(grid);\\nrotate([\\n [1, 2],\\n [3, 4],\\n], -2)',\n 'let { rotate } = import(grid);\\nrotate([\\n [1, 2],\\n [3, 4],\\n], -3)',\n ],\n seeAlso: ['grid.transpose', 'grid.flip-h', 'grid.flip-v'],\n },\n 'crop': {\n category: 'grid',\n description: 'Crops the grid `g` from the starting index `begin` to the optional ending index `stop`. The crop is inclusive of the starting index and exclusive of the ending index.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to slice.',\n },\n begin: {\n type: 'vector',\n description: 'The starting index of the slice as a vector of two numbers: `[row, col]`.',\n },\n stop: {\n type: 'vector',\n description: 'Optional ending index of the slice as a vector of two numbers: `[row, col]`.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n 'begin',\n ],\n },\n {\n argumentNames: [\n 'g',\n 'begin',\n 'stop',\n ],\n },\n ],\n examples: [\n 'let { crop } = import(grid);\\ncrop([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], [1, 1], [2, 2])',\n 'let { crop } = import(grid);\\ncrop([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], [1, 1])',\n ],\n hideOperatorForm: true,\n seeAlso: ['grid.slice-rows', 'grid.slice-cols'],\n },\n 'slice-rows': {\n category: 'grid',\n 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.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to slice.',\n },\n begin: {\n type: 'number',\n description: 'The starting index of the slice.',\n },\n stop: {\n type: 'number',\n description: 'Optional ending index of the slice.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n 'begin',\n ],\n },\n {\n argumentNames: [\n 'g',\n 'begin',\n 'stop',\n ],\n },\n ],\n examples: [\n 'let { slice-rows } = import(grid);\\nslice-rows([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], 1, 2)',\n 'let { slice-rows } = import(grid);\\nslice-rows([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], 1)',\n ],\n hideOperatorForm: true,\n seeAlso: ['grid.crop', 'grid.slice-cols', 'grid.splice-rows'],\n },\n 'slice-cols': {\n category: 'grid',\n 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.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to slice.',\n },\n begin: {\n type: 'number',\n description: 'The starting index of the slice.',\n },\n stop: {\n type: 'number',\n description: 'Optional ending index of the slice.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n 'begin',\n ],\n },\n {\n argumentNames: [\n 'g',\n 'begin',\n 'stop',\n ],\n },\n ],\n examples: [\n 'let { slice-cols } = import(grid);\\nslice-cols([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], 1, 2)',\n 'let { slice-cols } = import(grid);\\nslice-cols([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], 1)',\n ],\n hideOperatorForm: true,\n seeAlso: ['grid.crop', 'grid.slice-rows', 'grid.splice-cols'],\n },\n 'splice-rows': {\n category: 'grid',\n description: 'Splices rows of the grid `g` starting from the index `begin`. Deletes `deleteCount` rows and inserts the specified `items` at that position.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to splice.',\n },\n begin: {\n type: 'number',\n description: 'The starting index of the splice.',\n },\n deleteCount: {\n type: 'number',\n description: 'The number of rows to delete.',\n },\n items: {\n type: 'array',\n rest: true,\n description: 'The rows to insert.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n 'begin',\n 'deleteCount',\n ],\n },\n {\n argumentNames: [\n 'g',\n 'begin',\n 'deleteCount',\n 'items',\n ],\n },\n ],\n examples: [\n 'let { splice-rows } = import(grid);\\nsplice-rows([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], 1, 2)',\n '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])',\n ],\n hideOperatorForm: true,\n seeAlso: ['grid.splice-cols', 'grid.slice-rows'],\n },\n 'splice-cols': {\n category: 'grid',\n description: 'Splices columns of the grid `g` starting from the index `begin`. Deletes `deleteCount` columns and inserts the specified `items` at that position.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to splice.',\n },\n begin: {\n type: 'number',\n description: 'The starting index of the splice.',\n },\n deleteCount: {\n type: 'number',\n description: 'The number of columns to delete.',\n },\n items: {\n type: 'array',\n rest: true,\n description: 'The columns to insert.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n 'begin',\n 'deleteCount',\n ],\n },\n {\n argumentNames: [\n 'g',\n 'begin',\n 'deleteCount',\n 'items',\n ],\n },\n ],\n examples: [\n 'let { splice-cols } = import(grid);\\nsplice-cols([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], 1, 2)',\n '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\"])',\n ],\n hideOperatorForm: true,\n seeAlso: ['grid.splice-rows', 'grid.slice-cols'],\n },\n 'concat-rows': {\n category: 'grid',\n description: 'Concatenates two grids `a` and `b` by rows. The number of columns in both grids must be the same.',\n returns: {\n type: 'grid',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'grid',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { concat-rows } = import(grid);\\nconcat-rows([\\n [\"Albert\", \"father\"],\\n [\"Nina\", \"mother\"],\\n [\"Kian\", \"son\"],\\n], [\\n [1, 2],\\n [3, 4],\\n])',\n ],\n seeAlso: ['grid.concat-cols', 'grid.push-rows'],\n },\n 'concat-cols': {\n category: 'grid',\n description: 'Concatenates two grids `a` and `b` by columns. The number of rows in both grids must be the same.',\n returns: {\n type: 'grid',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'grid',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n '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])',\n ],\n seeAlso: ['grid.concat-rows', 'grid.push-cols'],\n },\n 'cell-map': {\n category: 'grid',\n description: 'Maps a function `a` over each element of the grid `b`, returning a new grid with the results.',\n returns: {\n type: 'grid',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'function',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { cell-map } = import(grid);\\ncell-map([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], str)',\n ],\n seeAlso: ['map', 'grid.cell-mapi', 'grid.cell-reduce'],\n },\n 'cell-mapi': {\n category: 'grid',\n description: 'Maps a function `a` over each element of the grid `b`, passing the row and column index as additional arguments to the function.',\n returns: {\n type: 'grid',\n },\n args: {\n a: {\n type: 'grid',\n },\n b: {\n type: 'function',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { cell-mapi } = import(grid);\\ncell-mapi([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], -> $1 ++ \"(\" ++ $2 ++ \", \" ++ $3 ++ \")\")',\n ],\n seeAlso: ['grid.cell-map', 'grid.cell-reducei', 'map'],\n },\n 'cell-reduce': {\n category: 'grid',\n description: 'Reduces the grid `a` using the function `b`, returning a single value.',\n returns: {\n type: 'any',\n },\n args: {\n 'g': {\n type: 'grid',\n description: 'The grid to reduce.',\n },\n 'fn': {\n type: 'function',\n description: 'The function to reduce the grid. It takes two arguments: the accumulator and the current element.',\n },\n 'initial-value': {\n type: 'any',\n description: 'The initial value for the accumulator.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n 'fn',\n 'initial-value',\n ],\n },\n ],\n examples: [\n '// Using \"as\" alias because \"reduce\" shadows a builtin function\\nlet { cell-reduce } = import(grid);\\ncell-reduce([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], ++, \"\")',\n ],\n seeAlso: ['reduce', 'grid.cell-reducei', 'grid.cell-map'],\n },\n 'cell-reducei': {\n category: 'grid',\n description: 'Reduces the grid `a` using the function `b`, passing the row and column indices as additional arguments to the function.',\n returns: {\n type: 'any',\n },\n args: {\n 'g': {\n type: 'grid',\n description: 'The grid to reduce.',\n },\n 'fn': {\n type: 'function',\n description: 'The function to reduce the grid. It takes four arguments: the accumulator, the current element, the row index, and the column index.',\n },\n 'initial-value': {\n type: 'any',\n description: 'The initial value for the accumulator.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n 'fn',\n 'initial-value',\n ],\n },\n ],\n examples: [\n '// Using \"as\" alias because \"reducei\" shadows a builtin function\\nlet { cell-reducei } = import(grid);\\ncell-reducei([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], ++, \"\")',\n ],\n seeAlso: ['grid.cell-reduce', 'grid.cell-mapi', 'reduce'],\n },\n 'push-rows': {\n category: 'grid',\n description: 'Pushes the specified rows into the grid `g` and returns the new grid.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to push rows into.',\n },\n rows: {\n type: 'array',\n rest: true,\n description: 'The rows to push into the grid.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n 'rows',\n ],\n },\n ],\n examples: [\n 'let { push-rows } = import(grid);\\npush-rows([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], [\"Nazanin\", \"mother\", 40])',\n ],\n hideOperatorForm: true,\n seeAlso: ['grid.unshift-rows', 'grid.pop-row', 'grid.shift-row', 'grid.concat-rows'],\n },\n 'unshift-rows': {\n category: 'grid',\n description: 'Unshifts the specified rows into the grid `g` and returns the new grid.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to unshift rows into.',\n },\n rows: {\n type: 'array',\n rest: true,\n description: 'The rows to unshift into the grid.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n 'rows',\n ],\n },\n ],\n examples: [\n 'let { unshift-rows } = import(grid);\\nunshift-rows([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], [\"Nazanin\", \"mother\", 40])',\n ],\n hideOperatorForm: true,\n seeAlso: ['grid.push-rows', 'grid.shift-row', 'grid.pop-row'],\n },\n 'pop-row': {\n category: 'grid',\n description: 'Pops the last row from the grid `g` and returns the new grid.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to pop a row from.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n ],\n },\n ],\n examples: [\n 'let { pop-row } = import(grid);\\npop-row([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n])',\n ],\n seeAlso: ['grid.shift-row', 'grid.push-rows', 'grid.unshift-rows'],\n },\n 'shift-row': {\n category: 'grid',\n description: 'Shifts the first row from the grid `g` and returns the new grid.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to shift a row from.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n ],\n },\n ],\n examples: [\n 'let { shift-row } = import(grid);\\nshift-row([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n])',\n ],\n seeAlso: ['grid.pop-row', 'grid.push-rows', 'grid.unshift-rows'],\n },\n 'push-cols': {\n category: 'grid',\n description: 'Pushes the specified columns into the grid `g` and returns the new grid.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to push columns into.',\n },\n cols: {\n type: 'array',\n rest: true,\n description: 'The columns to push into the grid.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n 'cols',\n ],\n },\n ],\n examples: [\n 'let { push-cols } = import(grid);\\npush-cols([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], [\"f\", \"m\", \"s\"])',\n ],\n hideOperatorForm: true,\n seeAlso: ['grid.unshift-cols', 'grid.pop-col', 'grid.shift-col', 'grid.concat-cols'],\n },\n 'unshift-cols': {\n category: 'grid',\n description: 'Unshifts the specified columns into the grid `g` and returns the new grid.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to unshift columns into.',\n },\n cols: {\n type: 'array',\n rest: true,\n description: 'The columns to unshift into the grid.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n 'cols',\n ],\n },\n ],\n examples: [\n 'let { unshift-cols } = import(grid);\\nunshift-cols([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n], [\"f\", \"m\", \"s\"])',\n ],\n hideOperatorForm: true,\n seeAlso: ['grid.push-cols', 'grid.shift-col', 'grid.pop-col'],\n },\n 'pop-col': {\n category: 'grid',\n description: 'Pops the last column from the grid `g` and returns the new grid.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to pop a column from.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n ],\n },\n ],\n examples: [\n 'let { pop-col } = import(grid);\\npop-col([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n])',\n ],\n seeAlso: ['grid.shift-col', 'grid.push-cols', 'grid.unshift-cols'],\n },\n 'shift-col': {\n category: 'grid',\n description: 'Shifts the first column from the grid `g` and returns the new grid.',\n returns: {\n type: 'grid',\n },\n args: {\n g: {\n type: 'grid',\n description: 'The grid to shift a column from.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'g',\n ],\n },\n ],\n examples: [\n 'let { shift-col } = import(grid);\\nshift-col([\\n [\"Albert\", \"father\", 10],\\n [\"Nina\", \"mother\", 20],\\n [\"Kian\", \"son\", 30],\\n])',\n ],\n seeAlso: ['grid.pop-col', 'grid.push-cols', 'grid.unshift-cols'],\n },\n 'from-array': {\n category: 'grid',\n 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.',\n returns: {\n type: 'grid',\n },\n args: {\n a: {\n type: 'array',\n },\n b: {\n type: 'number',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { from-array } = import(grid);\\nfrom-array([1, 2, 3, 4], 2)',\n 'let { from-array } = import(grid);\\nfrom-array([1, 2, 3, 4], 4)',\n ],\n seeAlso: ['grid.fill', 'grid.generate', 'grid.reshape'],\n },\n}\n","import type { Any } from '../../../interface'\n\nexport function transpose<T extends Any>(grid: T[][]): T[][] {\n const result: T[][] = []\n\n for (let i = 0; i < grid[0]!.length; i += 1) {\n const row: T[] = []\n for (let j = 0; j < grid.length; j += 1) {\n row.push(grid[j]![i]!)\n }\n result.push(row)\n }\n return result\n}\n","import { DvalaError } from '../../../errors'\nimport type { Any } from '../../../interface'\nimport { assertGrid, assertVector } from '../../../typeGuards/annotatedArrays'\nimport { assertArray } from '../../../typeGuards/array'\nimport { asAny, asFunctionLike, assertAny, assertFunctionLike } from '../../../typeGuards/dvala'\nimport { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { MaybePromise } from '../../../utils/maybePromise'\nimport { chain, everySequential, mapSequential, reduceSequential, someSequential } from '../../../utils/maybePromise'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport type { DvalaModule } from '../interface'\nimport { moduleDocs } from './docs'\nimport { fromArray } from './fromArray'\nimport { transpose } from './transpose'\n\nconst gridFunctions: BuiltinNormalExpressions = {\n 'cell-every?': {\n evaluate: ([grid, predicate], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<boolean> => {\n assertGrid(grid, sourceCodeInfo)\n assertFunctionLike(predicate, sourceCodeInfo)\n\n const cells: Any[] = []\n for (const row of grid) {\n for (const cell of row) {\n cells.push(cell)\n }\n }\n return everySequential(cells, cell => executeFunction(predicate, [cell], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(2),\n },\n 'some?': {\n evaluate: ([grid, predicate], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<boolean> => {\n assertGrid(grid, sourceCodeInfo)\n assertFunctionLike(predicate, sourceCodeInfo)\n\n const cells: Any[] = []\n for (const row of grid) {\n for (const cell of row) {\n cells.push(cell)\n }\n }\n return someSequential(cells, cell => executeFunction(predicate, [cell], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(2),\n },\n 'every-row?': {\n evaluate: ([grid, predicate], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<boolean> => {\n assertGrid(grid, sourceCodeInfo)\n assertFunctionLike(predicate, sourceCodeInfo)\n\n return everySequential(Array.from(grid), row => executeFunction(predicate, [row], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(2),\n },\n 'some-row?': {\n evaluate: ([grid, predicate], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<boolean> => {\n assertGrid(grid, sourceCodeInfo)\n assertFunctionLike(predicate, sourceCodeInfo)\n\n return someSequential(Array.from(grid), row => executeFunction(predicate, [row], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(2),\n },\n 'every-col?': {\n evaluate: ([grid, predicate], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<boolean> => {\n assertGrid(grid, sourceCodeInfo)\n assertFunctionLike(predicate, sourceCodeInfo)\n\n const transposed = transpose(grid)\n return everySequential(Array.from(transposed), row => executeFunction(predicate, [row], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(2),\n },\n 'some-col?': {\n evaluate: ([grid, predicate], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<boolean> => {\n assertGrid(grid, sourceCodeInfo)\n assertFunctionLike(predicate, sourceCodeInfo)\n\n const transposed = transpose(grid)\n return someSequential(Array.from(transposed), row => executeFunction(predicate, [row], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(2),\n },\n 'row': {\n evaluate: ([grid, row], sourceCodeInfo): Any[] => {\n assertGrid(grid, sourceCodeInfo)\n assertNumber(row, sourceCodeInfo, { integer: true, nonNegative: true, lt: grid.length })\n return grid[row]!\n },\n arity: toFixedArity(2),\n },\n 'col': {\n evaluate: ([grid, col], sourceCodeInfo): Any[] => {\n assertGrid(grid, sourceCodeInfo)\n assertNumber(col, sourceCodeInfo, { integer: true, nonNegative: true, lt: grid[0]!.length })\n return grid.map(row => row[col]!)\n },\n arity: toFixedArity(2),\n },\n 'shape': {\n evaluate: ([grid], sourceCodeInfo): Any[] => {\n assertGrid(grid, sourceCodeInfo)\n return [grid.length, grid[0]!.length]\n },\n arity: toFixedArity(1),\n },\n 'fill': {\n evaluate: ([rows, cols, value], sourceCodeInfo): Any[][] => {\n assertNumber(rows, sourceCodeInfo, { integer: true, positive: true })\n assertNumber(cols, sourceCodeInfo, { integer: true, positive: true })\n assertAny(value, sourceCodeInfo)\n const result: Any[][] = []\n for (let i = 0; i < rows; i += 1) {\n const row: Any[] = []\n for (let j = 0; j < cols; j += 1) {\n row.push(value)\n }\n result.push(row)\n }\n return result\n },\n arity: toFixedArity(3),\n },\n 'generate': {\n evaluate: ([rows, cols, generator], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any[][]> => {\n assertNumber(rows, sourceCodeInfo, { integer: true, positive: true })\n assertNumber(cols, sourceCodeInfo, { integer: true, positive: true })\n assertFunctionLike(generator, sourceCodeInfo)\n\n return mapSequential(Array.from({ length: rows }), (_, i) => {\n return mapSequential(Array.from({ length: cols }), (__, j) => {\n return chain(\n executeFunction(generator, [i, j], contextStack, sourceCodeInfo),\n (value) => {\n assertAny(value, sourceCodeInfo)\n return value\n },\n )\n })\n })\n },\n arity: toFixedArity(3),\n },\n 'reshape': {\n evaluate: ([grid, rows], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n assertNumber(rows, sourceCodeInfo, { integer: true, positive: true })\n\n const flatTable = grid.flat()\n if (flatTable.length % rows !== 0) {\n throw new DvalaError(`The number of elements in the grid must be divisible by rows, but got ${flatTable.length} and ${rows}`, sourceCodeInfo)\n }\n const cols = flatTable.length / rows\n\n const result: Any[][] = []\n for (let i = 0; i < rows; i += 1) {\n const row: Any[] = []\n for (let j = 0; j < cols; j += 1) {\n row.push(flatTable[i * cols + j]!)\n }\n result.push(row)\n }\n return result\n },\n arity: toFixedArity(2),\n },\n 'transpose': {\n evaluate: ([grid], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n return transpose(grid)\n },\n arity: toFixedArity(1),\n },\n 'flip-h': {\n evaluate: ([grid], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n return grid.map(row => row.reverse())\n },\n arity: toFixedArity(1),\n },\n 'flip-v': {\n evaluate: ([grid], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n return grid.reverse()\n },\n arity: toFixedArity(1),\n },\n 'rotate': {\n evaluate: ([grid, times], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n assertNumber(times, sourceCodeInfo, { integer: true })\n // Normalize times to be between 0 and 3\n times = ((times % 4) + 4) % 4\n\n // If times is 0, return the original grid\n if (times === 0 || grid.length === 0) {\n return grid.map(row => [...row])\n }\n\n const height = grid.length\n const width = grid[0]!.length\n\n let result: Any[][]\n\n switch (times) {\n case 1: // 90 degrees clockwise\n result = Array<Any>(width).fill(null).map(() => Array<Any>(height).fill(null))\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n result[x]![height - 1 - y] = grid[y]![x]!\n }\n }\n break\n\n case 2: // 180 degrees\n result = Array<Any>(height).fill(null).map(() => Array<Any>(width).fill(null))\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n result[height - 1 - y]![width - 1 - x] = grid[y]![x]!\n }\n }\n break\n\n case 3: // 270 degrees clockwise (or 90 degrees counter-clockwise)\n result = Array<Any>(width).fill(null).map(() => Array<Any>(height).fill(null))\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n result[width - 1 - x]![y] = grid[y]![x]!\n }\n }\n break\n }\n\n return result!\n },\n arity: toFixedArity(2),\n },\n 'crop': {\n evaluate: ([grid, start, end], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n assertVector(start, sourceCodeInfo)\n if (start.length !== 2) {\n throw new DvalaError(`The start vector must have 2 elements, but got ${start.length}`, sourceCodeInfo)\n }\n const [rowStart, colStart] = start\n assertNumber(rowStart, sourceCodeInfo, { integer: true, nonNegative: true, lt: grid.length })\n assertNumber(colStart, sourceCodeInfo, { integer: true, nonNegative: true, lt: grid[0]!.length })\n\n end ??= [grid.length, grid[0]!.length]\n assertVector(end, sourceCodeInfo)\n if (end.length !== 2) {\n throw new DvalaError(`The end vector must have 2 elements, but got ${end.length}`, sourceCodeInfo)\n }\n const [rowEnd, colEnd] = end\n assertNumber(rowEnd, sourceCodeInfo, { gt: rowStart, lte: grid.length })\n assertNumber(colEnd, sourceCodeInfo, { gt: colStart, lte: grid[0]!.length })\n\n const result: Any[][] = []\n for (let i = rowStart; i < rowEnd; i += 1) {\n const row: Any[] = []\n for (let j = colStart; j < colEnd; j += 1) {\n row.push(grid[i]![j]!)\n }\n result.push(row)\n }\n return result\n },\n arity: { min: 2, max: 3 },\n },\n 'slice-rows': {\n evaluate: ([grid, rowStart, rowEnd], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n\n if (typeof rowEnd === 'undefined') {\n assertNumber(rowStart, sourceCodeInfo, { integer: true, lte: grid.length, gte: -grid.length })\n if (rowStart < 0) {\n return grid.slice(grid.length + rowStart)\n }\n return grid.slice(rowStart)\n }\n\n assertNumber(rowStart, sourceCodeInfo, { integer: true, nonNegative: true, lte: grid.length })\n assertNumber(rowEnd, sourceCodeInfo, { integer: true })\n rowEnd = rowEnd < 0 ? grid.length + rowEnd : rowEnd\n assertNumber(rowEnd, sourceCodeInfo, { gt: rowStart, lte: grid.length })\n\n return grid.slice(rowStart, rowEnd)\n },\n arity: { min: 2, max: 3 },\n },\n 'slice-cols': {\n evaluate: ([grid, colStart, colEnd], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n const trMatrix = transpose(grid)\n\n if (typeof colEnd === 'undefined') {\n assertNumber(colStart, sourceCodeInfo, { integer: true, lte: trMatrix.length, gte: -trMatrix.length })\n if (colStart < 0) {\n return transpose(trMatrix.slice(trMatrix.length + colStart))\n }\n return transpose(trMatrix.slice(colStart))\n }\n\n assertNumber(colStart, sourceCodeInfo, { integer: true, nonNegative: true, lte: trMatrix.length })\n assertNumber(colEnd, sourceCodeInfo, { integer: true })\n colEnd = colEnd < 0 ? trMatrix.length + colEnd : colEnd\n assertNumber(colEnd, sourceCodeInfo, { gt: colStart, lte: trMatrix.length })\n\n return transpose(trMatrix.slice(colStart, colEnd))\n },\n arity: { min: 2, max: 3 },\n },\n 'splice-rows': {\n evaluate: ([grid, rowStart, rowDeleteCount, ...rows], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n assertNumber(rowStart, sourceCodeInfo, { integer: true, nonNegative: true, lte: grid.length })\n assertNumber(rowDeleteCount, sourceCodeInfo, { integer: true, nonNegative: true })\n if (rows.length !== 0) {\n assertGrid(rows, sourceCodeInfo)\n rows.every((row) => {\n assertArray(row, sourceCodeInfo)\n if (grid[0]!.length !== row.length) {\n throw new DvalaError(`All rows must have the same length as the number of columns in grid, but got ${row.length}`, sourceCodeInfo)\n }\n return true\n })\n }\n\n const result: Any[][] = []\n for (let i = 0; i < rowStart; i += 1) {\n result.push(grid[i]!)\n }\n if (rows.length > 0) {\n result.push(...(rows as Any[][]))\n }\n for (let i = rowStart + rowDeleteCount; i < grid.length; i += 1) {\n result.push(grid[i]!)\n }\n return result\n },\n arity: { min: 3 },\n },\n 'splice-cols': {\n evaluate: ([grid, colStart, colDeleteCount, ...cols], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n const trMatrix = transpose(grid)\n assertNumber(colStart, sourceCodeInfo, { integer: true, nonNegative: true, lte: trMatrix.length })\n assertNumber(colDeleteCount, sourceCodeInfo, { integer: true, nonNegative: true })\n\n if (cols.length !== 0) {\n assertGrid(cols, sourceCodeInfo)\n cols.every((row) => {\n assertArray(row, sourceCodeInfo)\n if (trMatrix[0]!.length !== row.length) {\n throw new DvalaError(`All rows must have the same length as the number of rows in grid, but got ${row.length}`, sourceCodeInfo)\n }\n return true\n })\n }\n\n const result: Any[][] = []\n for (let i = 0; i < colStart; i += 1) {\n result.push(trMatrix[i]!)\n }\n result.push(...(cols as Any[][]))\n for (let i = colStart + colDeleteCount; i < trMatrix.length; i += 1) {\n result.push(trMatrix[i]!)\n }\n return transpose(result)\n },\n arity: { min: 3 },\n },\n 'concat-rows': {\n evaluate: (params, sourceCodeInfo): Any[][] => {\n assertArray(params, sourceCodeInfo)\n params.every(grid => assertGrid(grid, sourceCodeInfo))\n const cols = (params[0] as Any[][])[0]!.length\n ;(params as Any[][][]).slice(1).every((grid) => {\n if (grid[0]!.length !== cols) {\n throw new DvalaError(`All grids must have the same number of columns, but got ${cols} and ${grid[0]!.length}`, sourceCodeInfo)\n }\n return true\n })\n\n const result: Any[][] = []\n ;(params as Any[][][]).forEach((grid) => {\n grid.forEach((row) => {\n result.push(row)\n })\n })\n return result\n },\n arity: { min: 1 },\n },\n 'concat-cols': {\n evaluate: (params, sourceCodeInfo): Any[][] => {\n assertArray(params, sourceCodeInfo)\n params.every(grid => assertGrid(grid, sourceCodeInfo))\n const rows = (params[0] as Any[][]).length\n ;(params as Any[][][]).slice(1).every((grid) => {\n if (grid.length !== rows) {\n throw new DvalaError(`All grids must have the same number of rows, but got ${rows} and ${grid.length}`, sourceCodeInfo)\n }\n return true\n })\n\n const result: Any[][] = []\n for (let i = 0; i < rows; i += 1) {\n const row: Any[] = []\n ;(params as Any[][][]).forEach((grid) => {\n row.push(...grid[i]!)\n })\n result.push(row)\n }\n return result\n },\n arity: { min: 1 },\n },\n 'cell-map': {\n evaluate: (params, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any[][]> => {\n const fn = asFunctionLike(params.at(-1), sourceCodeInfo)\n const grids = params.slice(0, -1)\n assertGrid(grids[0], sourceCodeInfo)\n const rows = grids[0].length\n const cols = grids[0][0]!.length\n grids.slice(1).forEach((grid) => {\n assertGrid(grid, sourceCodeInfo)\n if (grid.length !== rows) {\n throw new DvalaError(`All grids must have the same number of rows, but got ${rows} and ${grid.length}`, sourceCodeInfo)\n }\n if (grid[0]!.length !== cols) {\n throw new DvalaError(`All grids must have the same number of columns, but got ${cols} and ${grid[0]!.length}`, sourceCodeInfo)\n }\n })\n\n return mapSequential(Array.from({ length: rows }), (_, i) => {\n return mapSequential(Array.from({ length: cols }), (__, j) => {\n const args = grids.map(grid => (grid as Any[][])[i]![j])\n return chain(executeFunction(fn, args, contextStack, sourceCodeInfo), val => asAny(val))\n })\n })\n },\n arity: { min: 2 },\n },\n 'cell-mapi': {\n evaluate: ([grid, fn], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any[][]> => {\n assertGrid(grid, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n const rows = grid.length\n const cols = grid[0]!.length\n\n return mapSequential(Array.from({ length: rows }), (_, i) => {\n return mapSequential(Array.from({ length: cols }), (__, j) => {\n return chain(executeFunction(fn, [grid[i]![j], i, j], contextStack, sourceCodeInfo), val => asAny(val))\n })\n })\n },\n arity: toFixedArity(2),\n },\n 'cell-reduce': {\n evaluate: ([grid, fn, initialValue], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertGrid(grid, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n const cells: Any[] = []\n for (const row of grid) {\n for (const cell of row) {\n cells.push(cell)\n }\n }\n return reduceSequential(\n cells,\n (accumulator, cell) => executeFunction(fn, [accumulator, cell], contextStack, sourceCodeInfo),\n asAny(initialValue),\n )\n },\n arity: toFixedArity(3),\n },\n 'cell-reducei': {\n evaluate: ([grid, fn, initialValue], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertGrid(grid, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n const cells: { cell: Any, i: number, j: number }[] = []\n for (let i = 0; i < grid.length; i += 1) {\n for (let j = 0; j < grid[i]!.length; j += 1) {\n cells.push({ cell: grid[i]![j]!, i, j })\n }\n }\n return reduceSequential(\n cells,\n (accumulator, { cell, i, j }) => executeFunction(fn, [accumulator, cell, i, j], contextStack, sourceCodeInfo),\n asAny(initialValue),\n )\n },\n arity: toFixedArity(3),\n },\n 'push-rows': {\n evaluate: ([grid, ...rows], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n assertGrid(rows, sourceCodeInfo)\n if (grid[0]!.length !== rows[0]!.length) {\n throw new DvalaError(`All rows must have the same length as the number of columns in grid, but got ${grid[0]!.length} and ${rows[0]!.length}`, sourceCodeInfo)\n }\n return [...grid, ...rows]\n },\n arity: { min: 2 },\n },\n 'unshift-rows': {\n evaluate: ([grid, ...rows], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n assertGrid(rows, sourceCodeInfo)\n if (grid[0]!.length !== rows[0]!.length) {\n throw new DvalaError(`All rows must have the same length as the number of columns in grid, but got ${grid[0]!.length} and ${rows[0]!.length}`, sourceCodeInfo)\n }\n return [...rows, ...grid]\n },\n arity: { min: 2 },\n },\n 'pop-row': {\n evaluate: ([grid], sourceCodeInfo): Any[][] | null => {\n assertGrid(grid, sourceCodeInfo)\n if (grid.length === 1) {\n return null\n }\n return grid.slice(0, -1)\n },\n arity: toFixedArity(1),\n\n },\n 'shift-row': {\n evaluate: ([grid], sourceCodeInfo): Any[][] | null => {\n assertGrid(grid, sourceCodeInfo)\n if (grid.length === 1) {\n return null\n }\n return grid.slice(1)\n },\n arity: toFixedArity(1),\n },\n 'push-cols': {\n evaluate: ([grid, ...cols], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n assertGrid(cols, sourceCodeInfo)\n if (grid.length !== cols[0]!.length) {\n throw new DvalaError(`All columns must have the same length as the number of rows in grid, but got ${cols.length}`, sourceCodeInfo)\n }\n\n const result: Any[][] = []\n\n for (let i = 0; i < grid.length; i += 1) {\n const row: Any[] = []\n row.push(...grid[i]!)\n cols.forEach((col) => {\n row.push(col[i]!)\n })\n result.push(row)\n }\n return result\n },\n arity: { min: 2 },\n },\n 'unshift-cols': {\n evaluate: ([grid, ...cols], sourceCodeInfo): Any[][] => {\n assertGrid(grid, sourceCodeInfo)\n assertGrid(cols, sourceCodeInfo)\n if (grid.length !== cols[0]!.length) {\n throw new DvalaError(`All columns must have the same length as the number of rows in grid, but got ${cols.length}`, sourceCodeInfo)\n }\n\n const result: Any[][] = []\n\n for (let i = 0; i < grid.length; i += 1) {\n const row: Any[] = []\n cols.forEach((col) => {\n row.push(col[i]!)\n })\n row.push(...grid[i]!)\n result.push(row)\n }\n return result\n },\n arity: { min: 2 },\n },\n 'pop-col': {\n evaluate: ([grid], sourceCodeInfo): Any[][] | null => {\n assertGrid(grid, sourceCodeInfo)\n if (grid[0]!.length === 1) {\n return null\n }\n return grid.map(row => row.slice(0, -1))\n },\n arity: toFixedArity(1),\n },\n 'shift-col': {\n evaluate: ([grid], sourceCodeInfo): Any[][] | null => {\n assertGrid(grid, sourceCodeInfo)\n if (grid[0]!.length === 1) {\n return null\n }\n return grid.map(row => row.slice(1))\n },\n arity: toFixedArity(1),\n },\n 'from-array': {\n evaluate: ([array, rows], sourceCodeInfo): unknown[][] => {\n assertArray(array, sourceCodeInfo)\n assertNumber(rows, sourceCodeInfo, { integer: true, positive: true })\n if (array.length % rows !== 0) {\n throw new DvalaError(`The number of elements in the array must be divisible by rows, but got ${array.length} and ${rows}`, sourceCodeInfo)\n }\n return fromArray(array, rows)\n },\n arity: toFixedArity(2),\n },\n}\n\n/**\n * The grid module containing 2D array manipulation functions.\n */\nfor (const [key, docs] of Object.entries(moduleDocs)) {\n if (gridFunctions[key])\n gridFunctions[key].docs = docs\n}\n\nexport const gridModule: DvalaModule = {\n name: 'grid',\n functions: gridFunctions,\n}\n","/**\n * Creates a grid from a flat array with specified dimensions\n *\n * @param flatArray The flat array of values\n * @param rows Number of rows in the resulting grid\n * @returns A 2D array representing the grid\n */\nexport function fromArray(flatArray: unknown[], rows: number): unknown[][] {\n // Create the grid\n const grid: unknown[][] = []\n const cols = flatArray.length / rows\n // Reshape the flat array into rows and columns\n for (let i = 0; i < rows; i++) {\n const start = i * cols\n const end = start + cols\n grid.push(flatArray.slice(start, end))\n }\n\n return grid\n}\n","import type { FunctionDocs } from '../../interface'\n\nexport const moduleDocs: Record<string, FunctionDocs> = {\n 'random!': {\n category: 'random',\n description: 'Returns a random number between 0 and 1.',\n returns: {\n type: 'number',\n },\n args: {},\n variants: [\n {\n argumentNames: [],\n },\n ],\n examples: [\n `let { random! } = import(random);\nrandom!()`,\n ],\n seeAlso: ['random.random-float!', 'random.random-int!', 'random.random-boolean!'],\n },\n 'random-int!': {\n category: 'random',\n description: 'Returns a random integer between min and max (exclusive).',\n returns: {\n type: 'integer',\n },\n args: {\n a: {\n type: 'integer',\n description: 'The minimum value.',\n },\n b: {\n type: 'integer',\n description: 'The maximum value (exclusive).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n `let { random-int! } = import(random);\nrandom-int!(0, 10)`,\n `let { random-int! } = import(random);\nrandom-int!(1, 100)`,\n ],\n seeAlso: ['random.random-int-inclusive!', 'random.random-float!', 'random.random!'],\n },\n 'random-int-inclusive!': {\n category: 'random',\n description: 'Returns a random integer between min and max (inclusive).',\n returns: {\n type: 'integer',\n },\n args: {\n a: {\n type: 'integer',\n description: 'The minimum value.',\n },\n b: {\n type: 'integer',\n description: 'The maximum value (inclusive).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n `let { random-int-inclusive! } = import(random);\nrandom-int-inclusive!(0, 10)`,\n ],\n seeAlso: ['random.random-int!', 'random.random-float!'],\n },\n 'random-float!': {\n category: 'random',\n description: 'Returns a random float between min and max.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'number',\n description: 'The minimum value.',\n },\n b: {\n type: 'number',\n description: 'The maximum value.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n `let { random-float! } = import(random);\nrandom-float!(0, 10)`,\n `let { random-float! } = import(random);\nrandom-float!(1, 100)`,\n ],\n seeAlso: ['random.random!', 'random.random-int!', 'random.random-int-inclusive!'],\n },\n 'random-boolean!': {\n category: 'random',\n description: 'Returns a random boolean.',\n returns: {\n type: 'boolean',\n },\n args: {\n prob: {\n type: 'number',\n description: 'The probability of returning true (between 0 and 1).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'prob',\n ],\n },\n ],\n examples: [\n `let { random-boolean! } = import(random);\nrandom-boolean!()`,\n `let { random-boolean! } = import(random);\nrandom-boolean!(0.99)`,\n ],\n seeAlso: ['random.random!'],\n },\n 'random-item!': {\n category: 'random',\n description: 'Returns a random item from the array.',\n returns: {\n type: 'any',\n },\n args: {\n a: {\n type: 'array',\n description: 'The array to sample from.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n ],\n },\n ],\n examples: [\n `let { random-item! } = import(random);\nrandom-item!([1, 2, 3, 4, 5])`,\n `let { random-item! } = import(random);\nrandom-item!([\"apple\", \"banana\", \"cherry\"])`,\n ],\n seeAlso: ['random.random-sample!', 'random.random-sample-unique!', 'random.random-char!'],\n },\n 'random-sample-unique!': {\n category: 'random',\n description: 'Returns a random sample of n unique items from the array.',\n returns: {\n type: 'array',\n },\n args: {\n a: {\n type: 'array',\n description: 'The array to sample from.',\n },\n b: {\n type: 'integer',\n description: 'The number of items to sample.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n `let { random-sample-unique! } = import(random);\nrandom-sample-unique!([1, 2, 3, 4, 5], 3)`,\n `let { random-sample-unique! } = import(random);\nrandom-sample-unique!([\"apple\", \"banana\", \"cherry\"], 2)`,\n ],\n seeAlso: ['random.random-sample!', 'random.random-item!', 'random.shuffle!'],\n },\n 'random-sample!': {\n category: 'random',\n description: 'Returns a random sample of n items from the array.',\n returns: {\n type: 'array',\n },\n args: {\n a: {\n type: 'array',\n description: 'The array to sample from.',\n },\n b: {\n type: 'integer',\n description: 'The number of items to sample.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n `let { random-sample! } = import(random);\nrandom-sample!([1, 2, 3, 4, 5], 3)`,\n `let { random-sample! } = import(random);\nrandom-sample!([\"apple\", \"banana\", \"cherry\"], 10)`,\n ],\n seeAlso: ['random.random-sample-unique!', 'random.random-item!', 'random.shuffle!'],\n },\n 'shuffle!': {\n category: 'random',\n description: 'Returns a shuffled version of the array.',\n returns: {\n type: 'array',\n },\n args: {\n a: {\n type: 'array',\n description: 'The array to shuffle.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n ],\n },\n ],\n examples: [\n `let { shuffle! } = import(random);\nshuffle!([1, 2, 3, 4, 5])`,\n `let { shuffle! } = import(random);\nshuffle!([\"apple\", \"banana\", \"cherry\"])`,\n ],\n seeAlso: ['random.random-sample!', 'random.random-sample-unique!'],\n },\n 'random-normal!': {\n category: 'random',\n description: 'Returns a random number from a normal distribution with the given mean and standard deviation.',\n returns: {\n type: 'number',\n },\n args: {\n mean: {\n type: 'number',\n description: 'The mean of the normal distribution.',\n },\n stdDev: {\n type: 'number',\n description: 'The standard deviation of the normal distribution.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'mean',\n 'stdDev',\n ],\n },\n ],\n examples: [\n `let { random-normal! } = import(random);\nrandom-normal!(0, 1)`,\n `let { random-normal! } = import(random);\nrandom-normal!(5, 2)`,\n ],\n seeAlso: ['random.random-exponential!', 'random.random-binomial!', 'random.random-poisson!'],\n hideOperatorForm: true,\n },\n 'random-exponential!': {\n category: 'random',\n description: 'Returns a random number from an exponential distribution with the given rate parameter.',\n returns: {\n type: 'number',\n },\n args: {\n lambda: {\n type: 'number',\n description: 'The rate parameter of the exponential distribution.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'lambda',\n ],\n },\n ],\n examples: [\n `let { random-exponential! } = import(random);\nrandom-exponential!(1)`,\n `let { random-exponential! } = import(random);\nrandom-exponential!(0.5)`,\n ],\n seeAlso: ['random.random-normal!', 'random.random-poisson!', 'random.random-gamma!', 'random.random-pareto!'],\n },\n 'random-binomial!': {\n category: 'random',\n description: 'Returns a random number from a binomial distribution with the given number of trials and probability of success.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number of trials.',\n },\n p: {\n type: 'number',\n description: 'The probability of success on each trial.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n 'p',\n ],\n },\n ],\n examples: [\n `let { random-binomial! } = import(random);\nrandom-binomial!(10, 0.5)`,\n `let { random-binomial! } = import(random);\nrandom-binomial!(20, 0.3)`,\n ],\n seeAlso: ['random.random-normal!', 'random.random-poisson!'],\n hideOperatorForm: true,\n },\n 'random-poisson!': {\n category: 'random',\n description: 'Returns a random number from a Poisson distribution with the given rate parameter.',\n returns: {\n type: 'integer',\n },\n args: {\n lambda: {\n type: 'number',\n description: 'The rate parameter of the Poisson distribution.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'lambda',\n ],\n },\n ],\n examples: [\n `let { random-poisson! } = import(random);\nrandom-poisson!(1)`,\n `let { random-poisson! } = import(random);\nrandom-poisson!(5)`,\n ],\n seeAlso: ['random.random-binomial!', 'random.random-normal!', 'random.random-exponential!'],\n },\n 'random-gamma!': {\n category: 'random',\n description: 'Returns a random number from a gamma distribution with the given shape and scale parameters.',\n returns: {\n type: 'number',\n },\n args: {\n shape: {\n type: 'number',\n description: 'The shape parameter of the gamma distribution.',\n },\n scale: {\n type: 'number',\n description: 'The scale parameter of the gamma distribution.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'shape',\n 'scale',\n ],\n },\n ],\n examples: [\n `let { random-gamma! } = import(random);\nrandom-gamma!(2, 2)`,\n `let { random-gamma! } = import(random);\nrandom-gamma!(5, 1)`,\n ],\n seeAlso: ['random.random-exponential!', 'random.random-pareto!'],\n hideOperatorForm: true,\n },\n 'random-pareto!': {\n category: 'random',\n description: 'Returns a random number from a Pareto distribution with the given shape parameter.',\n returns: {\n type: 'number',\n },\n args: {\n alpha: {\n type: 'number',\n description: 'The shape parameter of the Pareto distribution.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'alpha',\n ],\n },\n ],\n examples: [\n `let { random-pareto! } = import(random);\nrandom-pareto!(1)`,\n `let { random-pareto! } = import(random);\nrandom-pareto!(2)`,\n ],\n seeAlso: ['random.random-gamma!', 'random.random-exponential!'],\n },\n 'uuid!': {\n category: 'random',\n description: 'Returns a random UUID v4 (Universally Unique Identifier).',\n returns: {\n type: 'string',\n },\n args: {},\n variants: [\n {\n argumentNames: [],\n },\n ],\n examples: [\n `let { uuid! } = import(random);\nuuid!()`,\n ],\n seeAlso: ['random.random-id!', 'random.random-string!'],\n },\n 'random-char!': {\n category: 'random',\n description: 'Returns a random character from the given string.',\n returns: {\n type: 'string',\n },\n args: {\n charSet: {\n type: 'string',\n description: 'The string to sample from.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'charSet',\n ],\n },\n ],\n examples: [\n `let { random-char! } = import(random);\nrandom-char!(\"abcde\")`,\n `let { random-char! } = import(random);\nrandom-char!(\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\")`,\n ],\n seeAlso: ['random.random-string!', 'random.random-item!'],\n },\n 'random-string!': {\n category: 'random',\n description: 'Returns a random string of the given length from the given string.',\n returns: {\n type: 'string',\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the random string.',\n },\n charSet: {\n type: 'string',\n description: 'The string to sample from.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n 'charSet',\n ],\n },\n ],\n examples: [\n `let { random-string! } = import(random);\nrandom-string!(10, \"abcde\")`,\n `let { random-string! } = import(random);\nrandom-string!(5, \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\")`,\n ],\n seeAlso: ['random.random-char!', 'random.random-id!', 'random.uuid!'],\n hideOperatorForm: true,\n },\n 'random-id!': {\n category: 'random',\n description: 'Returns a random ID of the given length.',\n returns: {\n type: 'string',\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the random ID.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n `let { random-id! } = import(random);\nrandom-id!(10)`,\n `let { random-id! } = import(random);\nrandom-id!(5)`,\n ],\n seeAlso: ['random.random-string!', 'random.uuid!'],\n },\n 'random-color!': {\n category: 'random',\n description: 'Returns a random color in hex format.',\n returns: {\n type: 'string',\n },\n args: {},\n variants: [\n {\n argumentNames: [],\n },\n ],\n examples: [\n `let { random-color! } = import(random);\nrandom-color!()`,\n ],\n },\n}\n","import { DvalaError } from '../../../errors'\nimport type { Any, Arr } from '../../../interface'\nimport { assertArray } from '../../../typeGuards/array'\nimport { asAny } from '../../../typeGuards/dvala'\nimport { assertNumber } from '../../../typeGuards/number'\nimport { assertString } from '../../../typeGuards/string'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport type { DvalaModule } from '../interface'\nimport { moduleDocs } from './docs'\n\nconst randomFunctions: BuiltinNormalExpressions = {\n 'random!': {\n evaluate: (): number => {\n return Math.random()\n },\n pure: false,\n arity: toFixedArity(0),\n },\n 'random-int!': {\n evaluate: ([min, max], sourceCodeInfo): number => {\n assertNumber(min, sourceCodeInfo, { integer: true })\n assertNumber(max, sourceCodeInfo, { integer: true, gt: min })\n return Math.floor(Math.random() * (max - min)) + min\n },\n pure: false,\n arity: toFixedArity(2),\n },\n 'random-int-inclusive!': {\n evaluate: ([min, max], sourceCodeInfo): number => {\n assertNumber(min, sourceCodeInfo, { integer: true })\n assertNumber(max, sourceCodeInfo, { integer: true, gte: min })\n return Math.floor(Math.random() * (max - min + 1)) + min\n },\n pure: false,\n arity: toFixedArity(2),\n },\n 'random-float!': {\n evaluate: ([min, max], sourceCodeInfo): number => {\n assertNumber(min, sourceCodeInfo)\n assertNumber(max, sourceCodeInfo, { gt: min })\n return Math.random() * (max - min) + min\n },\n pure: false,\n arity: toFixedArity(2),\n },\n 'random-boolean!': {\n evaluate: ([prob], sourceCodeInfo): boolean => {\n const probability = prob ?? 0.5\n assertNumber(probability, sourceCodeInfo, { gte: 0, lte: 1 })\n return Math.random() < probability\n },\n pure: false,\n arity: { min: 0, max: 1 },\n },\n 'random-item!': {\n evaluate: ([array], sourceCodeInfo): Any => {\n assertArray(array, sourceCodeInfo)\n const index = Math.floor(Math.random() * array.length)\n return asAny(array[index])\n },\n pure: false,\n arity: toFixedArity(1),\n },\n 'random-sample!': {\n evaluate: ([array, n], sourceCodeInfo): Arr => {\n assertArray(array, sourceCodeInfo)\n assertNumber(n, sourceCodeInfo, { integer: true, nonNegative: true })\n if (array.length === 0) {\n throw new DvalaError('Cannot sample from an empty array.', sourceCodeInfo)\n }\n\n const result: Arr = []\n\n for (let i = 0; i < n; i++) {\n // Pick a random index from the array\n const randomIndex = Math.floor(Math.random() * array.length)\n // Add the randomly selected item to the result\n result.push(array[randomIndex])\n }\n\n return result\n },\n pure: false,\n arity: toFixedArity(2),\n },\n 'random-sample-unique!': {\n evaluate: ([array, n], sourceCodeInfo): Arr => {\n assertArray(array, sourceCodeInfo)\n assertNumber(n, sourceCodeInfo, { integer: true, nonNegative: true, lte: array.length })\n if (array.length === 0) {\n throw new DvalaError('Cannot sample from an empty array.', sourceCodeInfo)\n }\n const result: Arr = []\n\n const copyArray = [...array]\n for (let i = 0; i < n; i++) {\n // Pick a random index from the array\n const randomIndex = Math.floor(Math.random() * copyArray.length)\n // Add the randomly selected item to the result\n result.push(copyArray[randomIndex])\n // Remove the used item from the copy array\n copyArray.splice(randomIndex, 1)\n }\n\n return result\n },\n pure: false,\n arity: toFixedArity(2),\n },\n 'shuffle!': {\n evaluate: ([array], sourceCodeInfo): Arr => {\n assertArray(array, sourceCodeInfo)\n const shuffledArray = [...array]\n for (let i = shuffledArray.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1))\n ;[shuffledArray[i], shuffledArray[j]] = [shuffledArray[j], shuffledArray[i]]\n }\n return shuffledArray\n },\n pure: false,\n arity: toFixedArity(1),\n },\n 'random-normal!': {\n evaluate: ([mean, stdDev], sourceCodeInfo): number => {\n assertNumber(mean, sourceCodeInfo)\n assertNumber(stdDev, sourceCodeInfo, { gt: 0 })\n const u1 = Math.random()\n const u2 = Math.random()\n const z0 = Math.sqrt(-2.0 * Math.log(u1)) * Math.cos(2.0 * Math.PI * u2)\n return z0 * stdDev + mean\n },\n pure: false,\n arity: toFixedArity(2),\n },\n 'random-exponential!': {\n evaluate: ([lambda], sourceCodeInfo): number => {\n assertNumber(lambda, sourceCodeInfo, { gt: 0 })\n const u = Math.random()\n return -Math.log(u) / lambda\n },\n pure: false,\n arity: toFixedArity(1),\n },\n 'random-binomial!': {\n evaluate: ([n, p], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, nonNegative: true })\n assertNumber(p, sourceCodeInfo, { gte: 0, lte: 1 })\n let k = 0\n for (let i = 0; i < n; i++) {\n if (Math.random() < p) {\n k++\n }\n }\n return k\n },\n pure: false,\n arity: toFixedArity(2),\n },\n 'random-poisson!': {\n evaluate: ([lambda], sourceCodeInfo): number => {\n assertNumber(lambda, sourceCodeInfo, { gt: 0 })\n\n const L = Math.exp(-lambda)\n let k = 0\n let p = 1\n\n do {\n k++\n p *= Math.random()\n } while (p > L)\n\n return k - 1\n },\n pure: false,\n arity: toFixedArity(1),\n },\n 'random-gamma!': {\n evaluate: ([shape, scale], sourceCodeInfo): number => {\n assertNumber(shape, sourceCodeInfo, { gt: 0 })\n assertNumber(scale, sourceCodeInfo, { gt: 0 })\n return randomGamma(shape, scale)\n },\n pure: false,\n arity: toFixedArity(2),\n },\n 'random-pareto!': {\n evaluate: ([alpha], sourceCodeInfo): number => {\n assertNumber(alpha, sourceCodeInfo, { gt: 0 })\n const u = Math.random()\n return (1 / u) ** (1 / alpha)\n },\n pure: false,\n arity: toFixedArity(1),\n },\n 'uuid!': {\n evaluate: (): string => {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (char) => {\n const random = Math.random() * 16 | 0\n const value = char === 'x' ? random : (random & 0x3 | 0x8)\n return value.toString(16)\n })\n },\n pure: false,\n arity: toFixedArity(0),\n },\n 'random-char!': {\n evaluate: ([charSet], sourceCodeInfo): string => {\n assertString(charSet, sourceCodeInfo)\n if (charSet.length === 0) {\n throw new DvalaError('Character set cannot be empty.', sourceCodeInfo)\n }\n const randomIndex = Math.floor(Math.random() * charSet.length)\n return charSet[randomIndex]!\n },\n pure: false,\n arity: toFixedArity(1),\n },\n 'random-string!': {\n evaluate: ([length, charSet], sourceCodeInfo): string => {\n assertNumber(length, sourceCodeInfo, { integer: true, positive: true })\n assertString(charSet, sourceCodeInfo)\n if (charSet.length === 0) {\n throw new DvalaError('Character set cannot be empty.', sourceCodeInfo)\n }\n let result = ''\n for (let i = 0; i < length; i++) {\n const randomIndex = Math.floor(Math.random() * charSet.length)\n result += charSet[randomIndex]!\n }\n return result\n },\n pure: false,\n arity: toFixedArity(2),\n },\n 'random-id!': {\n evaluate: ([length], sourceCodeInfo): string => {\n assertNumber(length, sourceCodeInfo, { integer: true, positive: true })\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'\n let result = ''\n for (let i = 0; i < length; i++) {\n const randomIndex = Math.floor(Math.random() * chars.length)\n result += chars[randomIndex]!\n }\n return result\n },\n pure: false,\n arity: toFixedArity(1),\n },\n 'random-color!': {\n evaluate: (): string => {\n const randomColor = Math.floor(Math.random() * 0x1000000).toString(16)\n return `#${randomColor.padStart(6, '0')}`\n },\n pure: false,\n arity: toFixedArity(0),\n },\n}\n\n/**\n * Generates a random number from a gamma distribution\n * @param shape The shape parameter (alpha) - must be positive\n * @param scale The scale parameter (beta) - must be positive\n * @returns A random number following the gamma distribution\n */\nfunction randomGamma(shape: number, scale: number = 1): number {\n // Special case for shape < 1\n if (shape < 1) {\n const d = shape + 1.0 - 1.0 / 3.0\n return randomGamma(d, scale) * Math.random() ** (1.0 / shape)\n }\n\n // Marsaglia and Tsang method for shape >= 1\n const d = shape - 1.0 / 3.0\n const c = 1.0 / Math.sqrt(9.0 * d)\n\n let x: number, v: number, u: number\n\n while (true) {\n do {\n x = randn() // Standard normal random variable\n v = 1.0 + c * x\n } while (v <= 0)\n\n v = v * v * v\n u = Math.random()\n\n if (u < 1.0 - 0.0331 * x * x * x * x) {\n return scale * d * v\n }\n\n if (Math.log(u) < 0.5 * x * x + d * (1.0 - v + Math.log(v))) {\n return scale * d * v\n }\n }\n}\n\n/**\n * Helper function to generate standard normal random variables\n * using Box-Muller transform\n */\nfunction randn(): number {\n let u = 0\n let v = 0\n while (u === 0) u = Math.random()\n while (v === 0) v = Math.random()\n\n return Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v)\n}\n\nfor (const [key, docs] of Object.entries(moduleDocs)) {\n if (randomFunctions[key])\n randomFunctions[key].docs = docs\n}\n\nexport const randomModule: DvalaModule = {\n name: 'random',\n functions: randomFunctions,\n}\n","import type { FunctionDocs } from '../../interface'\n\nexport const moduleDocs: Record<string, FunctionDocs> = {\n 'moving-mean': {\n category: 'vector',\n description: 'Returns the **moving mean** of the `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving mean** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-mean } = import(vector);\\nmoving-mean([1, 2, 3, 4, 5], 3)',\n 'let { moving-mean } = import(vector);\\nmoving-mean([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['moving-fn', 'mean', 'vector.centered-moving-mean', 'vector.running-mean'],\n },\n 'centered-moving-mean': {\n category: 'vector',\n description: 'Returns the **centered moving mean** of the `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving mean** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the centered moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-mean } = import(vector);\\ncentered-moving-mean([1, 2, 3, 4, 5], 3)',\n 'let { centered-moving-mean } = import(vector);\\ncentered-moving-mean([1, 2, 3, 4, 5], 3, 0, 10)',\n 'let { centered-moving-mean } = import(vector);\\ncentered-moving-mean([1, 2, 3, 4, 5], 3, 10)',\n ],\n seeAlso: ['mean', 'vector.moving-mean', 'vector.running-mean'],\n },\n 'running-mean': {\n category: 'vector',\n description: 'Returns the **running mean** of the `vector`.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running mean** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-mean } = import(vector);\\nrunning-mean([1, 2, 3, 4, 5])',\n ],\n seeAlso: ['running-fn', 'mean', 'vector.moving-mean', 'vector.centered-moving-mean'],\n },\n 'geometric-mean': {\n category: 'vector',\n description: 'Returns the **geometric mean** of all elements in the `vector`.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **geometric mean** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { geometric-mean } = import(vector);\\ngeometric-mean([1, 2, 3])',\n 'let { geometric-mean } = import(vector);\\ngeometric-mean([1, 2, 9])',\n ],\n seeAlso: ['vector.moving-geometric-mean', 'vector.centered-moving-geometric-mean', 'vector.running-geometric-mean', 'mean', 'vector.harmonic-mean'],\n },\n 'moving-geometric-mean': {\n category: 'vector',\n description: 'Returns the **moving geometric mean** of the `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving geometric mean** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-geometric-mean } = import(vector);\\nmoving-geometric-mean([1, 2, 3, 4, 5], 3)',\n 'let { moving-geometric-mean } = import(vector);\\nmoving-geometric-mean([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['vector.geometric-mean', 'vector.centered-moving-geometric-mean', 'vector.running-geometric-mean'],\n },\n 'centered-moving-geometric-mean': {\n category: 'vector',\n description: 'Returns the **centered moving geometric mean** of the `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving geometric mean** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the centered moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-geometric-mean } = import(vector);\\ncentered-moving-geometric-mean([1, 2, 3, 4, 5], 3)',\n 'let { centered-moving-geometric-mean } = import(vector);\\ncentered-moving-geometric-mean([1, 2, 3, 4, 5], 3, 0, 10)',\n 'let { centered-moving-geometric-mean } = import(vector);\\ncentered-moving-geometric-mean([1, 2, 3, 4, 5], 3, 10)',\n ],\n seeAlso: ['vector.geometric-mean', 'vector.moving-geometric-mean', 'vector.running-geometric-mean'],\n },\n 'running-geometric-mean': {\n category: 'vector',\n description: 'Returns the **running geometric mean** of the `vector`.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running geometric mean** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-geometric-mean } = import(vector);\\nrunning-geometric-mean([1, 2, 3, 4, 5])',\n ],\n seeAlso: ['vector.geometric-mean', 'vector.moving-geometric-mean', 'vector.centered-moving-geometric-mean'],\n },\n 'harmonic-mean': {\n category: 'vector',\n description: 'Returns the **harmonic mean** of all elements in the `vector`.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **harmonic mean** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { harmonic-mean } = import(vector);\\nharmonic-mean([1, 2, 3])',\n 'let { harmonic-mean } = import(vector);\\nharmonic-mean([1, 2, 9])',\n ],\n seeAlso: ['vector.moving-harmonic-mean', 'vector.centered-moving-harmonic-mean', 'vector.running-harmonic-mean', 'mean', 'vector.geometric-mean'],\n },\n 'moving-harmonic-mean': {\n category: 'vector',\n description: 'Returns the **moving harmonic mean** of the `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving harmonic mean** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-harmonic-mean } = import(vector);\\nmoving-harmonic-mean([1, 2, 3, 4, 5], 3)',\n 'let { moving-harmonic-mean } = import(vector);\\nmoving-harmonic-mean([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['vector.harmonic-mean', 'vector.centered-moving-harmonic-mean', 'vector.running-harmonic-mean'],\n },\n 'centered-moving-harmonic-mean': {\n category: 'vector',\n description: 'Returns the **centered moving harmonic mean** of the `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving harmonic mean** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the centered moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-harmonic-mean } = import(vector);\\ncentered-moving-harmonic-mean([1, 2, 3, 4, 5], 3)',\n 'let { centered-moving-harmonic-mean } = import(vector);\\ncentered-moving-harmonic-mean([1, 2, 3, 4, 5], 3, 0, 10)',\n 'let { centered-moving-harmonic-mean } = import(vector);\\ncentered-moving-harmonic-mean([1, 2, 3, 4, 5], 3, 10)',\n ],\n seeAlso: ['vector.harmonic-mean', 'vector.moving-harmonic-mean', 'vector.running-harmonic-mean'],\n },\n 'running-harmonic-mean': {\n category: 'vector',\n description: 'Returns the **running harmonic mean** of the `vector`.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running harmonic mean** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-harmonic-mean } = import(vector);\\nrunning-harmonic-mean([1, 2, 3, 4, 5])',\n ],\n seeAlso: ['vector.harmonic-mean', 'vector.moving-harmonic-mean', 'vector.centered-moving-harmonic-mean'],\n },\n 'moving-median': {\n category: 'vector',\n description: 'Returns the **moving median** of the `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving median** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-median } = import(vector);\\nmoving-median([1, 2, 3, 4, 5], 3)',\n 'let { moving-median } = import(vector);\\nmoving-median([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['median', 'vector.centered-moving-median', 'vector.running-median'],\n },\n 'centered-moving-median': {\n category: 'vector',\n description: 'Returns the **centered moving median** of the `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving median** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the centered moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-median } = import(vector);\\ncentered-moving-median([1, 2, 3, 4, 5], 3)',\n 'let { centered-moving-median } = import(vector);\\ncentered-moving-median([1, 2, 3, 4, 5], 3, 0, 10)',\n 'let { centered-moving-median } = import(vector);\\ncentered-moving-median([1, 2, 3, 4, 5], 3, 10)',\n ],\n seeAlso: ['median', 'vector.moving-median', 'vector.running-median'],\n },\n 'running-median': {\n category: 'vector',\n description: 'Returns the **running median** of the `vector`.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running median** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-median } = import(vector);\\nrunning-median([1, 2, 3, 4, 5])',\n ],\n seeAlso: ['median', 'vector.moving-median', 'vector.centered-moving-median'],\n },\n 'variance': {\n category: 'vector',\n description: 'Returns the **variance** of all elements in the `vector`.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **variance** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { variance } = import(vector);\\nvariance([1, 2, 3])',\n 'let { variance } = import(vector);\\nvariance([1, 2, -3])',\n ],\n seeAlso: ['linear-algebra.cov', 'vector.moving-variance', 'vector.centered-moving-variance', 'vector.running-variance', 'vector.stdev', 'vector.sample-variance', 'vector.mad'],\n },\n 'moving-variance': {\n category: 'vector',\n description: 'Returns the **moving variance** of the `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving variance** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-variance } = import(vector);\\nmoving-variance([1, 2, 3, 4, 5], 3)',\n 'let { moving-variance } = import(vector);\\nmoving-variance([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['vector.variance', 'vector.centered-moving-variance', 'vector.running-variance'],\n },\n 'centered-moving-variance': {\n category: 'vector',\n description: 'Returns the **centered moving variance** of the `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving variance** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the centered moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-variance } = import(vector);\\ncentered-moving-variance([1, 2, 3, 4, 5], 3)',\n 'let { centered-moving-variance } = import(vector);\\ncentered-moving-variance([1, 2, 3, 4, 5], 3, 1)',\n 'let { centered-moving-variance } = import(vector);\\ncentered-moving-variance([1, 2, 3, 4, 5], 3, 1, 5)',\n 'let { centered-moving-variance } = import(vector);\\ncentered-moving-variance([1, 2, 3, 4, 5], 3, 0, 6)',\n ],\n seeAlso: ['vector.variance', 'vector.moving-variance', 'vector.running-variance'],\n },\n 'running-variance': {\n category: 'vector',\n description: 'Returns the **running variance** of the `vector`.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running variance** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-variance } = import(vector);\\nrunning-variance([1, 2, 3, 4, 5])',\n ],\n seeAlso: ['vector.variance', 'vector.moving-variance', 'vector.centered-moving-variance'],\n },\n 'sample-variance': {\n category: 'vector',\n description: 'Returns the sample variance of all elements in the vector.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'Non emtpy vector to calculate the sample variance of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { sample-variance } = import(vector);\\nsample-variance([1, 2, 3])',\n 'let { sample-variance } = import(vector);\\nsample-variance([1, 2, -3])',\n 'let { sample-variance } = import(vector);\\nsample-variance([1, 2, 3, 4])',\n 'let { sample-variance } = import(vector);\\nsample-variance([1, 2, -3, 4])',\n 'let { sample-variance } = import(vector);\\nsample-variance([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['vector.moving-sample-variance', 'vector.centered-moving-sample-variance', 'vector.running-sample-variance', 'vector.variance', 'vector.sample-stdev'],\n },\n 'moving-sample-variance': {\n category: 'vector',\n description: 'Returns the **moving sample variance** of the `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving sample variance** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-sample-variance } = import(vector);\\nmoving-sample-variance([1, 2, 3, 4, 5], 3)',\n 'let { moving-sample-variance } = import(vector);\\nmoving-sample-variance([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['vector.sample-variance', 'vector.centered-moving-sample-variance', 'vector.running-sample-variance'],\n },\n 'centered-moving-sample-variance': {\n category: 'vector',\n description: 'Returns the **centered moving sample variance** of the `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving sample variance** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the centered moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-sample-variance } = import(vector);\\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3)',\n 'let { centered-moving-sample-variance } = import(vector);\\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3, 1)',\n 'let { centered-moving-sample-variance } = import(vector);\\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3, 1, 5)',\n 'let { centered-moving-sample-variance } = import(vector);\\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3, 0, 6)',\n ],\n seeAlso: ['vector.sample-variance', 'vector.moving-sample-variance', 'vector.running-sample-variance'],\n },\n 'running-sample-variance': {\n category: 'vector',\n description: 'Returns the **running sample variance** of the `vector`.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n 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.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-sample-variance } = import(vector);\\nrunning-sample-variance([1, 2, 3, 4, 5])',\n ],\n seeAlso: ['vector.sample-variance', 'vector.moving-sample-variance', 'vector.centered-moving-sample-variance'],\n },\n 'stdev': {\n category: 'vector',\n description: 'Returns the standard deviation of all elements in the vector.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'Non emtpy vector to calculate the standard deviation of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { stdev } = import(vector);\\nstdev([1, 2, 3])',\n 'let { stdev } = import(vector);\\nstdev([1, 2, -3])',\n 'let { stdev } = import(vector);\\nstdev([1, 2, 3, 4])',\n 'let { stdev } = import(vector);\\nstdev([1, 2, -3, 4])',\n 'let { stdev } = import(vector);\\nstdev([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['vector.moving-stdev', 'vector.centered-moving-stdev', 'vector.running-stdev', 'vector.variance', 'vector.sample-stdev', 'vector.rms', 'vector.mad'],\n },\n 'moving-stdev': {\n category: 'vector',\n description: 'Returns the **moving standard deviation** of the `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving standard deviation** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-stdev } = import(vector);\\nmoving-stdev([1, 2, 3, 4, 5], 3)',\n 'let { moving-stdev } = import(vector);\\nmoving-stdev([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['vector.stdev', 'vector.centered-moving-stdev', 'vector.running-stdev'],\n },\n 'centered-moving-stdev': {\n category: 'vector',\n description: 'Returns the **centered moving standard deviation** of the `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving standard deviation** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the centered moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-stdev } = import(vector);\\ncentered-moving-stdev([1, 2, 3, 4, 5], 3)',\n 'let { centered-moving-stdev } = import(vector);\\ncentered-moving-stdev([1, 2, 3, 4, 5], 3, 1)',\n 'let { centered-moving-stdev } = import(vector);\\ncentered-moving-stdev([1, 2, 3, 4, 5], 3, 1, 5)',\n 'let { centered-moving-stdev } = import(vector);\\ncentered-moving-stdev([1, 2, 3, 4, 5], 3, 0, 6)',\n ],\n seeAlso: ['vector.stdev', 'vector.moving-stdev', 'vector.running-stdev'],\n },\n 'running-stdev': {\n category: 'vector',\n description: 'Returns the **running standard deviation** of the `vector`.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running standard deviation** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-stdev } = import(vector);\\nrunning-stdev([1, 2, 3, 4, 5])',\n ],\n seeAlso: ['vector.stdev', 'vector.moving-stdev', 'vector.centered-moving-stdev'],\n },\n 'sample-stdev': {\n category: 'vector',\n description: 'Returns the sample standard deviation of all elements in the vector.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'Non emtpy vector to calculate the sample standard deviation of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { sample-stdev } = import(vector);\\nsample-stdev([1, 2, 3])',\n 'let { sample-stdev } = import(vector);\\nsample-stdev([1, 2, -3])',\n 'let { sample-stdev } = import(vector);\\nsample-stdev([1, 2, 3, 4])',\n 'let { sample-stdev } = import(vector);\\nsample-stdev([1, 2, -3, 4])',\n 'let { sample-stdev } = import(vector);\\nsample-stdev([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['vector.moving-sample-stdev', 'vector.centered-moving-sample-stdev', 'vector.running-sample-stdev', 'vector.stdev', 'vector.sample-variance'],\n },\n 'moving-sample-stdev': {\n category: 'vector',\n description: 'Returns the **moving sample standard deviation** of the `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving sample standard deviation** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-sample-stdev } = import(vector);\\nmoving-sample-stdev([1, 2, 3, 4, 5], 3)',\n 'let { moving-sample-stdev } = import(vector);\\nmoving-sample-stdev([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['vector.sample-stdev', 'vector.centered-moving-sample-stdev', 'vector.running-sample-stdev'],\n },\n 'centered-moving-sample-stdev': {\n category: 'vector',\n description: 'Returns the **centered moving sample standard deviation** of the `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving sample standard deviation** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the centered moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-sample-stdev } = import(vector);\\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3)',\n 'let { centered-moving-sample-stdev } = import(vector);\\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3, 1)',\n 'let { centered-moving-sample-stdev } = import(vector);\\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3, 1, 5)',\n 'let { centered-moving-sample-stdev } = import(vector);\\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3, 0, 6)',\n ],\n seeAlso: ['vector.sample-stdev', 'vector.moving-sample-stdev', 'vector.running-sample-stdev'],\n },\n 'running-sample-stdev': {\n category: 'vector',\n description: 'Returns the **running sample standard deviation** of the `vector`.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n 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.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-sample-stdev } = import(vector);\\nrunning-sample-stdev([1, 2, 3, 4, 5])',\n ],\n seeAlso: ['vector.sample-stdev', 'vector.moving-sample-stdev', 'vector.centered-moving-sample-stdev'],\n },\n 'iqr': {\n category: 'vector',\n description: 'Calculates the **interquartile range** of a `vector`. Returns the difference between the third and first quartiles.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **interquartile range** of. Minimum length is 4.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { iqr } = import(vector);\\niqr([1, 2, 3, 4])',\n 'let { iqr } = import(vector);\\niqr([5, 4, 3, 2, 1, 2, 3, 4, 5])',\n 'let { iqr } = import(vector);\\niqr(range(1, 1000))',\n 'let { iqr } = import(vector);\\niqr(map(range(1000), -> 1e6 / ($ + 1) ^ 2))',\n 'let { iqr } = import(vector);\\nlet { ln } = import(math);\\niqr(map(range(1000), -> ln($ + 1)))',\n ],\n seeAlso: ['vector.moving-iqr', 'vector.centered-moving-iqr', 'vector.running-iqr', 'vector.quartiles', 'median', 'vector.mad', 'vector.medad', 'vector.outliers?', 'vector.outliers'],\n },\n 'moving-iqr': {\n category: 'vector',\n description: 'Calculates the **moving interquartile range** of a `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving interquartile range** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-iqr } = import(vector);\\nmoving-iqr([1, 2, 4, 7, 11, 16], 4)',\n 'let { moving-iqr } = import(vector);\\nmoving-iqr([1, 2, 4, 7, 11, 16], 5)',\n 'let { moving-iqr } = import(vector);\\nmoving-iqr([1, 2, 4, 7, 11, 16], 6)',\n ],\n seeAlso: ['vector.iqr', 'vector.centered-moving-iqr', 'vector.running-iqr'],\n },\n 'centered-moving-iqr': {\n category: 'vector',\n description: 'Calculates the **centered moving interquartile range** of a `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving interquartile range** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-iqr } = import(vector);\\ncentered-moving-iqr([1, 2, 4, 7, 11, 16], 4)',\n 'let { centered-moving-iqr } = import(vector);\\ncentered-moving-iqr([1, 2, 4, 7, 11, 16], 4, 0, 0)',\n ],\n seeAlso: ['vector.iqr', 'vector.moving-iqr', 'vector.running-iqr'],\n },\n 'running-iqr': {\n category: 'vector',\n 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.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running interquartile range** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-iqr } = import(vector);\\nrunning-iqr([1, 2, 3, 4, 5, 6])',\n 'let { running-iqr } = import(vector);\\nrunning-iqr([-1, -2, -3, 1, 2, 3])',\n ],\n seeAlso: ['vector.iqr', 'vector.moving-iqr', 'vector.centered-moving-iqr'],\n },\n 'moving-sum': {\n category: 'vector',\n description: 'Returns the **moving sum** of the `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving sum** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-sum } = import(vector);\\nmoving-sum([1, 2, 3, 4, 5], 3)',\n 'let { moving-sum } = import(vector);\\nmoving-sum([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['sum', 'vector.centered-moving-sum', 'vector.running-sum'],\n },\n 'centered-moving-sum': {\n category: 'vector',\n description: 'Returns the **centered moving sum** of the `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving sum** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the centered moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-sum } = import(vector);\\ncentered-moving-sum([1, 2, 3, 4, 5], 3)',\n 'let { centered-moving-sum } = import(vector);\\ncentered-moving-sum([1, 2, 3, 4, 5], 3, 0, 0)',\n 'let { centered-moving-sum } = import(vector);\\ncentered-moving-sum([1, 2, 3, 4, 5], 3, 10)',\n ],\n seeAlso: ['sum', 'vector.moving-sum', 'vector.running-sum'],\n },\n 'running-sum': {\n category: 'vector',\n description: 'Returns the **running sum** of the `vector`.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running sum** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-sum } = import(vector);\\nrunning-sum([1, 2, 3])',\n 'let { running-sum } = import(vector);\\nrunning-sum([1, -2, -3])',\n ],\n seeAlso: ['sum', 'vector.moving-sum', 'vector.centered-moving-sum', 'vector.cumsum'],\n },\n 'moving-prod': {\n category: 'vector',\n description: 'Returns the **moving product** of the `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving product** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-prod } = import(vector);\\nmoving-prod([1, 2, 3, 4, 5], 3)',\n 'let { moving-prod } = import(vector);\\nmoving-prod([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['prod', 'vector.centered-moving-prod', 'vector.running-prod'],\n },\n 'centered-moving-prod': {\n category: 'vector',\n description: 'Returns the **centered moving product** of the `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving product** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-prod } = import(vector);\\ncentered-moving-prod([1, 2, 3, 4, 5], 3)',\n 'let { centered-moving-prod } = import(vector);\\ncentered-moving-prod([1, 2, 3, 4, 5], 3, 0, 0)',\n ],\n seeAlso: ['prod', 'vector.moving-prod', 'vector.running-prod'],\n },\n 'running-prod': {\n category: 'vector',\n description: 'Returns the **running product** of the `vector`.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running product** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-prod } = import(vector);\\nrunning-prod([1, 2, 3, 4, 5])',\n 'let { running-prod } = import(vector);\\nrunning-prod([1, -2, -3])',\n ],\n seeAlso: ['prod', 'vector.moving-prod', 'vector.centered-moving-prod', 'vector.cumprod'],\n },\n 'span': {\n category: 'vector',\n description: 'Returns the difference between the maximum and minimum values in a vector.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The vector to calculate the span of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { span } = import(vector);\\nspan([1, 2, 3])',\n 'let { span } = import(vector);\\nspan([1, 1, 2, 3, 3])',\n 'let { span } = import(vector);\\nspan([1, 2, -3])',\n ],\n seeAlso: ['vector.moving-span', 'vector.centered-moving-span', 'vector.running-span', 'min', 'max'],\n },\n 'moving-span': {\n category: 'vector',\n description: 'Calculates the **moving span** of a `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving span** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-span } = import(vector);\\nmoving-span([1, 2, 4, 7, 11, 16], 4)',\n 'let { moving-span } = import(vector);\\nmoving-span([1, 2, 4, 7, 11, 16], 5)',\n 'let { moving-span } = import(vector);\\nmoving-span([1, 2, 4, 7, 11, 16], 6)',\n ],\n seeAlso: ['vector.span', 'vector.centered-moving-span', 'vector.running-span'],\n },\n 'centered-moving-span': {\n category: 'vector',\n 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.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving span** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'The value to pad the result with on the left.',\n },\n rightPadding: {\n type: 'number',\n description: 'The value to pad the result with on the right.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-span } = import(vector);\\ncentered-moving-span([1, 2, 4, 7, 11, 16], 4)',\n 'let { centered-moving-span } = import(vector);\\ncentered-moving-span([1, 2, 4, 7, 11, 16], 3, 0, 100)',\n ],\n seeAlso: ['vector.span', 'vector.moving-span', 'vector.running-span'],\n },\n 'running-span': {\n category: 'vector',\n description: 'Calculates the **running span** of a `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running span** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-span } = import(vector);\\nrunning-span([1, 2, 4])',\n ],\n seeAlso: ['vector.span', 'vector.moving-span', 'vector.centered-moving-span'],\n },\n 'skewness': {\n category: 'vector',\n description: 'Calculates the **skewness** of a `vector`. Returns the third standardized moment.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **skewness** of. Minimum length is 3.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { skewness } = import(vector);\\nskewness([1, 2, 3, 6, 20])',\n 'let { skewness } = import(vector);\\nskewness([1, 2, 2, 3])',\n ],\n seeAlso: ['vector.moving-skewness', 'vector.centered-moving-skewness', 'vector.running-skewness', 'vector.kurtosis', 'vector.sample-skewness', 'vector.excess-kurtosis'],\n },\n 'moving-skewness': {\n category: 'vector',\n description: 'Calculates the **moving skewness** of a `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving skewness** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-skewness } = import(vector);\\nmoving-skewness([1, 2, 4, 7, 11, 16], 4)',\n 'let { moving-skewness } = import(vector);\\nmoving-skewness([1, 2, 4, 7, 11, 16], 5)',\n ],\n seeAlso: ['vector.skewness', 'vector.centered-moving-skewness', 'vector.running-skewness'],\n },\n 'centered-moving-skewness': {\n category: 'vector',\n description: 'Calculates the **centered moving skewness** of a `vector` with a given window size and padding.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving skewness** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-skewness } = import(vector);\\ncentered-moving-skewness([1, 2, 4, 7, 11, 16], 4)',\n 'let { centered-moving-skewness } = import(vector);\\ncentered-moving-skewness([1, 2, 4, 7, 11, 16], 4, 0, 0)',\n ],\n seeAlso: ['vector.skewness', 'vector.moving-skewness', 'vector.running-skewness'],\n },\n 'running-skewness': {\n category: 'vector',\n 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.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running skewness** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-skewness } = import(vector);\\nrunning-skewness([1, 2, 4, 7, 11])',\n ],\n seeAlso: ['vector.skewness', 'vector.moving-skewness', 'vector.centered-moving-skewness'],\n },\n 'sample-skewness': {\n category: 'vector',\n description: 'Calculates the **sample skewness** of a `vector`. Returns the third standardized moment.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **sample skewness** of. Minimum length is 3.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { sample-skewness } = import(vector);\\nsample-skewness([1, 2, 3, 6, 20])',\n 'let { sample-skewness } = import(vector);\\nsample-skewness([1, 2, 2, 3])',\n ],\n seeAlso: ['vector.moving-sample-skewness', 'vector.centered-moving-sample-skewness', 'vector.running-sample-skewness', 'vector.skewness', 'vector.sample-kurtosis'],\n },\n 'moving-sample-skewness': {\n category: 'vector',\n description: 'Calculates the **moving sample skewness** of a `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving sample skewness** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-sample-skewness } = import(vector);\\nmoving-sample-skewness([1, 2, 4, 7, 11, 16], 4)',\n 'let { moving-sample-skewness } = import(vector);\\nmoving-sample-skewness([1, 2, 4, 7, 11, 16], 5)',\n ],\n seeAlso: ['vector.sample-skewness', 'vector.centered-moving-sample-skewness', 'vector.running-sample-skewness'],\n },\n 'centered-moving-sample-skewness': {\n category: 'vector',\n description: 'Calculates the **centered moving sample skewness** of a `vector` with a given window size and padding.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving sample skewness** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-sample-skewness } = import(vector);\\ncentered-moving-sample-skewness([1, 2, 4, 7, 11, 16], 4)',\n 'let { centered-moving-sample-skewness } = import(vector);\\ncentered-moving-sample-skewness([1, 2, 4, 7, 11, 16], 3, 0, 100)',\n ],\n seeAlso: ['vector.sample-skewness', 'vector.moving-sample-skewness', 'vector.running-sample-skewness'],\n },\n 'running-sample-skewness': {\n category: 'vector',\n 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.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running sample skewness** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-sample-skewness } = import(vector);\\nrunning-sample-skewness([1, 2, 4, 7, 11])',\n ],\n seeAlso: ['vector.sample-skewness', 'vector.moving-sample-skewness', 'vector.centered-moving-sample-skewness'],\n },\n 'excess-kurtosis': {\n category: 'vector',\n description: 'Calculates the **excess kurtosis** of a `vector`. Returns the third standardized moment.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **excess kurtosis** of. Minimum length is 3.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { excess-kurtosis } = import(vector);\\nexcess-kurtosis([1, 2, 3, 6, 20])',\n 'let { excess-kurtosis } = import(vector);\\nexcess-kurtosis([1, 2, 2, 3])',\n ],\n seeAlso: ['vector.moving-excess-kurtosis', 'vector.centered-moving-excess-kurtosis', 'vector.running-excess-kurtosis', 'vector.kurtosis', 'vector.sample-excess-kurtosis', 'vector.skewness'],\n },\n 'moving-excess-kurtosis': {\n category: 'vector',\n description: 'Calculates the **moving excess kurtosis** of a `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving excess kurtosis** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-excess-kurtosis } = import(vector);\\nmoving-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)',\n 'let { moving-excess-kurtosis } = import(vector);\\nmoving-excess-kurtosis([1, 2, 4, 7, 11, 16], 5)',\n ],\n seeAlso: ['vector.excess-kurtosis', 'vector.centered-moving-excess-kurtosis', 'vector.running-excess-kurtosis'],\n },\n 'centered-moving-excess-kurtosis': {\n category: 'vector',\n description: 'Calculates the **centered moving excess kurtosis** of a `vector` with a given window size and padding.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving excess kurtosis** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-excess-kurtosis } = import(vector);\\ncentered-moving-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)',\n 'let { centered-moving-excess-kurtosis } = import(vector);\\ncentered-moving-excess-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 0)',\n ],\n seeAlso: ['vector.excess-kurtosis', 'vector.moving-excess-kurtosis', 'vector.running-excess-kurtosis'],\n },\n 'running-excess-kurtosis': {\n category: 'vector',\n 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.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running excess kurtosis** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-excess-kurtosis } = import(vector);\\nrunning-excess-kurtosis([1, 2, 4, 7, 11])',\n ],\n seeAlso: ['vector.excess-kurtosis', 'vector.moving-excess-kurtosis', 'vector.centered-moving-excess-kurtosis'],\n },\n 'kurtosis': {\n category: 'vector',\n description: 'Calculates the **kurtosis** of a `vector`. Returns the third standardized moment.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **kurtosis** of. Minimum length is 3.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { kurtosis } = import(vector);\\nkurtosis([1, 2, 3, 6, 20])',\n 'let { kurtosis } = import(vector);\\nkurtosis([1, 2, 2, 3])',\n ],\n seeAlso: ['vector.moving-kurtosis', 'vector.centered-moving-kurtosis', 'vector.running-kurtosis', 'vector.excess-kurtosis', 'vector.sample-kurtosis', 'vector.skewness'],\n },\n 'moving-kurtosis': {\n category: 'vector',\n description: 'Calculates the **moving kurtosis** of a `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving kurtosis** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-kurtosis } = import(vector);\\nmoving-kurtosis([1, 2, 4, 7, 11, 16], 4)',\n 'let { moving-kurtosis } = import(vector);\\nmoving-kurtosis([1, 2, 4, 7, 11, 16], 5)',\n ],\n seeAlso: ['vector.kurtosis', 'vector.centered-moving-kurtosis', 'vector.running-kurtosis'],\n },\n 'centered-moving-kurtosis': {\n category: 'vector',\n description: 'Calculates the **centered moving kurtosis** of a `vector` with a given window size and padding.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving kurtosis** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-kurtosis } = import(vector);\\ncentered-moving-kurtosis([1, 2, 4, 7, 11, 16], 4)',\n 'let { centered-moving-kurtosis } = import(vector);\\ncentered-moving-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 0)',\n ],\n seeAlso: ['vector.kurtosis', 'vector.moving-kurtosis', 'vector.running-kurtosis'],\n },\n 'running-kurtosis': {\n category: 'vector',\n 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.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running kurtosis** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-kurtosis } = import(vector);\\nrunning-kurtosis([1, 2, 4, 7, 11])',\n ],\n seeAlso: ['vector.kurtosis', 'vector.moving-kurtosis', 'vector.centered-moving-kurtosis'],\n },\n 'sample-excess-kurtosis': {\n category: 'vector',\n description: 'Calculates the **sample excess kurtosis** of a `vector`. Returns the third standardized moment.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **sample excess kurtosis** of. Minimum length is 3.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { sample-excess-kurtosis } = import(vector);\\nsample-excess-kurtosis([1, 2, 3, 6, 20])',\n 'let { sample-excess-kurtosis } = import(vector);\\nsample-excess-kurtosis([1, 2, 2, 3])',\n ],\n seeAlso: ['vector.moving-sample-excess-kurtosis', 'vector.centered-moving-sample-excess-kurtosis', 'vector.running-sample-excess-kurtosis', 'vector.sample-kurtosis', 'vector.excess-kurtosis'],\n },\n 'moving-sample-excess-kurtosis': {\n category: 'vector',\n description: 'Calculates the **moving sample excess kurtosis** of a `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving sample excess kurtosis** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-sample-excess-kurtosis } = import(vector);\\nmoving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)',\n 'let { moving-sample-excess-kurtosis } = import(vector);\\nmoving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 5)',\n ],\n seeAlso: ['vector.sample-excess-kurtosis', 'vector.centered-moving-sample-excess-kurtosis', 'vector.running-sample-excess-kurtosis'],\n },\n 'centered-moving-sample-excess-kurtosis': {\n category: 'vector',\n description: 'Calculates the **centered moving sample excess kurtosis** of a `vector` with a given window size and padding.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving sample excess kurtosis** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-sample-excess-kurtosis } = import(vector);\\ncentered-moving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)',\n 'let { centered-moving-sample-excess-kurtosis } = import(vector);\\ncentered-moving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 100)',\n ],\n seeAlso: ['vector.sample-excess-kurtosis', 'vector.moving-sample-excess-kurtosis', 'vector.running-sample-excess-kurtosis'],\n },\n 'running-sample-excess-kurtosis': {\n category: 'vector',\n 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.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running sample excess kurtosis** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-sample-excess-kurtosis } = import(vector);\\nrunning-sample-excess-kurtosis([1, 2, 4, 7, 11])',\n ],\n seeAlso: ['vector.sample-excess-kurtosis', 'vector.moving-sample-excess-kurtosis', 'vector.centered-moving-sample-excess-kurtosis'],\n },\n 'sample-kurtosis': {\n category: 'vector',\n description: 'Calculates the **sample kurtosis** of a `vector`. Returns the third standardized moment.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **sample kurtosis** of. Minimum length is 3.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { sample-kurtosis } = import(vector);\\nsample-kurtosis([1, 2, 3, 6, 20])',\n 'let { sample-kurtosis } = import(vector);\\nsample-kurtosis([1, 2, 2, 3])',\n ],\n seeAlso: ['vector.moving-sample-kurtosis', 'vector.centered-moving-sample-kurtosis', 'vector.running-sample-kurtosis', 'vector.sample-excess-kurtosis', 'vector.kurtosis', 'vector.sample-skewness'],\n },\n 'moving-sample-kurtosis': {\n category: 'vector',\n description: 'Calculates the **moving sample kurtosis** of a `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving sample kurtosis** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-sample-kurtosis } = import(vector);\\nmoving-sample-kurtosis([1, 2, 4, 7, 11, 16], 4)',\n 'let { moving-sample-kurtosis } = import(vector);\\nmoving-sample-kurtosis([1, 2, 4, 7, 11, 16], 5)',\n ],\n seeAlso: ['vector.sample-kurtosis', 'vector.centered-moving-sample-kurtosis', 'vector.running-sample-kurtosis'],\n },\n 'centered-moving-sample-kurtosis': {\n category: 'vector',\n description: 'Calculates the **centered moving sample kurtosis** of a `vector` with a given window size and padding.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving sample kurtosis** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-sample-kurtosis } = import(vector);\\ncentered-moving-sample-kurtosis([1, 2, 4, 7, 11, 16], 4)',\n 'let { centered-moving-sample-kurtosis } = import(vector);\\ncentered-moving-sample-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 100)',\n ],\n seeAlso: ['vector.sample-kurtosis', 'vector.moving-sample-kurtosis', 'vector.running-sample-kurtosis'],\n },\n 'running-sample-kurtosis': {\n category: 'vector',\n 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.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running sample kurtosis** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-sample-kurtosis } = import(vector);\\nrunning-sample-kurtosis([1, 2, 4, 7, 11])',\n ],\n seeAlso: ['vector.sample-kurtosis', 'vector.moving-sample-kurtosis', 'vector.centered-moving-sample-kurtosis'],\n },\n 'rms': {\n category: 'vector',\n description: 'Calculates the **root mean square** of a `vector`. Returns the square root of the average of the squares of the elements.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **root mean square** of. Minimum length is 1.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { rms } = import(vector);\\nrms([1, 2, 3, 4])',\n 'let { rms } = import(vector);\\nrms([5, 4, 3, 2, 1])',\n 'let { rms } = import(vector);\\nrms(range(1, 1000))',\n 'let { rms } = import(vector);\\nrms(map(range(1000), -> 1e6 / ($ + 1) ^ 2))',\n 'let { rms } = import(vector);\\nlet { ln } = import(math);\\nrms(map(range(1000), -> ln($ + 1)))',\n ],\n seeAlso: ['vector.moving-rms', 'vector.centered-moving-rms', 'vector.running-rms', 'mean', 'vector.stdev'],\n },\n 'moving-rms': {\n category: 'vector',\n description: 'Calculates the **moving root mean square** of a `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving root mean square** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-rms } = import(vector);\\nmoving-rms([1, 2, 4, 7, 11, 16], 4)',\n 'let { moving-rms } = import(vector);\\nmoving-rms([1, 2, 4, 7, 11, 16], 5)',\n 'let { moving-rms } = import(vector);\\nmoving-rms([1, 2, 4, 7, 11, 16], 6)',\n ],\n seeAlso: ['vector.rms', 'vector.centered-moving-rms', 'vector.running-rms'],\n },\n 'centered-moving-rms': {\n category: 'vector',\n description: 'Calculates the **centered moving root mean square** of a `vector` with a given window size and padding value.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving root mean square** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-rms } = import(vector);\\ncentered-moving-rms([1, 2, 4, 7, 11, 16], 4)',\n 'let { centered-moving-rms } = import(vector);\\ncentered-moving-rms([1, 2, 4, 7, 11, 16], 5, 0)',\n 'let { centered-moving-rms } = import(vector);\\ncentered-moving-rms([1, 2, 4, 7, 11, 16], 6, 0, 0)',\n ],\n seeAlso: ['vector.rms', 'vector.moving-rms', 'vector.running-rms'],\n },\n 'running-rms': {\n category: 'vector',\n description: 'Calculates the **running root mean square** of a `vector`.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running root mean square** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-rms } = import(vector);\\nrunning-rms([1, 2, 3, 4, 5, 6])',\n 'let { running-rms } = import(vector);\\nrunning-rms([1, -3, 2])',\n 'let { running-rms } = import(vector);\\nrunning-rms([-1, -2, -3])',\n 'let { running-rms } = import(vector);\\nrunning-rms([0])',\n ],\n seeAlso: ['vector.rms', 'vector.moving-rms', 'vector.centered-moving-rms'],\n },\n 'mad': {\n category: 'vector',\n description: 'Returns the **mean absolute deviation** of all elements in the `vector`.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **mean absolute deviation** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { mad } = import(vector);\\nmad([1, 2, 3])',\n 'let { mad } = import(vector);\\nmad([1, 2, -3])',\n ],\n seeAlso: ['vector.moving-mad', 'vector.centered-moving-mad', 'vector.running-mad', 'vector.medad', 'vector.stdev', 'vector.variance', 'vector.iqr'],\n },\n 'moving-mad': {\n category: 'vector',\n description: 'Returns the **moving mean absolute deviation** of the `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving mean absolute deviation** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-mad } = import(vector);\\nmoving-mad([1, 2, 3, 4, 5], 3)',\n 'let { moving-mad } = import(vector);\\nmoving-mad([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['vector.mad', 'vector.centered-moving-mad', 'vector.running-mad'],\n },\n 'centered-moving-mad': {\n category: 'vector',\n description: 'Returns the **centered moving mean absolute deviation** of the `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving mean absolute deviation** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-mad } = import(vector);\\ncentered-moving-mad([1, 2, 3, 4, 5], 3)',\n 'let { centered-moving-mad } = import(vector);\\ncentered-moving-mad([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['vector.mad', 'vector.moving-mad', 'vector.running-mad'],\n },\n 'running-mad': {\n category: 'vector',\n description: 'Returns the **running mean absolute deviation** of the `vector`.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running mean absolute deviation** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-mad } = import(vector);\\nrunning-mad([1, 2, 3])',\n 'let { running-mad } = import(vector);\\nrunning-mad([1, 2, -3])',\n ],\n seeAlso: ['vector.mad', 'vector.moving-mad', 'vector.centered-moving-mad'],\n },\n 'medad': {\n category: 'vector',\n description: 'Returns the **median absolute deviation** of all elements in the `vector`.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **median absolute deviation** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { medad } = import(vector);\\nmedad([1, 2, 3])',\n 'let { medad } = import(vector);\\nmedad([1, 2, -3])',\n ],\n seeAlso: ['vector.moving-medad', 'vector.centered-moving-medad', 'vector.running-medad', 'vector.mad', 'median', 'vector.iqr'],\n },\n 'moving-medad': {\n category: 'vector',\n description: 'Returns the **moving median absolute deviation** of the `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving median absolute deviation** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-medad } = import(vector);\\nmoving-medad([1, 2, 3, 4, 5], 3)',\n 'let { moving-medad } = import(vector);\\nmoving-medad([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['vector.medad', 'vector.centered-moving-medad', 'vector.running-medad'],\n },\n 'centered-moving-medad': {\n category: 'vector',\n description: 'Returns the **centered moving median absolute deviation** of the `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving median absolute deviation** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-medad } = import(vector);\\ncentered-moving-medad([1, 2, 3, 4, 5], 3)',\n 'let { centered-moving-medad } = import(vector);\\ncentered-moving-medad([1, 2, 3, 4, 5], 5)',\n ],\n seeAlso: ['vector.medad', 'vector.moving-medad', 'vector.running-medad'],\n },\n 'running-medad': {\n category: 'vector',\n description: 'Returns the **running median absolute deviation** of the `vector`.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running median absolute deviation** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-medad } = import(vector);\\nrunning-medad([1, 2, 3])',\n 'let { running-medad } = import(vector);\\nrunning-medad([1, 2, -3])',\n ],\n seeAlso: ['vector.medad', 'vector.moving-medad', 'vector.centered-moving-medad'],\n },\n 'gini-coefficient': {\n category: 'vector',\n description: 'Returns the **gini coefficient** of all elements in the `vector`.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **gini coefficient** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { gini-coefficient } = import(vector);\\ngini-coefficient([1, 2, 3])',\n 'let { gini-coefficient } = import(vector);\\ngini-coefficient([1, 1, 3])',\n ],\n seeAlso: ['vector.moving-gini-coefficient', 'vector.centered-moving-gini-coefficient', 'vector.running-gini-coefficient', 'vector.entropy'],\n },\n 'moving-gini-coefficient': {\n category: 'vector',\n description: 'Returns the **moving gini coefficient** of the `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving gini coefficient** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-gini-coefficient } = import(vector);\\nmoving-gini-coefficient([1, 2, 3], 2)',\n 'let { moving-gini-coefficient } = import(vector);\\nmoving-gini-coefficient([1, 1, 3], 2)',\n ],\n seeAlso: ['vector.gini-coefficient', 'vector.centered-moving-gini-coefficient', 'vector.running-gini-coefficient'],\n },\n 'centered-moving-gini-coefficient': {\n category: 'vector',\n description: 'Returns the **centered moving gini coefficient** of the `vector` with a given window size.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving gini coefficient** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-gini-coefficient } = import(vector);\\ncentered-moving-gini-coefficient([1, 2, 3], 2)',\n 'let { centered-moving-gini-coefficient } = import(vector);\\ncentered-moving-gini-coefficient([1, 1, 3], 2)',\n ],\n seeAlso: ['vector.gini-coefficient', 'vector.moving-gini-coefficient', 'vector.running-gini-coefficient'],\n },\n 'running-gini-coefficient': {\n category: 'vector',\n description: 'Returns the **running gini coefficient** of the `vector`.',\n returns: {\n type: 'array',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running gini coefficient** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-gini-coefficient } = import(vector);\\nrunning-gini-coefficient([1, 2, 3])',\n 'let { running-gini-coefficient } = import(vector);\\nrunning-gini-coefficient([1, 1, 3])',\n ],\n seeAlso: ['vector.gini-coefficient', 'vector.moving-gini-coefficient', 'vector.centered-moving-gini-coefficient'],\n },\n 'entropy': {\n category: 'vector',\n description: 'Calculates the **entropy** of a `vector`. The entropy is a measure of the uncertainty associated with a random variable.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **entropy** of. Minimum length is 1.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { entropy } = import(vector);\\nentropy([1, 1, 2, 3, 3, 3])',\n 'let { entropy } = import(vector);\\nentropy([1, 2, 3])',\n 'let { entropy } = import(vector);\\nentropy([1, 2, 2, 3])',\n 'let { entropy } = import(vector);\\nentropy([0])',\n 'let { entropy } = import(vector);\\nentropy([1])',\n 'let { entropy } = import(vector);\\nentropy([1, 2])',\n ],\n seeAlso: ['vector.moving-entropy', 'vector.centered-moving-entropy', 'vector.running-entropy', 'vector.gini-coefficient'],\n },\n 'moving-entropy': {\n category: 'vector',\n description: 'Calculates the **moving entropy** of a `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **moving entropy** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n ],\n examples: [\n 'let { moving-entropy } = import(vector);\\nmoving-entropy([1, 1, 2, 3, 3, 3], 4)',\n 'let { moving-entropy } = import(vector);\\nmoving-entropy([1, 1, 2, 3, 3, 3], 3)',\n 'let { moving-entropy } = import(vector);\\nmoving-entropy([1, 2], 2)',\n ],\n seeAlso: ['vector.entropy', 'vector.centered-moving-entropy', 'vector.running-entropy'],\n },\n 'centered-moving-entropy': {\n category: 'vector',\n description: 'Calculates the **centered moving entropy** of a `vector` with a given window size.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **centered moving entropy** of.',\n },\n windowSize: {\n type: 'integer',\n description: 'The size of the moving window.',\n },\n leftPadding: {\n type: 'number',\n description: 'Optional value to use for padding. Default is `null`.',\n },\n rightPadding: {\n type: 'number',\n description: 'Optional value to use for right padding. Default is `null`.',\n },\n a: {\n type: 'vector',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'windowSize',\n 'leftPadding',\n 'rightPadding',\n ],\n },\n ],\n examples: [\n 'let { centered-moving-entropy } = import(vector);\\ncentered-moving-entropy([1, 1, 2, 3, 3, 3], 4)',\n 'let { centered-moving-entropy } = import(vector);\\ncentered-moving-entropy([1, 1, 2, 3, 3, 3], 3)',\n 'let { centered-moving-entropy } = import(vector);\\ncentered-moving-entropy([1, 2], 2)',\n ],\n seeAlso: ['vector.entropy', 'vector.moving-entropy', 'vector.running-entropy'],\n },\n 'running-entropy': {\n category: 'vector',\n description: 'Calculates the **running entropy** of a `vector`.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to calculate the **running entropy** of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { running-entropy } = import(vector);\\nrunning-entropy([1, 1, 2, 3, 3, 3])',\n 'let { running-entropy } = import(vector);\\nrunning-entropy([1, 2])',\n ],\n seeAlso: ['vector.entropy', 'vector.moving-entropy', 'vector.centered-moving-entropy'],\n },\n 'monotonic?': {\n category: 'vector',\n description: 'Checks if a vector is monotonic.',\n returns: {\n type: 'boolean',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The vector to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { monotonic? } = import(vector);\\nmonotonic?([1, 2, 3])',\n 'let { monotonic? } = import(vector);\\nmonotonic?([1, 2, 2, 3])',\n 'let { monotonic? } = import(vector);\\nmonotonic?([3, 2, 1])',\n 'let { monotonic? } = import(vector);\\nmonotonic?([3, 2, 1, 1])',\n 'let { monotonic? } = import(vector);\\nmonotonic?([3, 2, 1, 2])',\n 'let { monotonic? } = import(vector);\\nmonotonic?([1])',\n 'let { monotonic? } = import(vector);\\nmonotonic?([])',\n ],\n seeAlso: ['vector.strictly-monotonic?', 'vector.increasing?', 'vector.decreasing?'],\n },\n 'strictly-monotonic?': {\n category: 'vector',\n description: 'Checks if a vector is strictly monotonic.',\n returns: {\n type: 'boolean',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The vector to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { strictly-monotonic? } = import(vector);\\nstrictly-monotonic?([1, 2, 3])',\n 'let { strictly-monotonic? } = import(vector);\\nstrictly-monotonic?([1, 2, 2, 3])',\n 'let { strictly-monotonic? } = import(vector);\\nstrictly-monotonic?([3, 2, 1])',\n 'let { strictly-monotonic? } = import(vector);\\nstrictly-monotonic?([3, 2, 1, 1])',\n 'let { strictly-monotonic? } = import(vector);\\nstrictly-monotonic?([3, 2, 1, 2])',\n 'let { strictly-monotonic? } = import(vector);\\nstrictly-monotonic?([1])',\n 'let { strictly-monotonic? } = import(vector);\\nstrictly-monotonic?([])',\n ],\n seeAlso: ['vector.monotonic?', 'vector.strictly-increasing?', 'vector.strictly-decreasing?'],\n },\n 'increasing?': {\n category: 'vector',\n description: 'Checks if a vector is increasing.',\n returns: {\n type: 'boolean',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The vector to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { increasing? } = import(vector);\\nincreasing?([1, 2, 3])',\n 'let { increasing? } = import(vector);\\nincreasing?([1, 2, 2, 3])',\n 'let { increasing? } = import(vector);\\nincreasing?([3, 2, 1])',\n 'let { increasing? } = import(vector);\\nincreasing?([3, 2, 1, 1])',\n 'let { increasing? } = import(vector);\\nincreasing?([3, 2, 1, 2])',\n 'let { increasing? } = import(vector);\\nincreasing?([1])',\n 'let { increasing? } = import(vector);\\nincreasing?([])',\n ],\n seeAlso: ['vector.strictly-increasing?', 'vector.decreasing?', 'vector.strictly-decreasing?', 'vector.monotonic?'],\n },\n 'decreasing?': {\n category: 'vector',\n description: 'Checks if a vector is decreasing.',\n returns: {\n type: 'boolean',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The vector to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { decreasing? } = import(vector);\\ndecreasing?([1, 2, 3])',\n 'let { decreasing? } = import(vector);\\ndecreasing?([1, 2, 2, 3])',\n 'let { decreasing? } = import(vector);\\ndecreasing?([3, 2, 1])',\n 'let { decreasing? } = import(vector);\\ndecreasing?([3, 2, 1, 1])',\n 'let { decreasing? } = import(vector);\\ndecreasing?([3, 2, 1, 2])',\n 'let { decreasing? } = import(vector);\\ndecreasing?([1])',\n 'let { decreasing? } = import(vector);\\ndecreasing?([])',\n ],\n seeAlso: ['vector.strictly-decreasing?', 'vector.increasing?', 'vector.strictly-increasing?', 'vector.monotonic?'],\n },\n 'strictly-increasing?': {\n category: 'vector',\n description: 'Checks if a vector is strictly increasing.',\n returns: {\n type: 'boolean',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The vector to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { strictly-increasing? } = import(vector);\\nstrictly-increasing?([1, 2, 3])',\n 'let { strictly-increasing? } = import(vector);\\nstrictly-increasing?([1, 2, 2, 3])',\n 'let { strictly-increasing? } = import(vector);\\nstrictly-increasing?([3, 2, 1])',\n 'let { strictly-increasing? } = import(vector);\\nstrictly-increasing?([3, 2, 1, 1])',\n 'let { strictly-increasing? } = import(vector);\\nstrictly-increasing?([3, 2, 1, 2])',\n 'let { strictly-increasing? } = import(vector);\\nstrictly-increasing?([1])',\n 'let { strictly-increasing? } = import(vector);\\nstrictly-increasing?([])',\n ],\n seeAlso: ['vector.increasing?', 'vector.decreasing?', 'vector.strictly-decreasing?', 'vector.strictly-monotonic?'],\n },\n 'strictly-decreasing?': {\n category: 'vector',\n description: 'Checks if a vector is strictly decreasing.',\n returns: {\n type: 'boolean',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The vector to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { strictly-decreasing? } = import(vector);\\nstrictly-decreasing?([1, 2, 3])',\n 'let { strictly-decreasing? } = import(vector);\\nstrictly-decreasing?([1, 2, 2, 3])',\n 'let { strictly-decreasing? } = import(vector);\\nstrictly-decreasing?([3, 2, 1])',\n 'let { strictly-decreasing? } = import(vector);\\nstrictly-decreasing?([3, 2, 1, 1])',\n 'let { strictly-decreasing? } = import(vector);\\nstrictly-decreasing?([3, 2, 1, 2])',\n 'let { strictly-decreasing? } = import(vector);\\nstrictly-decreasing?([1])',\n 'let { strictly-decreasing? } = import(vector);\\nstrictly-decreasing?([])',\n ],\n seeAlso: ['vector.increasing?', 'vector.strictly-increasing?', 'vector.decreasing?', 'vector.strictly-monotonic?'],\n },\n 'mode': {\n category: 'vector',\n description: 'Returns the mode of all elements in the vector.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The vector to calculate the mode of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { mode } = import(vector);\\nmode([1, 2, 3])',\n 'let { mode } = import(vector);\\nmode([1, 2, -3, 1])',\n 'let { mode } = import(vector);\\nmode([2, 2, 3, 3, 4])',\n 'let { mode } = import(vector);\\nmode([2, 2, 3, 3])',\n 'let { mode } = import(vector);\\nmode([1, 2, 3, 2, 1, 2])',\n ],\n seeAlso: ['mean', 'median'],\n },\n 'min-index': {\n category: 'vector',\n description: 'Returns the index of the minimum value of all elements in the vector.',\n returns: {\n type: 'integer',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'Non emtpy vector to calculate the minimum index of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { min-index } = import(vector);\\nmin-index([1, 2, 3])',\n 'let { min-index } = import(vector);\\nmin-index([1, 1, 2, 3, 3])',\n 'let { min-index } = import(vector);\\nmin-index([1, 2, -3])',\n 'let { min-index } = import(vector);\\nmin-index([1, 2, 3, 4])',\n 'let { min-index } = import(vector);\\nmin-index([1, 2, -3, 4])',\n ],\n seeAlso: ['vector.max-index', 'min'],\n },\n 'max-index': {\n category: 'vector',\n description: 'Returns the index of the maximum value of all elements in the vector.',\n returns: {\n type: 'integer',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'Non emtpy vector to calculate the maximum index of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { max-index } = import(vector);\\nmax-index([1, 2, 3])',\n 'let { max-index } = import(vector);\\nmax-index([1, 1, 2, 3, 3])',\n 'let { max-index } = import(vector);\\nmax-index([1, 2, -3])',\n 'let { max-index } = import(vector);\\nmax-index([1, 2, 3, 4])',\n 'let { max-index } = import(vector);\\nmax-index([1, 2, -3, 4])',\n ],\n seeAlso: ['vector.min-index', 'max'],\n },\n 'sort-indices': {\n category: 'vector',\n description: 'Returns the indices of the elements in the vector sorted in ascending order.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'Non emtpy vector to calculate the sorted indices of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { sort-indices } = import(vector);\\nsort-indices([1, 2, 3])',\n 'let { sort-indices } = import(vector);\\nsort-indices([1, 1, 2, 3, 3])',\n 'let { sort-indices } = import(vector);\\nsort-indices([1, 2, -3])',\n 'let { sort-indices } = import(vector);\\nsort-indices([1, 2, 3, 4])',\n 'let { sort-indices } = import(vector);\\nsort-indices([1, 2, -3, 4])',\n ],\n seeAlso: ['sort'],\n },\n 'count-values': {\n category: 'vector',\n description: 'Counts the number of occurrences of each value in the vector.',\n returns: {\n type: 'number',\n array: true,\n },\n args: {\n vector: {\n type: 'vector',\n description: 'Vector to count the values of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { count-values } = import(vector);\\ncount-values([1, 2, 3])',\n 'let { count-values } = import(vector);\\ncount-values([1, 1, 2, 3, 3])',\n 'let { count-values } = import(vector);\\ncount-values([1, 2, -3])',\n 'let { count-values } = import(vector);\\ncount-values([1, 2, 2, 1, 3, 2, 4, 2, 1, 2, 2, 1, 3, 2, 4])',\n ],\n seeAlso: ['sequence.frequencies', 'vector.bincount'],\n },\n 'linspace': {\n category: 'vector',\n description: 'Generates a vector of evenly spaced numbers between two values.',\n returns: {\n type: 'number',\n array: true,\n },\n args: {\n start: {\n type: 'number',\n description: 'The starting value.',\n },\n stop: {\n type: 'number',\n description: 'The ending value.',\n },\n n: {\n type: 'integer',\n description: 'The number of values to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'start',\n 'stop',\n 'n',\n ],\n },\n ],\n examples: [\n 'let { linspace } = import(vector);\\nlinspace(0, 10, 6)',\n 'let { linspace } = import(vector);\\nlinspace(10, 20, 25)',\n ],\n seeAlso: [\n 'range',\n ],\n },\n 'cumsum': {\n category: 'vector',\n description: 'Calculates the cumulative sum of a vector.',\n returns: {\n type: 'number',\n array: true,\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The vector to calculate the cumulative sum of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { cumsum } = import(vector);\\ncumsum([1, 2, 3])',\n 'let { cumsum } = import(vector);\\ncumsum([1, 2, -3])',\n 'let { cumsum } = import(vector);\\ncumsum([])',\n ],\n seeAlso: ['vector.cumprod', 'sum', 'vector.running-sum'],\n },\n 'cumprod': {\n category: 'vector',\n description: 'Calculates the cumulative product of a vector.',\n returns: {\n type: 'number',\n array: true,\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The vector to calculate the cumulative product of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { cumprod } = import(vector);\\ncumprod([1, 2, 3])',\n 'let { cumprod } = import(vector);\\ncumprod([1, 2, -3, 0, 10])',\n 'let { cumprod } = import(vector);\\ncumprod([])',\n ],\n seeAlso: ['vector.cumsum', 'prod', 'vector.running-prod'],\n },\n 'quartiles': {\n category: 'vector',\n description: 'Calculates the quartiles of a vector. Returns an array containing the first, second (median), and third quartiles.',\n returns: {\n type: 'number',\n array: true,\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The vector to calculate the quartiles of. Minimum length is 4.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { quartiles } = import(vector);\\nquartiles([1, 2, 3, 4])',\n 'let { quartiles } = import(vector);\\nquartiles([5, 4, 3, 2, 1, 2, 3, 4, 5])',\n 'let { quartiles } = import(vector);\\nquartiles(range(1, 1000))',\n 'let { quartiles } = import(vector);\\nquartiles(map(range(1000), -> 1e6 / ($ + 1) ^ 2))',\n 'let { quartiles } = import(vector);\\nlet { ln } = import(math);\\nquartiles(map(range(1000), -> ln($ + 1)))',\n ],\n seeAlso: ['vector.percentile', 'vector.quantile', 'median', 'vector.iqr'],\n },\n 'percentile': {\n category: 'vector',\n description: 'Calculates the percentile of a vector. Returns the value at the specified percentile.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The non empty vector to calculate the percentile of.',\n },\n percentile: {\n type: 'number',\n description: 'The percentile to calculate. Must be between 0 and 1.',\n },\n a: {\n type: 'number',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'percentile',\n ],\n },\n ],\n examples: [\n 'let { percentile } = import(vector);\\npercentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 35)',\n 'let { percentile } = import(vector);\\npercentile(range(100) ^ 0.5, 0)',\n 'let { percentile } = import(vector);\\npercentile(range(100) ^ 0.5, 10)',\n 'let { percentile } = import(vector);\\npercentile(range(100) ^ 0.5, 20)',\n 'let { percentile } = import(vector);\\npercentile(range(100) ^ 0.5, 30)',\n 'let { percentile } = import(vector);\\npercentile(range(100) ^ 0.5, 40)',\n 'let { percentile } = import(vector);\\npercentile(range(100) ^ 0.5, 50)',\n 'let { percentile } = import(vector);\\npercentile(range(100) ^ 0.5, 60)',\n 'let { percentile } = import(vector);\\npercentile(range(100) ^ 0.5, 70)',\n 'let { percentile } = import(vector);\\npercentile(range(100) ^ 0.5, 80)',\n 'let { percentile } = import(vector);\\npercentile(range(100) ^ 0.5, 90)',\n 'let { percentile } = import(vector);\\npercentile(range(100) ^ 0.5, 100)',\n ],\n seeAlso: ['vector.quantile', 'vector.quartiles', 'median', 'vector.ecdf', 'vector.winsorize'],\n },\n 'quantile': {\n category: 'vector',\n description: 'Calculates the quantile of a vector. Returns the value at the specified quantile.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The non empty vector to calculate the quantile of.',\n },\n quantile: {\n type: 'number',\n description: 'The quantile to calculate. Must be between 0 and 1.',\n },\n a: {\n type: 'number',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'quantile',\n ],\n },\n ],\n examples: [\n 'let { quantile } = import(vector);\\nquantile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0.35)',\n 'let { quantile } = import(vector);\\nquantile(range(100) ^ 0.5, 0)',\n 'let { quantile } = import(vector);\\nquantile(range(100) ^ 0.5, 0.1)',\n 'let { quantile } = import(vector);\\nquantile(range(100) ^ 0.5, 0.2)',\n 'let { quantile } = import(vector);\\nquantile(range(100) ^ 0.5, 0.3)',\n 'let { quantile } = import(vector);\\nquantile(range(100) ^ 0.5, 0.4)',\n 'let { quantile } = import(vector);\\nquantile(range(100) ^ 0.5, 0.5)',\n 'let { quantile } = import(vector);\\nquantile(range(100) ^ 0.5, 0.6)',\n 'let { quantile } = import(vector);\\nquantile(range(100) ^ 0.5, 0.7)',\n 'let { quantile } = import(vector);\\nquantile(range(100) ^ 0.5, 0.8)',\n 'let { quantile } = import(vector);\\nquantile(range(100) ^ 0.5, 0.9)',\n 'let { quantile } = import(vector);\\nquantile(range(100) ^ 0.5, 1)',\n ],\n seeAlso: ['vector.percentile', 'vector.quartiles', 'vector.ecdf'],\n },\n 'histogram': {\n category: 'vector',\n 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.',\n returns: {\n type: 'array',\n array: true,\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The numeric array to create a histogram from.',\n },\n bins: {\n type: 'integer',\n description: 'The number of bins to divide the data range into.',\n },\n a: {\n type: 'number',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'bins',\n ],\n },\n ],\n examples: [\n 'let { histogram } = import(vector);\\nhistogram([1, 2, 2, 3, 2, 6, 4, 3, 2, 4, 1, 3, 2, 9], 3)',\n 'let { histogram } = import(vector);\\nhistogram([1, 2, 3, 4, 5], 5)',\n 'let { histogram } = import(vector);\\nhistogram([1, 2, 3, 4, 5], 10)',\n 'let { histogram } = import(vector);\\nhistogram([1, 2, 3, 4, 5], 1)',\n ],\n seeAlso: ['vector.bincount', 'vector.ecdf'],\n },\n 'ecdf': {\n category: 'vector',\n 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.',\n returns: {\n type: 'number',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The numeric array to calculate the ECDF from.',\n },\n threshold: {\n type: 'number',\n description: 'The threshold value to calculate the ECDF for.',\n },\n a: {\n type: 'number',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'threshold',\n ],\n },\n ],\n examples: [\n 'let { ecdf } = import(vector);\\necdf([1, 2, 2, 3, 2, 6, 4, 3, 2, 4, 1, 3, 2, 9, 10, 12], 5)',\n 'let { ecdf } = import(vector);\\necdf([1, 2, 3, 4, 5], 3)',\n 'let { ecdf } = import(vector);\\necdf([1, 2, 3, 4, 5], 0)',\n 'let { ecdf } = import(vector);\\necdf([1, 2, 3, 4, 5], 10)',\n 'let { ecdf } = import(vector);\\necdf([1, 2, 3, 4, 5], 2)',\n ],\n seeAlso: ['vector.histogram', 'vector.percentile', 'vector.quantile'],\n },\n 'outliers?': {\n category: 'vector',\n description: 'Checks if the `vector` contains outliers based on the interquartile range (IQR) method. Returns `true` if outliers are present, `false` otherwise.',\n returns: {\n type: 'boolean',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to check for outliers.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { outliers? } = import(vector);\\noutliers?([1, 2, 3])',\n 'let { outliers? } = import(vector);\\noutliers?([1, 2, -3])',\n 'let { outliers? } = import(vector);\\noutliers?([1, 2, 3, 2, 4, 120])',\n ],\n seeAlso: ['vector.outliers', 'vector.winsorize', 'vector.iqr'],\n },\n 'outliers': {\n category: 'vector',\n description: 'Identifies outliers in the `vector` based on the interquartile range (IQR) method. Returns an array of outlier values.',\n returns: {\n type: 'number',\n array: true,\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The `vector` to check for outliers.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { outliers } = import(vector);\\noutliers([1, 2, 3])',\n 'let { outliers } = import(vector);\\noutliers([1, 2, -3])',\n 'let { outliers } = import(vector);\\noutliers([1, 2, 3, 2, 4, 120])',\n ],\n seeAlso: ['vector.outliers?', 'vector.winsorize', 'vector.iqr'],\n },\n 'bincount': {\n category: 'vector',\n 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**.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'The vector to count occurrences in.',\n },\n minSize: {\n type: 'integer',\n description: 'Optional minimum size of the output array.',\n },\n weights: {\n type: 'number',\n array: true,\n description: 'Optional weights for each element in the vector.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'minSize',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'minSize',\n 'weights',\n ],\n },\n ],\n examples: [\n 'let { bincount } = import(vector);\\nbincount([1, 2, 3])',\n 'let { bincount } = import(vector);\\nbincount([1, 2, 2, 3, 3])',\n ],\n seeAlso: ['vector.count-values', 'vector.histogram'],\n hideOperatorForm: true,\n },\n 'winsorize': {\n category: 'vector',\n 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.',\n returns: {\n type: 'vector',\n },\n args: {\n 'vector': {\n type: 'vector',\n description: 'The vector to winsorize.',\n },\n 'lower-quantile': {\n type: 'number',\n description: 'The lower quantile threshold (between 0 and 1).',\n },\n 'upper-quantile': {\n type: 'number',\n description: 'Optional Upper quantile threshold (between 0 and 1). Defaults to `(1 - lower-quantile)` if `lower-quantile <= 0.5` otherwise `1`.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'lower-quantile',\n ],\n },\n {\n argumentNames: [\n 'vector',\n 'lower-quantile',\n 'upper-quantile',\n ],\n },\n ],\n examples: [\n 'let { winsorize } = import(vector);\\nwinsorize([2, 5, 8, 10, 15, 18, 20, 35, 60, 100], 0.25)',\n 'let { winsorize } = import(vector);\\nwinsorize([2, 5, 8, 10, 15, 18, 20, 35, 60, 100], 0.25, 0.75)',\n 'let { winsorize } = import(vector);\\nwinsorize([2, 5, 8, 10, 15, 18, 20, 35, 60, 100], 0.25, 0.5)',\n ],\n seeAlso: ['vector.outliers', 'vector.outliers?', 'vector.percentile'],\n hideOperatorForm: true,\n },\n 'mse': {\n category: 'vector',\n description: 'Calculates the **Mean Squared Error (MSE)** between two vectors. Returns the average of the squared differences between corresponding elements.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n description: 'The first vector.',\n },\n b: {\n type: 'vector',\n description: 'The second vector.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { mse } = import(vector);\\nmse([1, 2, 3], [1, 2, 3])',\n 'let { mse } = import(vector);\\nmse([1, 2, 3], [4, 5, 6])',\n 'let { mse } = import(vector);\\nmse([1, 2, 3], [2, 2, 2])',\n 'let { mse } = import(vector);\\nmse([1, 2], [3, 3])',\n 'let { mse } = import(vector);\\nmse([1], [3])',\n ],\n seeAlso: ['vector.rmse', 'vector.mae', 'vector.smape'],\n },\n 'rmse': {\n category: 'vector',\n 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.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n description: 'The first vector.',\n },\n b: {\n type: 'vector',\n description: 'The second vector.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { rmse } = import(vector);\\nrmse([1, 2, 3], [1, 2, 3])',\n 'let { rmse } = import(vector);\\nrmse([1, 2, 3], [4, 5, 6])',\n 'let { rmse } = import(vector);\\nrmse([1, 2, 3], [2, 2, 2])',\n 'let { rmse } = import(vector);\\nrmse([1, 2], [3, 3])',\n 'let { rmse } = import(vector);\\nrmse([1], [3])',\n ],\n seeAlso: ['vector.mse', 'vector.mae', 'vector.smape'],\n },\n 'mae': {\n category: 'vector',\n description: 'Calculates the **Mean Absolute Error (MAE)** between two vectors. Returns the average of the absolute differences between corresponding elements.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n description: 'The first vector.',\n },\n b: {\n type: 'vector',\n description: 'The second vector.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { mae } = import(vector);\\nmae([1, 2, 3], [1, 2, 3])',\n 'let { mae } = import(vector);\\nmae([1, 2, 3], [4, 5, 6])',\n 'let { mae } = import(vector);\\nmae([1, 2, 3], [2, 2, 2])',\n 'let { mae } = import(vector);\\nmae([1, 2], [3, 3])',\n 'let { mae } = import(vector);\\nmae([1], [3])',\n ],\n seeAlso: ['vector.mse', 'vector.rmse', 'vector.smape'],\n },\n 'smape': {\n category: 'vector',\n description: 'Calculates the **Symmetric Mean Absolute Percentage Error (SMAPE)** between two vectors. Returns the average of the absolute percentage differences between corresponding elements.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n description: 'The first vector.',\n },\n b: {\n type: 'vector',\n description: 'The second vector.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { smape } = import(vector);\\nsmape([1, 2, 3], [1, 2, 3])',\n 'let { smape } = import(vector);\\nsmape([1, 2, 3], [4, 5, 6])',\n 'let { smape } = import(vector);\\nsmape([1, 2, 3], [2, 2, 2])',\n 'let { smape } = import(vector);\\nsmape([1, 2], [3, 3])',\n 'let { smape } = import(vector);\\nsmape([1], [3])',\n ],\n seeAlso: ['vector.mse', 'vector.rmse', 'vector.mae'],\n },\n}\n","/**\n * Checks if a vector has no extreme outliers using the IQR method\n * @param vector An array of numbers to check for extreme outliers\n * @returns true if there are no extreme outliers, false otherwise\n */\nexport function hasOutliers(vector: number[]): boolean {\n return outliers(vector).length > 0\n}\n\nexport function outliers(vector: number[]): number[] {\n // Handle edge cases\n if (vector.length <= 1)\n return []\n\n // Sort the vector to calculate quartiles\n const sorted = [...vector].sort((a, b) => a - b)\n\n // Calculate Q1 (25th percentile)\n const q1Index = Math.floor(sorted.length * 0.25)\n const q1 = sorted.length % 4 === 0\n ? (sorted[q1Index - 1]! + sorted[q1Index]!) / 2\n : sorted[q1Index]!\n\n // Calculate Q3 (75th percentile)\n const q3Index = Math.floor(sorted.length * 0.75)\n const q3 = sorted.length % 4 === 0\n ? (sorted[q3Index - 1]! + sorted[q3Index]!) / 2\n : sorted[q3Index]!\n\n // Calculate IQR (Interquartile Range)\n const iqr = q3 - q1\n\n // Define bounds for outliers (using 1.5*IQR for mild outliers and 3*IQR for extreme outliers)\n const lowerBound = q1 - iqr * 1.5\n const upperBound = q3 + iqr * 1.5\n\n // Filter the vector to find outliers\n return vector.filter(val => val < lowerBound || val > upperBound)\n}\n","/**\n * Calculate the percentile value from an array of numbers\n * @param data Array of numbers to calculate percentile from\n * @param percentile The percentile to calculate (0-100)\n * @returns The value at the specified percentile\n */\nexport function calcPercentile(data: number[], percentile: number): number {\n // Sort the data in ascending order\n const sortedData = [...data].sort((a, b) => a - b)\n\n // If percentile is 0, return the minimum value\n if (percentile === 0) {\n return sortedData[0]!\n }\n\n // If percentile is 100, return the maximum value\n if (percentile === 100) {\n return sortedData[sortedData.length - 1]!\n }\n\n // Calculate the index\n const index = (percentile / 100) * (sortedData.length - 1)\n\n // If index is an integer, return the value at that index\n if (Number.isInteger(index)) {\n return sortedData[index]!\n }\n\n // Otherwise, interpolate between the two adjacent values\n const lowerIndex = Math.floor(index)\n const upperIndex = Math.ceil(index)\n const weight = index - lowerIndex\n\n return sortedData[lowerIndex]! * (1 - weight) + sortedData[upperIndex]! * weight\n}\n","export function quartiles(vector: number[]): [number, number, number] {\n const sorted = [...vector].sort((a, b) => a - b)\n\n // Median calculation (Q2)\n const midIndex = sorted.length / 2\n let q2: number\n if (sorted.length % 2 === 0) {\n // Even length - average the two middle values\n q2 = (sorted[midIndex - 1]! + sorted[midIndex]!) / 2\n }\n else {\n // Odd length - take the middle value\n q2 = sorted[Math.floor(midIndex)]!\n }\n\n // Lower half for Q1\n const lowerHalf = sorted.slice(0, Math.floor(sorted.length / 2))\n // Upper half for Q3\n const upperHalf = sorted.slice(Math.ceil(sorted.length / 2))\n\n // Calculate Q1 and Q3 using the same median logic on the halves\n let q1: number, q3: number\n\n if (lowerHalf.length % 2 === 0) {\n const midLower = lowerHalf.length / 2\n q1 = (lowerHalf[midLower - 1]! + lowerHalf[midLower]!) / 2\n }\n else {\n q1 = lowerHalf[Math.floor(lowerHalf.length / 2)]!\n }\n\n if (upperHalf.length % 2 === 0) {\n const midUpper = upperHalf.length / 2\n q3 = (upperHalf[midUpper - 1]! + upperHalf[midUpper]!) / 2\n }\n else {\n q3 = upperHalf[Math.floor(upperHalf.length / 2)]!\n }\n\n return [q1, q2, q3]\n}\n","export function calcMean(vector: number[]): number {\n if (vector.length === 0) {\n return 0\n }\n\n const sum = vector.reduce((acc, val) => acc + val, 0)\n return sum / vector.length\n}\n","import { calcMean } from '../calcMean'\nimport type { ReductionFunctionDefinition } from '.'\n\nexport const meanReductionFunction: ReductionFunctionDefinition<'mean'> = {\n mean: vector => calcMean(vector),\n}\n\nexport const geometricMeanReductionFunction: ReductionFunctionDefinition<'geometric-mean'> = {\n 'geometric-mean': (vector) => {\n if (vector.some(val => val < 0)) {\n throw new Error('Geometric mean is not defined for non-positive numbers')\n }\n return Math.exp(vector.reduce((acc, val) => acc + Math.log(val), 0) / vector.length)\n },\n}\n\nexport const harmonicMeanReductionFunction: ReductionFunctionDefinition<'harmonic-mean'> = {\n 'harmonic-mean': vector => vector.length / vector.reduce((acc, val) => acc + 1 / val, 0),\n}\n","export function calcMedian(vector: number[]): number {\n const sorted = [...vector].sort((a, b) => a - b)\n const mid = Math.floor(sorted.length / 2)\n\n return sorted.length % 2 === 0\n ? (sorted[mid - 1]! + sorted[mid]!) / 2\n : sorted[mid]!\n}\n","import { calcMedian } from '../calcMedian'\nimport type { ReductionFunctionDefinition } from '.'\n\nexport const medianReductionFunction: ReductionFunctionDefinition<'median'> = {\n median: vector => calcMedian(vector),\n}\n","import { calcMean } from './calcMean'\n\nexport function calcVariance(vector: number[], optionalMean?: number): number {\n const mean = optionalMean ?? calcMean(vector)\n return vector.reduce((acc, val) => acc + (val - mean) ** 2, 0) / vector.length\n}\n\nexport function calcSampleVariance(vector: number[], optionalMean?: number): number {\n const mean = optionalMean ?? calcMean(vector)\n return vector.reduce((acc, val) => acc + (val - mean) ** 2, 0) / (vector.length - 1)\n}\n","import { calcSampleVariance, calcVariance } from '../calcVariance'\nimport type { ReductionFunctionDefinition } from '.'\n\nexport const varianceReductionFunction: ReductionFunctionDefinition<'variance'> = {\n variance: vector => calcVariance(vector),\n}\n\nexport const sampleVarianceReductionFunction: ReductionFunctionDefinition<'sample-variance'> = {\n 'sample-variance': vector => calcSampleVariance(vector),\n 'minLength': 2,\n}\n","import { calcVariance } from './calcVariance'\n\nexport function calcStdDev(vector: number[], optionalMean?: number): number {\n const variance = calcVariance(vector, optionalMean)\n return Math.sqrt(variance)\n}\n\nexport function calcSampleStdDev(vector: number[], optionalMean?: number): number {\n const variance = calcVariance(vector, optionalMean)\n return Math.sqrt(variance * (vector.length / (vector.length - 1)))\n}\n","import { calcSampleStdDev, calcStdDev } from '../calcStdDev'\nimport type { ReductionFunctionDefinition } from '.'\n\nexport const stdevReductionFunction: ReductionFunctionDefinition<'stdev'> = {\n stdev: vector => calcStdDev(vector),\n}\n\nexport const sampleStdevReductionFunction: ReductionFunctionDefinition<'sample-stdev'> = {\n 'sample-stdev': vector => calcSampleStdDev(vector),\n 'minLength': 2,\n}\n","import { quartiles } from '../quartiles'\nimport type { ReductionFunctionDefinition } from '.'\n\nexport const iqrReductionFunction: ReductionFunctionDefinition<'iqr'> = {\n iqr: (vector) => {\n const [q1, , q3] = quartiles(vector)\n return q3 - q1\n },\n minLength: 4,\n}\n","import type { ReductionFunctionDefinition } from '.'\n\nexport const spanReductionFunction: ReductionFunctionDefinition<'span'> = {\n span: vector => vector.length === 0 ? 0 : Math.max(...vector) - Math.min(...vector),\n minLength: 0,\n}\n","import { calcMean } from '../calcMean'\nimport { calcStdDev } from '../calcStdDev'\nimport type { ReductionFunctionDefinition } from '.'\n\nfunction skewness(vector: number[]): number {\n const mean = calcMean(vector)\n const stdDev = calcStdDev(vector)\n if (stdDev === 0) {\n throw new Error('Standard deviation is zero, skewness is undefined')\n }\n return vector.reduce((acc, val) => acc + ((val - mean) ** 3), 0) / (vector.length * stdDev ** 3)\n}\n\nfunction sampleSkewness(vector: number[]): number {\n const n = vector.length\n\n // Calculate the mean\n const mean = vector.reduce((acc, val) => acc + val, 0) / n\n\n // Calculate sum of squared differences and sum of cubed differences\n let sumSquaredDiffs = 0\n let sumCubedDiffs = 0\n\n for (const val of vector) {\n const diff = val - mean\n sumSquaredDiffs += diff * diff\n sumCubedDiffs += diff * diff * diff\n }\n\n // Calculate sample standard deviation (using n-1)\n const sampleVariance = sumSquaredDiffs / (n - 1)\n const sampleStdDev = Math.sqrt(sampleVariance)\n\n // If standard deviation is 0, skewness is undefined\n if (sampleStdDev === 0) {\n throw new Error('Cannot calculate sample skewness when standard deviation is 0')\n }\n\n // Calculate sample skewness with Fisher's adjustment\n return (n / ((n - 1) * (n - 2))) * sumCubedDiffs / sampleStdDev ** 3\n}\n\nexport const skewnessReductionFunction: ReductionFunctionDefinition<'skewness'> = {\n skewness: vector => skewness(vector),\n minLength: 3,\n}\n\nexport const sampleSkewnessReductionFunction: ReductionFunctionDefinition<'sample-skewness'> = {\n 'sample-skewness': vector => sampleSkewness(vector),\n 'minLength': 3,\n}\n","import { calcMean } from '../calcMean'\nimport { calcStdDev } from '../calcStdDev'\n\nimport type { ReductionFunctionDefinition } from '.'\n\nfunction kurtosis(vector: number[]): number {\n const mean = calcMean(vector)\n const stdDev = calcStdDev(vector)\n if (stdDev === 0) {\n throw new Error('Standard deviation is zero, kurtosis is undefined')\n }\n return vector.reduce((acc, val) => acc + ((val - mean) ** 4), 0) / (vector.length * stdDev ** 4)\n}\n\nfunction excessKurtosis(vector: number[]): number {\n return kurtosis(vector) - 3\n}\n\n/**\n * Calculates the sample kurtosis (bias-corrected)\n * @param vector Array of numeric values\n * @returns The sample kurtosis\n * @throws Error if sample size is less than 4 or if variance is zero\n */\nfunction sampleKurtosis(vector: number[]): number {\n const n = vector.length\n\n const mean = vector.reduce((sum, val) => sum + val, 0) / n\n const sumSquaredDeviations = vector.reduce((sum, val) => sum + (val - mean) ** 2, 0)\n const variance = sumSquaredDeviations / (n - 1)\n\n if (variance === 0) {\n throw new Error('Variance is zero, kurtosis is undefined')\n }\n\n const fourthMomentSum = vector.reduce((sum, val) => sum + (val - mean) ** 4, 0)\n\n // Correct formula for sample kurtosis\n return (n * (n + 1) * fourthMomentSum) / ((n - 1) * (n - 2) * (n - 3) * variance ** 2)\n}\n/**\n * Calculates the sample excess kurtosis (bias-corrected)\n * @param vector Array of numeric values\n * @returns The sample excess kurtosis\n * @throws Error if sample size is less than 4 or if variance is zero\n */\nfunction sampleExcessKurtosis(vector: number[]): number {\n const n = vector.length\n\n const mean = vector.reduce((sum, val) => sum + val, 0) / n\n const sumSquaredDeviations = vector.reduce((sum, val) => sum + (val - mean) ** 2, 0)\n const variance = sumSquaredDeviations / (n - 1)\n\n if (variance === 0) {\n throw new Error('Variance is zero, kurtosis is undefined')\n }\n\n const fourthMomentSum = vector.reduce((sum, val) => sum + (val - mean) ** 4, 0)\n const rawKurtosis = (n * (n + 1) * fourthMomentSum) / ((n - 1) * (n - 2) * (n - 3) * variance ** 2)\n\n // Compute excess kurtosis by subtracting 3 times the bias correction factor\n return rawKurtosis - (3 * (n - 1) * (n - 1)) / ((n - 2) * (n - 3))\n}\n\nexport const kurtosisReductionFunction: ReductionFunctionDefinition<'kurtosis'> = {\n kurtosis: vector => kurtosis(vector),\n minLength: 4,\n}\n\nexport const eccessKurtosisReductionFunction: ReductionFunctionDefinition<'excess-kurtosis'> = {\n 'excess-kurtosis': vector => excessKurtosis(vector),\n 'minLength': 4,\n}\n\nexport const sampleKurtosisReductionFunction: ReductionFunctionDefinition<'sample-kurtosis'> = {\n 'sample-kurtosis': vector => sampleKurtosis(vector),\n 'minLength': 4,\n}\n\nexport const sampleExcessKurtosisReductionFunction: ReductionFunctionDefinition<'sample-excess-kurtosis'> = {\n 'sample-excess-kurtosis': vector => sampleExcessKurtosis(vector),\n 'minLength': 4,\n}\n","import type { ReductionFunctionDefinition } from '.'\n\nexport const rmsReductionFunction: ReductionFunctionDefinition<'rms'> = {\n rms: vector => Math.sqrt(vector.reduce((acc, val) => acc + val ** 2, 0) / vector.length),\n}\n","import { calcMad } from '../calcMad'\nimport type { ReductionFunctionDefinition } from '.'\n\nexport const madReductionFunction: ReductionFunctionDefinition<'mad'> = {\n mad: vector => calcMad(vector),\n}\n","import { calcMedian } from './calcMedian'\n\nexport function calcMad(vector: number[]): number {\n const median = calcMedian(vector)\n\n // Calculate mean absolute deviation\n return vector.reduce((acc, val) => acc + Math.abs(val - median), 0) / vector.length\n}\n","import { calcMedian } from './calcMedian'\n\nexport function calcMedad(vector: number[]): number {\n const median = calcMedian(vector)\n // Calculate absolute deviations from the median\n const absoluteDeviations = vector.map(val => Math.abs(val - median))\n\n // Calculate the median of the absolute deviations\n const medianOfDeviations = calcMedian(absoluteDeviations)\n const scaleFactor = 1.4826 // Scale factor for robust scaling\n\n return medianOfDeviations * scaleFactor\n}\n","import { calcMedad } from '../calcMedad'\nimport type { ReductionFunctionDefinition } from '.'\n\nexport const medadReductionFunction: ReductionFunctionDefinition<'medad'> = {\n medad: vector => calcMedad(vector),\n}\n","import type { ReductionFunctionDefinition } from '.'\n\nexport const giniCoefficientReductionFunction: ReductionFunctionDefinition<'gini-coefficient'> = {\n 'gini-coefficient': (vector) => {\n if (vector.some(x => x < 0)) {\n throw new Error('Gini coefficient is not defined for negative values')\n }\n const sorted = [...vector].sort((a, b) => a - b)\n const n = sorted.length\n const sum = sorted.reduce((acc, val) => acc + val, 0)\n if (sum === 0) {\n return 0\n }\n const gini = (2 * sorted.reduce((acc, val, i) => acc + (i + 1) * val, 0)) / (n * sum) - (n + 1) / n\n return gini\n },\n 'minLength': 1,\n}\n","import { calculateEntropy } from '../entropy'\nimport type { ReductionFunctionDefinition } from '.'\n\nexport const entropyReductionFunction: ReductionFunctionDefinition<'entropy'> = {\n entropy: vector => calculateEntropy(vector),\n minLength: 1,\n}\n","/**\n * Calculates the Shannon entropy of a vector.\n * Entropy measures the amount of uncertainty or randomness in the data.\n *\n * @param vector - An array of values to calculate entropy for\n * @returns The entropy value (in bits) or 0 for empty arrays\n */\nexport function calculateEntropy<T>(vector: T[]): number {\n // Count occurrences of each value\n const frequencies = new Map<T, number>()\n for (const value of vector) {\n frequencies.set(value, (frequencies.get(value) || 0) + 1)\n }\n\n // Get the total number of elements\n const total = vector.length\n\n // Calculate entropy using Shannon's formula\n let entropy = 0\n for (const frequency of frequencies.values()) {\n const probability = frequency / total\n // Skip cases where probability is 0 (log(0) is undefined)\n if (probability > 0) {\n entropy -= probability * Math.log2(probability)\n }\n }\n\n return entropy\n}\n","import { DvalaError } from '../../../../errors'\nimport { assertVector } from '../../../../typeGuards/annotatedArrays'\nimport { assertNumber } from '../../../../typeGuards/number'\nimport type { BuiltinNormalExpression, BuiltinNormalExpressions } from '../../../../builtin/interface'\nimport { toFixedArity } from '../../../../utils/arity'\nimport { geometricMeanReductionFunction, harmonicMeanReductionFunction, meanReductionFunction } from './mean'\nimport { medianReductionFunction } from './median'\nimport { prodReductionFunction } from './prod'\nimport { sumReductionFunction } from './sum'\nimport { sampleVarianceReductionFunction, varianceReductionFunction } from './variance'\nimport { sampleStdevReductionFunction, stdevReductionFunction } from './standardDeviation'\nimport { iqrReductionFunction } from './iqr'\nimport { spanReductionFunction } from './span'\nimport { sampleSkewnessReductionFunction, skewnessReductionFunction } from './skewness'\nimport { eccessKurtosisReductionFunction, kurtosisReductionFunction, sampleExcessKurtosisReductionFunction, sampleKurtosisReductionFunction } from './kurtosis'\nimport { rmsReductionFunction } from './rms'\nimport { madReductionFunction } from './mad'\nimport { medadReductionFunction } from './medad'\nimport { giniCoefficientReductionFunction } from './giniCoefficient'\nimport { entropyReductionFunction } from './entropy'\n\ntype VectorReductionKey<T extends string> = `${T}`\ntype VectorMovingWindowKey<T extends string> = `moving-${T}`\ntype VectorCenteredMovingWindowKey<T extends string> = `centered-moving-${T}`\ntype VectorRunningKey<T extends string> = `running-${T}`\n\nexport type VectorReductionKeys<T extends string> = VectorReductionKey<T> | VectorMovingWindowKey<T> | VectorCenteredMovingWindowKey<T> | VectorRunningKey<T>\n\ntype ReductionFunction = (vector: number[]) => number\n// type MovingWindowFunction = (vector: number[], windowSize: number, sourceCodeInfo: SourceCodeInfo | undefined) => number[]\n\nexport type ReductionFunctionDefinition<T extends string> = Record<VectorReductionKey<T>, ReductionFunction> & {\n minLength?: number\n padding?: number\n}\n\nexport const reductionFunctionNormalExpressions: BuiltinNormalExpressions = {}\n\naddReductionFunctions(meanReductionFunction)\naddReductionFunctions(geometricMeanReductionFunction)\naddReductionFunctions(harmonicMeanReductionFunction)\naddReductionFunctions(medianReductionFunction)\naddReductionFunctions(sumReductionFunction)\naddReductionFunctions(prodReductionFunction)\naddReductionFunctions(varianceReductionFunction)\naddReductionFunctions(sampleVarianceReductionFunction)\naddReductionFunctions(stdevReductionFunction)\naddReductionFunctions(sampleStdevReductionFunction)\naddReductionFunctions(iqrReductionFunction)\naddReductionFunctions(spanReductionFunction)\naddReductionFunctions(skewnessReductionFunction)\naddReductionFunctions(sampleSkewnessReductionFunction)\naddReductionFunctions(eccessKurtosisReductionFunction)\naddReductionFunctions(kurtosisReductionFunction)\naddReductionFunctions(sampleExcessKurtosisReductionFunction)\naddReductionFunctions(sampleKurtosisReductionFunction)\naddReductionFunctions(rmsReductionFunction)\naddReductionFunctions(madReductionFunction)\naddReductionFunctions(medadReductionFunction)\naddReductionFunctions(giniCoefficientReductionFunction)\naddReductionFunctions(entropyReductionFunction)\n\n// Remove base variants that duplicate core built-ins (sum, prod, mean, median).\n// The moving/centered-moving/running variants are unique to the vector module.\ndelete reductionFunctionNormalExpressions.sum\ndelete reductionFunctionNormalExpressions.prod\ndelete reductionFunctionNormalExpressions.mean\ndelete reductionFunctionNormalExpressions.median\n\nfunction addReductionFunctions<T extends string>(fns: ReductionFunctionDefinition<T>) {\n for (const [key, value] of Object.entries(fns)) {\n /* v8 ignore next 3 */\n if (reductionFunctionNormalExpressions[key]) {\n throw new Error(`Duplicate normal expression key found: ${key}`)\n }\n if (key !== 'minLength' && key !== 'padding' && typeof value === 'function') {\n const reductionFn = value as ReductionFunction\n const baseKey = key.replace(/^/, '')\n const movingKey = `moving-${baseKey}` as VectorMovingWindowKey<T>\n const centeredMovingKey = `centered-moving-${baseKey}` as VectorCenteredMovingWindowKey<T>\n const runningKey = `running-${baseKey}` as VectorRunningKey<T>\n const minLength = fns.minLength ?? 1\n assertNumber(minLength, undefined, { integer: true, finite: true, gte: 0 })\n reductionFunctionNormalExpressions[key] = createReductionNormalExpression(reductionFn, minLength)\n reductionFunctionNormalExpressions[movingKey] = createMovingNormalExpression(reductionFn, minLength)\n reductionFunctionNormalExpressions[centeredMovingKey] = createCenteredMovingNormalExpression(reductionFn, minLength, fns.padding ?? null)\n reductionFunctionNormalExpressions[runningKey] = createRunningNormalExpression(reductionFn, minLength)\n }\n }\n}\n\nfunction createReductionNormalExpression(\n reductionFunction: ReductionFunction,\n minLength: number,\n): BuiltinNormalExpression<number> {\n return {\n evaluate: ([vector], sourceCodeInfo) => {\n assertVector(vector, sourceCodeInfo)\n if (vector.length < minLength) {\n throw new DvalaError(`Vector length must be at least ${minLength}`, sourceCodeInfo)\n }\n\n try {\n return reductionFunction(vector)\n }\n catch (error) {\n throw new DvalaError(error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(1),\n }\n}\n\nfunction createMovingNormalExpression(\n reductionFunction: ReductionFunction,\n minLength: number,\n): BuiltinNormalExpression<number[]> {\n return {\n evaluate: ([vector, windowSize], sourceCodeInfo) => {\n assertVector(vector, sourceCodeInfo)\n assertNumber(windowSize, sourceCodeInfo, { integer: true, finite: true, gte: minLength, lte: vector.length })\n if (vector.length === 0) {\n return []\n }\n try {\n if (windowSize >= vector.length) {\n return [reductionFunction(vector)]\n }\n const result = []\n for (let i = 0; i < vector.length - windowSize + 1; i += 1) {\n result.push(reductionFunction(vector.slice(i, i + windowSize)))\n }\n return result\n }\n catch (error) {\n throw new DvalaError(error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(2),\n }\n}\n\nfunction createCenteredMovingNormalExpression(\n reductionFunction: ReductionFunction,\n minLength: number,\n padding: number | null,\n): BuiltinNormalExpression<(number | null)[]> {\n return {\n evaluate: ([vector, windowSize, leftPadding, rightPadding], sourceCodeInfo) => {\n assertVector(vector, sourceCodeInfo)\n if (vector.length < minLength) {\n throw new DvalaError(`Vector length must be at least ${minLength}`, sourceCodeInfo)\n }\n\n assertNumber(windowSize, sourceCodeInfo, { integer: true, finite: true, gte: minLength, lte: vector.length })\n leftPadding = leftPadding ?? padding\n if (leftPadding !== null) {\n assertNumber(leftPadding, sourceCodeInfo, { finite: true })\n }\n rightPadding = rightPadding ?? padding\n if (rightPadding !== null) {\n assertNumber(rightPadding, sourceCodeInfo, { finite: true })\n }\n\n if (vector.length === 0) {\n return []\n }\n\n const halfWindowSize = Math.floor(windowSize / 2)\n const paddedVector = [\n ...Array<number | null>(halfWindowSize).fill(leftPadding),\n ...vector,\n ...Array<number | null>(halfWindowSize).fill(rightPadding),\n ]\n\n const start = typeof leftPadding === 'number' ? 0 : halfWindowSize\n const end = vector.length - (typeof rightPadding === 'number' ? 0 : (windowSize - halfWindowSize - 1))\n\n const result: (number | null)[] = [\n ...Array<null>(start).fill(null),\n ]\n\n try {\n for (let i = start; i < end; i += 1) {\n result.push(reductionFunction(paddedVector.slice(i, i + windowSize) as number[]))\n }\n }\n catch (error) {\n throw new DvalaError(error, sourceCodeInfo)\n }\n\n result.push(...Array<null>(vector.length - end).fill(null))\n return result\n },\n arity: { min: 2, max: 4 },\n }\n}\n\nfunction createRunningNormalExpression(\n reductionFunction: ReductionFunction,\n minLength: number,\n): BuiltinNormalExpression<(number | null)[]> {\n return {\n evaluate: ([vector], sourceCodeInfo) => {\n assertVector(vector, sourceCodeInfo)\n if (vector.length < minLength) {\n throw new DvalaError(`Vector length must be at least ${minLength}`, sourceCodeInfo)\n }\n\n if (vector.length === 0) {\n return []\n }\n\n try {\n const nullsCount = Math.max(minLength - 1, 0)\n const result: (number | null)[] = Array<null>(nullsCount).fill(null)\n\n for (let i = nullsCount; i < vector.length; i += 1) {\n result.push(reductionFunction(vector.slice(0, i + 1)))\n }\n return result\n }\n catch (error) {\n throw new DvalaError(error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(1),\n }\n}\n","import type { ReductionFunctionDefinition } from '.'\n\nexport const sumReductionFunction: ReductionFunctionDefinition<'sum'> = {\n sum: vector => vector.reduce((acc, val) => acc + val, 0),\n minLength: 0,\n}\n","import type { ReductionFunctionDefinition } from '.'\n\nexport const prodReductionFunction: ReductionFunctionDefinition<'prod'> = {\n prod: vector => vector.reduce((acc, val) => acc * val, 1),\n padding: 1,\n minLength: 0,\n}\n","import { DvalaError } from '../../../errors'\nimport { assertNonEmptyVector, assertVector } from '../../../typeGuards/annotatedArrays'\nimport { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport type { DvalaModule } from '../interface'\nimport { moduleDocs } from './docs'\nimport { bincount } from './bincount'\nimport { calcHistogram } from './histogram'\nimport { mode } from './mode'\nimport { hasOutliers, outliers } from './outliers'\nimport { calcPercentile } from './percentile'\nimport { quartiles } from './quartiles'\nimport { reductionFunctionNormalExpressions } from './reductionFunctions'\n\nconst vectorFunctions: BuiltinNormalExpressions = {\n 'monotonic?': {\n evaluate: ([vector], sourceCodeInfo): boolean => {\n assertVector(vector, sourceCodeInfo)\n return vector.every((val, i) => i === 0 || val >= vector[i - 1]!)\n || vector.every((val, i) => i === 0 || val <= vector[i - 1]!)\n },\n arity: toFixedArity(1),\n },\n 'strictly-monotonic?': {\n evaluate: ([vector], sourceCodeInfo): boolean => {\n assertVector(vector, sourceCodeInfo)\n return vector.every((val, i) => i === 0 || val > vector[i - 1]!)\n || vector.every((val, i) => i === 0 || val < vector[i - 1]!)\n },\n arity: toFixedArity(1),\n },\n 'increasing?': {\n evaluate: ([vector], sourceCodeInfo): boolean => {\n assertVector(vector, sourceCodeInfo)\n return vector.every((val, i) => i === 0 || val >= vector[i - 1]!)\n },\n arity: toFixedArity(1),\n },\n 'decreasing?': {\n evaluate: ([vector], sourceCodeInfo): boolean => {\n assertVector(vector, sourceCodeInfo)\n return vector.every((val, i) => i === 0 || val <= vector[i - 1]!)\n },\n arity: toFixedArity(1),\n },\n 'strictly-increasing?': {\n evaluate: ([vector], sourceCodeInfo): boolean => {\n assertVector(vector, sourceCodeInfo)\n return vector.every((val, i) => i === 0 || val > vector[i - 1]!)\n },\n arity: toFixedArity(1),\n },\n 'strictly-decreasing?': {\n evaluate: ([vector], sourceCodeInfo): boolean => {\n assertVector(vector, sourceCodeInfo)\n return vector.every((val, i) => i === 0 || val < vector[i - 1]!)\n },\n arity: toFixedArity(1),\n },\n 'mode': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return mode(vector)\n },\n arity: toFixedArity(1),\n },\n 'min-index': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n\n return vector.reduce((acc, val, i) => (val < vector[acc]! ? i : acc), 0)\n },\n arity: toFixedArity(1),\n },\n 'max-index': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n\n return vector.reduce((acc, val, i) => (val > vector[acc]! ? i : acc), 0)\n },\n arity: toFixedArity(1),\n },\n 'sort-indices': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n return [...vector.keys()].sort((a, b) => vector[a]! - vector[b]!)\n },\n arity: toFixedArity(1),\n },\n 'count-values': {\n evaluate: ([vector], sourceCodeInfo): [number, number][] => {\n assertVector(vector, sourceCodeInfo)\n\n const frequencyMap = new Map<number, number>()\n for (const value of vector) {\n frequencyMap.set(value, (frequencyMap.get(value) || 0) + 1)\n }\n return [...frequencyMap.entries()].sort((a, b) => {\n // First compare by count (descending)\n const countDiff = b[1] - a[1]\n if (countDiff !== 0)\n return countDiff\n // If counts are equal, sort by value (ascending)\n return a[0] - b[0]\n })\n },\n arity: toFixedArity(1),\n },\n 'linspace': {\n evaluate: ([start, end, numPoints], sourceCodeInfo): number[] => {\n assertNumber(start, sourceCodeInfo, { finite: true })\n assertNumber(end, sourceCodeInfo, { finite: true })\n assertNumber(numPoints, sourceCodeInfo, { integer: true, nonNegative: true })\n\n if (numPoints === 0) {\n return []\n }\n if (numPoints === 1) {\n return [start]\n }\n const step = (end - start) / (numPoints - 1)\n return Array.from({ length: numPoints }, (_, i) => start + i * step)\n },\n arity: toFixedArity(3),\n },\n 'cumsum': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n return vector.reduce((acc, val) => {\n const last = acc[acc.length - 1] ?? 0\n acc.push(last + val)\n return acc\n }, [] as number[])\n },\n arity: toFixedArity(1),\n },\n 'cumprod': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n return vector.reduce((acc, val) => {\n const last = acc[acc.length - 1] ?? 1\n acc.push(last * val)\n return acc\n }, [] as number[])\n },\n arity: toFixedArity(1),\n },\n 'quartiles': {\n evaluate: ([vector], sourceCodeInfo): [number, number, number] => {\n assertVector(vector, sourceCodeInfo)\n if (vector.length < 4) {\n throw new DvalaError('Quartiles require at least four values', sourceCodeInfo)\n }\n return quartiles(vector)\n },\n arity: toFixedArity(1),\n },\n 'percentile': {\n evaluate: ([vector, percentile], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n assertNumber(percentile, sourceCodeInfo, { finite: true, nonNegative: true, lte: 100 })\n return calcPercentile(vector, percentile)\n },\n arity: toFixedArity(2),\n },\n 'quantile': {\n evaluate: ([vector, quantile], sourceCodeInfo): number => {\n assertVector(vector, sourceCodeInfo)\n assertNumber(quantile, sourceCodeInfo, { finite: true, nonNegative: true, lte: 1 })\n return calcPercentile(vector, quantile * 100)\n },\n arity: toFixedArity(2),\n },\n 'histogram': {\n evaluate: ([vector, bins], sourceCodeInfo): [number, number, number][] => {\n assertVector(vector, sourceCodeInfo)\n assertNumber(bins, sourceCodeInfo, { integer: true, positive: true })\n\n return calcHistogram(vector, bins)\n },\n arity: toFixedArity(2),\n },\n 'ecdf': {\n evaluate: ([vector, value], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n assertNumber(value, sourceCodeInfo, { finite: true })\n\n const sorted = [...vector].sort((a, b) => a - b)\n const index = sorted.findIndex(val => val > value)\n\n return index === -1 ? 1 : index / sorted.length\n },\n arity: toFixedArity(2),\n },\n 'outliers?': {\n evaluate: ([vector], sourceCodeInfo): boolean => {\n assertVector(vector, sourceCodeInfo)\n return hasOutliers(vector)\n },\n arity: toFixedArity(1),\n },\n 'outliers': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n return outliers(vector)\n },\n arity: toFixedArity(1),\n },\n 'bincount': {\n evaluate: (params, sourceCodeInfo): number[] => {\n const vector = params[0]\n assertVector(vector, sourceCodeInfo)\n vector.forEach(val => assertNumber(val, sourceCodeInfo, { finite: true, integer: true, nonNegative: true }))\n\n const minSize = params[1] ?? 0\n assertNumber(minSize, sourceCodeInfo, { integer: true, nonNegative: true })\n\n const weights = params[2] ?? undefined\n if (weights !== undefined) {\n assertVector(weights, sourceCodeInfo)\n if (weights.length !== vector.length) {\n throw new DvalaError('Weights vector must be the same length as the input vector', sourceCodeInfo)\n }\n weights.forEach(val => assertNumber(val, sourceCodeInfo, { finite: true }))\n }\n\n return bincount(vector, minSize, weights)\n },\n arity: { min: 1, max: 3 },\n },\n 'winsorize': {\n evaluate: ([vector, lowerQuantile, upperQuantile], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n assertNumber(lowerQuantile, sourceCodeInfo, { finite: true, gte: 0, lte: 1 })\n upperQuantile ??= lowerQuantile > 0.5 ? 1 : (1 - lowerQuantile)\n assertNumber(upperQuantile, sourceCodeInfo, { finite: true, gte: lowerQuantile, lte: 1 })\n\n if (vector.length === 0)\n return []\n\n const sorted = [...vector].sort((a, b) => a - b)\n\n const lowerIndex = Math.max(0, Math.floor(lowerQuantile * vector.length))\n const upperIndex = Math.min(vector.length - 1, Math.max(0, Math.floor(upperQuantile * vector.length) - 1))\n\n const lowerBound = sorted[lowerIndex]!\n const upperBound = sorted[upperIndex]!\n\n return vector.map(val => Math.max(lowerBound, Math.min(val, upperBound)))\n },\n arity: { min: 2, max: 3 },\n },\n 'mse': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n return vectorA.reduce((acc, val, i) => acc + (val - vectorB[i]!) ** 2, 0) / vectorA.length\n },\n arity: toFixedArity(2),\n },\n 'rmse': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n return Math.sqrt(vectorA.reduce((acc, val, i) => acc + (val - vectorB[i]!) ** 2, 0) / vectorA.length)\n },\n arity: toFixedArity(2),\n },\n 'mae': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n return vectorA.reduce((acc, val, i) => acc + Math.abs(val - vectorB[i]!), 0) / vectorA.length\n },\n arity: toFixedArity(2),\n },\n 'smape': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n return vectorA.reduce((acc, val, i) => {\n const diff = Math.abs(val - vectorB[i]!)\n const denom = (Math.abs(val) + Math.abs(vectorB[i]!)) / 2\n return acc + (denom === 0 ? 0 : diff / denom)\n }, 0) / vectorA.length\n },\n arity: toFixedArity(2),\n },\n\n}\n\naddReductionFunctions(reductionFunctionNormalExpressions)\n\nfunction addReductionFunctions(sequences: BuiltinNormalExpressions) {\n for (const [key, value] of Object.entries(sequences)) {\n /* v8 ignore next 3 */\n if (vectorFunctions[key]) {\n throw new Error(`Duplicate normal expression key found: ${key}`)\n }\n vectorFunctions[key] = value\n }\n}\n\nfor (const [key, docs] of Object.entries(moduleDocs)) {\n if (vectorFunctions[key])\n vectorFunctions[key].docs = docs\n}\n\nexport const vectorModule: DvalaModule = {\n name: 'vector',\n functions: vectorFunctions,\n}\n","/**\n * Calculates the mode (most frequent value(s)) of a dataset\n * @param values An array of values of any type\n * @returns An array containing the mode(s) of the dataset\n */\nexport function mode(values: number[]): number[] {\n // Create a frequency map\n const frequencyMap = new Map<number, number>()\n\n // Count occurrences of each value\n for (const value of values) {\n frequencyMap.set(value, (frequencyMap.get(value) || 0) + 1)\n }\n\n // Find the maximum frequency\n let maxFrequency = 0\n for (const frequency of frequencyMap.values()) {\n if (frequency > maxFrequency) {\n maxFrequency = frequency\n }\n }\n\n // If all values appear only once, there is no mode\n if (maxFrequency === 1) {\n return values\n }\n\n // Collect all values that appear with the maximum frequency\n const modes: number[] = []\n for (const [value, frequency] of frequencyMap.entries()) {\n if (frequency === maxFrequency) {\n modes.push(value)\n }\n }\n\n return modes\n}\n","/**\n * Creates a histogram from an array of numbers, returning bin ranges and counts.\n * Each bin is represented as a tuple of [minValue, maxValue, count].\n *\n * @param vector - Array of numeric values\n * @param bins - Number of bins to divide the data into\n * @returns Array of tuples, each containing [binStart, binEnd, count]\n */\nexport function calcHistogram(vector: number[], bins: number): [number, number, number][] {\n if (vector.length === 0) {\n // Return empty bins with zero counts if input is empty\n const result: [number, number, number][] = []\n for (let i = 0; i < bins; i++) {\n result.push([0, 0, 0])\n }\n return result\n }\n\n // Find min and max values\n const min = Math.min(...vector)\n const max = Math.max(...vector)\n\n // Handle the case where all values are the same\n if (min === max) {\n const result: [number, number, number][] = []\n // Create bins with the same min/max and zero counts\n for (let i = 0; i < bins; i++) {\n result.push([min, min, 0])\n }\n // Put all values in the first bin\n result[0]![2] = vector.length\n return result\n }\n\n // Calculate bin size\n const binSize = (max - min) / bins\n\n // Initialize histogram array with bin boundaries and zero counts\n const histogram: [number, number, number][] = []\n for (let i = 0; i < bins; i++) {\n const binStart = min + i * binSize\n const binEnd = i === bins - 1 ? max : min + (i + 1) * binSize\n histogram.push([binStart, binEnd, 0])\n }\n\n // Count values in each bin\n for (const value of vector) {\n if (value === max) {\n // Place maximum value in the last bin\n histogram[bins - 1]![2] += 1\n }\n else {\n const binIndex = Math.min(\n Math.floor((value - min) / binSize),\n bins - 1,\n )\n histogram[binIndex]![2] += 1\n }\n }\n\n return histogram\n}\n","/**\n * Counts occurrences of each integer value in an array of non-negative integers.\n *\n * @param array - Array of non-negative integers to count\n * @param minLength - Minimum length of the output array (default: 0)\n * @param weights - Optional array of weights (same length as input array)\n * @returns An array where index i contains the count of occurrences of i in the input array\n */\nexport function bincount(\n array: number[],\n minLength: number = 0,\n weights?: number[],\n): number[] {\n if (array.length === 0) {\n return Array.from({ length: minLength }, () => 0)\n }\n\n // Find the maximum value to determine output array size\n const maxValue = Math.max(...array)\n const outputLength = Math.max(maxValue + 1, minLength)\n const counts = Array.from({ length: outputLength }, () => 0)\n\n // Count occurrences (or sum weights if provided)\n for (let i = 0; i < array.length; i++) {\n const value = Math.floor(array[i]!)\n\n if (value < outputLength) {\n // If weights provided, add weight; otherwise add 1\n counts[value]! += weights ? weights[i]! : 1\n }\n }\n\n return counts\n}\n","import type { FunctionDocs } from '../../interface'\n\nexport const moduleDocs: Record<string, FunctionDocs> = {\n 'reflect': {\n category: 'linear-algebra',\n description: 'Reflects a vector across a given axis.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Vector to reflect.',\n },\n b: {\n type: 'vector',\n description: 'Axis of reflection.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { reflect } = import(linear-algebra);\\nreflect([1, 2], [0, 1])',\n 'let { reflect } = import(linear-algebra);\\nreflect([1, 2, 3], [0, 0, 1])',\n ],\n seeAlso: ['linear-algebra.refract', 'linear-algebra.projection'],\n },\n 'refract': {\n category: 'linear-algebra',\n description: 'Refracts a vector across a given axis.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: 'Vector to refract.',\n },\n axis: {\n type: 'vector',\n description: 'Axis of refraction.',\n },\n eta: {\n type: 'number',\n description: 'Refraction index.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n 'axis',\n 'eta',\n ],\n },\n ],\n examples: [\n 'let { refract } = import(linear-algebra);\\nrefract([1, 2], [0, 1], 1.5)',\n 'let { refract } = import(linear-algebra);\\nrefract([1, 2, 3], [0, 0, 1], 1.5)',\n ],\n seeAlso: ['linear-algebra.reflect'],\n },\n 'lerp': {\n category: 'linear-algebra',\n description: 'Performs linear interpolation between two vectors.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Start vector.',\n },\n b: {\n type: 'vector',\n description: 'End vector.',\n },\n t: {\n type: 'number',\n description: 'Interpolation factor (0 to 1).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n 't',\n ],\n },\n ],\n examples: [\n 'let { lerp } = import(linear-algebra);\\nlerp([1, 2], [3, 4], 0.5)',\n 'let { lerp } = import(linear-algebra);\\nlerp([1, 2], [3, 4], 2)',\n 'let { lerp } = import(linear-algebra);\\nlerp([1, 2], [3, 4], -1)',\n 'let { lerp } = import(linear-algebra);\\nlerp([1, 2, 3], [4, 5, 6], 0.25)',\n ],\n seeAlso: ['linear-algebra.projection'],\n },\n 'rotate2d': {\n category: 'linear-algebra',\n description: 'Rotates a 2D vector by a given angle in radians.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Vector to rotate.',\n },\n b: {\n type: 'number',\n description: 'Angle in b.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { rotate2d } = import(linear-algebra);\\nrotate2d([1, 0], PI / 2)',\n 'let { rotate2d } = import(linear-algebra);\\nrotate2d([0, 1], PI)',\n ],\n seeAlso: ['linear-algebra.rotate3d', 'linear-algebra.angle'],\n },\n 'rotate3d': {\n category: 'linear-algebra',\n description: 'Rotates a 3D vector around a given axis by a given angle in radians.',\n returns: {\n type: 'vector',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to rotate.',\n },\n axis: {\n type: 'vector',\n description: 'Axis of rotation.',\n },\n radians: {\n type: 'number',\n description: 'Angle in radians.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n 'axis',\n 'radians',\n ],\n },\n ],\n examples: [\n 'let { rotate3d } = import(linear-algebra);\\nrotate3d([1, 0, 0], [0, 1, 0], PI / 2)',\n 'let { rotate3d } = import(linear-algebra);\\nrotate3d([0, 1, 0], [1, 0, 0], PI)',\n ],\n seeAlso: ['linear-algebra.rotate2d', 'linear-algebra.angle'],\n },\n 'dot': {\n category: 'linear-algebra',\n description: 'Calculates the dot product of two vectors. The result is a scalar.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n description: 'First vector.',\n },\n b: {\n type: 'vector',\n description: 'Second vector.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { dot } = import(linear-algebra);\\ndot([1, 2], [3, 4])',\n 'let { dot } = import(linear-algebra);\\ndot([1, 2, 3], [4, 5, 6])',\n ],\n seeAlso: ['linear-algebra.cross', 'linear-algebra.cosine-similarity', 'linear-algebra.angle', 'linear-algebra.projection', 'linear-algebra.orthogonal?'],\n },\n 'cross': {\n category: 'linear-algebra',\n description: 'Calculates the cross product of two 3D vectors. The result is a vector perpendicular to both input vectors.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'First vector (3D).',\n },\n b: {\n type: 'vector',\n description: 'Second vector (3D).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { cross } = import(linear-algebra);\\ncross([1, 2, 3], [4, 5, 6])',\n 'let { cross } = import(linear-algebra);\\ncross([1, 0, 0], [0, 1, 0])',\n 'let { cross } = import(linear-algebra);\\ncross([0, 0, 1], [1, 0, 0])',\n 'let { cross } = import(linear-algebra);\\ncross([1, 2, 3], [0, 0, 0])',\n 'let { cross } = import(linear-algebra);\\ncross([0, 0, 0], [1, 2, 3])',\n ],\n seeAlso: ['linear-algebra.dot'],\n },\n 'normalize-minmax': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using min-max normalization. The result is a vector with values between 0 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-minmax } = import(linear-algebra);\\nnormalize-minmax([1, 2, 3])',\n 'let { normalize-minmax } = import(linear-algebra);\\nnormalize-minmax([1, 2, -3])',\n 'let { normalize-minmax } = import(linear-algebra);\\nnormalize-minmax([1, 2, 3, 4])',\n 'let { normalize-minmax } = import(linear-algebra);\\nnormalize-minmax([1, 2, -3, 4])',\n 'let { normalize-minmax } = import(linear-algebra);\\nnormalize-minmax([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-zscore', 'linear-algebra.normalize-robust', 'linear-algebra.normalize-l1', 'linear-algebra.normalize-l2', 'linear-algebra.normalize-log'],\n },\n 'normalize-zscore': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using z-score normalization. The result is a vector with mean 0 and standard deviation 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-zscore } = import(linear-algebra);\\nnormalize-zscore([1, 2, 3])',\n 'let { normalize-zscore } = import(linear-algebra);\\nnormalize-zscore([1, 2, -3])',\n 'let { normalize-zscore } = import(linear-algebra);\\nnormalize-zscore([1, 2, 3, 4])',\n 'let { normalize-zscore } = import(linear-algebra);\\nnormalize-zscore([1, 2, -3, 4])',\n 'let { normalize-zscore } = import(linear-algebra);\\nnormalize-zscore([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-minmax', 'linear-algebra.normalize-robust', 'linear-algebra.normalize-l1', 'linear-algebra.normalize-l2', 'linear-algebra.normalize-log'],\n },\n 'normalize-robust': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using robust normalization. The result is a vector with median 0 and median absolute deviation 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-robust } = import(linear-algebra);\\nnormalize-robust([1, 2, 3])',\n 'let { normalize-robust } = import(linear-algebra);\\nnormalize-robust([1, 2, -3])',\n 'let { normalize-robust } = import(linear-algebra);\\nnormalize-robust([1, 2, 3, 4])',\n 'let { normalize-robust } = import(linear-algebra);\\nnormalize-robust([1, 2, -3, 4])',\n 'let { normalize-robust } = import(linear-algebra);\\nnormalize-robust([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-minmax', 'linear-algebra.normalize-zscore'],\n },\n 'normalize-l1': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using L1 normalization. The result is a vector with L1 norm equal to 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-l1 } = import(linear-algebra);\\nnormalize-l1([1, 2, 3])',\n 'let { normalize-l1 } = import(linear-algebra);\\nnormalize-l1([1, 2, -3])',\n 'let { normalize-l1 } = import(linear-algebra);\\nnormalize-l1([1, 2, 3, 4])',\n 'let { normalize-l1 } = import(linear-algebra);\\nnormalize-l1([1, 2, -3, 4])',\n 'let { normalize-l1 } = import(linear-algebra);\\nnormalize-l1([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-l2', 'linear-algebra.normalize-minmax', 'linear-algebra.manhattan-norm', 'linear-algebra.normalize-zscore'],\n },\n 'normalize-l2': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using L2 normalization. The result is a vector with L2 norm equal to 1.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-l2 } = import(linear-algebra);\\nnormalize-l2([1, 2, 3])',\n 'let { normalize-l2 } = import(linear-algebra);\\nnormalize-l2([1, 2, 3])',\n 'let { normalize-l2 } = import(linear-algebra);\\nnormalize-l2([1, 2, -3])',\n 'let { normalize-l2 } = import(linear-algebra);\\nnormalize-l2([1, 2, 3, 4])',\n 'let { normalize-l2 } = import(linear-algebra);\\nnormalize-l2([1, 2, -3, 4])',\n 'let { normalize-l2 } = import(linear-algebra);\\nnormalize-l2([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-l1', 'linear-algebra.normalize-minmax', 'linear-algebra.euclidean-norm', 'linear-algebra.normalize-zscore'],\n },\n 'normalize-log': {\n category: 'linear-algebra',\n description: 'Normalizes the vector using natural log normalization. The result is a vector with log-transformed values.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to normalize.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { normalize-log } = import(linear-algebra);\\nnormalize-log([1, 2, 3])',\n 'let { normalize-log } = import(linear-algebra);\\nnormalize-log([1, 2, 3, 4])',\n 'let { normalize-log } = import(linear-algebra);\\nnormalize-log([1, 2, 3, 40, 50])',\n ],\n seeAlso: ['linear-algebra.normalize-minmax', 'linear-algebra.normalize-zscore'],\n },\n 'angle': {\n category: 'linear-algebra',\n description: 'Calculates the **angle** between two vectors in radians.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { angle } = import(linear-algebra);\\nangle([1, 0], [0, 1])',\n 'let { angle } = import(linear-algebra);\\nangle([1, 0, 1], [0, 1, 0])',\n ],\n 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'],\n },\n 'projection': {\n category: 'linear-algebra',\n description: 'Calculates the **projection** of vector `a` onto vector `b`.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { projection } = import(linear-algebra);\\nprojection([1, 2], [3, 4])',\n 'let { projection } = import(linear-algebra);\\nprojection([1, 2, 3], [4, 5, 6])',\n ],\n seeAlso: ['linear-algebra.dot', 'linear-algebra.reflect', 'linear-algebra.lerp'],\n },\n 'collinear?': {\n category: 'linear-algebra',\n description: 'Checks if two vectors are **collinear**.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { collinear? } = import(linear-algebra);\\ncollinear?([1, 2], [2, 4])',\n 'let { collinear? } = import(linear-algebra);\\ncollinear?([1, 2], [-2, -4])',\n 'let { collinear? } = import(linear-algebra);\\ncollinear?([1, 2, 3], [2, 4, 6])',\n ],\n seeAlso: ['linear-algebra.parallel?', 'linear-algebra.orthogonal?', 'linear-algebra.angle'],\n },\n 'parallel?': {\n category: 'linear-algebra',\n description: 'Checks if two vectors are **parallel**.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { parallel? } = import(linear-algebra);\\nparallel?([1, 2], [2, 4])',\n 'let { parallel? } = import(linear-algebra);\\nparallel?([1, 2], [-2, -4])',\n 'let { parallel? } = import(linear-algebra);\\nparallel?([1, 2, 3], [2, 4, 6])',\n 'let { parallel? } = import(linear-algebra);\\nparallel?([1, 2], [3, 4])',\n ],\n seeAlso: ['linear-algebra.collinear?', 'linear-algebra.orthogonal?', 'linear-algebra.angle'],\n },\n 'orthogonal?': {\n category: 'linear-algebra',\n description: 'Checks if two vectors are **orthogonal**.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { orthogonal? } = import(linear-algebra);\\northogonal?([1, 0], [0, 1])',\n 'let { orthogonal? } = import(linear-algebra);\\northogonal?([1, 0, 1], [0, 1, 0])',\n 'let { orthogonal? } = import(linear-algebra);\\northogonal?([1, 2], [2, -1])',\n ],\n seeAlso: ['linear-algebra.collinear?', 'linear-algebra.parallel?', 'linear-algebra.dot', 'matrix.orthogonal-matrix?', 'linear-algebra.angle'],\n },\n 'cosine-similarity': {\n category: 'linear-algebra',\n description: 'Calculates the **cosine similarity** between two vectors. The result is a value between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { cosine-similarity } = import(linear-algebra);\\ncosine-similarity([1, 2], [3, 4])',\n 'let { cosine-similarity } = import(linear-algebra);\\ncosine-similarity([1, 2, 3], [4, 5, 6])',\n 'let { cosine-similarity } = import(linear-algebra);\\ncosine-similarity([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.dot', 'linear-algebra.angle', 'linear-algebra.euclidean-distance'],\n },\n 'euclidean-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Euclidean distance** between two vectors. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { euclidean-distance } = import(linear-algebra);\\neuclidean-distance([1, 2], [3, 4])',\n 'let { euclidean-distance } = import(linear-algebra);\\neuclidean-distance([1, 2, 3], [4, 5, 6])',\n 'let { euclidean-distance } = import(linear-algebra);\\neuclidean-distance([1, 0], [0, 1])',\n ],\n 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'],\n },\n 'euclidean-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Euclidean norm** (L2 norm) of a vector. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { euclidean-norm } = import(linear-algebra);\\neuclidean-norm([1, 2])',\n 'let { euclidean-norm } = import(linear-algebra);\\neuclidean-norm([3, 4])',\n 'let { euclidean-norm } = import(linear-algebra);\\neuclidean-norm([1, 2, 3])',\n ],\n 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'],\n },\n 'manhattan-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Manhattan distance** between two vectors. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { manhattan-distance } = import(linear-algebra);\\nmanhattan-distance([1, 2], [3, 4])',\n 'let { manhattan-distance } = import(linear-algebra);\\nmanhattan-distance([1, 2, 3], [4, 5, 6])',\n 'let { manhattan-distance } = import(linear-algebra);\\nmanhattan-distance([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.euclidean-distance', 'linear-algebra.chebyshev-distance', 'linear-algebra.minkowski-distance', 'linear-algebra.manhattan-norm', 'linear-algebra.hamming-distance'],\n },\n 'manhattan-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Manhattan norm** (L1 norm) of a vector. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { manhattan-norm } = import(linear-algebra);\\nmanhattan-norm([1, 2])',\n 'let { manhattan-norm } = import(linear-algebra);\\nmanhattan-norm([3, 4])',\n 'let { manhattan-norm } = import(linear-algebra);\\nmanhattan-norm([1, 2, 3])',\n ],\n 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'],\n },\n 'hamming-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Hamming distance** between two vectors. The result is a non-negative integer.',\n returns: {\n type: 'integer',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { hamming-distance } = import(linear-algebra);\\nhamming-distance([1, 2], [3, 4])',\n 'let { hamming-distance } = import(linear-algebra);\\nhamming-distance([1, 2, 3], [4, 5, 6])',\n 'let { hamming-distance } = import(linear-algebra);\\nhamming-distance([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.euclidean-distance', 'linear-algebra.manhattan-distance', 'linear-algebra.hamming-norm'],\n },\n 'hamming-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Hamming norm** of a vector. The result is a non-negative integer.',\n returns: {\n type: 'integer',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { hamming-norm } = import(linear-algebra);\\nhamming-norm([1, 2])',\n 'let { hamming-norm } = import(linear-algebra);\\nhamming-norm([3, 4])',\n 'let { hamming-norm } = import(linear-algebra);\\nhamming-norm([1, 2, 3])',\n ],\n seeAlso: ['linear-algebra.euclidean-norm', 'linear-algebra.manhattan-norm', 'linear-algebra.hamming-distance'],\n },\n 'chebyshev-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Chebyshev distance** between two vectors. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { chebyshev-distance } = import(linear-algebra);\\nchebyshev-distance([1, 2], [3, 4])',\n 'let { chebyshev-distance } = import(linear-algebra);\\nchebyshev-distance([1, 2, 3], [4, 5, 6])',\n 'let { chebyshev-distance } = import(linear-algebra);\\nchebyshev-distance([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.euclidean-distance', 'linear-algebra.manhattan-distance', 'linear-algebra.minkowski-distance', 'linear-algebra.chebyshev-norm'],\n },\n 'chebyshev-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Chebyshev norm** of a vector. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n v: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { chebyshev-norm } = import(linear-algebra);\\nchebyshev-norm([1, 2])',\n 'let { chebyshev-norm } = import(linear-algebra);\\nchebyshev-norm([3, 4])',\n 'let { chebyshev-norm } = import(linear-algebra);\\nchebyshev-norm([1, 2, 3])',\n ],\n seeAlso: ['linear-algebra.euclidean-norm', 'linear-algebra.manhattan-norm', 'linear-algebra.minkowski-norm', 'linear-algebra.chebyshev-distance'],\n },\n 'minkowski-distance': {\n category: 'linear-algebra',\n description: 'Calculates the **Minkowski distance** between two vectors. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n p: {\n type: 'number',\n description: 'Order of the norm (p).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n 'p',\n ],\n },\n ],\n examples: [\n 'let { minkowski-distance } = import(linear-algebra);\\nminkowski-distance([1, 2], [3, 4], 2)',\n 'let { minkowski-distance } = import(linear-algebra);\\nminkowski-distance([1, 2, 3], [4, 5, 6], 3)',\n 'let { minkowski-distance } = import(linear-algebra);\\nminkowski-distance([1, 0], [0, 1], 1)',\n ],\n seeAlso: ['linear-algebra.euclidean-distance', 'linear-algebra.manhattan-distance', 'linear-algebra.chebyshev-distance', 'linear-algebra.minkowski-norm'],\n },\n 'minkowski-norm': {\n category: 'linear-algebra',\n description: 'Calculates the **Minkowski norm** of a vector. The result is a non-negative number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Vector to calculate the norm for.',\n },\n b: {\n type: 'number',\n description: 'Order of the norm (p).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { minkowski-norm } = import(linear-algebra);\\nminkowski-norm([1, 2], 2)',\n 'let { minkowski-norm } = import(linear-algebra);\\nminkowski-norm([3, 4], 3)',\n 'let { minkowski-norm } = import(linear-algebra);\\nminkowski-norm([1, 2, 3], 4)',\n ],\n seeAlso: ['linear-algebra.euclidean-norm', 'linear-algebra.manhattan-norm', 'linear-algebra.chebyshev-norm', 'linear-algebra.minkowski-distance'],\n },\n 'cov': {\n category: 'linear-algebra',\n description: 'Calculates the **covariance** between two vectors. The result is a number.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { cov } = import(linear-algebra);\\ncov([1, 2], [3, 4])',\n 'let { cov } = import(linear-algebra);\\ncov([1, 2, 3], [4, 5, 6])',\n 'let { cov } = import(linear-algebra);\\ncov([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.corr', 'linear-algebra.pearson-corr', 'vector.variance'],\n },\n 'corr': {\n category: 'linear-algebra',\n description: 'Calculates the **correlation** between two vectors. The result is a number between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { corr } = import(linear-algebra);\\ncorr([1, 2], [3, 4])',\n 'let { corr } = import(linear-algebra);\\ncorr([1, 2, 3], [4, 5, 6])',\n 'let { corr } = import(linear-algebra);\\ncorr([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.cov', 'linear-algebra.pearson-corr', 'linear-algebra.spearman-corr', 'linear-algebra.kendall-tau', 'linear-algebra.autocorrelation', 'linear-algebra.cross-correlation'],\n },\n 'spearman-corr': {\n category: 'linear-algebra',\n description: 'Calculates the **Spearman rank correlation** between two vectors. The result is a number between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { spearman-corr } = import(linear-algebra);\\nspearman-corr([1, 2], [3, 4])',\n 'let { spearman-corr } = import(linear-algebra);\\nspearman-corr([1, 2, 3], [4, 5, 6])',\n 'let { spearman-corr } = import(linear-algebra);\\nspearman-corr([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.pearson-corr', 'linear-algebra.kendall-tau', 'linear-algebra.corr'],\n },\n 'pearson-corr': {\n category: 'linear-algebra',\n description: 'Calculates the **Pearson correlation** between two vectors. The result is a number between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { pearson-corr } = import(linear-algebra);\\npearson-corr([1, 2], [3, 4])',\n 'let { pearson-corr } = import(linear-algebra);\\npearson-corr([1, 2, 3], [4, 5, 6])',\n 'let { pearson-corr } = import(linear-algebra);\\npearson-corr([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.spearman-corr', 'linear-algebra.kendall-tau', 'linear-algebra.corr', 'linear-algebra.cov'],\n },\n 'kendall-tau': {\n category: 'linear-algebra',\n description: 'Calculates the **Kendall Tau** rank correlation coefficient between two vectors. The result is a number between -1 and 1.',\n returns: {\n type: 'number',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { kendall-tau } = import(linear-algebra);\\nkendall-tau([1, 2], [3, 4])',\n 'let { kendall-tau } = import(linear-algebra);\\nkendall-tau([1, 2, 3], [4, 5, 6])',\n 'let { kendall-tau } = import(linear-algebra);\\nkendall-tau([1, 0], [0, 1])',\n ],\n seeAlso: ['linear-algebra.spearman-corr', 'linear-algebra.pearson-corr', 'linear-algebra.corr'],\n },\n 'autocorrelation': {\n category: 'linear-algebra',\n description: 'Calculates the **autocorrelation** of a vector. The result is a vector of autocorrelation coefficients.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n description: 'Vector to calculate the autocorrelation for.',\n },\n b: {\n type: 'integer',\n description: 'Lag value for the autocorrelation.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { autocorrelation } = import(linear-algebra);\\nautocorrelation([1, 2, 3], -2)',\n 'let { autocorrelation } = import(linear-algebra);\\nautocorrelation([1, 2, 3], -1)',\n 'let { autocorrelation } = import(linear-algebra);\\nautocorrelation([1, 2, 3], 0)',\n 'let { autocorrelation } = import(linear-algebra);\\nautocorrelation([1, 2, 3], 1)',\n 'let { autocorrelation } = import(linear-algebra);\\nautocorrelation([1, 2, 3], 2)',\n ],\n seeAlso: ['linear-algebra.cross-correlation', 'linear-algebra.corr'],\n },\n 'cross-correlation': {\n category: 'linear-algebra',\n description: 'Calculates the **cross-correlation** between two vectors. The result is a vector of cross-correlation coefficients.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'vector',\n },\n b: {\n type: 'vector',\n },\n lag: {\n type: 'integer',\n description: 'Lag value for the cross-correlation.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n 'lag',\n ],\n },\n ],\n examples: [\n 'let { cross-correlation } = import(linear-algebra);\\ncross-correlation([1, 2, 3], [4, 5, 6], -2)',\n 'let { cross-correlation } = import(linear-algebra);\\ncross-correlation([1, 2, 3], [4, 5, 6], -1)',\n 'let { cross-correlation } = import(linear-algebra);\\ncross-correlation([1, 2, 3], [4, 5, 6], 0)',\n 'let { cross-correlation } = import(linear-algebra);\\ncross-correlation([1, 2, 3], [4, 5, 6], 1)',\n 'let { cross-correlation } = import(linear-algebra);\\ncross-correlation([1, 2, 3], [4, 5, 6], 2)',\n ],\n seeAlso: ['linear-algebra.autocorrelation', 'linear-algebra.corr'],\n },\n 'rref': {\n category: 'linear-algebra',\n description: 'Calculates the **Reduced Row Echelon Form** (RREF) of a matrix.',\n returns: {\n type: 'matrix',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'Matrix to calculate the RREF for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { rref } = import(linear-algebra);\\nrref([[1, 2], [3, 4]])',\n 'let { rref } = import(linear-algebra);\\nrref([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n 'let { rref } = import(linear-algebra);\\nrref([[1, 2, 3], [7, 8, 9], [4, 5, 7]])',\n ],\n seeAlso: ['linear-algebra.solve', 'matrix.rank'],\n },\n 'solve': {\n category: 'linear-algebra',\n description: 'Solves a system of linear equations represented by a matrix and a vector.',\n returns: {\n type: 'vector',\n },\n args: {\n a: {\n type: 'matrix',\n },\n b: {\n type: 'vector',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n '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])',\n `let { solve } = import(linear-algebra);\nsolve([[2, 0, 0], [3, 1, 0], [4, 5, 6]], [4, 5, 38])`,\n `let { solve } = import(linear-algebra);\nsolve([[2, 3], [1, -1]], [8, 2])`,\n ],\n seeAlso: ['linear-algebra.rref', 'matrix.inv'],\n },\n 'to-polar': {\n category: 'linear-algebra',\n description: 'Converts a 2D vector to polar coordinates.',\n returns: {\n type: 'vector',\n },\n args: {\n vector: {\n type: 'vector',\n description: '2D Vector to convert.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'vector',\n ],\n },\n ],\n examples: [\n 'let { to-polar } = import(linear-algebra);\\nto-polar([1, 2])',\n 'let { to-polar } = import(linear-algebra);\\nto-polar([3, 4])',\n ],\n seeAlso: ['linear-algebra.from-polar', 'linear-algebra.angle'],\n },\n 'from-polar': {\n category: 'linear-algebra',\n description: 'Converts polar coordinates to a 2D vector.',\n returns: {\n type: 'vector',\n },\n args: {\n polar: {\n type: 'vector',\n description: 'Polar coordinates to convert.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'polar',\n ],\n },\n ],\n examples: [\n 'let { from-polar } = import(linear-algebra);\\nfrom-polar([1, PI / 4])',\n 'let { from-polar } = import(linear-algebra);\\nfrom-polar([1, 0])',\n 'let { from-polar } = import(linear-algebra);\\nfrom-polar([1, -PI / 2])',\n ],\n seeAlso: ['linear-algebra.to-polar'],\n },\n}\n","import { approxZero } from '../../../../utils'\n\n/**\n * Performs Gauss-Jordan elimination on a matrix, transforming it to reduced row echelon form\n *\n * @param matrix - The input matrix\n * @returns A tuple containing the reduced row echelon form matrix and the rank\n */\nexport function gaussJordanElimination(matrix: number[][]): [number[][], number] {\n // Create a copy of the matrix to avoid modifying the original\n const m = matrix.map(row => [...row])\n const rows = m.length\n const cols = m[0]!.length\n\n let rank = 0\n let rowsProcessed = 0\n\n // Row reduction to reduced row echelon form\n for (let col = 0; col < cols; col++) {\n // Find the pivot\n let pivotRow = -1\n\n for (let row = rowsProcessed; row < rows; row++) {\n if (!approxZero(m[row]![col]!)) {\n pivotRow = row\n break\n }\n }\n\n if (pivotRow === -1)\n continue // No pivot in this column\n\n // Increase rank\n rank += 1\n\n // Swap rows\n if (pivotRow !== rowsProcessed) {\n [m[pivotRow], m[rowsProcessed]] = [m[rowsProcessed]!, m[pivotRow]!]\n }\n\n // Get the pivot value\n const pivotValue = m[rowsProcessed]![col]!\n\n // Normalize the pivot row (always, for RREF)\n for (let j = col; j < cols; j++) {\n m[rowsProcessed]![j]! /= pivotValue\n }\n\n // Eliminate above and below (full Gauss-Jordan)\n for (let row = 0; row < rows; row++) {\n if (row !== rowsProcessed && !approxZero(m[row]![col]!)) {\n const factor = m[row]![col]!\n for (let j = col; j < cols; j++) {\n m[row]![j]! -= factor * m[rowsProcessed]![j]!\n }\n }\n }\n\n rowsProcessed++\n if (rowsProcessed === rows)\n break\n }\n\n return [m, rank]\n}\n","import { approxEqual, approxZero } from '../../../../utils'\n\nexport function areVectorsCollinear(vectorA: number[], vectorB: number[]): boolean {\n // Check if either vector is zero\n const isZeroVector = (vec: number[]): boolean =>\n vec.every(component => approxZero(component))\n\n if (isZeroVector(vectorA) || isZeroVector(vectorB)) {\n return true // Zero vector is technically collinear to all vectors\n }\n\n // Find the first non-zero component in vectorA\n let index = 0\n while (index < vectorA.length && approxZero(vectorA[index]!)) {\n index++\n }\n\n // Calculate the scale factor\n const ratio = vectorB[index]! / vectorA[index]!\n\n // Check if all other components maintain the same ratio\n for (let i = 0; i < vectorA.length; i++) {\n // Skip components where both vectors have (near) zero values\n if (approxZero(vectorA[i]!) && approxZero(vectorB[i]!))\n continue\n\n // If vectorA component is near zero but vectorB is not, vectors are not collinear\n if (approxZero(vectorA[i]!))\n return false\n\n // Check if the ratio is consistent\n if (!approxEqual(vectorB[i]! / vectorA[i]!, ratio)) {\n return false\n }\n }\n\n return true\n}\n\nexport function areVectorsParallel(vectorA: number[], vectorB: number[]): boolean {\n if (!areVectorsCollinear(vectorA, vectorB)) {\n return false\n }\n\n // Then verify they point in the same direction\n // Find first non-zero component in both vectors\n for (let i = 0; i < vectorA.length; i++) {\n if (!approxZero(vectorA[i]!) && !approxZero(vectorB[i]!)) {\n return Math.sign(vectorA[i]!) === Math.sign(vectorB[i]!)\n }\n }\n\n // If we get here, one of the vectors must be zero\n return true\n}\n","import { approxZero } from '../../../../utils'\n\nexport function isZeroVector(vector: number[]): boolean {\n return vector.every(component => approxZero(component))\n}\n","import { calcMean } from '../../vector/calcMean'\n\nexport function pearsonCorr(vectorA: number[], vectorB: number[]): number {\n const meanA = calcMean(vectorA)\n const meanB = calcMean(vectorB)\n\n let sumNumerator = 0\n let sumSquareA = 0\n let sumSquareB = 0\n\n for (let i = 0; i < vectorA.length; i++) {\n const diffA = vectorA[i]! - meanA\n const diffB = vectorB[i]! - meanB\n\n sumNumerator += diffA * diffB\n sumSquareA += diffA * diffA\n sumSquareB += diffB * diffB\n }\n\n // Check if either vector has zero variance\n if (sumSquareA === 0 || sumSquareB === 0) {\n throw new Error('Cannot calculate Pearson correlation coefficient: one of the vectors has zero variance.')\n }\n\n return sumNumerator / (Math.sqrt(sumSquareA) * Math.sqrt(sumSquareB))\n}\n","export function calcFractionalRanks(vector: number[]): number[] {\n // Create array of indices and sort by values\n const indices = [...vector.keys()].sort((a, b) => vector[a]! - vector[b]!)\n\n // Create ranks array (same size as input vector)\n const ranks: number[] = Array.from<number>({ length: vector.length }).fill(0)\n\n // Assign ranks, handling ties properly\n let currentRank = 1\n let i = 0\n while (i < indices.length) {\n const value = vector[indices[i]!]\n let j = i\n\n // Find all indices with the same value\n while (j < indices.length && vector[indices[j]!] === value) {\n j++\n }\n\n // Calculate average rank for ties\n const averageRank = currentRank + (j - i - 1) / 2\n\n // Assign average rank to all tied elements\n for (let k = i; k < j; k++) {\n ranks[indices[k]!] = averageRank\n }\n\n // Update current rank and index\n currentRank += j - i\n i = j\n }\n\n return ranks\n}\n","import { calcMean } from '../../vector/calcMean'\n\n/**\n * Calculate covariance between two segments\n */\nexport function calcCovariance(segmentA: number[], segmentB: number[]): number {\n const meanA = calcMean(segmentA)\n const meanB = calcMean(segmentB)\n\n let sum = 0\n for (let i = 0; i < segmentA.length; i++) {\n sum += (segmentA[i]! - meanA) * (segmentB[i]! - meanB)\n }\n\n return sum / segmentA.length\n}\n","import { DvalaError } from '../../../../errors'\nimport type { SourceCodeInfo } from '../../../../tokenizer/token'\nimport { approxZero } from '../../../../utils'\n\nexport function getUnit<T extends number[]>(\n value: T,\n sourceCodeInfo: SourceCodeInfo | undefined,\n): T {\n if (value.length === 0) {\n return value\n }\n const length = Math.sqrt(value.reduce((acc, item) => acc + item ** 2, 0))\n if (approxZero(length)) {\n throw new DvalaError('The vector must not be zero', sourceCodeInfo)\n }\n return value.map(item => item / length) as T\n}\n","export function dot(\n vector1: number[],\n vector2: number[],\n): number {\n return vector1.reduce((acc, item, index) => acc + item * vector2[index]!, 0)\n}\n","export function subtract<T extends number[]>(\n vector1: T,\n vector2: T,\n): T {\n return vector1.map((item, index) => item - vector2[index]!) as T\n}\n","export function scale<T extends number[]>(\n vector: T,\n scalar: number,\n): T {\n return vector.map(item => item * scalar) as T\n}\n","import { DvalaError } from '../../../errors'\nimport { assert2dVector, assert3dVector, assertMatrix, assertNonEmptyVector, assertSquareMatrix, assertVector } from '../../../typeGuards/annotatedArrays'\nimport { assertNumber } from '../../../typeGuards/number'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport type { DvalaModule } from '../interface'\nimport { calcMean } from '../vector/calcMean'\nimport { calcMedad } from '../vector/calcMedad'\nimport { calcMedian } from '../vector/calcMedian'\nimport { calcStdDev } from '../vector/calcStdDev'\nimport { toFixedArity } from '../../../utils/arity'\nimport { moduleDocs } from './docs'\nimport { gaussJordanElimination } from './helpers/gaussJordanElimination'\nimport { solve } from './helpers/solve'\nimport { areVectorsCollinear, areVectorsParallel } from './helpers/collinear'\nimport { isZeroVector } from './helpers/isZeroVector'\nimport { pearsonCorr } from './helpers/pearsonCorr'\nimport { calcFractionalRanks } from './helpers/calcFractionalRanks'\nimport { kendallTau } from './helpers/kendallTau'\nimport { calcCovariance } from './helpers/covariance'\nimport { calcCorrelation, extractOverlappingSegments } from './helpers/corrleation'\nimport { getUnit } from './helpers/getUnit'\nimport { dot } from './helpers/dot'\nimport { subtract } from './helpers/subtract'\nimport { scale } from './helpers/scale'\nimport { length } from './helpers/length'\n\nexport const linearAlgebraNormalExpression: BuiltinNormalExpressions = {\n 'rotate2d': {\n evaluate: ([vector, radians], sourceCodeInfo): number[] => {\n assert2dVector(vector, sourceCodeInfo)\n if (isZeroVector(vector)) {\n return vector\n }\n assertNumber(radians, sourceCodeInfo, { finite: true })\n const cosTheta = Math.cos(radians)\n const sinTheta = Math.sin(radians)\n return [\n vector[0] * cosTheta - vector[1] * sinTheta,\n vector[0] * sinTheta + vector[1] * cosTheta,\n ]\n },\n arity: toFixedArity(2),\n },\n 'rotate3d': {\n evaluate: ([vector, axis, radians], sourceCodeInfo): number[] => {\n assert3dVector(vector, sourceCodeInfo)\n if (isZeroVector(vector)) {\n return vector\n }\n assertNumber(radians, sourceCodeInfo, { finite: true })\n assert3dVector(axis, sourceCodeInfo)\n if (isZeroVector(axis)) {\n throw new DvalaError('Rotation axis must not be zero', sourceCodeInfo)\n }\n const cosTheta = Math.cos(radians)\n const sinTheta = Math.sin(radians)\n const [u, v, w] = getUnit(axis, sourceCodeInfo)\n const dotProduct = vector[0] * u + vector[1] * v + vector[2] * w\n return [\n dotProduct * u * (1 - cosTheta) + vector[0] * cosTheta + (-w * vector[1] + v * vector[2]) * sinTheta,\n dotProduct * v * (1 - cosTheta) + vector[1] * cosTheta + (w * vector[0] - u * vector[2]) * sinTheta,\n dotProduct * w * (1 - cosTheta) + vector[2] * cosTheta + (-v * vector[0] + u * vector[1]) * sinTheta,\n ]\n },\n arity: toFixedArity(3),\n },\n 'reflect': {\n evaluate: ([vector, normal], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n assertVector(normal, sourceCodeInfo)\n if (vector.length !== normal.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n if (isZeroVector(normal)) {\n throw new DvalaError('Reflection normal must not be zero', sourceCodeInfo)\n }\n if (isZeroVector(vector)) {\n return vector\n }\n const unitNormal = getUnit(normal, sourceCodeInfo)\n const doubleDot = 2 * dot(vector, unitNormal)\n return subtract(vector, scale(unitNormal, doubleDot))\n },\n arity: toFixedArity(2),\n },\n 'refract': {\n evaluate: ([vector, normal, eta], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n assertVector(normal, sourceCodeInfo)\n assertNumber(eta, sourceCodeInfo, { finite: true, positive: true })\n if (vector.length !== normal.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n if (isZeroVector(normal)) {\n throw new DvalaError('Refraction normal must not be zero', sourceCodeInfo)\n }\n if (isZeroVector(vector)) {\n return vector\n }\n // Make sure vectors are normalized\n const normalizedV = getUnit(vector, sourceCodeInfo)\n const normalizedNormal = getUnit(normal, sourceCodeInfo)\n\n // Calculate dot product between incident vector and normal\n const dotProduct = dot(normalizedV, normalizedNormal)\n\n // Calculate discriminant\n const discriminant = 1 - eta * eta * (1 - dotProduct * dotProduct)\n\n // Check for total internal reflection\n if (discriminant < 0) {\n return vector // Total internal reflection occurs\n }\n\n // Calculate the refracted vector\n const scaledIncident = scale(normalizedV, eta)\n const scaledNormal = scale(\n normalizedNormal,\n eta * dotProduct + Math.sqrt(discriminant),\n )\n\n return subtract(scaledIncident, scaledNormal)\n },\n arity: toFixedArity(3),\n },\n 'lerp': {\n evaluate: ([vectorA, vectorB, t], sourceCodeInfo): number[] => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n assertNumber(t, sourceCodeInfo, { finite: true })\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n return vectorA.map((val, i) => val + (vectorB[i]! - val) * t)\n },\n arity: toFixedArity(3),\n },\n 'dot': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return dot(vectorA, vectorB)\n },\n arity: toFixedArity(2),\n },\n 'cross': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number[] => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== 3 || vectorB.length !== 3) {\n throw new DvalaError('Cross product is only defined for 3D vectors', sourceCodeInfo)\n }\n\n return [\n vectorA[1]! * vectorB[2]! - vectorA[2]! * vectorB[1]!,\n vectorA[2]! * vectorB[0]! - vectorA[0]! * vectorB[2]!,\n vectorA[0]! * vectorB[1]! - vectorA[1]! * vectorB[0]!,\n ] as number[]\n },\n arity: toFixedArity(2),\n },\n 'normalize-minmax': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n if (vector.length === 0) {\n return []\n }\n\n const min = vector.reduce((acc, val) => (val < acc ? val : acc), vector[0]!)\n const max = vector.reduce((acc, val) => (val > acc ? val : acc), vector[0]!)\n\n if (min === max) {\n return vector.map(() => 0)\n }\n\n return vector.map(val => (val - min) / (max - min))\n },\n arity: toFixedArity(1),\n },\n 'normalize-robust': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n if (vector.length === 0) {\n return []\n }\n\n const median = calcMedian(vector)\n const medad = calcMedad(vector)\n\n if (medad === 0) {\n return vector.map(val => val - median)\n }\n return vector.map(val => (val - median) / medad)\n },\n arity: toFixedArity(1),\n },\n 'normalize-zscore': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n const mean = calcMean(vector)\n const stdDev = calcStdDev(vector)\n\n if (stdDev === 0) {\n return vector.map(() => 0)\n }\n\n return vector.map(val => (val - mean) / stdDev)\n },\n arity: toFixedArity(1),\n },\n 'normalize-l1': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n if (vector.length === 0) {\n return []\n }\n const norm = vector.reduce((acc, val) => acc + Math.abs(val), 0)\n\n if (norm === 0) {\n return vector.map(() => 0)\n }\n\n return vector.map(val => val / norm)\n },\n arity: toFixedArity(1),\n },\n 'normalize-l2': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n return getUnit(vector, sourceCodeInfo)\n },\n arity: toFixedArity(1),\n },\n 'normalize-log': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assertVector(vector, sourceCodeInfo)\n\n if (vector.length === 0) {\n return []\n }\n\n const min = Math.min(...vector)\n\n if (min <= 0) {\n throw new DvalaError('Log normalization requires all values to be positive', sourceCodeInfo)\n }\n\n return vector.map(val => Math.log(val / min))\n },\n arity: toFixedArity(1),\n },\n 'angle': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n if (isZeroVector(vectorA) || isZeroVector(vectorB)) {\n throw new DvalaError('Cannot calculate angle with zero-length vector', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const dotProduct = vectorA.reduce((acc, val, i) => acc + val * vectorB[i]!, 0)\n const magnitudeA = Math.sqrt(vectorA.reduce((acc, val) => acc + val * val, 0))\n const magnitudeB = Math.sqrt(vectorB.reduce((acc, val) => acc + val * val, 0))\n\n return Math.acos(dotProduct / (magnitudeA * magnitudeB))\n },\n arity: toFixedArity(2),\n },\n 'projection': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number[] => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n if (isZeroVector(vectorB)) {\n throw new DvalaError('Cannot project onto zero-length vector', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const dotProduct = vectorA.reduce((acc, val, i) => acc + val * vectorB[i]!, 0)\n const magnitudeB = Math.sqrt(vectorB.reduce((acc, val) => acc + val * val, 0))\n\n return vectorB.map(val => (dotProduct / (magnitudeB ** 2)) * val)\n },\n arity: toFixedArity(2),\n },\n 'orthogonal?': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): boolean => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const dotProduct = vectorA.reduce((acc, val, i) => acc + val * vectorB[i]!, 0)\n return dotProduct === 0\n },\n arity: toFixedArity(2),\n },\n 'parallel?': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): boolean => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return areVectorsParallel(vectorA, vectorB)\n },\n arity: toFixedArity(2),\n },\n 'collinear?': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): boolean => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return areVectorsCollinear(vectorA, vectorB)\n },\n arity: toFixedArity(2),\n },\n 'cosine-similarity': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n if (isZeroVector(vectorA) || isZeroVector(vectorB)) {\n throw new DvalaError('Cannot calculate cosine similarity with zero-length vector', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const dotProduct = vectorA.reduce((acc, val, i) => acc + val * vectorB[i]!, 0)\n const magnitudeA = Math.sqrt(vectorA.reduce((acc, val) => acc + val * val, 0))\n const magnitudeB = Math.sqrt(vectorB.reduce((acc, val) => acc + val * val, 0))\n\n return dotProduct / (magnitudeA * magnitudeB)\n },\n arity: toFixedArity(2),\n },\n 'euclidean-distance': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return Math.sqrt(vectorA.reduce((acc, val, i) => acc + (val - vectorB[i]!) ** 2, 0))\n },\n arity: toFixedArity(2),\n },\n 'euclidean-norm': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n\n return length(vector)\n },\n arity: toFixedArity(1),\n },\n 'manhattan-distance': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return vectorA.reduce((acc, val, i) => acc + Math.abs(val - vectorB[i]!), 0)\n },\n arity: toFixedArity(2),\n },\n 'manhattan-norm': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n\n return vector.reduce((acc, val) => acc + Math.abs(val), 0)\n },\n arity: toFixedArity(1),\n },\n 'hamming-distance': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return vectorA.reduce((acc, val, i) => acc + (val !== vectorB[i]! ? 1 : 0), 0)\n },\n arity: toFixedArity(2),\n },\n 'hamming-norm': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc + (val !== 0 ? 1 : 0), 0)\n },\n arity: toFixedArity(1),\n },\n 'chebyshev-distance': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return Math.max(...vectorA.map((val, i) => Math.abs(val - vectorB[i]!)))\n },\n arity: toFixedArity(2),\n },\n 'chebyshev-norm': {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return Math.max(...vector.map(val => Math.abs(val)))\n },\n arity: toFixedArity(1),\n },\n 'minkowski-distance': {\n evaluate: ([vectorA, vectorB, p], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n assertNumber(p, sourceCodeInfo, { finite: true, positive: true })\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n return vectorA.reduce((acc, val, i) => acc + Math.abs(val - vectorB[i]!) ** p, 0) ** (1 / p)\n },\n arity: toFixedArity(3),\n },\n 'minkowski-norm': {\n evaluate: ([vector, p], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n assertNumber(p, sourceCodeInfo, { finite: true, positive: true })\n return vector.reduce((acc, val) => acc + Math.abs(val) ** p, 0) ** (1 / p)\n },\n arity: toFixedArity(2),\n },\n 'cov': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertNonEmptyVector(vectorA, sourceCodeInfo)\n assertNonEmptyVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n if (vectorA.length === 1) {\n return 0\n }\n\n return calcCovariance(vectorA, vectorB)\n },\n arity: toFixedArity(2),\n },\n 'corr': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length <= 1) {\n throw new DvalaError('Vectors must have at least 2 elements for corr', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const meanA = calcMean(vectorA)\n const meanB = calcMean(vectorB)\n\n const numerator = vectorA.reduce((acc, val, i) => acc + (val - meanA) * (vectorB[i]! - meanB), 0)\n const denominator = Math.sqrt(\n vectorA.reduce((acc, val) => acc + (val - meanA) ** 2, 0) * vectorB.reduce((acc, val) => acc + (val - meanB) ** 2, 0),\n )\n\n return numerator / denominator\n },\n arity: toFixedArity(2),\n },\n 'spearman-corr': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length <= 1) {\n throw new DvalaError('Vectors must have at least 2 elements for corr', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n const ranksA = calcFractionalRanks(vectorA)\n const ranksB = calcFractionalRanks(vectorB)\n\n try {\n return pearsonCorr(ranksA, ranksB)\n }\n catch (error) {\n throw new DvalaError(error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(2),\n },\n 'pearson-corr': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length <= 1) {\n throw new DvalaError('Vectors must have at least 2 elements for pearson-corr', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n try {\n return pearsonCorr(vectorA, vectorB)\n }\n catch (error) {\n throw new DvalaError(error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(2),\n },\n 'kendall-tau': {\n evaluate: ([vectorA, vectorB], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length < 2) {\n throw new DvalaError('Vectors must have at least 2 elements for kendall-tau', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n try {\n return kendallTau(vectorA, vectorB)\n }\n catch (error) {\n throw new DvalaError(error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(2),\n },\n 'autocorrelation': {\n evaluate: ([vector, lag], sourceCodeInfo): number => {\n assertVector(vector, sourceCodeInfo)\n if (vector.length < 2) {\n throw new DvalaError('Vector must have at least 2 elements for autocorrelation', sourceCodeInfo)\n }\n\n assertNumber(lag, sourceCodeInfo, {\n integer: true,\n lt: vector.length,\n gt: -vector.length,\n })\n\n // For lag 0, return 1 (a series is perfectly correlated with itself)\n if (lag === 0) {\n return 1\n }\n const absLag = Math.abs(lag)\n const mean = calcMean(vector)\n\n // Calculate the numerator (sum of products of deviations)\n let numerator = 0\n const n = vector.length\n\n // If lag is positive, correlate current with past values\n // If lag is negative, correlate current with future values (same calculation, different interpretation)\n for (let i = 0; i < n - absLag; i++) {\n const currentIndex = lag < 0 ? i + absLag : i\n const laggedIndex = lag < 0 ? i : i + absLag\n\n numerator += (vector[currentIndex]! - mean) * (vector[laggedIndex]! - mean)\n }\n\n // Calculate the denominator (sum of squared deviations)\n let denominator = 0\n for (let i = 0; i < n; i++) {\n denominator += (vector[i]! - mean) ** 2\n }\n\n // Handle edge case of zero variance\n if (denominator === 0) {\n return 0 // Conventional definition\n }\n\n // Return the autocorrelation coefficient\n return numerator / denominator\n },\n arity: toFixedArity(2),\n },\n\n 'cross-correlation': {\n evaluate: ([vectorA, vectorB, lag], sourceCodeInfo): number => {\n assertVector(vectorA, sourceCodeInfo)\n assertVector(vectorB, sourceCodeInfo)\n\n if (vectorA.length < 2) {\n throw new DvalaError('Vectors must have at least 2 elements', sourceCodeInfo)\n }\n\n if (vectorA.length !== vectorB.length) {\n throw new DvalaError('Vectors must be of the same length', sourceCodeInfo)\n }\n\n assertNumber(lag, sourceCodeInfo, {\n integer: true,\n lt: vectorA.length,\n gt: -vectorA.length,\n })\n\n // For lag 0 between identical vectors, return 1\n if (lag === 0\n && vectorA.length === vectorB.length\n && vectorA.every((v, i) => v === vectorB[i])) {\n return 1\n }\n\n const [segmentA, segmentB] = extractOverlappingSegments(vectorA, vectorB, lag)\n return calcCorrelation(segmentA, segmentB)\n },\n arity: toFixedArity(3),\n },\n 'rref': {\n evaluate: ([matrix], sourceCodeInfo): number[][] => {\n assertMatrix(matrix, sourceCodeInfo)\n\n // Reduced Row Echelon Form (RREF)\n const [rref] = gaussJordanElimination(matrix)\n return rref\n },\n arity: toFixedArity(1),\n },\n 'solve': {\n evaluate: ([matrix, vector], sourceCodeInfo): number[] | null => {\n assertSquareMatrix(matrix, sourceCodeInfo)\n assertVector(vector, sourceCodeInfo)\n if (matrix.length !== vector.length) {\n throw new DvalaError(`The number of rows in the matrix must be equal to the length of the vector, but got ${matrix.length} and ${vector.length}`, sourceCodeInfo)\n }\n return solve(matrix, vector)\n },\n arity: toFixedArity(2),\n },\n 'to-polar': {\n evaluate: ([vector], sourceCodeInfo): number[] => {\n assert2dVector(vector, sourceCodeInfo)\n if (isZeroVector(vector)) {\n return [0, 0]\n }\n const r = Math.sqrt(vector[0] ** 2 + vector[1] ** 2)\n const theta = Math.atan2(vector[1], vector[0])\n return [r, theta]\n },\n arity: toFixedArity(1),\n },\n 'from-polar': {\n evaluate: ([polar], sourceCodeInfo): number[] => {\n assert2dVector(polar, sourceCodeInfo)\n const [r, theta] = polar\n if (r === 0) {\n return [0, 0]\n }\n return [r * Math.cos(theta), r * Math.sin(theta)]\n },\n arity: toFixedArity(1),\n },\n}\n\nfor (const [key, docs] of Object.entries(moduleDocs)) {\n if (linearAlgebraNormalExpression[key])\n linearAlgebraNormalExpression[key].docs = docs\n}\n\nexport const linearAlgebraModule: DvalaModule = {\n name: 'linear-algebra',\n functions: linearAlgebraNormalExpression,\n}\n","export function length(vector: number[]): number {\n return Math.sqrt(vector.reduce((acc, item) => acc + item ** 2, 0))\n}\n","/**\n * Calculates Kendall's Tau-b rank correlation coefficient between two vectors\n * This implementation handles ties and uses an epsilon value for floating-point comparisons\n *\n * @param vectorA - First vector of numbers\n * @param vectorB - Second vector of numbers\n * @param epsilon - Threshold for considering two values as equal (default: 1e-10)\n * @returns The Kendall's Tau-b correlation coefficient\n */\nexport function kendallTau(vectorA: number[], vectorB: number[], epsilon: number = 1e-10): number {\n let concordant = 0\n let discordant = 0\n let tiesInA = 0\n let tiesInB = 0\n\n // Compare all pairs\n for (let i = 0; i < vectorA.length; i++) {\n for (let j = i + 1; j < vectorA.length; j++) {\n // Calculate differences\n const diffA = vectorA[i]! - vectorA[j]!\n const diffB = vectorB[i]! - vectorB[j]!\n\n // Check for ties using epsilon\n const isTieA = Math.abs(diffA) < epsilon\n const isTieB = Math.abs(diffB) < epsilon\n\n if (isTieA && isTieB) {\n // Tied in both vectors\n continue\n }\n else if (isTieA) {\n // Tied in vector A only\n tiesInA += 1\n }\n else if (isTieB) {\n // Tied in vector B only\n tiesInB += 1\n }\n else if (diffA * diffB > 0) {\n // Concordant pair\n concordant += 1\n }\n else {\n // Discordant pair\n discordant += 1\n }\n }\n }\n\n const n1 = concordant + discordant + tiesInA\n const n2 = concordant + discordant + tiesInB\n\n // Handle edge cases to avoid division by zero\n if (n1 === 0 || n2 === 0) {\n throw new Error('Not enough data to calculate Kendall\\'s Tau')\n }\n\n // Kendall's Tau-b formula\n return (concordant - discordant) / Math.sqrt(n1 * n2)\n}\n","import { calcMean } from '../../vector/calcMean'\nimport { calcStdDev } from '../../vector/calcStdDev'\nimport { calcCovariance } from './covariance'\n\n/**\n * Calculate Pearson correlation between two segments\n */\nexport function calcCorrelation(segmentA: number[], segmentB: number[]): number {\n const meanA = calcMean(segmentA)\n const meanB = calcMean(segmentB)\n\n const stdA = calcStdDev(segmentA, meanA)\n const stdB = calcStdDev(segmentB, meanB)\n\n // Handle zero variance\n if (stdA === 0 || stdB === 0) {\n // If both have zero variance and are the same constant, they're perfectly correlated\n if (stdA === 0 && stdB === 0 && meanA === meanB) {\n return 1\n }\n // Otherwise, no meaningful correlation can be established\n return 0\n }\n\n const covariance = calcCovariance(segmentA, segmentB)\n return covariance / (stdA * stdB)\n}\n\n/**\n * Extract overlapping segments from two vectors based on lag\n */\nexport function extractOverlappingSegments(\n vectorA: number[],\n vectorB: number[],\n lag: number,\n): [number[], number[]] {\n const absLag = Math.abs(lag)\n const overlapLength = vectorA.length - absLag\n\n let segmentA = []\n let segmentB = []\n\n if (lag >= 0) {\n segmentA = vectorA.slice(0, overlapLength)\n segmentB = vectorB.slice(lag, lag + overlapLength)\n }\n else {\n segmentA = vectorA.slice(absLag)\n segmentB = vectorB.slice(0, overlapLength)\n }\n\n return [segmentA, segmentB]\n}\n","import { approxZero } from '../../../../utils'\nimport { gaussJordanElimination } from './gaussJordanElimination'\n\n/**\n * Solves a system of linear equations Ax = b\n *\n * @param A - The coefficient matrix\n * @param b - The constant vector\n * @returns The solution vector x, or null if no unique solution exists\n */\nexport function solve(A: number[][], b: number[]): number[] | null {\n const n = A.length\n\n // Create augmented matrix [A|b]\n const augmented = A.map((row, i) => [...row, b[i]!])\n\n // Convert to row echelon form using your existing function\n const [echelon] = gaussJordanElimination(augmented)\n\n // Check if the system has a unique solution\n for (let i = 0; i < n; i += 1) {\n if (approxZero(echelon[i]![i]!)) {\n return null // No unique solution\n }\n }\n\n // Back substitution\n const x = Array.from({ length: n }, () => 0)\n for (let i = n - 1; i >= 0; i--) {\n let sum = 0\n for (let j = i + 1; j < n; j++) {\n sum += echelon[i]![j]! * x[j]!\n }\n x[i] = (echelon[i]![n]! - sum) / echelon[i]![i]!\n }\n\n return x\n}\n","import type { FunctionDocs } from '../../interface'\n\nexport const moduleDocs: Record<string, FunctionDocs> = {\n 'mul': {\n category: 'matrix',\n description: 'Multiplies two `matrices` using standard `matrix` multiplication based on **dot products** of rows and columns.',\n returns: {\n type: 'matrix',\n },\n args: {\n a: {\n type: 'matrix',\n },\n b: {\n type: 'matrix',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { mul } = import(matrix);\\nmul([[1, 2], [3, 4]], [[5, 6], [7, 8]])',\n 'let { mul } = import(matrix);\\nmul([[1, 2, 3], [4, 5, 6]], [[7, 8], [9, 10], [11, 12]])',\n ],\n seeAlso: ['matrix.det', 'matrix.inv'],\n },\n 'det': {\n category: 'matrix',\n description: 'Calculates the **determinant** of a square matrix.',\n returns: {\n type: 'number',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to calculate the determinant of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { det } = import(matrix);\\ndet([[1, 2], [3, 4]])',\n 'let { det } = import(matrix);\\ndet([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n ],\n seeAlso: ['matrix.inv', 'matrix.cofactor', 'matrix.adj', 'matrix.trace', 'matrix.rank', 'matrix.invertible?', 'matrix.mul', 'matrix.minor'],\n },\n 'inv': {\n category: 'matrix',\n description: 'Calculates the **inverse** of a square matrix.',\n returns: {\n type: 'matrix',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to calculate the inverse of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { inv } = import(matrix);\\ninv([[1, 2], [3, 4]])',\n 'let { inv } = import(matrix);\\ninv([[1, 2, 3], [4, 5, 7], [7, 8, 10]])',\n ],\n seeAlso: ['matrix.det', 'matrix.adj', 'matrix.invertible?', 'linear-algebra.solve', 'matrix.mul', 'matrix.orthogonal-matrix?'],\n },\n 'adj': {\n category: 'matrix',\n description: 'Calculates the **adjugate** of a square matrix.',\n returns: {\n type: 'matrix',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to calculate the adjugate of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { adj } = import(matrix);\\nadj([[1, 2], [3, 4]])',\n 'let { adj } = import(matrix);\\nadj([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n 'let { adj } = import(matrix);\\nadj([[1, 2, 3], [7, 8, 9], [4, 5, 6]])',\n ],\n seeAlso: ['matrix.cofactor', 'matrix.det', 'matrix.inv'],\n },\n 'cofactor': {\n category: 'matrix',\n description: 'Calculates the **cofactor** of a square matrix.',\n returns: {\n type: 'matrix',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to calculate the cofactor of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { cofactor } = import(matrix);\\ncofactor([[1, 2], [3, 4]])',\n 'let { cofactor } = import(matrix);\\ncofactor([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n 'let { cofactor } = import(matrix);\\ncofactor([[1, 2, 3], [7, 8, 9], [4, 5, 6]])',\n ],\n seeAlso: ['matrix.adj', 'matrix.minor', 'matrix.det'],\n },\n 'minor': {\n category: 'matrix',\n description: 'Calculates the **minor** of a square matrix.',\n returns: {\n type: 'matrix',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to calculate the minor of.',\n },\n row: {\n type: 'integer',\n description: 'The row index of the element to calculate the minor for.',\n },\n col: {\n type: 'integer',\n description: 'The column index of the element to calculate the minor for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n 'row',\n 'col',\n ],\n },\n ],\n examples: [\n 'let { minor } = import(matrix);\\nminor([[1, 2], [3, 4]], 0, 1)',\n 'let { minor } = import(matrix);\\nminor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 1, 1)',\n ],\n seeAlso: ['matrix.cofactor', 'matrix.det'],\n },\n 'trace': {\n category: 'matrix',\n description: 'Calculates the **trace** of a square matrix.',\n returns: {\n type: 'number',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to calculate the trace of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { trace } = import(matrix);\\ntrace([[1, 2], [3, 4]])',\n 'let { trace } = import(matrix);\\ntrace([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n ],\n seeAlso: ['matrix.det', 'matrix.diagonal?'],\n },\n 'symmetric?': {\n category: 'matrix',\n description: 'Checks if a `matrix` is **symmetric**.',\n returns: {\n type: 'boolean',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to check for symmetry.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { symmetric? } = import(matrix);\\nsymmetric?([[1, 2], [2, 1]])',\n 'let { symmetric? } = import(matrix);\\nsymmetric?([[1, 2, 3], [2, 1, 4], [3, 4, 1]])',\n ],\n seeAlso: ['matrix.orthogonal-matrix?', 'matrix.diagonal?', 'matrix.square?', 'matrix.hilbert'],\n },\n 'triangular?': {\n category: 'matrix',\n description: 'Checks if a `matrix` is **triangular**.',\n returns: {\n type: 'boolean',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to check for triangularity.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { triangular? } = import(matrix);\\ntriangular?([[2, 0], [0, 1]])',\n 'let { triangular? } = import(matrix);\\ntriangular?([[1, 2, 3], [0, 4, 5], [0, 0, 6]])',\n ],\n seeAlso: ['matrix.upper-triangular?', 'matrix.lower-triangular?', 'matrix.diagonal?', 'matrix.banded?'],\n },\n 'upper-triangular?': {\n category: 'matrix',\n description: 'Checks if a `matrix` is **upper triangular**.',\n returns: {\n type: 'boolean',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to check for upper triangularity.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { upper-triangular? } = import(matrix);\\nupper-triangular?([[1, 2], [0, 3]])',\n 'let { upper-triangular? } = import(matrix);\\nupper-triangular?([[1, 2, 3], [0, 4, 5], [0, 0, 6]])',\n ],\n seeAlso: ['matrix.lower-triangular?', 'matrix.triangular?', 'matrix.diagonal?'],\n },\n 'lower-triangular?': {\n category: 'matrix',\n description: 'Checks if a `matrix` is **lower triangular**.',\n returns: {\n type: 'boolean',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to check for lower triangularity.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { lower-triangular? } = import(matrix);\\nlower-triangular?([[1, 0], [2, 3]])',\n 'let { lower-triangular? } = import(matrix);\\nlower-triangular?([[1, 0, 0], [2, 3, 0], [4, 5, 6]])',\n ],\n seeAlso: ['matrix.upper-triangular?', 'matrix.triangular?', 'matrix.diagonal?'],\n },\n 'diagonal?': {\n category: 'matrix',\n description: 'Checks if a `matrix` is **diagonal**.',\n returns: {\n type: 'boolean',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to check for diagonal property.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { diagonal? } = import(matrix);\\ndiagonal?([[1, 0], [0, 2]])',\n 'let { diagonal? } = import(matrix);\\ndiagonal?([[1, 0, 0], [0, 2, 0], [0, 0, 3]])',\n 'let { diagonal? } = import(matrix);\\ndiagonal?([[1, 0, 0], [2, 2, 2], [0, 0, 3]])',\n ],\n seeAlso: ['matrix.identity?', 'matrix.symmetric?', 'matrix.triangular?', 'matrix.trace', 'matrix.upper-triangular?', 'matrix.lower-triangular?', 'matrix.band', 'matrix.banded?'],\n },\n 'square?': {\n category: 'matrix',\n description: 'Checks if a `matrix` is **square**.',\n returns: {\n type: 'boolean',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to check for square property.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { square? } = import(matrix);\\nsquare?([[1, 2], [3, 4]])',\n 'let { square? } = import(matrix);\\nsquare?([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n 'let { square? } = import(matrix);\\nsquare?([[1, 2, 3], [4, 5, 6]])',\n ],\n seeAlso: ['matrix.symmetric?', 'matrix.identity?', 'matrix.invertible?'],\n },\n 'orthogonal-matrix?': {\n category: 'matrix',\n description: 'Checks if a `matrix` is **orthogonal**.',\n returns: {\n type: 'boolean',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to check for **orthogonality**.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { orthogonal-matrix? } = import(matrix);\\northogonal-matrix?([[1, 0], [0, 1]])',\n 'let { orthogonal-matrix? } = import(matrix);\\northogonal-matrix?([[1, 0], [0, -1]])',\n 'let { orthogonal-matrix? } = import(matrix);\\northogonal-matrix?([[1, 2], [3, 4]])',\n ],\n seeAlso: ['matrix.symmetric?', 'matrix.inv', 'matrix.identity?', 'linear-algebra.orthogonal?'],\n },\n 'identity?': {\n category: 'matrix',\n description: 'Checks if a `matrix` is an **identity matrix**.',\n returns: {\n type: 'boolean',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to check for identity property.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { identity? } = import(matrix);\\nidentity?([[1, 0], [0, 1]])',\n 'let { identity? } = import(matrix);\\nidentity?([[1, 0, 0], [0, 1, 0], [0, 0, 1]])',\n 'let { identity? } = import(matrix);\\nidentity?([[1, 0, 0], [0, 1, 0], [0, 0, 0]])',\n ],\n seeAlso: ['matrix.diagonal?', 'matrix.square?', 'matrix.orthogonal-matrix?'],\n },\n 'invertible?': {\n category: 'matrix',\n description: 'Checks if a `matrix` is **invertible**.',\n returns: {\n type: 'boolean',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to check for invertibility.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { invertible? } = import(matrix);\\ninvertible?([[1, 2], [3, 4]])',\n 'let { invertible? } = import(matrix);\\ninvertible?([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n 'let { invertible? } = import(matrix);\\ninvertible?([[1, 2], [2, 4]])',\n ],\n seeAlso: ['matrix.det', 'matrix.inv', 'matrix.rank', 'matrix.square?'],\n },\n 'hilbert': {\n category: 'matrix',\n description: 'Generates a **Hilbert matrix** of size `n`.',\n returns: {\n type: 'matrix',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The size of the Hilbert matrix.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { hilbert } = import(matrix);\\nhilbert(3)',\n 'let { hilbert } = import(matrix);\\nhilbert(4)',\n ],\n seeAlso: ['matrix.vandermonde', 'matrix.symmetric?'],\n },\n 'vandermonde': {\n category: 'matrix',\n description: 'Generates a **Vandermonde matrix** from a vector.',\n returns: {\n type: 'matrix',\n },\n args: {\n v: {\n type: 'vector',\n description: 'The vector to generate the Vandermonde matrix from.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'v',\n ],\n },\n ],\n examples: [\n 'let { vandermonde } = import(matrix);\\nvandermonde([1, 2, 3])',\n 'let { vandermonde } = import(matrix);\\nvandermonde([1, 0, 1])',\n ],\n seeAlso: ['matrix.hilbert', 'matrix.band'],\n },\n 'band': {\n category: 'matrix',\n description: 'Generates a **banded matrix** of size `n` with lower band index `lband` and upper band index `uband`.',\n returns: {\n type: 'matrix',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The size of the banded matrix.',\n },\n lband: {\n type: 'integer',\n description: 'The lower band index.',\n },\n uband: {\n type: 'integer',\n description: 'The upper band index.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n 'lband',\n 'uband',\n ],\n },\n ],\n examples: [\n 'let { band } = import(matrix);\\nband(3, 1, 1)',\n 'let { band } = import(matrix);\\nband(4, 1, 2)',\n ],\n seeAlso: ['matrix.banded?', 'matrix.diagonal?', 'matrix.vandermonde'],\n },\n 'banded?': {\n category: 'matrix',\n description: 'Checks if a `matrix` is **banded** with lower band index `lband` and upper band index `uband`.',\n returns: {\n type: 'boolean',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to check for **banded** property.',\n },\n lband: {\n type: 'integer',\n description: 'The lower band index.',\n },\n uband: {\n type: 'integer',\n description: 'The upper band index.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n 'lband',\n 'uband',\n ],\n },\n ],\n examples: [\n '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)',\n '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)',\n ],\n seeAlso: ['matrix.band', 'matrix.triangular?', 'matrix.diagonal?'],\n },\n 'rank': {\n category: 'matrix',\n description: 'Calculates the **rank** of a matrix using **Gaussian elimination**.',\n returns: {\n type: 'number',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to calculate the rank of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { rank } = import(matrix);\\nrank([[1, 0, 0], [0, 1, 0], [0, 0, 1]])',\n 'let { rank } = import(matrix);\\nrank([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n 'let { rank } = import(matrix);\\nrank([[2, 4, 6], [3, 6, 9], [4, 8, 12]])',\n ],\n seeAlso: ['matrix.det', 'matrix.invertible?', 'linear-algebra.rref'],\n },\n 'frobenius-norm': {\n category: 'matrix',\n description: 'Calculates the **Frobenius norm** of a matrix.',\n returns: {\n type: 'number',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to calculate the Frobenius norm of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { frobenius-norm } = import(matrix);\\nfrobenius-norm([[1, 2], [3, 4]])',\n 'let { frobenius-norm } = import(matrix);\\nfrobenius-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n ],\n seeAlso: ['matrix.one-norm', 'matrix.inf-norm', 'matrix.max-norm'],\n },\n 'one-norm': {\n category: 'matrix',\n description: 'Calculates the **one-norm** (column norm) of a matrix.',\n returns: {\n type: 'number',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to calculate the one-norm of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { one-norm } = import(matrix);\\none-norm([[1, 2], [3, 4]])',\n 'let { one-norm } = import(matrix);\\none-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n ],\n seeAlso: ['matrix.frobenius-norm', 'matrix.inf-norm', 'matrix.max-norm'],\n },\n 'inf-norm': {\n category: 'matrix',\n description: 'Calculates the **infinity norm** of a matrix.',\n returns: {\n type: 'number',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to calculate the infinity norm of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { inf-norm } = import(matrix);\\ninf-norm([[1, 2], [3, 4]])',\n 'let { inf-norm } = import(matrix);\\ninf-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n ],\n seeAlso: ['matrix.frobenius-norm', 'matrix.one-norm', 'matrix.max-norm'],\n },\n 'max-norm': {\n category: 'matrix',\n description: 'Calculates the **max norm** of a matrix.',\n returns: {\n type: 'number',\n },\n args: {\n m: {\n type: 'matrix',\n description: 'The `matrix` to calculate the max norm of.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'm',\n ],\n },\n ],\n examples: [\n 'let { max-norm } = import(matrix);\\nmax-norm([[1, 2], [3, 4]])',\n 'let { max-norm } = import(matrix);\\nmax-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])',\n ],\n seeAlso: ['matrix.frobenius-norm', 'matrix.one-norm', 'matrix.inf-norm'],\n },\n}\n","import { approxZero } from '../../../../utils'\n\n/**\n * Calculates the determinant of a matrix using Gaussian Elimination\n * @param matrix A square matrix represented as a 2D array\n * @returns The determinant of the matrix\n */\nexport function determinant(matrix: number[][]): number {\n // First, make a deep copy of the matrix to avoid modifying the original\n const n = matrix.length\n const A: number[][] = []\n\n for (let i = 0; i < n; i++) {\n A[i] = [...matrix[i]!]\n }\n\n // Handle special cases for small matrices\n if (n === 1) {\n return A[0]![0]!\n }\n\n if (n === 2) {\n return A[0]![0]! * A[1]![1]! - A[0]![1]! * A[1]![0]!\n }\n\n // For larger matrices, use Gaussian elimination\n let sign = 1 // Track sign changes from row swaps\n\n // Perform Gaussian elimination to get an upper triangular matrix\n for (let i = 0; i < n - 1; i += 1) {\n // Find pivot (maximum element in current column)\n let maxRow = i\n\n for (let j = i + 1; j < n; j += 1) {\n if (Math.abs(A[j]![i]!) > Math.abs(A[maxRow]![i]!)) {\n maxRow = j\n }\n }\n\n // If the pivot is zero, the determinant is zero\n if (approxZero(A[maxRow]![i]!)) {\n return 0\n }\n\n // Swap rows if necessary\n if (maxRow !== i) {\n [A[i], A[maxRow]] = [A[maxRow]!, A[i]!] // ES6 array destructuring for swap\n sign = -sign // Each row swap changes the sign\n }\n\n // Eliminate entries below the pivot\n for (let j = i + 1; j < n; j += 1) {\n const factor = A[j]![i]! / A[i]![i]!\n\n // Subtract (factor * pivot row) from current row\n for (let k = i; k < n; k++) {\n A[j]![k]! -= factor * A[i]![k]!\n }\n }\n }\n\n // Calculate determinant as the product of diagonal elements\n let det = sign\n for (let i = 0; i < n; i++) {\n det *= A[i]![i]!\n }\n\n return det\n}\n","export function minor(matrix: number[][], row: number, col: number): number[][] {\n const n = matrix.length\n const result: number[][] = []\n\n for (let i = 0; i < n; i++) {\n if (i !== row) {\n const minorRow: number[] = []\n for (let j = 0; j < n; j++) {\n if (j !== col) {\n minorRow.push(matrix[i]![j]!)\n }\n }\n result.push(minorRow)\n }\n }\n\n return result\n}\n","import { determinant } from './determinant'\nimport { minor } from './minor'\n\nexport function adjugate(matrix: number[][]): number[][] {\n const n = matrix.length\n const adj: number[][] = []\n for (let i = 0; i < n; i++) {\n adj[i] = []\n for (let j = 0; j < n; j++) {\n const min = minor(matrix, j, i)\n const sign = (-1) ** (i + j)\n const cofactor = sign * determinant(min)\n adj[i]![j] = cofactor\n }\n }\n return adj\n}\n","export function isSquare(matrix: number[][]): boolean {\n return matrix.length === matrix[0]!.length\n}\n","import { approxEqual, approxZero } from '../../../../utils'\nimport { isSquare } from './isSquare'\n\nexport function isIdentity(matrix: number[][]): boolean {\n if (!isSquare(matrix)) {\n return false\n }\n const n = matrix.length\n\n for (let i = 0; i < n; i++) {\n for (let j = 0; j < n; j++) {\n if (i === j) {\n if (!approxEqual(matrix[i]![j]!, 1)) {\n return false\n }\n }\n else {\n if (!approxZero(matrix[i]![j]!)) {\n return false\n }\n }\n }\n }\n\n return true\n}\n","/**\n * Performs cache-optimized matrix multiplication.\n * @param A The first input matrix (m x n)\n * @param B The second input matrix (n x p)\n * @returns The result matrix C (m x p) where C = A × B\n */\nexport function matrixMultiply(A: number[][], B: number[][]): number[][] {\n // Check if matrices can be multiplied\n if (A.length === 0 || B.length === 0 || A[0]!.length !== B.length) {\n throw new Error('Matrix dimensions do not match for multiplication')\n }\n\n const m = A.length // Number of rows in A\n const n = A[0]!.length // Number of columns in A / Number of rows in B\n const p = B[0]!.length // Number of columns in B\n\n // Initialize result matrix C with zeros\n const C: number[][] = (Array(m).fill(0) as number[]).map(() => Array(p).fill(0) as number[])\n\n // Perform multiplication with cache-optimized loop order (i-k-j)\n for (let i = 0; i < m; i++) {\n for (let k = 0; k < n; k++) {\n const aik = A[i]![k]! // Cache this value to avoid repeated lookups\n for (let j = 0; j < p; j++) {\n C[i]![j]! += aik * B[k]![j]!\n }\n }\n }\n\n return C\n}\n","import { DvalaError } from '../../../errors'\nimport { assertMatrix, assertSquareMatrix, assertVector, isSquareMatrix } from '../../../typeGuards/annotatedArrays'\nimport { assertNumber } from '../../../typeGuards/number'\nimport { approxZero } from '../../../utils'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport type { DvalaModule } from '../interface'\nimport { gaussJordanElimination } from '../linear-algebra/helpers/gaussJordanElimination'\nimport { moduleDocs } from './docs'\nimport { adjugate } from './helpers/adjugate'\nimport { band } from './helpers/band'\nimport { cofactor } from './helpers/cofactor'\nimport { determinant } from './helpers/determinant'\nimport { inverse } from './helpers/inverse'\nimport { isBanded } from './helpers/isBanded'\nimport { isDiagonal } from './helpers/isDiagonal'\nimport { isIdentity } from './helpers/isIdentity'\nimport { isOrthogonal } from './helpers/isOrthogonal'\nimport { isSquare } from './helpers/isSquare'\nimport { isSymetric } from './helpers/isSymetric'\nimport { isTriangular, isTriangularLower, isTriangularUpper } from './helpers/isTriangular'\nimport { matrixMultiply } from './helpers/matrixMultiply'\nimport { minor } from './helpers/minor'\nimport { norm1 } from './helpers/norm1'\nimport { trace } from './helpers/trace'\n\nexport const matrixNormalExpression: BuiltinNormalExpressions = {\n 'mul': {\n evaluate: ([matrix1, matrix2], sourceCodeInfo): number[][] => {\n assertMatrix(matrix1, sourceCodeInfo)\n assertMatrix(matrix2, sourceCodeInfo)\n try {\n return matrixMultiply(matrix1, matrix2)\n }\n catch (error) {\n throw new DvalaError(`The number of columns in the first matrix must be equal to the number of rows in the second matrix, but got ${matrix1[0]!.length} and ${matrix2.length}`, sourceCodeInfo)\n }\n },\n arity: toFixedArity(2),\n },\n 'det': {\n evaluate: ([matrix], sourceCodeInfo): number => {\n assertSquareMatrix(matrix, sourceCodeInfo)\n return determinant(matrix)\n },\n arity: toFixedArity(1),\n },\n 'inv': {\n evaluate: ([matrix], sourceCodeInfo): number[][] => {\n assertSquareMatrix(matrix, sourceCodeInfo)\n const result = inverse(matrix)\n if (result === null) {\n throw new DvalaError('The matrix must be invertible', sourceCodeInfo)\n }\n return result\n },\n arity: toFixedArity(1),\n },\n 'adj': {\n evaluate: ([matrix], sourceCodeInfo): number[][] => {\n assertSquareMatrix(matrix, sourceCodeInfo)\n return adjugate(matrix)\n },\n arity: toFixedArity(1),\n },\n 'cofactor': {\n evaluate: ([matrix], sourceCodeInfo): number[][] => {\n assertSquareMatrix(matrix, sourceCodeInfo)\n return cofactor(matrix)\n },\n arity: toFixedArity(1),\n },\n 'minor': {\n evaluate: ([matrix, row, col], sourceCodeInfo): number[][] => {\n assertMatrix(matrix, sourceCodeInfo)\n assertNumber(row, sourceCodeInfo, { integer: true, nonNegative: true, lte: matrix.length })\n assertNumber(col, sourceCodeInfo, { integer: true, nonNegative: true, lte: matrix[0]!.length })\n\n return minor(matrix, row, col)\n },\n arity: toFixedArity(3),\n },\n 'trace': {\n evaluate: ([matrix], sourceCodeInfo): number => {\n assertSquareMatrix(matrix, sourceCodeInfo)\n return trace(matrix)\n },\n arity: toFixedArity(1),\n },\n 'symmetric?': {\n evaluate: ([matrix], sourceCodeInfo): boolean => {\n assertMatrix(matrix, sourceCodeInfo)\n return isSymetric(matrix)\n },\n arity: toFixedArity(1),\n },\n 'triangular?': {\n evaluate: ([matrix], sourceCodeInfo): boolean => {\n assertMatrix(matrix, sourceCodeInfo)\n return isTriangular(matrix)\n },\n arity: toFixedArity(1),\n },\n 'upper-triangular?': {\n evaluate: ([matrix], sourceCodeInfo): boolean => {\n assertMatrix(matrix, sourceCodeInfo)\n return isTriangularUpper(matrix)\n },\n arity: toFixedArity(1),\n },\n 'lower-triangular?': {\n evaluate: ([matrix], sourceCodeInfo): boolean => {\n assertMatrix(matrix, sourceCodeInfo)\n return isTriangularLower(matrix)\n },\n arity: toFixedArity(1),\n },\n 'diagonal?': {\n evaluate: ([matrix], sourceCodeInfo): boolean => {\n assertMatrix(matrix, sourceCodeInfo)\n return isDiagonal(matrix)\n },\n arity: toFixedArity(1),\n },\n 'square?': {\n evaluate: ([matrix], sourceCodeInfo): boolean => {\n assertMatrix(matrix, sourceCodeInfo)\n return isSquare(matrix)\n },\n arity: toFixedArity(1),\n },\n 'orthogonal-matrix?': {\n evaluate: ([matrix], sourceCodeInfo): boolean => {\n assertMatrix(matrix, sourceCodeInfo)\n return isOrthogonal(matrix)\n },\n arity: toFixedArity(1),\n },\n 'identity?': {\n evaluate: ([matrix], sourceCodeInfo): boolean => {\n assertMatrix(matrix, sourceCodeInfo)\n return isIdentity(matrix)\n },\n arity: toFixedArity(1),\n },\n 'invertible?': {\n evaluate: ([matrix], sourceCodeInfo): boolean => {\n assertMatrix(matrix, sourceCodeInfo)\n if (!isSquareMatrix(matrix)) {\n return false\n }\n return !approxZero(determinant(matrix))\n },\n arity: toFixedArity(1),\n },\n 'hilbert': {\n evaluate: ([size], sourceCodeInfo): number[][] => {\n assertNumber(size, sourceCodeInfo, { integer: true, positive: true })\n const result: number[][] = []\n for (let i = 0; i < size; i += 1) {\n const row: number[] = []\n for (let j = 0; j < size; j += 1) {\n row.push(1 / (i + j + 1))\n }\n result.push(row)\n }\n return result\n },\n arity: toFixedArity(1),\n },\n 'vandermonde': {\n evaluate: ([vector], sourceCodeInfo): number[][] => {\n assertVector(vector, sourceCodeInfo)\n const result: number[][] = []\n for (let i = 0; i < vector.length; i += 1) {\n const row: number[] = []\n for (let j = 0; j < vector.length; j += 1) {\n row.push((vector[i]!) ** j)\n }\n result.push(row)\n }\n return result\n },\n arity: toFixedArity(1),\n },\n 'band': {\n evaluate: ([n, lband, uband], sourceCodeInfo): number[][] => {\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n assertNumber(lband, sourceCodeInfo, { integer: true, nonNegative: true, lt: n })\n assertNumber(uband, sourceCodeInfo, { integer: true, nonNegative: true, lte: n })\n return band(n, lband, uband)\n },\n arity: toFixedArity(3),\n },\n 'banded?': {\n evaluate: ([matrix, lband, uband], sourceCodeInfo): boolean => {\n assertMatrix(matrix, sourceCodeInfo)\n const maxBand = Math.max(matrix.length, matrix[0]!.length)\n assertNumber(lband, sourceCodeInfo, { integer: true, nonNegative: true, lt: maxBand })\n assertNumber(uband, sourceCodeInfo, { integer: true, nonNegative: true, lt: maxBand })\n return isBanded(matrix, lband, uband)\n },\n arity: toFixedArity(3),\n },\n 'rank': {\n evaluate: ([matrix], sourceCodeInfo): number => {\n assertMatrix(matrix, sourceCodeInfo)\n const [, result] = gaussJordanElimination(matrix)\n return result\n },\n arity: toFixedArity(1),\n },\n // Frobenius norm\n 'frobenius-norm': {\n evaluate: ([matrix], sourceCodeInfo): number => {\n assertMatrix(matrix, sourceCodeInfo)\n return Math.sqrt(matrix.reduce((sum, row) => sum + row.reduce((rowSum, cell) => rowSum + cell * cell, 0), 0))\n },\n arity: toFixedArity(1),\n },\n // one-norm (column norm)\n 'one-norm': {\n evaluate: ([matrix], sourceCodeInfo): number => {\n assertMatrix(matrix, sourceCodeInfo)\n return norm1(matrix)\n },\n arity: toFixedArity(1),\n },\n // Infinity norm\n 'inf-norm': {\n evaluate: ([matrix], sourceCodeInfo): number => {\n assertMatrix(matrix, sourceCodeInfo)\n return matrix.reduce((max, row) => Math.max(max, row.reduce((sum, cell) => sum + Math.abs(cell), 0)), 0)\n },\n arity: toFixedArity(1),\n },\n // Max norm\n 'max-norm': {\n evaluate: ([matrix], sourceCodeInfo): number => {\n assertMatrix(matrix, sourceCodeInfo)\n return matrix.reduce((maxVal, row) => {\n const rowMax = row.reduce((max, val) => Math.max(max, Math.abs(val)), 0)\n return Math.max(maxVal, rowMax)\n }, 0)\n },\n arity: toFixedArity(1),\n },\n}\n\nfor (const [key, docs] of Object.entries(moduleDocs)) {\n if (matrixNormalExpression[key])\n matrixNormalExpression[key].docs = docs\n}\n\nexport const matrixModule: DvalaModule = {\n name: 'matrix',\n functions: matrixNormalExpression,\n}\n","/**\n * Calculate the inverse of a matrix using the adjugate method\n * @param matrix The input matrix\n * @returns The inverse matrix or null if the matrix is not invertible\n */\n\nimport { approxZero } from '../../../../utils'\nimport { adjugate } from './adjugate'\nimport { determinant } from './determinant'\n\nexport function inverse(matrix: number[][]): number[][] | null {\n const n = matrix.length\n\n // Special case for 1x1 matrix - handle it directly\n if (n === 1) {\n const element = matrix[0]![0]!\n if (approxZero(element)) {\n return null // Not invertible\n }\n return [[1 / element]]\n }\n\n // Calculate determinant\n const det = determinant(matrix)\n\n // Check if matrix is invertible\n if (approxZero(det)) {\n return null // Matrix is not invertible\n }\n\n // Get the adjugate matrix\n const adj = adjugate(matrix)\n\n // Calculate the inverse: inverse = adjugate / determinant\n const inverseMatrix: number[][] = []\n for (let i = 0; i < n; i++) {\n inverseMatrix[i] = []\n for (let j = 0; j < n; j++) {\n inverseMatrix[i]![j] = adj[i]![j]! / det\n }\n }\n\n return inverseMatrix\n}\n","import { determinant } from './determinant'\nimport { minor } from './minor'\n\nexport function cofactor(matrix: number[][]): number[][] {\n const n = matrix.length\n const cofactors: number[][] = []\n\n // Create a new matrix to store cofactors\n for (let i = 0; i < n; i++) {\n cofactors[i] = []\n for (let j = 0; j < n; j++) {\n // Get the minor by removing row i and column j\n const min = minor(matrix, i, j)\n const sign = (-1) ** (i + j)\n cofactors[i]![j] = sign * determinant(min)\n }\n }\n\n return cofactors\n}\n","/**\n * Calculates the trace of a square matrix.\n * The trace is defined as the sum of the elements on the main diagonal.\n *\n * @param matrix - A 2D array representing a square matrix.\n * @returns The trace of the matrix.\n */\nexport function trace(matrix: number[][]): number {\n return matrix.reduce((sum, row, i) => sum + row[i]!, 0)\n}\n","import { isSquare } from './isSquare'\n\n/**\n * Checks if a given matrix is symmetric.\n * A matrix is symmetric if it is square and its transpose is equal to itself.\n *\n * @param matrix - A 2D array representing the matrix.\n * @returns `true` if the matrix is symmetric, otherwise `false`.\n */\nexport function isSymetric(matrix: number[][]): boolean {\n const rows = matrix.length\n\n // Check if the matrix is square\n if (!isSquare(matrix)) {\n return false\n }\n\n // Check symmetry\n for (let i = 0; i < rows; i += 1) {\n for (let j = 0; j < i; j += 1) {\n if (matrix[i]![j]! !== matrix[j]![i]!) {\n return false\n }\n }\n }\n\n return true\n}\n","import { isSquare } from './isSquare'\n\n/**\n * Determines whether a given matrix is triangular.\n *\n * A triangular matrix is a square matrix where all elements\n * below or above the main diagonal are zero. This function\n * checks if the matrix is square and symmetric.\n *\n * @param matrix - A two-dimensional array of numbers representing the matrix.\n * @returns `true` if the matrix is triangular, otherwise `false`.\n */\nexport function isTriangular(matrix: number[][]): boolean {\n if (!isSquare(matrix)) {\n return false\n }\n\n const rows = matrix.length\n\n let isUpperTriangular = true\n let isLowerTriangular = true\n\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < rows; j++) {\n if (i > j && matrix[i]![j] !== 0) {\n isUpperTriangular = false\n if (!isLowerTriangular) {\n return false\n }\n }\n if (i < j && matrix[i]![j] !== 0) {\n isLowerTriangular = false\n }\n }\n }\n\n return isUpperTriangular || isLowerTriangular\n}\n\nexport function isTriangularUpper(matrix: number[][]): boolean {\n if (!isSquare(matrix)) {\n return false\n }\n const rows = matrix.length\n\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < i; j++) {\n if (matrix[i]![j] !== 0) {\n return false\n }\n }\n }\n\n return true\n}\n\nexport function isTriangularLower(matrix: number[][]): boolean {\n if (!isSquare(matrix)) {\n return false\n }\n const rows = matrix.length\n\n // Check if the matrix is square\n if (!matrix.every(row => row.length === rows)) {\n return false\n }\n\n for (let i = 0; i < rows; i++) {\n for (let j = i + 1; j < rows; j++) {\n if (matrix[i]![j] !== 0) {\n return false\n }\n }\n }\n\n return true\n}\n","import { isSquare } from './isSquare'\n\n/**\n * Checks if a given matrix is diagonal.\n *\n * A matrix is considered diagonal if it is square (i.e., the number of rows equals the number of columns)\n * and all elements outside the main diagonal are zero.\n *\n * @param matrix - A two-dimensional array of numbers representing the matrix to check.\n * @returns `true` if the matrix is diagonal, otherwise `false`.\n */\nexport function isDiagonal(matrix: number[][]): boolean {\n if (!isSquare(matrix)) {\n return false\n }\n const rows = matrix.length\n\n for (let i = 0; i < rows; i += 1) {\n for (let j = 0; j < rows; j += 1) {\n if (i !== j && matrix[i]![j] !== 0) {\n return false\n }\n }\n }\n\n return true\n}\n","import { transpose } from '../../../modules/grid/transpose'\nimport { matrixMultiply } from './matrixMultiply'\nimport { isIdentity } from './isIdentity'\nimport { isSquare } from './isSquare'\n\nexport function isOrthogonal(matrix: number[][]): boolean {\n if (!isSquare(matrix)) {\n return false\n }\n\n // Calculate matrix transpose\n const transposed = transpose(matrix)\n\n // Check if matrix * transpose = Identity\n const product = matrixMultiply(matrix, transposed)\n\n // Check if the product is an identity matrix\n return isIdentity(product)\n}\n","/**\n * Creates a band matrix with specified lower and upper bandwidths\n *\n * @param n Size of the square matrix\n * @param lband Lower bandwidth (number of non-zero diagonals below main diagonal)\n * @param uband Upper bandwidth (number of non-zero diagonals above main diagonal)\n * @returns A 2D array representing the band matrix with 1s in the band and 0s elsewhere\n */\nexport function band(n: number, lband: number, uband: number): number[][] {\n // Create an n×n matrix filled with zeros\n const matrix: number[][] = Array.from({ length: n }, () => Array.from({ length: n }, () => 0))\n\n // Fill the band with 1s\n for (let i = 0; i < n; i++) {\n for (let j = Math.max(0, i - lband); j <= Math.min(n - 1, i + uband); j++) {\n matrix[i]![j] = 1\n }\n }\n\n return matrix\n}\n","/**\n * Checks if a matrix is banded with the given lower and upper bandwidth.\n * A matrix is banded if all non-zero elements are within 'lower' diagonals\n * below the main diagonal and 'upper' diagonals above the main diagonal.\n *\n * @param matrix - The matrix to check, represented as a 2D array of numbers\n * @param lower - Number of non-zero diagonals below the main diagonal\n * @param upper - Number of non-zero diagonals above the main diagonal\n * @returns true if the matrix is banded with the given parameters, false otherwise\n */\nexport function isBanded(matrix: number[][], lower: number, upper: number): boolean {\n const rows = matrix.length\n const cols = matrix[0]!.length\n\n // Check each element in the matrix\n for (let i = 0; i < rows; i++) {\n for (let j = 0; j < cols; j++) {\n // If we find a non-zero element outside the band, return false\n if (matrix[i]![j] !== 0 && (i - j > lower || j - i > upper)) {\n return false\n }\n }\n }\n\n // All elements outside the band are zero\n return true\n}\n","// Assuming a matrix is represented as a 2D array\nexport function norm1(matrix: number[][]): number {\n const numRows = matrix.length\n const numCols = matrix[0]!.length\n\n let maxColSum = 0\n\n // Iterate through each column\n for (let j = 0; j < numCols; j += 1) {\n let colSum = 0\n\n // Sum the absolute values of all elements in this column\n for (let i = 0; i < numRows; i += 1) {\n colSum += Math.abs(matrix[i]![j]!)\n }\n\n // Update the maximum column sum if necessary\n maxColSum = Math.max(maxColSum, colSum)\n }\n\n return maxColSum\n}\n","import type { FunctionDocs } from '../../interface'\n\nexport const moduleDocs: Record<string, FunctionDocs> = {\n 'abundant-seq': {\n category: 'number-theory',\n description: 'Generates the abundant numbers up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { abundant-seq } = import(number-theory);\\nabundant-seq(1)',\n 'let { abundant-seq } = import(number-theory);\\nabundant-seq(5)',\n ],\n seeAlso: ['number-theory.abundant-nth', 'number-theory.abundant-take-while', 'number-theory.abundant?', 'number-theory.deficient-seq', 'number-theory.perfect-seq'],\n },\n 'abundant-take-while': {\n category: 'number-theory',\n description: 'Generates the abundant numbers while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { abundant-take-while } = import(number-theory);\\nabundant-take-while(-> $ < 100)',\n ],\n seeAlso: ['number-theory.abundant-seq', 'number-theory.abundant-nth', 'number-theory.abundant?'],\n },\n 'abundant-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the abundant numbers.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the number in the sequence.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { abundant-nth } = import(number-theory);\\nabundant-nth(1)',\n 'let { abundant-nth } = import(number-theory);\\nabundant-nth(5)',\n ],\n seeAlso: ['number-theory.abundant-seq', 'number-theory.abundant-take-while', 'number-theory.abundant?'],\n },\n 'abundant?': {\n category: 'number-theory',\n description: 'Checks if a number is abundant.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { abundant? } = import(number-theory);\\nabundant?(12)',\n 'let { abundant? } = import(number-theory);\\nabundant?(15)',\n ],\n 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'],\n },\n 'arithmetic-seq': {\n category: 'number-theory',\n description: 'Generates the arithmetic sequence for a given $start, $step, and $length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n start: {\n type: 'number',\n description: 'The starting term of the sequence.',\n },\n step: {\n type: 'number',\n description: 'The common difference of the sequence.',\n },\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'start',\n 'step',\n 'length',\n ],\n },\n ],\n examples: [\n 'let { arithmetic-seq } = import(number-theory);\\narithmetic-seq(3, 2, 2)',\n 'let { arithmetic-seq } = import(number-theory);\\narithmetic-seq(2, 3, 2)',\n 'let { arithmetic-seq } = import(number-theory);\\narithmetic-seq(1, 2, 2)',\n 'let { arithmetic-seq } = import(number-theory);\\narithmetic-seq(1, 1.5, 12)',\n ],\n seeAlso: ['number-theory.arithmetic-nth', 'number-theory.arithmetic-take-while', 'number-theory.arithmetic?', 'number-theory.geometric-seq'],\n },\n 'arithmetic-take-while': {\n category: 'number-theory',\n description: 'Generates the arithmetic sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n start: {\n type: 'number',\n description: 'The starting term of the sequence.',\n },\n step: {\n type: 'number',\n description: 'The common difference of the sequence.',\n },\n takeWhile: {\n type: 'function',\n description: 'A function that takes a number and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'start',\n 'step',\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { arithmetic-take-while } = import(number-theory);\\narithmetic-take-while(1, 0.25, -> $ < 3)',\n ],\n seeAlso: ['number-theory.arithmetic-seq', 'number-theory.arithmetic-nth', 'number-theory.arithmetic?'],\n },\n 'arithmetic-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the arithmetic sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n start: {\n type: 'number',\n description: 'The starting term of the sequence.',\n },\n step: {\n type: 'number',\n description: 'The common difference of the sequence.',\n },\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'start',\n 'step',\n 'n',\n ],\n },\n ],\n examples: [\n 'let { arithmetic-nth } = import(number-theory);\\narithmetic-nth(3, 2, 2)',\n 'let { arithmetic-nth } = import(number-theory);\\narithmetic-nth(2, 3, 2)',\n 'let { arithmetic-nth } = import(number-theory);\\narithmetic-nth(1, 2, 2)',\n 'let { arithmetic-nth } = import(number-theory);\\narithmetic-nth(1, 1.5, 12)',\n ],\n seeAlso: ['number-theory.arithmetic-seq', 'number-theory.arithmetic-take-while', 'number-theory.arithmetic?'],\n },\n 'arithmetic?': {\n category: 'number-theory',\n description: 'Checks if a number is part of the arithmetic sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n start: {\n type: 'number',\n description: 'The starting term of the sequence.',\n },\n step: {\n type: 'number',\n description: 'The common difference of the sequence.',\n },\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'start',\n 'step',\n 'n',\n ],\n },\n ],\n examples: [\n 'let { arithmetic? } = import(number-theory);\\narithmetic?(3, 2, 2)',\n 'let { arithmetic? } = import(number-theory);\\narithmetic?(2, 3, 2)',\n 'let { arithmetic? } = import(number-theory);\\narithmetic?(1, 2, 2)',\n 'let { arithmetic? } = import(number-theory);\\narithmetic?(1, 1.5, 12)',\n ],\n seeAlso: ['number-theory.arithmetic-seq', 'number-theory.arithmetic-nth', 'number-theory.geometric?', 'number-theory.arithmetic-take-while'],\n },\n 'bell-seq': {\n category: 'number-theory',\n description: 'Generates the Bell sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate. If not provided, the default is 22 (the maximum length of the pre-calculated bell numbers).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n {\n argumentNames: [],\n },\n ],\n examples: [\n 'let { bell-seq } = import(number-theory);\\nbell-seq(5)',\n 'let { bell-seq } = import(number-theory);\\nbell-seq(10)',\n 'let { bell-seq } = import(number-theory);\\nbell-seq()',\n ],\n 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'],\n },\n 'bell-take-while': {\n category: 'number-theory',\n description: 'Generates the Bell sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { bell-take-while } = import(number-theory);\\nbell-take-while(-> $ < 1000)',\n ],\n seeAlso: ['number-theory.bell-seq', 'number-theory.bell-nth', 'number-theory.bell?'],\n },\n 'bell-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the Bell sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { bell-nth } = import(number-theory);\\nbell-nth(5)',\n 'let { bell-nth } = import(number-theory);\\nbell-nth(10)',\n ],\n seeAlso: ['number-theory.bell-seq', 'number-theory.bell-take-while', 'number-theory.bell?'],\n },\n 'bell?': {\n category: 'number-theory',\n description: 'Checks if a number is in the Bell sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { bell? } = import(number-theory);\\nbell?(1)',\n 'let { bell? } = import(number-theory);\\nbell?(27644437)',\n 'let { bell? } = import(number-theory);\\nbell?(27644436)',\n ],\n seeAlso: ['number-theory.bell-seq', 'number-theory.bell-nth', 'number-theory.catalan?', 'number-theory.bell-take-while'],\n },\n 'bernoulli-seq': {\n category: 'number-theory',\n description: 'Generates the Bernoulli sequence up to a specified length.',\n returns: {\n type: 'number',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { bernoulli-seq } = import(number-theory);\\nbernoulli-seq(5)',\n 'let { bernoulli-seq } = import(number-theory);\\nbernoulli-seq(10)',\n ],\n seeAlso: ['number-theory.bernoulli-nth', 'number-theory.bernoulli-take-while'],\n },\n 'bernoulli-take-while': {\n category: 'number-theory',\n description: 'Generates the Bernoulli sequence while a condition is met.',\n returns: {\n type: 'number',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { bernoulli-take-while } = import(number-theory);\\nbernoulli-take-while(-> abs($) < 100)',\n ],\n seeAlso: ['number-theory.bernoulli-seq', 'number-theory.bernoulli-nth'],\n },\n 'bernoulli-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the Bernoulli sequence.',\n returns: {\n type: 'number',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { bernoulli-nth } = import(number-theory);\\nbernoulli-nth(5)',\n 'let { bernoulli-nth } = import(number-theory);\\nbernoulli-nth(10)',\n 'let { bernoulli-nth } = import(number-theory);\\nbernoulli-nth(23)',\n ],\n seeAlso: ['number-theory.bernoulli-seq', 'number-theory.bernoulli-take-while'],\n },\n 'catalan-seq': {\n category: 'number-theory',\n description: 'Generates the Catalan sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate. If not provided, the default is 30 (the maximum length of the pre-calculated catalan numbers).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n {\n argumentNames: [],\n },\n ],\n examples: [\n 'let { catalan-seq } = import(number-theory);\\ncatalan-seq(5)',\n 'let { catalan-seq } = import(number-theory);\\ncatalan-seq(10)',\n 'let { catalan-seq } = import(number-theory);\\ncatalan-seq()',\n ],\n seeAlso: ['number-theory.catalan-nth', 'number-theory.catalan-take-while', 'number-theory.catalan?', 'number-theory.bell-seq'],\n },\n 'catalan-take-while': {\n category: 'number-theory',\n description: 'Generates the Catalan sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { catalan-take-while } = import(number-theory);\\ncatalan-take-while(-> $ < 1000)',\n ],\n seeAlso: ['number-theory.catalan-seq', 'number-theory.catalan-nth', 'number-theory.catalan?'],\n },\n 'catalan-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the Catalan sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { catalan-nth } = import(number-theory);\\ncatalan-nth(5)',\n 'let { catalan-nth } = import(number-theory);\\ncatalan-nth(10)',\n ],\n seeAlso: ['number-theory.catalan-seq', 'number-theory.catalan-take-while', 'number-theory.catalan?'],\n },\n 'catalan?': {\n category: 'number-theory',\n description: 'Determines if a number is in the Catalan sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { catalan? } = import(number-theory);\\ncatalan?(5)',\n 'let { catalan? } = import(number-theory);\\ncatalan?(10)',\n ],\n seeAlso: ['number-theory.catalan-seq', 'number-theory.catalan-nth', 'number-theory.bell?', 'number-theory.catalan-take-while'],\n },\n 'collatz-seq': {\n category: 'number-theory',\n description: 'Generates the collatz sequence starting from a given integer.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n start: {\n type: 'integer',\n description: 'The starting integer for the collatz sequence.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'start',\n ],\n },\n ],\n examples: [\n 'let { collatz-seq } = import(number-theory);\\ncollatz-seq(3)',\n 'let { collatz-seq } = import(number-theory);\\ncollatz-seq(11)',\n ],\n seeAlso: ['number-theory.juggler-seq'],\n },\n 'composite-seq': {\n category: 'number-theory',\n description: 'Generates the composite sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { composite-seq } = import(number-theory);\\ncomposite-seq(1)',\n 'let { composite-seq } = import(number-theory);\\ncomposite-seq(2)',\n 'let { composite-seq } = import(number-theory);\\ncomposite-seq(10)',\n ],\n seeAlso: ['number-theory.composite-nth', 'number-theory.composite-take-while', 'number-theory.composite?', 'number-theory.prime-seq'],\n },\n 'composite-take-while': {\n category: 'number-theory',\n description: 'Generates the composite sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { composite-take-while } = import(number-theory);\\ncomposite-take-while(-> $ < 50)',\n ],\n seeAlso: ['number-theory.composite-seq', 'number-theory.composite-nth', 'number-theory.composite?'],\n },\n 'composite-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the composite sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the composite number to retrieve.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { composite-nth } = import(number-theory);\\ncomposite-nth(1)',\n 'let { composite-nth } = import(number-theory);\\ncomposite-nth(2)',\n 'let { composite-nth } = import(number-theory);\\ncomposite-nth(10)',\n ],\n seeAlso: ['number-theory.composite-seq', 'number-theory.composite-take-while', 'number-theory.composite?'],\n },\n 'composite?': {\n category: 'number-theory',\n description: 'Determines if a number is composite.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { composite? } = import(number-theory);\\ncomposite?(4)',\n 'let { composite? } = import(number-theory);\\ncomposite?(5)',\n 'let { composite? } = import(number-theory);\\ncomposite?(11)',\n ],\n seeAlso: ['number-theory.composite-seq', 'number-theory.composite-nth', 'number-theory.prime?', 'number-theory.prime-factors', 'number-theory.composite-take-while'],\n },\n 'deficient-seq': {\n category: 'number-theory',\n description: 'Generates the deficient numbers up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { deficient-seq } = import(number-theory);\\ndeficient-seq(1)',\n 'let { deficient-seq } = import(number-theory);\\ndeficient-seq(5)',\n ],\n seeAlso: ['number-theory.deficient-nth', 'number-theory.deficient-take-while', 'number-theory.deficient?', 'number-theory.abundant-seq', 'number-theory.perfect-seq'],\n },\n 'deficient-take-while': {\n category: 'number-theory',\n description: 'Generates the deficient numbers while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { deficient-take-while } = import(number-theory);\\ndeficient-take-while(-> $ < 100)',\n ],\n seeAlso: ['number-theory.deficient-seq', 'number-theory.deficient-nth', 'number-theory.deficient?'],\n },\n 'deficient-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the deficient numbers.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the number in the sequence.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { deficient-nth } = import(number-theory);\\ndeficient-nth(5)',\n 'let { deficient-nth } = import(number-theory);\\ndeficient-nth(12)',\n ],\n seeAlso: ['number-theory.deficient-seq', 'number-theory.deficient-take-while', 'number-theory.deficient?'],\n },\n 'deficient?': {\n category: 'number-theory',\n description: 'Checks if a number is deficient.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { deficient? } = import(number-theory);\\ndeficient?(12)',\n 'let { deficient? } = import(number-theory);\\ndeficient?(15)',\n ],\n 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'],\n },\n 'factorial-seq': {\n category: 'number-theory',\n description: 'Generates the factorial sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate. If not provided, the default is 19 (the maximum length of the pre-calculated factorial numbers).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n {\n argumentNames: [],\n },\n ],\n examples: [\n 'let { factorial-seq } = import(number-theory);\\nfactorial-seq(1)',\n 'let { factorial-seq } = import(number-theory);\\nfactorial-seq(2)',\n 'let { factorial-seq } = import(number-theory);\\nfactorial-seq(3)',\n 'let { factorial-seq } = import(number-theory);\\nfactorial-seq(4)',\n 'let { factorial-seq } = import(number-theory);\\nfactorial-seq(5)',\n 'let { factorial-seq } = import(number-theory);\\nfactorial-seq(10)',\n ],\n seeAlso: ['number-theory.factorial-nth', 'number-theory.factorial-take-while', 'number-theory.factorial?', 'number-theory.factorial'],\n },\n 'factorial-take-while': {\n category: 'number-theory',\n description: 'Generates the factorial sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { factorial-take-while } = import(number-theory);\\nfactorial-take-while(-> $ < 1000)',\n ],\n seeAlso: ['number-theory.factorial-seq', 'number-theory.factorial-nth', 'number-theory.factorial?'],\n },\n 'factorial-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the factorial sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { factorial-nth } = import(number-theory);\\nfactorial-nth(1)',\n 'let { factorial-nth } = import(number-theory);\\nfactorial-nth(2)',\n 'let { factorial-nth } = import(number-theory);\\nfactorial-nth(3)',\n 'let { factorial-nth } = import(number-theory);\\nfactorial-nth(4)',\n 'let { factorial-nth } = import(number-theory);\\nfactorial-nth(5)',\n 'let { factorial-nth } = import(number-theory);\\nfactorial-nth(10)',\n ],\n seeAlso: ['number-theory.factorial-seq', 'number-theory.factorial-take-while', 'number-theory.factorial?', 'number-theory.factorial'],\n },\n 'factorial?': {\n category: 'number-theory',\n description: 'Checks if a number is in the factorial sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { factorial? } = import(number-theory);\\nfactorial?(1)',\n 'let { factorial? } = import(number-theory);\\nfactorial?(2)',\n 'let { factorial? } = import(number-theory);\\nfactorial?(3)',\n 'let { factorial? } = import(number-theory);\\nfactorial?(4)',\n 'let { factorial? } = import(number-theory);\\nfactorial?(5)',\n 'let { factorial? } = import(number-theory);\\nfactorial?(6)',\n 'let { factorial? } = import(number-theory);\\nfactorial?(7)',\n 'let { factorial? } = import(number-theory);\\nfactorial?(8)',\n 'let { factorial? } = import(number-theory);\\nfactorial?(9)',\n 'let { factorial? } = import(number-theory);\\nfactorial?(3628800)',\n ],\n seeAlso: ['number-theory.factorial-seq', 'number-theory.factorial-nth', 'number-theory.factorial', 'number-theory.factorial-take-while'],\n },\n 'fibonacci-seq': {\n category: 'number-theory',\n description: 'Generates the fibonacci sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate. If not provided, the default is 79 (the maximum length of the pre-calculated Fibonacci numbers).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n {\n argumentNames: [],\n },\n ],\n examples: [\n 'let { fibonacci-seq } = import(number-theory);\\nfibonacci-seq(1)',\n 'let { fibonacci-seq } = import(number-theory);\\nfibonacci-seq(2)',\n 'let { fibonacci-seq } = import(number-theory);\\nfibonacci-seq()',\n ],\n 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'],\n },\n 'fibonacci-take-while': {\n category: 'number-theory',\n description: 'Generates the fibonacci sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { fibonacci-take-while } = import(number-theory);\\nfibonacci-take-while(-> $ < 100)',\n ],\n seeAlso: ['number-theory.fibonacci-seq', 'number-theory.fibonacci-nth', 'number-theory.fibonacci?'],\n },\n 'fibonacci-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the fibonacci sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { fibonacci-nth } = import(number-theory);\\nfibonacci-nth(5)',\n 'let { fibonacci-nth } = import(number-theory);\\nfibonacci-nth(50)',\n ],\n seeAlso: ['number-theory.fibonacci-seq', 'number-theory.fibonacci-take-while', 'number-theory.fibonacci?'],\n },\n 'fibonacci?': {\n category: 'number-theory',\n description: 'Determines if a number is in the fibonacci sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { fibonacci? } = import(number-theory);\\nfibonacci?(0)',\n 'let { fibonacci? } = import(number-theory);\\nfibonacci?(1)',\n 'let { fibonacci? } = import(number-theory);\\nfibonacci?(2)',\n 'let { fibonacci? } = import(number-theory);\\nfibonacci?(3)',\n 'let { fibonacci? } = import(number-theory);\\nfibonacci?(4)',\n 'let { fibonacci? } = import(number-theory);\\nfibonacci?(5)',\n 'let { fibonacci? } = import(number-theory);\\nfibonacci?(6)',\n 'let { fibonacci? } = import(number-theory);\\nfibonacci?(7)',\n 'let { fibonacci? } = import(number-theory);\\nfibonacci?(8)',\n 'let { fibonacci? } = import(number-theory);\\nfibonacci?(9)',\n ],\n 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?'],\n },\n 'geometric-seq': {\n category: 'number-theory',\n description: 'Generates the geometric sequence for a given $start, $ratio, and $length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n start: {\n type: 'number',\n description: 'The starting term of the sequence.',\n },\n ratio: {\n type: 'number',\n description: 'The common ratio of the sequence.',\n },\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'start',\n 'ratio',\n 'length',\n ],\n },\n ],\n examples: [\n 'let { geometric-seq } = import(number-theory);\\ngeometric-seq(3, 2, 2)',\n 'let { geometric-seq } = import(number-theory);\\ngeometric-seq(2, 3, 2)',\n 'let { geometric-seq } = import(number-theory);\\ngeometric-seq(1, 2, 2)',\n 'let { geometric-seq } = import(number-theory);\\ngeometric-seq(1, 1.5, 12)',\n ],\n seeAlso: ['number-theory.geometric-nth', 'number-theory.geometric-take-while', 'number-theory.geometric?', 'number-theory.arithmetic-seq'],\n },\n 'geometric-take-while': {\n category: 'number-theory',\n description: 'Generates the geometric sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n start: {\n type: 'number',\n description: 'The starting term of the sequence.',\n },\n ratio: {\n type: 'number',\n description: 'The common ratio of the sequence.',\n },\n takeWhile: {\n type: 'function',\n description: 'A function that takes a number and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'start',\n 'ratio',\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { geometric-take-while } = import(number-theory);\\ngeometric-take-while(1, 1.5, -> $ < 10)',\n ],\n seeAlso: ['number-theory.geometric-seq', 'number-theory.geometric-nth', 'number-theory.geometric?'],\n },\n 'geometric-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the geometric sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n start: {\n type: 'number',\n description: 'The starting term of the sequence.',\n },\n ratio: {\n type: 'number',\n description: 'The common ratio of the sequence.',\n },\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'start',\n 'ratio',\n 'n',\n ],\n },\n ],\n examples: [\n 'let { geometric-nth } = import(number-theory);\\ngeometric-nth(3, 2, 2)',\n 'let { geometric-nth } = import(number-theory);\\ngeometric-nth(2, 3, 2)',\n 'let { geometric-nth } = import(number-theory);\\ngeometric-nth(1, 2, 2)',\n 'let { geometric-nth } = import(number-theory);\\ngeometric-nth(1, 1.5, 4)',\n ],\n seeAlso: ['number-theory.geometric-seq', 'number-theory.geometric-take-while', 'number-theory.geometric?'],\n },\n 'geometric?': {\n category: 'number-theory',\n description: 'Checks if a number is in the geometric sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n start: {\n type: 'number',\n description: 'The starting term of the sequence.',\n },\n ratio: {\n type: 'number',\n description: 'The common ratio of the sequence.',\n },\n n: {\n type: 'number',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'start',\n 'ratio',\n 'n',\n ],\n },\n ],\n examples: [\n 'let { geometric? } = import(number-theory);\\ngeometric?(1, 2, 1)',\n 'let { geometric? } = import(number-theory);\\ngeometric?(2, 3, 2)',\n 'let { geometric? } = import(number-theory);\\ngeometric?(3, 2, 2)',\n 'let { geometric? } = import(number-theory);\\ngeometric?(1, 1.5, 2.25)',\n 'let { geometric? } = import(number-theory);\\ngeometric?(1, 1.5, -4)',\n ],\n seeAlso: ['number-theory.geometric-seq', 'number-theory.geometric-nth', 'number-theory.arithmetic?', 'number-theory.geometric-take-while'],\n },\n 'golomb-seq': {\n category: 'number-theory',\n description: 'Generates the Golomb sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { golomb-seq } = import(number-theory);\\ngolomb-seq(5)',\n 'let { golomb-seq } = import(number-theory);\\ngolomb-seq(20)',\n ],\n seeAlso: ['number-theory.golomb-nth', 'number-theory.golomb-take-while', 'number-theory.golomb?', 'number-theory.recaman-seq'],\n },\n 'golomb-take-while': {\n category: 'number-theory',\n description: 'Generates the Golomb sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { golomb-take-while } = import(number-theory);\\ngolomb-take-while(-> $ <= 10)',\n ],\n seeAlso: ['number-theory.golomb-seq', 'number-theory.golomb-nth', 'number-theory.golomb?'],\n },\n 'golomb-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the Golomb sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { golomb-nth } = import(number-theory);\\ngolomb-nth(5)',\n 'let { golomb-nth } = import(number-theory);\\ngolomb-nth(1000)',\n ],\n seeAlso: ['number-theory.golomb-seq', 'number-theory.golomb-take-while', 'number-theory.golomb?'],\n },\n 'golomb?': {\n category: 'number-theory',\n description: 'Checks if a number is in the Golomb sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { golomb? } = import(number-theory);\\ngolomb?(1)',\n 'let { golomb? } = import(number-theory);\\ngolomb?(2)',\n 'let { golomb? } = import(number-theory);\\ngolomb?(3345)',\n 'let { golomb? } = import(number-theory);\\ngolomb?(67867864)',\n ],\n seeAlso: ['number-theory.golomb-seq', 'number-theory.golomb-nth', 'number-theory.golomb-take-while'],\n },\n 'happy-seq': {\n category: 'number-theory',\n description: 'Generates the happy sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate. If not provided, the default is 20 (the maximum length of the pre-calculated happy numbers).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n {\n argumentNames: [],\n },\n ],\n examples: [\n 'let { happy-seq } = import(number-theory);\\nhappy-seq(1)',\n 'let { happy-seq } = import(number-theory);\\nhappy-seq(2)',\n 'let { happy-seq } = import(number-theory);\\nhappy-seq(20)',\n ],\n seeAlso: ['number-theory.happy-nth', 'number-theory.happy-take-while', 'number-theory.happy?', 'number-theory.lucky-seq'],\n },\n 'happy-take-while': {\n category: 'number-theory',\n description: 'Generates the happy sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { happy-take-while } = import(number-theory);\\nhappy-take-while(-> $ < 100)',\n ],\n seeAlso: ['number-theory.happy-seq', 'number-theory.happy-nth', 'number-theory.happy?'],\n },\n 'happy-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the happy sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the happy number to return.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { happy-nth } = import(number-theory);\\nhappy-nth(1)',\n 'let { happy-nth } = import(number-theory);\\nhappy-nth(2)',\n 'let { happy-nth } = import(number-theory);\\nhappy-nth(20)',\n ],\n seeAlso: ['number-theory.happy-seq', 'number-theory.happy-take-while', 'number-theory.happy?'],\n },\n 'happy?': {\n category: 'number-theory',\n description: 'Determines if a number is a happy number.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { happy? } = import(number-theory);\\nhappy?(1)',\n 'let { happy? } = import(number-theory);\\nhappy?(2)',\n 'let { happy? } = import(number-theory);\\nhappy?(100)',\n ],\n seeAlso: ['number-theory.happy-seq', 'number-theory.happy-nth', 'number-theory.happy-take-while'],\n },\n 'juggler-seq': {\n category: 'number-theory',\n description: 'Generates the Juggler sequence starting from a given integer.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n start: {\n type: 'integer',\n description: 'The starting integer for the Juggler sequence.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'start',\n ],\n },\n ],\n examples: [\n 'let { juggler-seq } = import(number-theory);\\njuggler-seq(3)',\n 'let { juggler-seq } = import(number-theory);\\njuggler-seq(5)',\n ],\n seeAlso: ['number-theory.collatz-seq'],\n },\n 'look-and-say-seq': {\n category: 'number-theory',\n description: 'Generates the Look-and-Say sequence up to a specified length.',\n returns: {\n type: 'string',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { look-and-say-seq } = import(number-theory);\\nlook-and-say-seq(5)',\n ],\n seeAlso: ['number-theory.look-and-say-nth', 'number-theory.look-and-say-take-while', 'number-theory.look-and-say?'],\n },\n 'look-and-say-take-while': {\n category: 'number-theory',\n description: 'Generates the Look-and-Say sequence while a condition is met.',\n returns: {\n type: 'string',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes a string and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { look-and-say-take-while } = import(number-theory);\\nlook-and-say-take-while((term, index) -> count(term) < 10)',\n 'let { look-and-say-take-while } = import(number-theory);\\nlook-and-say-take-while(-> $2 <= 10)',\n ],\n seeAlso: ['number-theory.look-and-say-seq', 'number-theory.look-and-say-nth', 'number-theory.look-and-say?'],\n },\n 'look-and-say-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the Look-and-Say sequence.',\n returns: {\n type: 'string',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term in the sequence.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { look-and-say-nth } = import(number-theory);\\nlook-and-say-nth(5)',\n ],\n seeAlso: ['number-theory.look-and-say-seq', 'number-theory.look-and-say-take-while', 'number-theory.look-and-say?'],\n },\n 'look-and-say?': {\n category: 'number-theory',\n description: 'Checks if a string is a valid Look-and-Say term.',\n returns: {\n type: 'boolean',\n },\n args: {\n term: {\n type: 'string',\n description: 'The term to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'term',\n ],\n },\n ],\n examples: [\n 'let { look-and-say? } = import(number-theory);\\nlook-and-say?(\"111221\")',\n 'let { look-and-say? } = import(number-theory);\\nlook-and-say?(\"123\")',\n ],\n seeAlso: ['number-theory.look-and-say-seq', 'number-theory.look-and-say-nth', 'number-theory.look-and-say-take-while'],\n },\n 'lucas-seq': {\n category: 'number-theory',\n description: 'Generates the lucas sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate. If not provided, the default is 77 (the maximum length of the pre-calculated Lucas numbers).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n {\n argumentNames: [],\n },\n ],\n examples: [\n 'let { lucas-seq } = import(number-theory);\\nlucas-seq(1)',\n 'let { lucas-seq } = import(number-theory);\\nlucas-seq(2)',\n 'let { lucas-seq } = import(number-theory);\\nlucas-seq()',\n ],\n seeAlso: ['number-theory.lucas-nth', 'number-theory.lucas-take-while', 'number-theory.lucas?', 'number-theory.fibonacci-seq'],\n },\n 'lucas-take-while': {\n category: 'number-theory',\n description: 'Generates the lucas sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { lucas-take-while } = import(number-theory);\\nlucas-take-while(-> $ < 100)',\n ],\n seeAlso: ['number-theory.lucas-seq', 'number-theory.lucas-nth', 'number-theory.lucas?'],\n },\n 'lucas-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the lucas sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { lucas-nth } = import(number-theory);\\nlucas-nth(1)',\n 'let { lucas-nth } = import(number-theory);\\nlucas-nth(2)',\n 'let { lucas-nth } = import(number-theory);\\nlucas-nth(10)',\n ],\n seeAlso: ['number-theory.lucas-seq', 'number-theory.lucas-take-while', 'number-theory.lucas?'],\n },\n 'lucas?': {\n category: 'number-theory',\n description: 'Determines if a number is in the lucas sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { lucas? } = import(number-theory);\\nlucas?(1)',\n 'let { lucas? } = import(number-theory);\\nlucas?(2)',\n 'let { lucas? } = import(number-theory);\\nlucas?(10)',\n ],\n seeAlso: ['number-theory.lucas-seq', 'number-theory.lucas-nth', 'number-theory.fibonacci?', 'number-theory.lucas-take-while'],\n },\n 'lucky-seq': {\n category: 'number-theory',\n description: 'Generates the lucky sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { lucky-seq } = import(number-theory);\\nlucky-seq(1)',\n 'let { lucky-seq } = import(number-theory);\\nlucky-seq(2)',\n 'let { lucky-seq } = import(number-theory);\\nlucky-seq(20)',\n ],\n seeAlso: ['number-theory.lucky-nth', 'number-theory.lucky-take-while', 'number-theory.lucky?', 'number-theory.happy-seq', 'number-theory.prime-seq'],\n },\n 'lucky-take-while': {\n category: 'number-theory',\n description: 'Generates the lucky sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { lucky-take-while } = import(number-theory);\\nlucky-take-while(-> $ < 100)',\n ],\n seeAlso: ['number-theory.lucky-seq', 'number-theory.lucky-nth', 'number-theory.lucky?'],\n },\n 'lucky-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the lucky sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The position in the sequence.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { lucky-nth } = import(number-theory);\\nlucky-nth(1)',\n 'let { lucky-nth } = import(number-theory);\\nlucky-nth(2)',\n 'let { lucky-nth } = import(number-theory);\\nlucky-nth(20)',\n ],\n seeAlso: ['number-theory.lucky-seq', 'number-theory.lucky-take-while', 'number-theory.lucky?'],\n },\n 'lucky?': {\n category: 'number-theory',\n description: 'Checks if a number is a lucky number.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { lucky? } = import(number-theory);\\nlucky?(4)',\n 'let { lucky? } = import(number-theory);\\nlucky?(7)',\n 'let { lucky? } = import(number-theory);\\nlucky?(33)',\n ],\n seeAlso: ['number-theory.lucky-seq', 'number-theory.lucky-nth', 'number-theory.prime?', 'number-theory.lucky-take-while'],\n },\n 'mersenne-seq': {\n category: 'number-theory',\n description: 'Generates the Mersenne sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate. If not provided, the default is 9 (the maximum length of the pre-calculated mersenne numbers).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n {\n argumentNames: [],\n },\n ],\n examples: [\n 'let { mersenne-seq } = import(number-theory);\\nmersenne-seq(1)',\n 'let { mersenne-seq } = import(number-theory);\\nmersenne-seq(5)',\n 'let { mersenne-seq } = import(number-theory);\\nmersenne-seq()',\n ],\n seeAlso: ['number-theory.mersenne-nth', 'number-theory.mersenne-take-while', 'number-theory.mersenne?', 'number-theory.prime-seq'],\n },\n 'mersenne-take-while': {\n category: 'number-theory',\n description: 'Generates the Mersenne sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { mersenne-take-while } = import(number-theory);\\nmersenne-take-while(-> $ < 1000)',\n ],\n seeAlso: ['number-theory.mersenne-seq', 'number-theory.mersenne-nth', 'number-theory.mersenne?'],\n },\n 'mersenne-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the Mersenne sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { mersenne-nth } = import(number-theory);\\nmersenne-nth(1)',\n 'let { mersenne-nth } = import(number-theory);\\nmersenne-nth(5)',\n ],\n seeAlso: ['number-theory.mersenne-seq', 'number-theory.mersenne-take-while', 'number-theory.mersenne?'],\n },\n 'mersenne?': {\n category: 'number-theory',\n description: 'Checks if a number is in the Mersenne sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { mersenne? } = import(number-theory);\\nmersenne?(3)',\n 'let { mersenne? } = import(number-theory);\\nmersenne?(4)',\n 'let { mersenne? } = import(number-theory);\\nmersenne?(7)',\n ],\n seeAlso: ['number-theory.mersenne-seq', 'number-theory.mersenne-nth', 'number-theory.prime?', 'number-theory.mersenne-take-while'],\n },\n 'padovan-seq': {\n category: 'number-theory',\n description: 'Generates the Padovan sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { padovan-seq } = import(number-theory);\\npadovan-seq(5)',\n 'let { padovan-seq } = import(number-theory);\\npadovan-seq(10)',\n 'let { padovan-seq } = import(number-theory);\\npadovan-seq(20)',\n ],\n seeAlso: ['number-theory.padovan-nth', 'number-theory.padovan-take-while', 'number-theory.padovan?', 'number-theory.fibonacci-seq'],\n },\n 'padovan-take-while': {\n category: 'number-theory',\n description: 'Generates the Padovan sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { padovan-take-while } = import(number-theory);\\npadovan-take-while(-> $ < 1000)',\n ],\n seeAlso: ['number-theory.padovan-seq', 'number-theory.padovan-nth', 'number-theory.padovan?'],\n },\n 'padovan-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the Padovan sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { padovan-nth } = import(number-theory);\\npadovan-nth(5)',\n 'let { padovan-nth } = import(number-theory);\\npadovan-nth(10)',\n 'let { padovan-nth } = import(number-theory);\\npadovan-nth(20)',\n ],\n seeAlso: ['number-theory.padovan-seq', 'number-theory.padovan-take-while', 'number-theory.padovan?'],\n },\n 'padovan?': {\n category: 'number-theory',\n description: 'Checks if a number is in the Padovan sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { padovan? } = import(number-theory);\\npadovan?(1)',\n 'let { padovan? } = import(number-theory);\\npadovan?(265)',\n 'let { padovan? } = import(number-theory);\\npadovan?(6)',\n ],\n seeAlso: ['number-theory.padovan-seq', 'number-theory.padovan-nth', 'number-theory.fibonacci?', 'number-theory.padovan-take-while'],\n },\n 'partition-seq': {\n category: 'number-theory',\n 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).',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n {\n argumentNames: [],\n },\n ],\n examples: [\n 'let { partition-seq } = import(number-theory);\\npartition-seq(1)',\n 'let { partition-seq } = import(number-theory);\\npartition-seq(10)',\n 'let { partition-seq } = import(number-theory);\\npartition-seq()',\n ],\n seeAlso: ['number-theory.partition-nth', 'number-theory.partition-take-while', 'number-theory.partition?', 'number-theory.partitions', 'number-theory.count-partitions'],\n },\n 'partition-take-while': {\n category: 'number-theory',\n description: 'Generates the partition numbers while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { partition-take-while } = import(number-theory);\\npartition-take-while(-> $ < 1000)',\n ],\n seeAlso: ['number-theory.partition-seq', 'number-theory.partition-nth', 'number-theory.partition?'],\n },\n 'partition-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the partition numbers.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the partition number to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { partition-nth } = import(number-theory);\\npartition-nth(1)',\n 'let { partition-nth } = import(number-theory);\\npartition-nth(5)',\n ],\n seeAlso: ['number-theory.partition-seq', 'number-theory.partition-take-while', 'number-theory.partition?'],\n },\n 'partition?': {\n category: 'number-theory',\n description: 'Checks if a number is in the partition numbers.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { partition? } = import(number-theory);\\npartition?(0)',\n 'let { partition? } = import(number-theory);\\npartition?(1)',\n 'let { partition? } = import(number-theory);\\npartition?(2)',\n 'let { partition? } = import(number-theory);\\npartition?(3)',\n 'let { partition? } = import(number-theory);\\npartition?(4)',\n 'let { partition? } = import(number-theory);\\npartition?(5)',\n ],\n seeAlso: ['number-theory.partition-seq', 'number-theory.partition-nth', 'number-theory.partitions', 'number-theory.partition-take-while'],\n },\n 'pell-seq': {\n category: 'number-theory',\n description: 'Generates the Pell sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate. If not provided, the default is 42 (the maximum length of the pre-calculated Pell numbers).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n {\n argumentNames: [],\n },\n ],\n examples: [\n 'let { pell-seq } = import(number-theory);\\npell-seq(5)',\n 'let { pell-seq } = import(number-theory);\\npell-seq(10)',\n 'let { pell-seq } = import(number-theory);\\npell-seq()',\n ],\n seeAlso: ['number-theory.pell-nth', 'number-theory.pell-take-while', 'number-theory.pell?', 'number-theory.fibonacci-seq'],\n },\n 'pell-take-while': {\n category: 'number-theory',\n description: 'Generates the Pell sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { pell-take-while } = import(number-theory);\\npell-take-while(-> $ < 1000)',\n ],\n seeAlso: ['number-theory.pell-seq', 'number-theory.pell-nth', 'number-theory.pell?'],\n },\n 'pell-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the Pell sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { pell-nth } = import(number-theory);\\npell-nth(5)',\n 'let { pell-nth } = import(number-theory);\\npell-nth(10)',\n 'let { pell-nth } = import(number-theory);\\npell-nth(20)',\n ],\n seeAlso: ['number-theory.pell-seq', 'number-theory.pell-take-while', 'number-theory.pell?'],\n },\n 'pell?': {\n category: 'number-theory',\n description: 'Checks if a number is a Pell number.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { pell? } = import(number-theory);\\npell?(1)',\n 'let { pell? } = import(number-theory);\\npell?(470832)',\n 'let { pell? } = import(number-theory);\\npell?(10)',\n ],\n seeAlso: ['number-theory.pell-seq', 'number-theory.pell-nth', 'number-theory.fibonacci?', 'number-theory.pell-take-while'],\n },\n 'perfect-seq': {\n category: 'number-theory',\n description: 'Generates the perfect numbers up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n 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).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n {\n argumentNames: [],\n },\n ],\n examples: [\n 'let { perfect-seq } = import(number-theory);\\nperfect-seq(1)',\n 'let { perfect-seq } = import(number-theory);\\nperfect-seq(5)',\n 'let { perfect-seq } = import(number-theory);\\nperfect-seq()',\n ],\n seeAlso: ['number-theory.perfect-nth', 'number-theory.perfect-take-while', 'number-theory.perfect?', 'number-theory.abundant-seq', 'number-theory.deficient-seq', 'number-theory.amicable?'],\n },\n 'perfect-take-while': {\n category: 'number-theory',\n description: 'Generates the perfect numbers while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { perfect-take-while } = import(number-theory);\\nperfect-take-while(-> $ < 1000)',\n ],\n seeAlso: ['number-theory.perfect-seq', 'number-theory.perfect-nth', 'number-theory.perfect?'],\n },\n 'perfect-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the perfect numbers.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the perfect number to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { perfect-nth } = import(number-theory);\\nperfect-nth(1)',\n 'let { perfect-nth } = import(number-theory);\\nperfect-nth(5)',\n ],\n seeAlso: ['number-theory.perfect-seq', 'number-theory.perfect-take-while', 'number-theory.perfect?'],\n },\n 'perfect?': {\n category: 'number-theory',\n description: 'Checks if a number is in the perfect numbers.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { perfect? } = import(number-theory);\\nperfect?(0)',\n 'let { perfect? } = import(number-theory);\\nperfect?(1)',\n 'let { perfect? } = import(number-theory);\\nperfect?(2)',\n 'let { perfect? } = import(number-theory);\\nperfect?(3)',\n 'let { perfect? } = import(number-theory);\\nperfect?(4)',\n 'let { perfect? } = import(number-theory);\\nperfect?(5)',\n 'let { perfect? } = import(number-theory);\\nperfect?(6)',\n 'let { perfect? } = import(number-theory);\\nperfect?(7)',\n 'let { perfect? } = import(number-theory);\\nperfect?(8)',\n 'let { perfect? } = import(number-theory);\\nperfect?(9)',\n ],\n 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'],\n },\n 'perfect-square-seq': {\n category: 'number-theory',\n description: 'Generates the perfect square numbers up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { perfect-square-seq } = import(number-theory);\\nperfect-square-seq(5)',\n 'let { perfect-square-seq } = import(number-theory);\\nperfect-square-seq(20)',\n ],\n 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'],\n },\n 'perfect-square-take-while': {\n category: 'number-theory',\n description: 'Generates the perfect square numbers while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { perfect-square-take-while } = import(number-theory);\\nperfect-square-take-while(-> $ <= 100)',\n ],\n seeAlso: ['number-theory.perfect-square-seq', 'number-theory.perfect-square-nth', 'number-theory.perfect-square?'],\n },\n 'perfect-square-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the perfect square numbers.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { perfect-square-nth } = import(number-theory);\\nperfect-square-nth(1)',\n 'let { perfect-square-nth } = import(number-theory);\\nperfect-square-nth(5)',\n ],\n seeAlso: ['number-theory.perfect-square-seq', 'number-theory.perfect-square-take-while', 'number-theory.perfect-square?'],\n },\n 'perfect-square?': {\n category: 'number-theory',\n description: 'Checks if a number is a perfect square.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { perfect-square? } = import(number-theory);\\nperfect-square?(16)',\n 'let { perfect-square? } = import(number-theory);\\nperfect-square?(20)',\n ],\n 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?'],\n },\n 'perfect-cube-seq': {\n category: 'number-theory',\n description: 'Generates the perfect cube numbers up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { perfect-cube-seq } = import(number-theory);\\nperfect-cube-seq(5)',\n 'let { perfect-cube-seq } = import(number-theory);\\nperfect-cube-seq(20)',\n ],\n 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'],\n },\n 'perfect-cube-take-while': {\n category: 'number-theory',\n description: 'Generates the perfect cube numbers while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { perfect-cube-take-while } = import(number-theory);\\nperfect-cube-take-while(-> $ <= 100)',\n ],\n seeAlso: ['number-theory.perfect-cube-seq', 'number-theory.perfect-cube-nth', 'number-theory.perfect-cube?'],\n },\n 'perfect-cube-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the perfect cube numbers.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { perfect-cube-nth } = import(number-theory);\\nperfect-cube-nth(1)',\n 'let { perfect-cube-nth } = import(number-theory);\\nperfect-cube-nth(5)',\n ],\n seeAlso: ['number-theory.perfect-cube-seq', 'number-theory.perfect-cube-take-while', 'number-theory.perfect-cube?'],\n },\n 'perfect-cube?': {\n category: 'number-theory',\n description: 'Checks if a number is in the perfect cube numbers.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { perfect-cube? } = import(number-theory);\\nperfect-cube?(7)',\n 'let { perfect-cube? } = import(number-theory);\\nperfect-cube?(8)',\n 'let { perfect-cube? } = import(number-theory);\\nperfect-cube?(9)',\n ],\n 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'],\n },\n 'perfect-power-seq': {\n category: 'number-theory',\n description: 'Generates the perfect power numbers up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { perfect-power-seq } = import(number-theory);\\nperfect-power-seq(5)',\n 'let { perfect-power-seq } = import(number-theory);\\nperfect-power-seq(20)',\n ],\n 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'],\n },\n 'perfect-power-take-while': {\n category: 'number-theory',\n description: 'Generates the perfect power numbers while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { perfect-power-take-while } = import(number-theory);\\nperfect-power-take-while(-> $ <= 100)',\n ],\n seeAlso: ['number-theory.perfect-power-seq', 'number-theory.perfect-power-nth', 'number-theory.perfect-power?'],\n },\n 'perfect-power-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the perfect power numbers.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { perfect-power-nth } = import(number-theory);\\nperfect-power-nth(3)',\n 'let { perfect-power-nth } = import(number-theory);\\nperfect-power-nth(15)',\n ],\n seeAlso: ['number-theory.perfect-power-seq', 'number-theory.perfect-power-take-while', 'number-theory.perfect-power?'],\n },\n 'perfect-power?': {\n category: 'number-theory',\n description: 'Checks if a number is in the perfect power numbers.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { perfect-power? } = import(number-theory);\\nperfect-power?(7)',\n 'let { perfect-power? } = import(number-theory);\\nperfect-power?(8)',\n 'let { perfect-power? } = import(number-theory);\\nperfect-power?(9)',\n 'let { perfect-power? } = import(number-theory);\\nperfect-power?(10)',\n ],\n 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'],\n },\n 'polygonal-seq': {\n category: 'number-theory',\n description: 'Generates the polygonal sequence for a given number of sides and length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n sides: {\n type: 'integer',\n description: 'The number of sides of the polygon.',\n },\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n a: {\n type: 'integer',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'sides',\n 'length',\n ],\n },\n ],\n examples: [\n 'let { polygonal-seq } = import(number-theory);\\npolygonal-seq(3, 2)',\n 'let { polygonal-seq } = import(number-theory);\\npolygonal-seq(4, 2)',\n 'let { polygonal-seq } = import(number-theory);\\npolygonal-seq(5, 3)',\n 'let { polygonal-seq } = import(number-theory);\\npolygonal-seq(6, 5)',\n 'let { polygonal-seq } = import(number-theory);\\npolygonal-seq(100, 10)',\n ],\n seeAlso: ['number-theory.polygonal-nth', 'number-theory.polygonal-take-while', 'number-theory.polygonal?', 'number-theory.perfect-square-seq'],\n },\n 'polygonal-take-while': {\n category: 'number-theory',\n description: 'Generates the polygonal sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n sides: {\n type: 'integer',\n description: 'The number of sides of the polygon.',\n },\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n a: {\n type: 'integer',\n },\n b: {\n type: 'function',\n },\n },\n variants: [\n {\n argumentNames: [\n 'sides',\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { polygonal-take-while } = import(number-theory);\\npolygonal-take-while(15, -> $ < 1000)',\n ],\n seeAlso: ['number-theory.polygonal-seq', 'number-theory.polygonal-nth', 'number-theory.polygonal?'],\n },\n 'polygonal-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the polygonal sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n sides: {\n type: 'integer',\n description: 'The number of sides of the polygon.',\n },\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n a: {\n type: 'integer',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'sides',\n 'n',\n ],\n },\n ],\n examples: [\n 'let { polygonal-nth } = import(number-theory);\\npolygonal-nth(3, 9)',\n 'let { polygonal-nth } = import(number-theory);\\npolygonal-nth(4, 5)',\n 'let { polygonal-nth } = import(number-theory);\\npolygonal-nth(5, 5)',\n ],\n seeAlso: ['number-theory.polygonal-seq', 'number-theory.polygonal-take-while', 'number-theory.polygonal?'],\n },\n 'polygonal?': {\n category: 'number-theory',\n description: 'Checks if a number is in the polygonal sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n sides: {\n type: 'integer',\n description: 'The number of sides of the polygon.',\n },\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n a: {\n type: 'integer',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'sides',\n 'n',\n ],\n },\n ],\n examples: [\n 'let { polygonal? } = import(number-theory);\\npolygonal?(3, 10)',\n 'let { polygonal? } = import(number-theory);\\npolygonal?(3, 9)',\n 'let { polygonal? } = import(number-theory);\\npolygonal?(4, 10000)',\n 'let { polygonal? } = import(number-theory);\\npolygonal?(4, 1000)',\n 'let { polygonal? } = import(number-theory);\\npolygonal?(6, 45)',\n ],\n seeAlso: ['number-theory.polygonal-seq', 'number-theory.polygonal-nth', 'number-theory.perfect-square?', 'number-theory.polygonal-take-while'],\n },\n 'prime-seq': {\n category: 'number-theory',\n description: 'Generates the prime sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { prime-seq } = import(number-theory);\\nprime-seq(1)',\n 'let { prime-seq } = import(number-theory);\\nprime-seq(2)',\n 'let { prime-seq } = import(number-theory);\\nprime-seq(10)',\n ],\n 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'],\n },\n 'prime-take-while': {\n category: 'number-theory',\n description: 'Generates the prime sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { prime-take-while } = import(number-theory);\\nprime-take-while(-> $ < 50)',\n ],\n seeAlso: ['number-theory.prime-seq', 'number-theory.prime-nth', 'number-theory.prime?'],\n },\n 'prime-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the prime sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { prime-nth } = import(number-theory);\\nprime-nth(1)',\n 'let { prime-nth } = import(number-theory);\\nprime-nth(2)',\n 'let { prime-nth } = import(number-theory);\\nprime-nth(10)',\n ],\n seeAlso: ['number-theory.prime-seq', 'number-theory.prime-take-while', 'number-theory.prime?'],\n },\n 'prime?': {\n category: 'number-theory',\n description: 'Determines if a number is prime.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { prime? } = import(number-theory);\\nprime?(1)',\n 'let { prime? } = import(number-theory);\\nprime?(2)',\n 'let { prime? } = import(number-theory);\\nprime?(3)',\n 'let { prime? } = import(number-theory);\\nprime?(4)',\n 'let { prime? } = import(number-theory);\\nprime?(997)',\n 'let { prime? } = import(number-theory);\\nprime?(1001)',\n ],\n 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?'],\n },\n 'recaman-seq': {\n category: 'number-theory',\n description: 'Generates the Recaman sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { recaman-seq } = import(number-theory);\\nrecaman-seq(5)',\n 'let { recaman-seq } = import(number-theory);\\nrecaman-seq(10)',\n 'let { recaman-seq } = import(number-theory);\\nrecaman-seq(20)',\n ],\n seeAlso: ['number-theory.recaman-nth', 'number-theory.recaman-take-while', 'number-theory.recaman?', 'number-theory.golomb-seq'],\n },\n 'recaman-take-while': {\n category: 'number-theory',\n description: 'Generates the Recaman sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { recaman-take-while } = import(number-theory);\\nrecaman-take-while(-> $ < 10)',\n ],\n seeAlso: ['number-theory.recaman-seq', 'number-theory.recaman-nth', 'number-theory.recaman?'],\n },\n 'recaman-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the Recaman sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { recaman-nth } = import(number-theory);\\nrecaman-nth(5)',\n 'let { recaman-nth } = import(number-theory);\\nrecaman-nth(10)',\n 'let { recaman-nth } = import(number-theory);\\nrecaman-nth(20)',\n ],\n seeAlso: ['number-theory.recaman-seq', 'number-theory.recaman-take-while', 'number-theory.recaman?'],\n },\n 'recaman?': {\n category: 'number-theory',\n description: 'Checks if a number is in the Recaman sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { recaman? } = import(number-theory);\\nrecaman?(5)',\n 'let { recaman? } = import(number-theory);\\nrecaman?(10)',\n 'let { recaman? } = import(number-theory);\\nrecaman?(20)',\n ],\n seeAlso: ['number-theory.recaman-seq', 'number-theory.recaman-nth', 'number-theory.recaman-take-while'],\n },\n 'sylvester-seq': {\n category: 'number-theory',\n description: 'Generates the Sylvester sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate. If not provided, the default is 6 (the maximum length of the pre-calculated Sylvester numbers).',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n {\n argumentNames: [],\n },\n ],\n examples: [\n 'let { sylvester-seq } = import(number-theory);\\nsylvester-seq(5)',\n 'let { sylvester-seq } = import(number-theory);\\nsylvester-seq()',\n 'let { sylvester-seq } = import(number-theory);\\nsylvester-seq()',\n ],\n seeAlso: ['number-theory.sylvester-nth', 'number-theory.sylvester-take-while', 'number-theory.sylvester?'],\n },\n 'sylvester-take-while': {\n category: 'number-theory',\n description: 'Generates the Sylvester sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { sylvester-take-while } = import(number-theory);\\nsylvester-take-while(-> $ < 100000)',\n ],\n seeAlso: ['number-theory.sylvester-seq', 'number-theory.sylvester-nth', 'number-theory.sylvester?'],\n },\n 'sylvester-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the Sylvester sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { sylvester-nth } = import(number-theory);\\nsylvester-nth(1)',\n 'let { sylvester-nth } = import(number-theory);\\nsylvester-nth(5)',\n ],\n seeAlso: ['number-theory.sylvester-seq', 'number-theory.sylvester-take-while', 'number-theory.sylvester?'],\n },\n 'sylvester?': {\n category: 'number-theory',\n description: 'Checks if a number is in the Sylvester sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { sylvester? } = import(number-theory);\\nsylvester?(2)',\n 'let { sylvester? } = import(number-theory);\\nsylvester?(3)',\n 'let { sylvester? } = import(number-theory);\\nsylvester?(6)',\n ],\n seeAlso: ['number-theory.sylvester-seq', 'number-theory.sylvester-nth', 'number-theory.sylvester-take-while'],\n },\n 'thue-morse-seq': {\n category: 'number-theory',\n description: 'Generates the Thue-Morse sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { thue-morse-seq } = import(number-theory);\\nthue-morse-seq(5)',\n 'let { thue-morse-seq } = import(number-theory);\\nthue-morse-seq(10)',\n 'let { thue-morse-seq } = import(number-theory);\\nthue-morse-seq(20)',\n ],\n seeAlso: ['number-theory.thue-morse-nth', 'number-theory.thue-morse-take-while', 'number-theory.thue-morse?'],\n },\n 'thue-morse-take-while': {\n category: 'number-theory',\n description: 'Generates the Thue-Morse sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { thue-morse-take-while } = import(number-theory);\\nthue-morse-take-while(-> $2 < 10)',\n ],\n seeAlso: ['number-theory.thue-morse-seq', 'number-theory.thue-morse-nth', 'number-theory.thue-morse?'],\n },\n 'thue-morse-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the Thue-Morse sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term in the sequence.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { thue-morse-nth } = import(number-theory);\\nthue-morse-nth(5)',\n 'let { thue-morse-nth } = import(number-theory);\\nthue-morse-nth(10)',\n 'let { thue-morse-nth } = import(number-theory);\\nthue-morse-nth(20)',\n ],\n seeAlso: ['number-theory.thue-morse-seq', 'number-theory.thue-morse-take-while', 'number-theory.thue-morse?'],\n },\n 'thue-morse?': {\n category: 'number-theory',\n description: 'Checks if a number is part of the Thue-Morse sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { thue-morse? } = import(number-theory);\\nthue-morse?(1)',\n 'let { thue-morse? } = import(number-theory);\\nthue-morse?(2)',\n ],\n seeAlso: ['number-theory.thue-morse-seq', 'number-theory.thue-morse-nth', 'number-theory.thue-morse-take-while'],\n },\n 'tribonacci-seq': {\n category: 'number-theory',\n description: 'Generates the tribonacci sequence up to a specified length.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n length: {\n type: 'integer',\n description: 'The length of the sequence to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\n },\n ],\n examples: [\n 'let { tribonacci-seq } = import(number-theory);\\ntribonacci-seq(1)',\n 'let { tribonacci-seq } = import(number-theory);\\ntribonacci-seq(2)',\n 'let { tribonacci-seq } = import(number-theory);\\ntribonacci-seq(10)',\n ],\n seeAlso: ['number-theory.tribonacci-nth', 'number-theory.tribonacci-take-while', 'number-theory.tribonacci?', 'number-theory.fibonacci-seq'],\n },\n 'tribonacci-take-while': {\n category: 'number-theory',\n description: 'Generates the tribonacci sequence while a condition is met.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n takeWhile: {\n type: 'function',\n description: 'A function that takes an integer and an index and returns a boolean.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'takeWhile',\n ],\n },\n ],\n examples: [\n 'let { tribonacci-take-while } = import(number-theory);\\ntribonacci-take-while(-> $ < 100)',\n ],\n seeAlso: ['number-theory.tribonacci-seq', 'number-theory.tribonacci-nth', 'number-theory.tribonacci?'],\n },\n 'tribonacci-nth': {\n category: 'number-theory',\n description: 'Generates the nth term of the tribonacci sequence.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The index of the term to generate.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { tribonacci-nth } = import(number-theory);\\ntribonacci-nth(1)',\n 'let { tribonacci-nth } = import(number-theory);\\ntribonacci-nth(2)',\n 'let { tribonacci-nth } = import(number-theory);\\ntribonacci-nth(10)',\n ],\n seeAlso: ['number-theory.tribonacci-seq', 'number-theory.tribonacci-take-while', 'number-theory.tribonacci?'],\n },\n 'tribonacci?': {\n category: 'number-theory',\n description: 'Determines if a number is in the tribonacci sequence.',\n returns: {\n type: 'boolean',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { tribonacci? } = import(number-theory);\\ntribonacci?(0)',\n 'let { tribonacci? } = import(number-theory);\\ntribonacci?(1)',\n 'let { tribonacci? } = import(number-theory);\\ntribonacci?(2)',\n 'let { tribonacci? } = import(number-theory);\\ntribonacci?(3)',\n 'let { tribonacci? } = import(number-theory);\\ntribonacci?(4)',\n 'let { tribonacci? } = import(number-theory);\\ntribonacci?(5)',\n 'let { tribonacci? } = import(number-theory);\\ntribonacci?(6)',\n 'let { tribonacci? } = import(number-theory);\\ntribonacci?(7)',\n 'let { tribonacci? } = import(number-theory);\\ntribonacci?(8)',\n 'let { tribonacci? } = import(number-theory);\\ntribonacci?(9)',\n 'let { tribonacci? } = import(number-theory);\\ntribonacci?(10)',\n ],\n seeAlso: ['number-theory.tribonacci-seq', 'number-theory.tribonacci-nth', 'number-theory.fibonacci?', 'number-theory.tribonacci-take-while'],\n },\n 'count-combinations': {\n category: 'number-theory',\n description: 'Calculates the number of combinations of n items taken k at a time.',\n returns: {\n type: 'integer',\n },\n args: {\n a: {\n type: 'integer',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { count-combinations } = import(number-theory);\\ncount-combinations(5, 3)',\n 'let { count-combinations } = import(number-theory);\\ncount-combinations(10, 2)',\n ],\n 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'],\n },\n 'combinations': {\n category: 'number-theory',\n description: 'Generates all possible combinations of a specified size from a collection.',\n returns: {\n type: 'array',\n array: true,\n },\n args: {\n set: {\n type: 'array',\n array: true,\n description: 'The input collection to generate combinations from.',\n },\n n: {\n type: 'integer',\n description: 'The size of each combination.',\n },\n a: {\n type: 'array',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'set',\n 'n',\n ],\n },\n ],\n examples: [\n 'let { combinations } = import(number-theory);\\ncombinations([1, 2, 3], 2)',\n 'let { combinations } = import(number-theory);\\ncombinations([\"a\", \"b\", \"c\"], 2)',\n 'let { combinations } = import(number-theory);\\ncombinations([1, 2, 3], 0)',\n 'let { combinations } = import(number-theory);\\ncombinations([1, 2, 3], 1)',\n 'let { combinations } = import(number-theory);\\ncombinations([1, 2, 3], 3)',\n ],\n seeAlso: ['number-theory.count-combinations', 'number-theory.permutations', 'number-theory.power-set', 'number-theory.cartesian-product', 'number-theory.partitions'],\n },\n 'count-derangements': {\n category: 'number-theory',\n description: 'Calculates the number of derangements (permutations where no element appears in its original position) of n items.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The total number of items.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { count-derangements } = import(number-theory);\\ncount-derangements(4)',\n 'let { count-derangements } = import(number-theory);\\ncount-derangements(5)',\n ],\n seeAlso: ['number-theory.derangements', 'number-theory.count-permutations', 'number-theory.factorial'],\n },\n 'derangements': {\n category: 'number-theory',\n description: 'Generates all derangements (permutations where no element appears in its original position) of a set.',\n returns: {\n type: 'array',\n array: true,\n },\n args: {\n set: {\n type: 'array',\n array: true,\n description: 'The input collection to generate derangements from.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'set',\n ],\n },\n ],\n examples: [\n 'let { derangements } = import(number-theory);\\nderangements([1, 2, 3, 4])',\n 'let { derangements } = import(number-theory);\\nderangements([\"a\", \"b\", \"c\"])',\n ],\n seeAlso: ['number-theory.count-derangements', 'number-theory.permutations'],\n },\n 'divisors': {\n category: 'number-theory',\n description: 'Returns the divisors of a number.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to find divisors for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { divisors } = import(number-theory);\\ndivisors(12)',\n 'let { divisors } = import(number-theory);\\ndivisors(100)',\n 'let { divisors } = import(number-theory);\\ndivisors(37)',\n ],\n 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'],\n },\n 'count-divisors': {\n category: 'number-theory',\n description: 'Returns the number of divisors of a number.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to count divisors for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { count-divisors } = import(number-theory);\\ncount-divisors(12)',\n 'let { count-divisors } = import(number-theory);\\ncount-divisors(100)',\n 'let { count-divisors } = import(number-theory);\\ncount-divisors(37)',\n ],\n seeAlso: ['number-theory.divisors', 'number-theory.count-proper-divisors', 'number-theory.sigma'],\n },\n 'proper-divisors': {\n category: 'number-theory',\n description: 'Returns the proper divisors of a number.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to find proper divisors for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { proper-divisors } = import(number-theory);\\nproper-divisors(12)',\n 'let { proper-divisors } = import(number-theory);\\nproper-divisors(100)',\n 'let { proper-divisors } = import(number-theory);\\nproper-divisors(37)',\n ],\n seeAlso: ['number-theory.count-proper-divisors', 'number-theory.divisors', 'number-theory.amicable?', 'number-theory.perfect?'],\n },\n 'count-proper-divisors': {\n category: 'number-theory',\n description: 'Returns the number of proper divisors of a number.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to count proper divisors for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { count-proper-divisors } = import(number-theory);\\ncount-proper-divisors(12)',\n 'let { count-proper-divisors } = import(number-theory);\\ncount-proper-divisors(100)',\n 'let { count-proper-divisors } = import(number-theory);\\ncount-proper-divisors(37)',\n ],\n seeAlso: ['number-theory.proper-divisors', 'number-theory.count-divisors', 'number-theory.divisors'],\n },\n 'factorial': {\n category: 'number-theory',\n description: 'Calculates the factorial of a number.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to calculate the factorial for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { factorial } = import(number-theory);\\nfactorial(5)',\n 'let { factorial } = import(number-theory);\\nfactorial(0)',\n 'let { factorial } = import(number-theory);\\nfactorial(10)',\n 'let { factorial } = import(number-theory);\\nfactorial(20)',\n ],\n 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'],\n },\n 'partitions': {\n category: 'number-theory',\n description: 'Generates all partitions of a number.',\n returns: {\n type: 'array',\n array: true,\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to partition.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { partitions } = import(number-theory);\\npartitions(4)',\n 'let { partitions } = import(number-theory);\\npartitions(8)',\n ],\n seeAlso: ['number-theory.count-partitions', 'number-theory.partition-seq', 'number-theory.combinations', 'number-theory.partition?'],\n },\n 'count-partitions': {\n category: 'number-theory',\n description: 'Returns the number of partitions of a number.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to count partitions for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { count-partitions } = import(number-theory);\\ncount-partitions(4)',\n 'let { count-partitions } = import(number-theory);\\ncount-partitions(8)',\n 'let { count-partitions } = import(number-theory);\\ncount-partitions(15)',\n ],\n seeAlso: ['number-theory.partitions', 'number-theory.partition-seq', 'number-theory.count-combinations'],\n },\n 'permutations': {\n category: 'number-theory',\n description: 'Generates all permutations of a collection.',\n returns: {\n type: 'array',\n array: true,\n },\n args: {\n set: {\n type: 'array',\n array: true,\n description: 'The input collection to generate permutations from.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'set',\n ],\n },\n ],\n examples: [\n 'let { permutations } = import(number-theory);\\npermutations([1, 2, 3])',\n 'let { permutations } = import(number-theory);\\npermutations([\"a\", \"b\", \"c\"])',\n 'let { permutations } = import(number-theory);\\npermutations([1, 2, 3, 4])',\n 'let { permutations } = import(number-theory);\\npermutations([1, 2])',\n 'let { permutations } = import(number-theory);\\npermutations([1])',\n 'let { permutations } = import(number-theory);\\npermutations([])',\n ],\n seeAlso: ['number-theory.count-permutations', 'number-theory.combinations', 'number-theory.derangements', 'number-theory.cartesian-product'],\n },\n 'count-permutations': {\n category: 'number-theory',\n description: 'Returns the number of permutations of n items taken k at a time.',\n returns: {\n type: 'integer',\n },\n args: {\n a: {\n type: 'integer',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { count-permutations } = import(number-theory);\\ncount-permutations(5, 3)',\n 'let { count-permutations } = import(number-theory);\\ncount-permutations(10, 2)',\n 'let { count-permutations } = import(number-theory);\\ncount-permutations(10, 10)',\n 'let { count-permutations } = import(number-theory);\\ncount-permutations(10, 0)',\n 'let { count-permutations } = import(number-theory);\\ncount-permutations(10, 1)',\n ],\n seeAlso: ['number-theory.permutations', 'number-theory.count-combinations', 'number-theory.factorial', 'number-theory.multinomial', 'number-theory.stirling-first', 'number-theory.count-derangements'],\n },\n 'power-set': {\n category: 'number-theory',\n description: 'Generates the power set of a collection.',\n returns: {\n type: 'array',\n array: true,\n },\n args: {\n set: {\n type: 'any',\n array: true,\n description: 'The input collection to generate the power set from.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'set',\n ],\n },\n ],\n examples: [\n 'let { power-set } = import(number-theory);\\npower-set([\"a\", \"b\", \"c\"])',\n 'let { power-set } = import(number-theory);\\npower-set([1, 2])',\n 'let { power-set } = import(number-theory);\\npower-set([1])',\n 'let { power-set } = import(number-theory);\\npower-set([])',\n ],\n seeAlso: ['number-theory.count-power-set', 'number-theory.combinations', 'number-theory.cartesian-product'],\n },\n 'count-power-set': {\n category: 'number-theory',\n description: 'Returns the number of subsets of a set.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The size of the set.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { count-power-set } = import(number-theory);\\ncount-power-set(3)',\n 'let { count-power-set } = import(number-theory);\\ncount-power-set(5)',\n 'let { count-power-set } = import(number-theory);\\ncount-power-set(10)',\n ],\n seeAlso: ['number-theory.power-set', 'number-theory.count-combinations'],\n },\n 'prime-factors': {\n category: 'number-theory',\n description: 'Returns the prime factors of a number.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to factor.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { prime-factors } = import(number-theory);\\nprime-factors(12)',\n 'let { prime-factors } = import(number-theory);\\nprime-factors(100)',\n 'let { prime-factors } = import(number-theory);\\nprime-factors(37)',\n ],\n 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'],\n },\n 'count-prime-factors': {\n category: 'number-theory',\n description: 'Returns the number of prime factors of a number.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to count prime factors for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { count-prime-factors } = import(number-theory);\\ncount-prime-factors(12)',\n 'let { count-prime-factors } = import(number-theory);\\ncount-prime-factors(100)',\n 'let { count-prime-factors } = import(number-theory);\\ncount-prime-factors(37)',\n ],\n seeAlso: ['number-theory.prime-factors', 'number-theory.distinct-prime-factors', 'number-theory.count-distinct-prime-factors'],\n },\n 'distinct-prime-factors': {\n category: 'number-theory',\n description: 'Returns the distinct prime factors of a number.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to find distinct prime factors for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { distinct-prime-factors } = import(number-theory);\\ndistinct-prime-factors(12)',\n 'let { distinct-prime-factors } = import(number-theory);\\ndistinct-prime-factors(100)',\n 'let { distinct-prime-factors } = import(number-theory);\\ndistinct-prime-factors(37)',\n ],\n seeAlso: ['number-theory.prime-factors', 'number-theory.count-distinct-prime-factors', 'number-theory.count-prime-factors'],\n },\n 'count-distinct-prime-factors': {\n category: 'number-theory',\n description: 'Returns the number of distinct prime factors of a number.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to count distinct prime factors for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { count-distinct-prime-factors } = import(number-theory);\\ncount-distinct-prime-factors(12)',\n 'let { count-distinct-prime-factors } = import(number-theory);\\ncount-distinct-prime-factors(100)',\n 'let { count-distinct-prime-factors } = import(number-theory);\\ncount-distinct-prime-factors(37)',\n ],\n seeAlso: ['number-theory.distinct-prime-factors', 'number-theory.prime-factors', 'number-theory.count-prime-factors'],\n },\n 'coprime?': {\n category: 'number-theory',\n description: 'Checks if two numbers are coprime (i.e., their GCD is 1).',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'integer',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { coprime? } = import(number-theory);\\ncoprime?(12, 8)',\n 'let { coprime? } = import(number-theory);\\ncoprime?(12, 5)',\n 'let { coprime? } = import(number-theory);\\ncoprime?(37, 1)',\n 'let { coprime? } = import(number-theory);\\ncoprime?(0, 0)',\n 'let { coprime? } = import(number-theory);\\ncoprime?(0, 5)',\n 'let { coprime? } = import(number-theory);\\ncoprime?(5, 0)',\n 'let { coprime? } = import(number-theory);\\ncoprime?(1, 0)',\n 'let { coprime? } = import(number-theory);\\ncoprime?(0, 1)',\n 'let { coprime? } = import(number-theory);\\ncoprime?(1, 1)',\n 'let { coprime? } = import(number-theory);\\ncoprime?(2, 3)',\n ],\n seeAlso: ['number-theory.gcd', 'number-theory.euler-totient', 'number-theory.divisible-by?', 'number-theory.lcm', 'number-theory.carmichael-lambda'],\n },\n 'divisible-by?': {\n category: 'number-theory',\n description: 'Checks if a number is divisible by another number.',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'integer',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { divisible-by? } = import(number-theory);\\ndivisible-by?(12, 4)',\n 'let { divisible-by? } = import(number-theory);\\ndivisible-by?(12, 5)',\n 'let { divisible-by? } = import(number-theory);\\ndivisible-by?(37, 1)',\n 'let { divisible-by? } = import(number-theory);\\ndivisible-by?(0, 0)',\n 'let { divisible-by? } = import(number-theory);\\ndivisible-by?(0, 5)',\n 'let { divisible-by? } = import(number-theory);\\ndivisible-by?(5, 0)',\n ],\n seeAlso: ['number-theory.divisors', 'number-theory.gcd', 'number-theory.coprime?'],\n },\n 'gcd': {\n category: 'number-theory',\n description: 'Calculates the greatest common divisor (GCD) of two numbers.',\n returns: {\n type: 'integer',\n },\n args: {\n a: {\n type: 'integer',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { gcd } = import(number-theory);\\ngcd(100, 25)',\n 'let { gcd } = import(number-theory);\\ngcd(37, 1)',\n 'let { gcd } = import(number-theory);\\ngcd(0, 0)',\n 'let { gcd } = import(number-theory);\\ngcd(0, 5)',\n 'let { gcd } = import(number-theory);\\ngcd(5, 0)',\n ],\n seeAlso: ['number-theory.lcm', 'number-theory.extended-gcd', 'number-theory.coprime?', 'number-theory.divisible-by?'],\n },\n 'lcm': {\n category: 'number-theory',\n description: 'Calculates the least common multiple (LCM) of two numbers.',\n returns: {\n type: 'integer',\n },\n args: {\n a: {\n type: 'integer',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { lcm } = import(number-theory);\\nlcm(100, 25)',\n 'let { lcm } = import(number-theory);\\nlcm(37, 1)',\n 'let { lcm } = import(number-theory);\\nlcm(0, 5)',\n 'let { lcm } = import(number-theory);\\nlcm(5, 0)',\n ],\n seeAlso: ['number-theory.gcd', 'number-theory.divisors', 'number-theory.coprime?'],\n },\n 'multinomial': {\n category: 'number-theory',\n description: 'Calculates the multinomial coefficient from of a list of numbers representing the sizes of each group.',\n returns: {\n type: 'integer',\n },\n args: {\n args: {\n type: 'integer',\n rest: true,\n description: 'The numbers representing the sizes of each group.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'args',\n ],\n },\n ],\n examples: [\n 'let { multinomial } = import(number-theory);\\nmultinomial(5, 2, 3)',\n 'let { multinomial } = import(number-theory);\\nmultinomial(10, 2, 3, 5)',\n ],\n seeAlso: ['number-theory.count-combinations', 'number-theory.factorial', 'number-theory.count-permutations'],\n hideOperatorForm: true,\n },\n 'amicable?': {\n category: 'number-theory',\n description: 'Checks if two numbers are amicable (i.e., the sum of the proper divisors of each number equals the other number).',\n returns: {\n type: 'boolean',\n },\n args: {\n a: {\n type: 'integer',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { amicable? } = import(number-theory);\\namicable?(220, 284)',\n 'let { amicable? } = import(number-theory);\\namicable?(1184, 1210)',\n 'let { amicable? } = import(number-theory);\\namicable?(2620, 2924)',\n 'let { amicable? } = import(number-theory);\\namicable?(5020, 5564)',\n 'let { amicable? } = import(number-theory);\\namicable?(6232, 6368)',\n ],\n seeAlso: ['number-theory.proper-divisors', 'number-theory.perfect?', 'number-theory.sigma', 'number-theory.perfect-seq'],\n },\n 'euler-totient': {\n category: 'number-theory',\n description: 'Calculates the Euler\\'s totient function (φ(n)) of a number, which counts the integers up to n that are coprime to n.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to calculate the totient for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { euler-totient } = import(number-theory);\\neuler-totient(1)',\n 'let { euler-totient } = import(number-theory);\\neuler-totient(2)',\n 'let { euler-totient } = import(number-theory);\\neuler-totient(10)',\n 'let { euler-totient } = import(number-theory);\\neuler-totient(20)',\n ],\n seeAlso: ['number-theory.coprime?', 'number-theory.carmichael-lambda', 'number-theory.mobius', 'number-theory.prime-factors', 'number-theory.mertens'],\n },\n 'mobius': {\n category: 'number-theory',\n description: 'Calculates the Möbius function (μ(n)) of a number, which is used in number theory.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to calculate the Möbius function for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { mobius } = import(number-theory);\\nmobius(1)',\n 'let { mobius } = import(number-theory);\\nmobius(2)',\n 'let { mobius } = import(number-theory);\\nmobius(3)',\n 'let { mobius } = import(number-theory);\\nmobius(4)',\n 'let { mobius } = import(number-theory);\\nmobius(6)',\n 'let { mobius } = import(number-theory);\\nmobius(12)',\n 'let { mobius } = import(number-theory);\\nmobius(30)',\n ],\n seeAlso: ['number-theory.mertens', 'number-theory.euler-totient', 'number-theory.prime-factors'],\n },\n 'mertens': {\n category: 'number-theory',\n description: 'Calculates the Mertens function (M(n)) of a number, which is the sum of the Möbius function up to n.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to calculate the Mertens function for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { mobius } = import(number-theory);\\nmobius(1)',\n 'let { mobius } = import(number-theory);\\nmobius(2)',\n 'let { mobius } = import(number-theory);\\nmobius(3)',\n 'let { mobius } = import(number-theory);\\nmobius(4)',\n 'let { mobius } = import(number-theory);\\nmobius(6)',\n 'let { mobius } = import(number-theory);\\nmobius(12)',\n 'let { mobius } = import(number-theory);\\nmobius(30)',\n ],\n seeAlso: ['number-theory.mobius', 'number-theory.euler-totient'],\n },\n 'sigma': {\n category: 'number-theory',\n description: 'Calculates the sum of divisors function (σ(n)) of a number, which is the sum of all positive divisors of n.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to calculate the sum of divisors for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { sigma } = import(number-theory);\\nsigma(1)',\n 'let { sigma } = import(number-theory);\\nsigma(2)',\n 'let { sigma } = import(number-theory);\\nsigma(3)',\n 'let { sigma } = import(number-theory);\\nsigma(4)',\n 'let { sigma } = import(number-theory);\\nsigma(6)',\n 'let { sigma } = import(number-theory);\\nsigma(12)',\n 'let { sigma } = import(number-theory);\\nsigma(30)',\n ],\n seeAlso: ['number-theory.divisors', 'number-theory.perfect?', 'number-theory.abundant?', 'number-theory.deficient?', 'number-theory.amicable?', 'number-theory.count-divisors'],\n },\n 'carmichael-lambda': {\n category: 'number-theory',\n 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.',\n returns: {\n type: 'integer',\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to calculate the Carmichael function for.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { carmichael-lambda } = import(number-theory);\\ncarmichael-lambda(1)',\n 'let { carmichael-lambda } = import(number-theory);\\ncarmichael-lambda(2)',\n 'let { carmichael-lambda } = import(number-theory);\\ncarmichael-lambda(3)',\n 'let { carmichael-lambda } = import(number-theory);\\ncarmichael-lambda(4)',\n 'let { carmichael-lambda } = import(number-theory);\\ncarmichael-lambda(6)',\n 'let { carmichael-lambda } = import(number-theory);\\ncarmichael-lambda(12)',\n 'let { carmichael-lambda } = import(number-theory);\\ncarmichael-lambda(30)',\n ],\n seeAlso: ['number-theory.euler-totient', 'number-theory.mod-exp', 'number-theory.coprime?'],\n },\n 'cartesian-product': {\n category: 'number-theory',\n description: 'Calculates the Cartesian product of two or more sets.',\n returns: {\n type: 'array',\n array: true,\n },\n args: {\n sets: {\n type: 'array',\n array: true,\n description: 'The input collections to calculate the Cartesian product from.',\n },\n a: {\n type: 'array',\n },\n b: {\n type: 'array',\n },\n },\n variants: [\n {\n argumentNames: [\n 'sets',\n ],\n },\n ],\n examples: [\n 'let { cartesian-product } = import(number-theory);\\ncartesian-product([1, 2], [\"a\", \"b\"])',\n 'let { cartesian-product } = import(number-theory);\\ncartesian-product([1, 2], [\"a\", \"b\"], [true, false])',\n 'let { cartesian-product } = import(number-theory);\\ncartesian-product([1, 2, 3], [\"x\", \"y\", \"z\"])',\n ],\n seeAlso: ['number-theory.combinations', 'number-theory.power-set', 'number-theory.permutations'],\n },\n 'perfect-power': {\n category: 'number-theory',\n description: 'Returns a tuple of the base and exponent if the number is a perfect power, otherwise returns null.',\n returns: {\n type: 'array',\n array: true,\n },\n args: {\n n: {\n type: 'integer',\n description: 'The number to check.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'n',\n ],\n },\n ],\n examples: [\n 'let { perfect-power } = import(number-theory);\\nperfect-power(1)',\n 'let { perfect-power } = import(number-theory);\\nperfect-power(2)',\n 'let { perfect-power } = import(number-theory);\\nperfect-power(4)',\n 'let { perfect-power } = import(number-theory);\\nperfect-power(8)',\n 'let { perfect-power } = import(number-theory);\\nperfect-power(9)',\n 'let { perfect-power } = import(number-theory);\\nperfect-power(16)',\n 'let { perfect-power } = import(number-theory);\\nperfect-power(19)',\n ],\n seeAlso: ['number-theory.perfect-power?', 'number-theory.perfect-power-seq', 'number-theory.perfect-square?', 'number-theory.perfect-cube?'],\n },\n 'mod-exp': {\n category: 'number-theory',\n description: 'Calculates the modular exponentiation of a base raised to an exponent modulo a modulus.',\n returns: {\n type: 'integer',\n },\n args: {\n base: {\n type: 'integer',\n },\n exponent: {\n type: 'integer',\n },\n modulus: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'base',\n 'exponent',\n 'modulus',\n ],\n },\n ],\n examples: [\n 'let { mod-exp } = import(number-theory);\\nmod-exp(2, 3, 5)',\n 'let { mod-exp } = import(number-theory);\\nmod-exp(3, 4, 7)',\n 'let { mod-exp } = import(number-theory);\\nmod-exp(5, 6, 11)',\n 'let { mod-exp } = import(number-theory);\\nmod-exp(7, 8, 13)',\n ],\n seeAlso: ['number-theory.mod-inv', 'number-theory.carmichael-lambda', 'number-theory.chinese-remainder'],\n },\n 'mod-inv': {\n category: 'number-theory',\n description: 'Calculates the modular multiplicative inverse of a number modulo another number.',\n returns: {\n type: 'integer',\n },\n args: {\n a: {\n type: 'integer',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'm',\n ],\n },\n ],\n examples: [\n 'let { mod-inv } = import(number-theory);\\nmod-inv(3, 11)',\n 'let { mod-inv } = import(number-theory);\\nmod-inv(10, 17)',\n 'let { mod-inv } = import(number-theory);\\nmod-inv(5, 13)',\n 'let { mod-inv } = import(number-theory);\\nmod-inv(7, 19)',\n ],\n seeAlso: ['number-theory.mod-exp', 'number-theory.extended-gcd', 'number-theory.chinese-remainder'],\n },\n 'extended-gcd': {\n category: 'number-theory',\n description: 'Calculates the extended greatest common divisor (GCD) of two numbers, returning the GCD and the coefficients of Bézout\\'s identity.',\n returns: {\n type: 'integer',\n array: true,\n },\n args: {\n a: {\n type: 'integer',\n },\n b: {\n type: 'integer',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { extended-gcd } = import(number-theory);\\nextended-gcd(30, 12)',\n 'let { extended-gcd } = import(number-theory);\\nextended-gcd(56, 98)',\n 'let { extended-gcd } = import(number-theory);\\nextended-gcd(101, 10)',\n 'let { extended-gcd } = import(number-theory);\\nextended-gcd(17, 13)',\n ],\n seeAlso: ['number-theory.gcd', 'number-theory.mod-inv', 'number-theory.chinese-remainder'],\n },\n 'chinese-remainder': {\n category: 'number-theory',\n description: 'Solves a system of simultaneous congruences using the Chinese Remainder Theorem.',\n returns: {\n type: 'integer',\n },\n args: {\n remainders: {\n type: 'integer',\n array: true,\n description: 'The remainders of the congruences.',\n },\n moduli: {\n type: 'integer',\n array: true,\n description: 'The moduli of the congruences.',\n },\n a: {\n type: 'array',\n },\n b: {\n type: 'array',\n },\n },\n variants: [\n {\n argumentNames: [\n 'remainders',\n 'moduli',\n ],\n },\n ],\n examples: [\n 'let { chinese-remainder } = import(number-theory);\\nchinese-remainder([2, 3], [3, 5])',\n 'let { chinese-remainder } = import(number-theory);\\nchinese-remainder([1, 2], [3, 4])',\n 'let { chinese-remainder } = import(number-theory);\\nchinese-remainder([0, 1], [2, 3])',\n 'let { chinese-remainder } = import(number-theory);\\nchinese-remainder([1, 2, 3], [4, 5, 7])',\n ],\n seeAlso: ['number-theory.mod-exp', 'number-theory.mod-inv', 'number-theory.extended-gcd'],\n },\n 'stirling-first': {\n category: 'number-theory',\n description: 'Calculates the Stirling numbers of the first kind, which count the number of permutations of n elements with k cycles.',\n returns: {\n type: 'integer',\n },\n args: {\n a: {\n type: 'integer',\n description: 'The number of elements.',\n },\n b: {\n type: 'integer',\n description: 'The number of cycles.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { stirling-first } = import(number-theory);\\nstirling-first(5, 2)',\n 'let { stirling-first } = import(number-theory);\\nstirling-first(4, 3)',\n 'let { stirling-first } = import(number-theory);\\nstirling-first(6, 1)',\n 'let { stirling-first } = import(number-theory);\\nstirling-first(7, 4)',\n 'let { stirling-first } = import(number-theory);\\nstirling-first(8, 5)',\n ],\n seeAlso: ['number-theory.stirling-second', 'number-theory.bell-seq', 'number-theory.count-permutations'],\n },\n 'stirling-second': {\n category: 'number-theory',\n description: 'Calculates the Stirling numbers of the second kind, which count the number of ways to partition n elements into k non-empty subsets.',\n returns: {\n type: 'integer',\n },\n args: {\n a: {\n type: 'integer',\n description: 'The number of elements.',\n },\n b: {\n type: 'integer',\n description: 'The number of subsets.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'a',\n 'b',\n ],\n },\n ],\n examples: [\n 'let { stirling-second } = import(number-theory);\\nstirling-second(5, 2)',\n 'let { stirling-second } = import(number-theory);\\nstirling-second(4, 3)',\n 'let { stirling-second } = import(number-theory);\\nstirling-second(6, 1)',\n 'let { stirling-second } = import(number-theory);\\nstirling-second(7, 4)',\n 'let { stirling-second } = import(number-theory);\\nstirling-second(8, 5)',\n ],\n seeAlso: ['number-theory.stirling-first', 'number-theory.bell-seq', 'number-theory.count-combinations'],\n },\n}\n","export function binomialCoefficient(n: number, k: number): number {\n if (k === 0 || k === n)\n return 1\n\n let result = 1\n for (let i = 0; i < k; i++)\n result *= (n - i) / (i + 1)\n\n return result\n}\n","import type { Arr } from '../../../interface'\nimport { assertArray } from '../../../typeGuards/array'\nimport { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport { binomialCoefficient } from './binomialCefficient'\n\n/**\n * Generates all possible combinations of a specified size from a collection.\n * @param collection The input collection to generate combinations from\n * @param size The size of each combination\n * @returns An array of arrays, where each inner array is a combination of the specified size\n */\nfunction combinations<T>(collection: T[], size: number): T[][] {\n // Base case: if size is 1, return each element as its own combination\n if (size === 1) {\n return collection.map(item => [item])\n }\n\n const result: T[][] = []\n\n // Recursive approach to build combinations\n for (let i = 0; i <= collection.length - size; i++) {\n // Take the current element\n const current = collection[i]!\n\n // Get all combinations of size-1 from the rest of the elements\n const subCombinations = combinations(\n collection.slice(i + 1),\n size - 1,\n )\n\n // Add the current element to each sub-combination\n for (const subComb of subCombinations) {\n result.push([current, ...subComb])\n }\n }\n\n return result\n}\n\nexport const combinationsNormalExpressions: BuiltinNormalExpressions = {\n 'combinations': {\n evaluate: ([set, n], sourceCodeInfo): Arr[] => {\n assertArray(set, sourceCodeInfo)\n assertNumber(n, sourceCodeInfo, { integer: true, nonNegative: true, lte: set.length })\n if (n === 0)\n return [[]]\n return combinations(set, n)\n },\n arity: toFixedArity(2),\n },\n 'count-combinations': {\n evaluate: ([n, k], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, nonNegative: true })\n assertNumber(k, sourceCodeInfo, { integer: true, nonNegative: true, lte: n })\n return binomialCoefficient(n, k)\n },\n arity: toFixedArity(2),\n },\n}\n","import type { Arr } from '../../../interface'\nimport { assertArray } from '../../../typeGuards/array'\nimport { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\n\nfunction getAllDerangements(arr: Arr): Arr[] {\n const n = arr.length\n const result: Arr[] = []\n const used = Array.from({ length: n }, () => false)\n const temp: Arr = Array.from({ length: n })\n\n function generateDerangements(pos: number): void {\n if (pos === n) {\n result.push([...temp])\n return\n }\n\n for (let i = 0; i < n; i++) {\n // Skip if element is already used or would be in its original position\n if (used[i] || i === pos) {\n continue\n }\n\n used[i] = true\n temp[pos] = arr[i]!\n generateDerangements(pos + 1)\n used[i] = false\n }\n }\n\n generateDerangements(0)\n return result\n}\n\nfunction countDerangements(n: number): number {\n if (n === 1)\n return 0\n\n let a = 1 // !0\n let b = 0 // !1\n let result = 0\n\n for (let i = 2; i <= n; i++) {\n result = (i - 1) * (a + b)\n a = b\n b = result\n }\n\n return result\n}\n\nexport const derangementsNormalExpressions: BuiltinNormalExpressions = {\n 'derangements': {\n evaluate: ([set], sourceCodeInfo): Arr => {\n assertArray(set, sourceCodeInfo)\n return getAllDerangements(set)\n },\n arity: toFixedArity(1),\n },\n 'count-derangements': {\n evaluate: ([n], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { finite: true, integer: true, positive: true })\n return countDerangements(n)\n },\n arity: toFixedArity(1),\n },\n}\n","import { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\n\nfunction calcUnsortedDivisors(number: number): number[] {\n const divisors: number[] = []\n for (let i = 1; i <= Math.sqrt(number); i++) {\n if (number % i === 0) {\n divisors.push(i)\n if (i !== number / i) {\n divisors.push(number / i)\n }\n }\n }\n return divisors\n}\n\nexport function getDivisors(n: number): number[] {\n const unsortedDivisors = calcUnsortedDivisors(n)\n const sortedDivisors = unsortedDivisors.sort((a, b) => a - b)\n return sortedDivisors\n}\n\nexport function getProperDivisors(n: number): number[] {\n return getDivisors(n).slice(0, -1) // Exclude the number itself\n}\n\nexport const divisorsNormalExpressions: BuiltinNormalExpressions = {\n 'divisors': {\n evaluate: ([number], sourceCodeInfo): number[] => {\n assertNumber(number, sourceCodeInfo, { finite: true, integer: true, positive: true })\n return getDivisors(number)\n },\n arity: toFixedArity(1),\n },\n 'count-divisors': {\n evaluate: ([number], sourceCodeInfo): number => {\n assertNumber(number, sourceCodeInfo, { finite: true, integer: true, positive: true })\n return calcUnsortedDivisors(number).length\n },\n arity: toFixedArity(1),\n },\n 'proper-divisors': {\n evaluate: ([number], sourceCodeInfo): number[] => {\n assertNumber(number, sourceCodeInfo, { finite: true, integer: true, positive: true })\n return getProperDivisors(number)\n },\n arity: toFixedArity(1),\n },\n 'count-proper-divisors': {\n evaluate: ([number], sourceCodeInfo): number => {\n assertNumber(number, sourceCodeInfo, { finite: true, integer: true, positive: true })\n return calcUnsortedDivisors(number).length - 1 // Exclude the number itself\n },\n arity: toFixedArity(1),\n },\n}\n","export const factorialNumbers = [\n 1,\n 1,\n 2,\n 6,\n 24,\n 120,\n 720,\n 5040,\n 40320,\n 362880,\n 3628800,\n 39916800,\n 479001600,\n 6227020800,\n 87178291200,\n 1307674368000,\n 20922789888000,\n 355687428096000,\n 6402373705728000,\n]\n","import { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport { factorialNumbers } from './sequences/factorial'\n\nexport function factorialOf(n: number): number {\n if (n < 0)\n throw new Error('Factorial is not defined for negative numbers')\n\n if (n === 0 || n === 1)\n return 1\n\n if (n <= 18) {\n return factorialNumbers[n]!\n }\n let result = factorialNumbers[18]!\n for (let i = 19; i <= n; i++)\n result *= i\n\n return result\n}\n\nexport const factorialNormalExpressions: BuiltinNormalExpressions = {\n factorial: {\n evaluate: ([n], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, nonNegative: true, lte: 170 })\n return factorialOf(n)\n },\n arity: toFixedArity(1),\n },\n}\n","export const partitionNumbers = [\n 1,\n 2,\n 3,\n 5,\n 7,\n 11,\n 15,\n 22,\n 30,\n 42,\n 56,\n 77,\n 101,\n 135,\n 176,\n 231,\n 297,\n 385,\n 490,\n 627,\n 792,\n 1002,\n 1255,\n 1575,\n 1958,\n 2436,\n 3010,\n 3718,\n 4565,\n 5604,\n 6842,\n 8349,\n 10143,\n 12310,\n 14883,\n 17977,\n 21637,\n 26015,\n 31185,\n 37338,\n 44583,\n 53174,\n 63261,\n 75175,\n 89134,\n 105558,\n 124754,\n 147273,\n 173525,\n 204226,\n 239943,\n 281589,\n 329931,\n 386155,\n 451276,\n 526823,\n 614154,\n 715220,\n 831820,\n 966467,\n 1121505,\n 1300156,\n 1505499,\n 1741630,\n 2012558,\n 2323520,\n 2679689,\n 3087735,\n 3554345,\n 4087968,\n 4697205,\n 5392783,\n 6185689,\n 7089500,\n 8118264,\n 9289091,\n 10619863,\n 12132164,\n 13848650,\n 15796476,\n 18004327,\n 20506255,\n 23338469,\n 26543660,\n 30167357,\n 34262962,\n 38887673,\n 44108109,\n 49995925,\n 56634173,\n 64112359,\n 72533807,\n 82010177,\n 92669720,\n 104651419,\n 118114304,\n 133230930,\n 150198136,\n 169229875,\n 190569292,\n 214481126,\n 241265379,\n 271248950,\n 304801365,\n 342325709,\n 384276336,\n 431149389,\n 483502844,\n 541946240,\n 607163746,\n 679903203,\n 761002156,\n 851376628,\n 952050665,\n 1064144451,\n 1188908248,\n 1327710076,\n 1482074143,\n 1653668665,\n 1844349560,\n 2056148051,\n 2291320912,\n 2552338241,\n 2841940500,\n 3163127352,\n 3519222692,\n 3913864295,\n 4351078600,\n 4835271870,\n 5371315400,\n 5964539504,\n 6620830889,\n 7346629512,\n 8149040695,\n 9035836076,\n 10015581680,\n 11097645016,\n 12292341831,\n 13610949895,\n 15065878135,\n 16670689208,\n 18440293320,\n 20390982757,\n 22540654445,\n 24908858009,\n 27517052599,\n 30388671978,\n 33549419497,\n 37027355200,\n 40853235313,\n 45060624582,\n 49686288421,\n 54770336324,\n 60356673280,\n 66493182097,\n 73232243759,\n 80630964769,\n 88751778802,\n 97662728555,\n 107438159466,\n 118159068427,\n 129913904637,\n 142798995930,\n 156919475295,\n 172389800255,\n 189334822579,\n 207890420102,\n 228204732751,\n 250438925115,\n 274768617130,\n 301384802048,\n 330495499613,\n 362326859895,\n 397125074750,\n 435157697830,\n 476715857290,\n 522115831195,\n 571701605655,\n 625846753120,\n 684957390936,\n 749474411781,\n 819876908323,\n 896684817527,\n 980462880430,\n 1071823774337,\n 1171432692373,\n 1280011042268,\n 1398341745571,\n 1527273599625,\n 1667727404093,\n 1820701100652,\n 1987276856363,\n 2168627105469,\n 2366022741845,\n 2580840212973,\n 2814570987591,\n 3068829878530,\n 3345365983698,\n 3646072432125,\n 3972999029388,\n 4328363658647,\n 4714566886083,\n 5134205287973,\n 5590088317495,\n 6085253859260,\n 6622987708040,\n 7206841706490,\n 7840656226137,\n 8528581302375,\n 9275102575355,\n 10085065885767,\n 10963707205259,\n 11916681236278,\n 12950095925895,\n 14070545699287,\n 15285151248481,\n 16601598107914,\n 18028182516671,\n 19573856161145,\n 21248279009367,\n 23061871173849,\n 25025873760111,\n 27152408925615,\n 29454549941750,\n 31946390696157,\n 34643126322519,\n 37561133582570,\n 40718063627362,\n 44132934884255,\n 47826239745920,\n 51820051838712,\n 56138148670947,\n 60806135438329,\n 65851585970275,\n 71304185514919,\n 77195892663512,\n 83561103925871,\n 90436839668817,\n 97862933703585,\n 105882246722733,\n 114540884553038,\n 123888443077259,\n 133978259344888,\n 144867692496445,\n 156618412527946,\n 169296722391554,\n 182973889854026,\n 197726516681672,\n 213636919820625,\n 230793554364681,\n 249291451168559,\n 269232701252579,\n 290726957916112,\n 313891991306665,\n 338854264248680,\n 365749566870782,\n 394723676655357,\n 425933084409356,\n 459545750448675,\n 495741934760846,\n 534715062908609,\n 576672674947168,\n 621837416509615,\n 670448123060170,\n 722760953690372,\n 779050629562167,\n 839611730366814,\n 904760108316360,\n 974834369944625,\n 1050197489931117,\n 1131238503938606,\n 1218374349844333,\n 1312051800816215,\n 1412749565173450,\n 1520980492851175,\n 1637293969337171,\n 1762278433057269,\n 1896564103591584,\n 2040825852575075,\n 2195786311682516,\n 2362219145337711,\n 2540952590045698,\n 2732873183547535,\n 2938929793929555,\n 3160137867148997,\n 3397584011986773,\n 3652430836071053,\n 3925922161489422,\n 4219388528587095,\n 4534253126900886,\n 4872038056472084,\n 5234371069753672,\n 5622992691950605,\n 6039763882095515,\n 6486674127079088,\n 6965850144195831,\n 7479565078510584,\n 8030248384943040,\n 8620496275465025,\n]\n","import { DvalaError } from '../../../errors'\nimport { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport { partitionNumbers } from './sequences/partition'\n\nfunction partitions(n: number): number[][] {\n // Base cases\n if (n <= 0)\n return [[]]\n if (n === 1)\n return [[1]]\n\n const result: number[][] = []\n\n // Helper function to generate partitions recursively\n function generatePartitions(remaining: number, max: number, current: number[]): void {\n if (remaining === 0) {\n result.push([...current])\n return\n }\n\n // Try all possible numbers from 1 up to max\n for (let i = Math.min(max, remaining); i >= 1; i--) {\n current.push(i)\n generatePartitions(remaining - i, i, current)\n current.pop()\n }\n }\n\n generatePartitions(n, n, [])\n return result\n}\n\nexport const partitionsNormalExpressions: BuiltinNormalExpressions = {\n 'partitions': {\n evaluate: ([n], sourceCodeInfo): number[][] => {\n assertNumber(n, sourceCodeInfo, { integer: true, nonNegative: true })\n return partitions(n)\n },\n arity: toFixedArity(1),\n },\n 'count-partitions': {\n evaluate: ([n], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, nonNegative: true })\n if (n === 0)\n return 1\n\n if (n > partitionNumbers.length) {\n throw new DvalaError(`n is too large. The maximum value is ${partitionNumbers.length - 1}.`, sourceCodeInfo)\n }\n\n return partitionNumbers[n - 1]!\n },\n arity: toFixedArity(1),\n },\n}\n","import type { Arr } from '../../../interface'\nimport { assertArray } from '../../../typeGuards/array'\nimport { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport { factorialOf } from './factorial'\n\n/**\n * Generates all possible permutations of a collection.\n * @param collection The input collection to generate permutations from\n * @returns An array of arrays, where each inner array is a permutation of the input collection\n */\nfunction permutations<T>(collection: T[]): T[][] {\n // Base case: empty array has one permutation - itself\n if (collection.length === 0) {\n return [[]]\n }\n\n const result: T[][] = []\n\n // For each element in the array\n for (let i = 0; i < collection.length; i++) {\n // Extract the current element\n const current = collection[i]!\n\n // Create a new array without the current element\n const remainingElements = [...collection.slice(0, i), ...collection.slice(i + 1)]\n\n // Generate all permutations of the remaining elements\n const subPermutations = permutations(remainingElements)\n\n // Add the current element to the beginning of each sub-permutation\n for (const subPerm of subPermutations) {\n result.push([current, ...subPerm])\n }\n }\n\n return result\n}\n\nexport const permutationsNormalExpressions: BuiltinNormalExpressions = {\n 'permutations': {\n evaluate: ([set], sourceCodeInfo): Arr[] => {\n assertArray(set, sourceCodeInfo)\n return permutations(set)\n },\n arity: toFixedArity(1),\n },\n 'count-permutations': {\n evaluate: ([n, k], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, nonNegative: true })\n assertNumber(k, sourceCodeInfo, { integer: true, nonNegative: true, lte: n })\n return factorialOf(n) / factorialOf(n - k)\n },\n arity: toFixedArity(2),\n },\n}\n","import type { Arr } from '../../../interface'\nimport { assertArray } from '../../../typeGuards/array'\nimport { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\n\nfunction powerSet(set: Arr): Arr[] {\n const result: Arr[] = [[]]\n\n for (const value of set) {\n const newSubsets = result.map(subset => [...subset, value])\n result.push(...newSubsets)\n }\n\n return result\n}\n\nexport const powerSetNormalExpressions: BuiltinNormalExpressions = {\n 'power-set': {\n evaluate: ([set], sourceCodeInfo): Arr[] => {\n assertArray(set, sourceCodeInfo)\n return powerSet(set)\n },\n arity: toFixedArity(1),\n },\n 'count-power-set': {\n evaluate: ([n], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, nonNegative: true })\n if (n >= 53) {\n // Number.MAX_SAFE_INTEGER is 2^53 - 1\n return Infinity\n }\n\n return 2 ** n\n },\n arity: toFixedArity(1),\n },\n}\n","import { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\n\n/**\n * Returns the prime factorization of a number as an array of its prime factors.\n * For example, factors(12) returns [2, 2, 3].\n * Special case: factors(1) returns an empty array [].\n *\n * @param n - A positive integer to factorize\n * @returns An array of prime factors in ascending order\n */\nexport function primeFactors(n: number): number[] {\n // Special case: 1 has no prime factors\n if (n === 1) {\n return []\n }\n\n const factors: number[] = []\n let divisor = 2\n\n // Find factors by trial division\n while (n > 1) {\n // If divisor divides n evenly\n if (n % divisor === 0) {\n // Add divisor to the factors list\n factors.push(divisor)\n // Divide n by the found factor\n n /= divisor\n }\n else {\n // Move to the next potential divisor\n divisor++\n }\n }\n\n return factors\n}\n\nexport const primeFactorsNormalExpressions: BuiltinNormalExpressions = {\n 'prime-factors': {\n evaluate: ([number], sourceCodeInfo): number[] => {\n assertNumber(number, sourceCodeInfo, { finite: true, integer: true, positive: true })\n return primeFactors(number)\n },\n arity: toFixedArity(1),\n },\n 'distinct-prime-factors': {\n evaluate: ([n], sourceCodeInfo): number[] => {\n assertNumber(n, sourceCodeInfo, { finite: true, integer: true, positive: true })\n const factors = primeFactors(n)\n const distinctFactors = new Set(factors)\n return Array.from(distinctFactors)\n },\n arity: toFixedArity(1),\n },\n 'count-prime-factors': {\n evaluate: ([n], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { finite: true, integer: true, positive: true })\n return primeFactors(n).length\n },\n arity: toFixedArity(1),\n },\n 'count-distinct-prime-factors': {\n evaluate: ([n], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { finite: true, integer: true, positive: true })\n const factors = primeFactors(n)\n const distinctFactors = new Set(factors)\n return distinctFactors.size\n },\n arity: toFixedArity(1),\n },\n}\n","import { getProperDivisors } from '../divisors'\nimport type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceDefinition } from '.'\n\nfunction isAbundant(num: number): boolean {\n const properDivisors = getProperDivisors(num)\n const sum = properDivisors.reduce((acc, curr) => acc + curr, 0)\n return sum > num\n}\n\nexport const abundantSequence: SequenceDefinition<'abundant'> = {\n 'abundant-seq': (length) => {\n const abundants = []\n let num = 2\n while (abundants.length < length) {\n if (isAbundant(num)) {\n abundants.push(num)\n }\n num += 1\n }\n return abundants\n },\n 'abundant?': n => isAbundant(n),\n 'abundant-take-while': (takeWhile) => {\n const abundants: number[] = []\n function loop(i: number): MaybePromise<number[]> {\n if (!isAbundant(i))\n return loop(i + 1)\n return chain(takeWhile(i, abundants.length), (keep) => {\n if (!keep)\n return abundants\n abundants.push(i)\n return loop(i + 1)\n })\n }\n return loop(2)\n },\n}\n","import { assertFunctionLike } from '../../../../typeGuards/dvala'\nimport { assertNumber } from '../../../../typeGuards/number'\nimport { approxEqual } from '../../../../utils'\nimport { toFixedArity } from '../../../../utils/arity'\nimport type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceNormalExpressions } from '.'\n\n/**\n * Checks if a number is a member of an arithmetic sequence.\n * @param start The first term of the sequence\n * @param step The common difference between terms\n * @param n The number to check\n * @returns true if the number is in the sequence, false otherwise\n */\nfunction isInArithmeticSequence(\n start: number,\n step: number,\n n: number,\n): boolean {\n // Special case: If step is 0, n must equal start\n if (step === 0) {\n return approxEqual(n, start)\n }\n\n // Calculate position in sequence\n const position = (n - start) / step\n\n // Position must be non-negative\n if (position < 0) {\n return false\n }\n\n // Find nearest integer position\n const roundedPosition = Math.round(position)\n\n // Calculate the value at that position\n const calculatedValue = start + step * roundedPosition\n\n // Check both if position is close to an integer and if the\n // calculated value is close to the input value\n return approxEqual(position, roundedPosition) && approxEqual(calculatedValue, n)\n}\n\nexport const arithmeticNormalExpressions: SequenceNormalExpressions<'arithmetic'> = {\n 'arithmetic-seq': {\n evaluate: ([start, step, length], sourceCodeInfo): number[] => {\n assertNumber(start, sourceCodeInfo, { finite: true })\n assertNumber(step, sourceCodeInfo, { finite: true })\n assertNumber(length, sourceCodeInfo, { integer: true, positive: true })\n\n return Array.from({ length }, (_, i) => start + i * step)\n },\n arity: toFixedArity(3),\n },\n 'arithmetic-take-while': {\n evaluate: ([start, step, fn], sourceCodeInfo, contextStack, { executeFunction }) => {\n assertNumber(start, sourceCodeInfo, { finite: true })\n assertNumber(step, sourceCodeInfo, { finite: true })\n assertFunctionLike(fn, sourceCodeInfo)\n const s = start\n const d = step\n const f = fn\n\n const arithmetic: number[] = []\n function loop(i: number): MaybePromise<number[]> {\n const value = s + i * d\n return chain(executeFunction(f, [value, i], contextStack, sourceCodeInfo), (keep) => {\n if (!keep)\n return arithmetic\n arithmetic.push(value)\n return loop(i + 1)\n })\n }\n return loop(0)\n },\n arity: toFixedArity(3),\n },\n 'arithmetic-nth': {\n evaluate: ([start, step, n], sourceCodeInfo): number => {\n assertNumber(start, sourceCodeInfo, { finite: true })\n assertNumber(step, sourceCodeInfo, { finite: true })\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n return start + (n - 1) * step\n },\n arity: toFixedArity(3),\n },\n 'arithmetic?': {\n evaluate: ([start, step, n], sourceCodeInfo): boolean => {\n assertNumber(n, sourceCodeInfo)\n assertNumber(start, sourceCodeInfo, { finite: true })\n assertNumber(step, sourceCodeInfo, { finite: true })\n\n return isInArithmeticSequence(start, step, n)\n },\n arity: toFixedArity(3),\n },\n}\n","import { assertFunctionLike } from '../../../../typeGuards/dvala'\nimport { assertNumber } from '../../../../typeGuards/number'\nimport { binomialCoefficient } from '../binomialCefficient'\nimport { toFixedArity } from '../../../../utils/arity'\nimport type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceNormalExpressions } from '.'\n\nfunction getBernoulliSeq(length: number): number[] {\n const bernoulli = [1]\n for (let n = 1; n < length; n += 1) {\n let sum = 0\n for (let k = 0; k < n; k += 1) {\n sum += binomialCoefficient(n + 1, k) * bernoulli[k]!\n }\n bernoulli[n] = n > 1 && n % 2 === 1 ? 0 : -sum / (n + 1)\n }\n return bernoulli\n}\n\n/**\n * Generates Bernoulli numbers as long as the predicate function returns true\n * @param predicate - Function that takes a Bernoulli number and its index and returns true if generation should continue\n * @returns Array of Bernoulli numbers generated until predicate returns false\n */\nfunction generateBernoulli(\n predicate: (value: number, index: number) => MaybePromise<boolean>,\n): MaybePromise<number[]> {\n const bernoulli: number[] = [1]\n\n function loop(n: number): MaybePromise<number[]> {\n let sum = 0\n for (let k = 0; k < n; k++) {\n sum += binomialCoefficient(n + 1, k) * bernoulli[k]!\n }\n\n const newValue = n > 1 && n % 2 === 1 ? 0 : -sum / (n + 1)\n\n return chain(predicate(newValue, n), (keep) => {\n if (!keep)\n return bernoulli\n bernoulli.push(newValue)\n return loop(n + 1)\n })\n }\n\n return loop(1)\n}\n\nexport const bernoulliNormalExpressions: Omit<SequenceNormalExpressions<'bernoulli'>, 'bernoulli?'> = {\n 'bernoulli-seq': {\n evaluate: ([length], sourceCodeInfo): number[] => {\n assertNumber(length, sourceCodeInfo, { integer: true, positive: true })\n return getBernoulliSeq(length)\n },\n arity: toFixedArity(1),\n },\n 'bernoulli-nth': {\n evaluate: ([n], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n const bernoulli = getBernoulliSeq(n)\n return bernoulli[n - 1]!\n },\n arity: toFixedArity(1),\n },\n 'bernoulli-take-while': {\n evaluate: ([fn], sourceCodeInfo, contextStack, { executeFunction }) => {\n assertFunctionLike(fn, sourceCodeInfo)\n const f = fn\n return generateBernoulli((value, index) => chain(executeFunction(f, [value, index], contextStack), val => !!val))\n },\n arity: toFixedArity(1),\n },\n}\n","import type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceDefinition } from '.'\n\nexport function isPrime(num: number): boolean {\n if (num <= 1) {\n return false\n }\n if (num <= 3) {\n return true\n }\n if (num % 2 === 0 || num % 3 === 0) {\n return false\n }\n\n for (let i = 5; i * i <= num; i += 6) {\n if (num % i === 0 || num % (i + 2) === 0) {\n return false\n }\n }\n return true\n}\n\nexport const primeSequence: SequenceDefinition<'prime'> = {\n 'prime-seq': (length) => {\n const primes = []\n let num = 2\n while (primes.length < length) {\n if (isPrime(num)) {\n primes.push(num)\n }\n num += 1\n }\n return primes\n },\n 'prime?': n => isPrime(n),\n 'prime-take-while': (takeWhile) => {\n const primes: number[] = []\n function loop(i: number): MaybePromise<number[]> {\n if (!isPrime(i))\n return loop(i + 1)\n return chain(takeWhile(i, primes.length), (keep) => {\n if (!keep)\n return primes\n primes.push(i)\n return loop(i + 1)\n })\n }\n return loop(2)\n },\n}\n","import type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport { isPrime } from './prime'\nimport type { SequenceDefinition } from '.'\n\nexport function isComposite(num: number): boolean {\n if (num <= 1) {\n return false\n }\n return !isPrime(num)\n}\n\nexport const compositeSequence: SequenceDefinition<'composite'> = {\n 'composite-seq': (length) => {\n const composites = []\n let num = 2\n while (composites.length < length) {\n if (isComposite(num)) {\n composites.push(num)\n }\n num += 1\n }\n return composites\n },\n 'composite?': n => isComposite(n),\n 'composite-take-while': (takeWhile) => {\n const composites: number[] = []\n function loop(i: number): MaybePromise<number[]> {\n if (!isComposite(i))\n return loop(i + 1)\n return chain(takeWhile(i, composites.length), (keep) => {\n if (!keep)\n return composites\n composites.push(i)\n return loop(i + 1)\n })\n }\n return loop(4)\n },\n}\n","import { getProperDivisors } from '../divisors'\nimport type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceDefinition } from '.'\n\nfunction isDeficient(num: number): boolean {\n const properDivisors = getProperDivisors(num)\n const sum = properDivisors.reduce((acc, curr) => acc + curr, 0)\n return sum < num\n}\n\nexport const deficientSequence: SequenceDefinition<'deficient'> = {\n 'deficient-seq': (length) => {\n const deficients = []\n let num = 1\n while (deficients.length < length) {\n if (isDeficient(num)) {\n deficients.push(num)\n }\n num += 1\n }\n return deficients\n },\n 'deficient?': n => isDeficient(n),\n 'deficient-take-while': (takeWhile) => {\n const deficients: number[] = []\n function loop(i: number): MaybePromise<number[]> {\n if (!isDeficient(i))\n return loop(i + 1)\n return chain(takeWhile(i, deficients.length), (keep) => {\n if (!keep)\n return deficients\n deficients.push(i)\n return loop(i + 1)\n })\n }\n return loop(1)\n },\n}\n","import { assertFunctionLike } from '../../../../typeGuards/dvala'\nimport { assertNumber } from '../../../../typeGuards/number'\nimport { approxEqual } from '../../../../utils'\nimport { toFixedArity } from '../../../../utils/arity'\nimport type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceNormalExpressions } from '.'\n\n/**\n * Checks if a number is a member of a geometric sequence.\n * @param initialTerm The first term of the sequence (a)\n * @param ratio The common ratio of the sequence (r)\n * @param number The number to check\n * @returns true if the number is in the sequence, false otherwise\n */\nfunction isInGeometricSequence(\n initialTerm: number,\n ratio: number,\n number: number,\n): boolean {\n // Handle special cases\n if (approxEqual(initialTerm, 0)) {\n return approxEqual(number, 0)\n }\n if (approxEqual(ratio, 1)) {\n return approxEqual(number, initialTerm)\n }\n if (approxEqual(ratio, 0)) {\n return approxEqual(number, 0) || approxEqual(number, initialTerm)\n }\n\n // Check if the number is exactly the initial term\n if (approxEqual(number, initialTerm)) {\n return true\n }\n\n // Special case for ratio = -1 (alternating sequence)\n if (approxEqual(ratio, -1)) {\n // In an alternating sequence with ratio -1, the terms are just initialTerm and -initialTerm\n return approxEqual(number, initialTerm) || approxEqual(number, -initialTerm)\n }\n\n // For negative ratios, we need special handling\n if (ratio < 0) {\n // Calculate log using absolute values\n const logResult = Math.log(Math.abs(number / initialTerm)) / Math.log(Math.abs(ratio))\n\n // Check if logResult is very close to an integer\n const roundedLogResult = Math.round(logResult)\n if (!approxEqual(roundedLogResult, logResult) || roundedLogResult < 0) {\n return false\n }\n\n // For negative ratios, alternating terms have alternating signs\n // Check if sign matches what we expect based on the power\n const expectedSign = roundedLogResult % 2 === 0\n ? Math.sign(initialTerm)\n : Math.sign(initialTerm) * Math.sign(ratio)\n\n return Math.sign(number) === expectedSign\n }\n\n // For positive ratios\n\n // Quick check based on sequence direction\n if ((ratio > 1 && number < initialTerm) || (ratio < 1 && number > initialTerm)) {\n return false\n }\n\n // Calculate n in: number = initialTerm * (ratio^n)\n const logResult = Math.log(number / initialTerm) / Math.log(ratio)\n\n // Check if logResult is very close to an integer and non-negative\n const roundedLogResult = Math.round(logResult)\n if (!approxEqual(roundedLogResult, logResult) || roundedLogResult < 0) {\n return false\n }\n\n // Verify calculated value matches the number exactly\n const calculatedValue = initialTerm * ratio ** roundedLogResult\n\n return approxEqual(calculatedValue, number)\n}\nexport const geometricNormalExpressions: SequenceNormalExpressions<'geometric'> = {\n 'geometric-seq': {\n evaluate: ([start, ratio, length], sourceCodeInfo): number[] => {\n assertNumber(start, sourceCodeInfo, { finite: true })\n assertNumber(ratio, sourceCodeInfo, { finite: true })\n assertNumber(length, sourceCodeInfo, { integer: true, positive: true })\n\n return Array.from({ length }, (_, i) => start * ratio ** i)\n },\n arity: toFixedArity(3),\n },\n 'geometric-take-while': {\n evaluate: ([start, ratio, fn], sourceCodeInfo, contextStack, { executeFunction }) => {\n assertNumber(start, sourceCodeInfo, { finite: true })\n assertNumber(ratio, sourceCodeInfo, { finite: true })\n assertFunctionLike(fn, sourceCodeInfo)\n const s = start\n const r = ratio\n const f = fn\n\n const geometric: number[] = []\n function loop(i: number): MaybePromise<number[]> {\n const value = s * r ** i\n return chain(executeFunction(f, [value, i], contextStack, sourceCodeInfo), (keep) => {\n if (!keep)\n return geometric\n geometric.push(value)\n return loop(i + 1)\n })\n }\n return loop(0)\n },\n arity: toFixedArity(3),\n },\n 'geometric-nth': {\n evaluate: ([start, ratio, n], sourceCodeInfo): number => {\n assertNumber(start, sourceCodeInfo, { finite: true })\n assertNumber(ratio, sourceCodeInfo, { finite: true })\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n return start * ratio ** (n - 1)\n },\n arity: toFixedArity(3),\n },\n 'geometric?': {\n evaluate: ([start, ratio, n], sourceCodeInfo): boolean => {\n assertNumber(n, sourceCodeInfo)\n assertNumber(start, sourceCodeInfo, { finite: true })\n assertNumber(ratio, sourceCodeInfo, { finite: true })\n\n return isInGeometricSequence(start, ratio, n)\n },\n arity: toFixedArity(3),\n },\n}\n","import type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceDefinition } from '.'\n\nfunction getGolombSeq(n: number): number[] {\n const golomb = [0, 1]\n for (let i = 2; i <= n; i += 1) {\n golomb.push(1 + golomb[i - golomb[golomb[i - 1]!]!]!)\n }\n return golomb.slice(1)\n}\n\nfunction generateGolombSeq(pred: (golombNumber: number, index: number) => MaybePromise<boolean>): MaybePromise<number[]> {\n const golomb = [0, 1]\n return chain(pred(1, 0), (keepFirst) => {\n if (!keepFirst)\n return []\n function loop(i: number): MaybePromise<number[]> {\n const golombNumber = 1 + golomb[i - golomb[golomb[i - 1]!]!]!\n return chain(pred(golombNumber, i - 1), (keep) => {\n if (!keep)\n return golomb.slice(1)\n golomb.push(golombNumber)\n return loop(i + 1)\n })\n }\n return loop(2)\n })\n}\n\nexport const golombSequence: SequenceDefinition<'golomb'> = {\n 'golomb-seq': length => getGolombSeq(length),\n 'golomb?': () => true,\n 'golomb-take-while': takeWhile => generateGolombSeq(takeWhile),\n}\n","import type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceDefinition } from '.'\n\nfunction isHappyNumber(n: number): boolean {\n // A happy number is defined by the following process:\n // 1. Starting with any positive integer, replace the number by the sum of the squares of its digits\n // 2. Repeat until either:\n // - The number equals 1 (in which case it's a happy number)\n // - It enters a cycle that doesn't include 1 (in which case it's not a happy number)\n\n if (n <= 0)\n return false\n\n // Use a set to detect cycles\n const seen = new Set()\n\n // Continue until we either reach 1 or detect a cycle\n while (n !== 1 && !seen.has(n)) {\n seen.add(n)\n n = getSumOfSquaredDigits(n)\n }\n\n // If we reached 1, it's a happy number\n return n === 1\n}\n\nfunction getSumOfSquaredDigits(n: number): number {\n let sum = 0\n\n while (n > 0) {\n const digit = n % 10\n sum += digit * digit\n n = Math.floor(n / 10)\n }\n\n return sum\n}\n\nexport const happySequence: SequenceDefinition<'happy'> = {\n 'happy-seq': (length) => {\n const happyNumbers: number[] = []\n for (let i = 1; happyNumbers.length < length; i++) {\n let n = i\n const seen = new Set<number>()\n while (n !== 1 && !seen.has(n)) {\n seen.add(n)\n n = String(n)\n .split('')\n .reduce((sum, digit) => sum + Number(digit) ** 2, 0)\n }\n if (n === 1)\n happyNumbers.push(i)\n }\n return happyNumbers\n },\n 'happy?': n => isHappyNumber(n),\n 'happy-take-while': (takeWhile) => {\n const happyNumbers: number[] = []\n function loop(i: number): MaybePromise<number[]> {\n if (!isHappyNumber(i))\n return loop(i + 1)\n return chain(takeWhile(i, happyNumbers.length), (keep) => {\n if (!keep)\n return happyNumbers\n happyNumbers.push(i)\n return loop(i + 1)\n })\n }\n return loop(1)\n },\n}\n","import type { SequenceDefinition } from '.'\n\nexport const jugglerSequence: Omit<SequenceDefinition<'juggler'>, 'juggler-nth' | 'juggler-take-while' | 'juggler?'> = {\n 'juggler-seq': (start) => {\n let next = start\n const juggler = [next]\n\n while (next > 1) {\n next = next % 2 === 0\n ? Math.floor(Math.sqrt(next))\n : Math.floor(next ** (3 / 2))\n juggler.push(next)\n }\n return juggler\n },\n 'noNth': true,\n}\n","import type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceDefinition } from '.'\n\n/**\n * Checks if a number is part of the Look-and-Say sequence.\n *\n * The Look-and-Say sequence starts with \"1\" and each subsequent term describes\n * the previous term by counting consecutive digits. For example:\n * 1, 11, 21, 1211, 111221, 312211, 13112221, ...\n *\n * @param {string|number} target - The number to check (can be a string or number)\n * @returns {boolean} - Whether the target is in the sequence\n */\nfunction isLookAndSay(target: string): boolean {\n // The first term of the sequence\n let current = '1'\n\n // Check if the first term matches\n if (current === target) {\n return true\n }\n\n // Generate terms and check against the target\n while (true) {\n current = getNextLookAndSayTerm(current)\n\n if (current === target) {\n return true\n }\n\n // Optimization: if the current term is longer than the target, and\n // the sequence is strictly increasing in length, the target won't be found\n if (current.length > target.length) {\n return false\n }\n }\n}\n\n/**\n * Generates the next term in the Look-and-Say sequence\n *\n * @param {string} term - The current term\n * @returns {string} - The next term in the sequence\n */\nfunction getNextLookAndSayTerm(term: string): string {\n let result = ''\n let count = 1\n\n for (let i = 0; i < term.length; i++) {\n // If the current digit is the same as the next one, increment count\n if (i + 1 < term.length && term[i] === term[i + 1]) {\n count++\n }\n else {\n // Otherwise, append count and the digit to the result\n result += count.toString() + term[i]\n count = 1\n }\n }\n\n return result\n}\n\nexport const lookAndSaySequence: SequenceDefinition<'look-and-say', string> = {\n 'string': true,\n 'look-and-say-seq': (length) => {\n const lookAndSay = ['1']\n for (let i = 1; i < length; i += 1) {\n const prev = lookAndSay[i - 1]!\n const next = prev.replace(/(\\d)\\1*/g, match => `${match.length}${match[0]}`)\n lookAndSay[i] = next\n }\n return lookAndSay\n },\n 'look-and-say-take-while': (takeWhile) => {\n const lookAndSay: string[] = []\n return chain(takeWhile('1', 0), (keepFirst) => {\n if (!keepFirst)\n return lookAndSay\n lookAndSay.push('1')\n function loop(i: number): MaybePromise<string[]> {\n const prev = lookAndSay[i - 1]!\n const next = prev.replace(/(\\d)\\1*/g, match => `${match.length}${match[0]}`)\n return chain(takeWhile(next, i), (keep) => {\n if (!keep)\n return lookAndSay\n lookAndSay.push(next)\n return loop(i + 1)\n })\n }\n return loop(1)\n })\n },\n 'look-and-say?': n => isLookAndSay(n),\n}\n","import type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceDefinition } from '.'\n\n/**\n * Generates lucky numbers while the predicate function returns true.\n *\n * @param predicate - Function that tests if we should continue generating numbers.\n * Takes the current lucky number and index as parameters.\n * @returns An array of lucky numbers\n */\nfunction generateLuckyNumbers(\n predicate: (luckyNumber: number, index: number) => MaybePromise<boolean>,\n): MaybePromise<number[]> {\n // Start with counting from 1\n const numbers: number[] = []\n for (let i = 1; i <= 2000; i++) {\n numbers.push(i)\n }\n\n // First step: remove all even numbers (keep 1)\n let filteredNumbers: number[] = [1]\n for (let i = 1; i < numbers.length; i++) {\n if (numbers[i]! % 2 !== 0) {\n filteredNumbers.push(numbers[i]!)\n }\n }\n\n const luckyNumbers: number[] = [1] // 1 is always the first lucky number\n let count = 1\n\n // Check if we should continue after the first number\n return chain(predicate(1, 0), (keepFirst) => {\n if (!keepFirst)\n return []\n\n // Continue the sieve process\n let index = 1 // Start with the second element (index 1, which is 3)\n\n function loop(): MaybePromise<number[]> {\n // Get the current lucky number\n const luckyNumber = filteredNumbers[index]!\n\n // Check if we should continue\n return chain(predicate(luckyNumber, count), (keep) => {\n if (!keep)\n return luckyNumbers\n\n // Add to result\n luckyNumbers.push(luckyNumber)\n count++\n\n // Apply the sieve\n const step = luckyNumber\n const newFiltered: number[] = []\n\n for (let i = 0; i < filteredNumbers.length; i++) {\n if ((i + 1) % step !== 0) { // Keep numbers not at positions divisible by step\n newFiltered.push(filteredNumbers[i]!)\n }\n }\n\n filteredNumbers = newFiltered\n index++\n\n // If we're running low on numbers, extend the sequence\n if (index >= filteredNumbers.length - 5) {\n const lastNum = filteredNumbers[filteredNumbers.length - 1]!\n let next = lastNum + 2\n\n while (filteredNumbers.length < index + 1000) {\n filteredNumbers.push(next)\n next += 2\n }\n }\n\n return loop()\n })\n }\n\n return loop()\n })\n}\n\n/**\n * Generates lucky numbers up to a specified length or count\n *\n * Lucky numbers are a subset of integers defined by a specific sieving process:\n * 1. Start with all positive integers: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, ...\n * 2. Keep 1, delete every 2nd number: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, ...\n * 3. The second remaining number is 3, so keep it and delete every 3rd number: 1, 3, 7, 9, 13, 15, 19, ...\n * 4. The third remaining number is 7, so keep it and delete every 7th number\n * 5. Continue this process to get all lucky numbers\n *\n * @param count - The number of lucky numbers to generate\n * @returns An array containing the first 'count' lucky numbers\n */\nfunction getLuckyNumbers(count: number): number[] {\n // Step 1: Start with all odd numbers (we skip the first elimination step since we know\n // the first sieve removes all even numbers)\n const numbers: number[] = []\n let n = 1\n // Generate enough odd numbers to ensure we'll have 'count' lucky numbers after sieving\n // The factor depends on how many numbers we expect to be eliminated\n // For larger counts, we need a higher factor to ensure we have enough numbers\n const factor = count < 100 ? 20 : 30\n const initialSize = count * factor\n\n while (numbers.length < initialSize) {\n numbers.push(n)\n n += 2\n }\n\n // Step 2 and beyond: Apply the lucky number sieve\n let sieveIndex = 1 // Start at index 1 (the second element which is 3)\n\n while (sieveIndex < numbers.length && sieveIndex < count) {\n const sieveValue = numbers[sieveIndex]!\n\n // Remove every sieveValue-th number\n // This is an optimization over creating a new array each time\n let j = 0\n for (let i = 0; i < numbers.length; i++) {\n if ((i + 1) % sieveValue !== 0) {\n numbers[j++] = numbers[i]!\n }\n }\n numbers.length = j // Truncate the array\n\n // Only increment sieveIndex if it's still within the new array bounds\n if (sieveIndex < numbers.length) {\n sieveIndex++\n }\n }\n\n // Return the requested number of lucky numbers\n return numbers.slice(0, count)\n}\n\nexport const luckySequence: SequenceDefinition<'lucky'> = {\n 'lucky-seq': length => getLuckyNumbers(length),\n 'lucky?': n => (generateLuckyNumbers(l => l <= n) as number[]).includes(n),\n 'lucky-take-while': takeWhile => generateLuckyNumbers(takeWhile),\n}\n","import type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceDefinition } from '.'\n\n/**\n * Checks if a number is a Padovan number.\n * Padovan numbers follow the recurrence relation: P(n) = P(n-2) + P(n-3) for n >= 3,\n * with initial values P(0) = P(1) = P(2) = 1.\n *\n * The first few Padovan numbers are:\n * 1, 1, 1, 2, 2, 3, 4, 5, 7, 9, 12, 16, 21, 28, 37, 49, 65, 86, 114, 151, 200, ...\n *\n * @param num - The number to check\n * @returns True if the number is a Padovan number, false otherwise\n */\nfunction isPadovan(num: number): boolean {\n // Padovan numbers are always positive integers\n if (!Number.isInteger(num) || num <= 0) {\n return false\n }\n\n // Special case: The first three Padovan numbers are all 1\n if (num === 1) {\n return true\n }\n\n // Pre-calculated Padovan numbers (for efficient lookup, verified for correctness)\n const padovanNumbers = [\n 1,\n 1,\n 1,\n 2,\n 2,\n 3,\n 4,\n 5,\n 7,\n 9,\n 12,\n 16,\n 21,\n 28,\n 37,\n 49,\n 65,\n 86,\n 114,\n 151,\n 200,\n 265,\n 351,\n 465,\n 616,\n 816,\n 1081,\n 1432,\n 1897,\n 2513,\n 3329,\n 4410,\n 5842,\n 7739,\n 10252,\n 13581,\n 17991,\n 23833,\n 31572,\n 41824,\n 55405,\n 73396,\n 97229,\n ]\n\n // Direct lookup for known values\n if (padovanNumbers.includes(num)) {\n return true\n }\n\n // For numbers larger than our pre-calculated list but within JavaScript's safe range\n if (num > padovanNumbers[padovanNumbers.length - 1]! && num <= Number.MAX_SAFE_INTEGER) {\n // Start with the last three values from our known sequence\n let a = padovanNumbers[padovanNumbers.length - 3]!\n let b = padovanNumbers[padovanNumbers.length - 2]!\n let c = padovanNumbers[padovanNumbers.length - 1]!\n let next\n\n // Generate Padovan numbers until we either find a match or exceed the input\n while (c < num) {\n next = a + b\n a = b\n b = c\n c = next\n\n if (c === num) {\n return true\n }\n\n // Check for numeric overflow/precision issues\n if (!Number.isSafeInteger(c)) {\n return false\n }\n }\n }\n\n return false\n}\n\nexport const padovanSequence: SequenceDefinition<'padovan'> = {\n 'padovan-seq': (length) => {\n const padovan = [1, 1, 1]\n for (let i = 3; i < length; i += 1) {\n padovan[i] = padovan[i - 2]! + padovan[i - 3]!\n }\n return padovan.slice(0, length)\n },\n 'padovan?': n => isPadovan(n),\n 'padovan-take-while': (takeWhile) => {\n const padovan: number[] = []\n return chain(takeWhile(1, 0), (keep0) => {\n if (!keep0)\n return padovan\n padovan.push(1)\n return chain(takeWhile(1, 1), (keep1) => {\n if (!keep1)\n return padovan\n padovan.push(1)\n return chain(takeWhile(1, 2), (keep2) => {\n if (!keep2)\n return padovan\n padovan.push(1)\n let a = 1\n let b = 1\n let c = 1\n function loop(i: number): MaybePromise<number[]> {\n const temp = a + b\n a = b\n b = c\n c = temp\n return chain(takeWhile(c, i), (keep) => {\n if (!keep)\n return padovan\n padovan.push(c)\n return loop(i + 1)\n })\n }\n return loop(4)\n })\n })\n })\n },\n}\n","import type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceDefinition } from '.'\n\nexport const perfectCubeSequence: SequenceDefinition<'perfect-cube'> = {\n 'perfect-cube-seq': (length) => {\n const perfectcubes = []\n for (let i = 1; i <= length; i++) {\n perfectcubes.push(i ** 3)\n }\n return perfectcubes\n },\n 'perfect-cube?': n => n > 0 && Number.isInteger(Math.cbrt(n)),\n 'perfect-cube-take-while': (takeWhile) => {\n const perfectcubes: number[] = []\n function loop(i: number): MaybePromise<number[]> {\n const value = i ** 3\n return chain(takeWhile(value, i), (keep) => {\n if (!keep)\n return perfectcubes\n perfectcubes.push(value)\n return loop(i + 1)\n })\n }\n return loop(1)\n },\n}\n","import { approxEqual } from '../../../../utils'\nimport type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceDefinition } from '.'\n\n/**\n * Checks if a number is a perfect power and returns the base and exponent if it is.\n * A perfect power is a number that can be expressed as an integer power of another integer.\n *\n * @param n - The number to check\n * @returns [base, exponent] if n is a perfect power, null otherwise\n */\nexport function perfectPower(n: number): [number, number] | null {\n // Handle edge cases\n if (n < 2) {\n if (n === 1) {\n // 1 is 1^k for any k, we return [1, 2] as the simplest representation\n return [1, 2]\n }\n return null // Non positive numbers are not perfect powers\n }\n\n // For each possible exponent k, try to find base b such that b^k = n\n const maxK = Math.floor(Math.log2(n)) + 1\n\n for (let k = 2; k <= maxK; k++) {\n // Calculate the potential base as n^(1/k)\n const b = n ** (1 / k)\n const roundedB = Math.round(b)\n\n if (approxEqual(roundedB ** k, n)) {\n return [roundedB, k]\n }\n }\n\n return null // Not a perfect power\n}\n\nexport const perfectPowerSequence: SequenceDefinition<'perfect-power'> = {\n 'perfect-power-seq': (length) => {\n const perfectPowers: number[] = []\n for (let i = 1; perfectPowers.length < length; i++) {\n if (perfectPower(i)) {\n perfectPowers.push(i)\n }\n }\n return perfectPowers\n },\n 'perfect-power?': n => perfectPower(n) !== null,\n 'perfect-power-take-while': (takeWhile) => {\n const perfectPowers: number[] = []\n function loop(i: number): MaybePromise<number[]> {\n if (!perfectPower(i))\n return loop(i + 1)\n return chain(takeWhile(i, perfectPowers.length), (keep) => {\n if (!keep)\n return perfectPowers\n perfectPowers.push(i)\n return loop(i + 1)\n })\n }\n return loop(1)\n },\n}\n","import type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceDefinition } from '.'\n\nexport const perfectSquareSequence: SequenceDefinition<'perfect-square'> = {\n 'perfect-square-seq': (length) => {\n const perfectSquares = []\n for (let i = 1; i <= length; i++) {\n perfectSquares.push(i ** 2)\n }\n return perfectSquares\n },\n 'perfect-square?': n => n > 0 && Number.isInteger(Math.sqrt(n)),\n 'perfect-square-take-while': (takeWhile) => {\n const perfectSquares: number[] = []\n function loop(i: number): MaybePromise<number[]> {\n const value = i ** 2\n return chain(takeWhile(value, i), (keep) => {\n if (!keep)\n return perfectSquares\n perfectSquares.push(value)\n return loop(i + 1)\n })\n }\n return loop(1)\n },\n}\n","import { assertFunctionLike } from '../../../../typeGuards/dvala'\nimport { assertNumber } from '../../../../typeGuards/number'\nimport { toFixedArity } from '../../../../utils/arity'\nimport type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceNormalExpressions } from '.'\n\nexport const poligonalNormalExpressions: SequenceNormalExpressions<'polygonal'> = {\n 'polygonal-seq': {\n evaluate: ([sides, n], sourceCodeInfo): number[] => {\n assertNumber(sides, sourceCodeInfo, { integer: true, gte: 3 })\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n\n const polygonal = []\n for (let i = 1; i <= n; i += 1) {\n polygonal[i - 1] = (i * i * (sides - 2) - i * (sides - 4)) / 2\n }\n return polygonal\n },\n arity: toFixedArity(2),\n },\n 'polygonal-take-while': {\n evaluate: ([sides, fn], sourceCodeInfo, contextStack, { executeFunction }) => {\n assertNumber(sides, sourceCodeInfo, { integer: true, gte: 3 })\n assertFunctionLike(fn, sourceCodeInfo)\n const s = sides\n const f = fn\n\n const polygonal: number[] = []\n function loop(i: number): MaybePromise<number[]> {\n const value = (i * i * (s - 2) - i * (s - 4)) / 2\n return chain(executeFunction(f, [value, i], contextStack, sourceCodeInfo), (keep) => {\n if (!keep)\n return polygonal\n polygonal.push(value)\n return loop(i + 1)\n })\n }\n return loop(1)\n },\n arity: toFixedArity(2),\n },\n 'polygonal-nth': {\n evaluate: ([sides, n], sourceCodeInfo): number => {\n assertNumber(sides, sourceCodeInfo, { integer: true, gte: 3 })\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n return (n * n * (sides - 2) - n * (sides - 4)) / 2\n },\n arity: toFixedArity(2),\n },\n 'polygonal?': {\n evaluate: ([sides, n], sourceCodeInfo): boolean => {\n assertNumber(n, sourceCodeInfo, { integer: true })\n assertNumber(sides, sourceCodeInfo, { integer: true, gte: 3 })\n\n if (n <= 0) {\n return false\n }\n const a = sides - 2\n const b = sides - 4\n\n const discriminant = 8 * a * n + b * b\n const sqrtPart = Math.sqrt(discriminant)\n\n // Discriminant must yield an integer square root\n if (!Number.isInteger(sqrtPart))\n return false\n\n const numerator = sqrtPart + b\n\n // Numerator must be divisible by 2*a\n if (numerator % (2 * a) !== 0)\n return false\n\n const x = numerator / (2 * a)\n\n // x must be a positive integer\n return Number.isInteger(x) && x > 0\n },\n arity: toFixedArity(2),\n },\n}\n","import type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceDefinition } from '.'\n\n/**\n * Generates the first 'n' terms of the Recamán sequence.\n *\n * @param n - Number of terms to generate\n * @returns Array containing the first n terms of the Recamán sequence\n */\nexport function generateRecamanSequence(n: number): number[] {\n if (n === 1)\n return [0]\n\n const sequence: number[] = [0]\n const seen = new Set<number>([0])\n\n for (let i = 1; i < n; i++) {\n // Try to go backward\n let next = sequence[i - 1]! - i\n\n // If that's not positive or already seen, go forward\n if (next <= 0 || seen.has(next)) {\n next = sequence[i - 1]! + i\n }\n\n sequence.push(next)\n seen.add(next)\n }\n\n return sequence\n}\n\nexport const recamanSequence: SequenceDefinition<'recaman'> = {\n 'recaman-seq': length => generateRecamanSequence(length),\n 'recaman-take-while': (takeWhile) => {\n const sequence: number[] = []\n const seen = new Set<number>([0])\n\n return chain(takeWhile(0, 0), (keepFirst) => {\n if (!keepFirst)\n return sequence\n sequence.push(0)\n\n function loop(i: number): MaybePromise<number[]> {\n // Try to go backward\n let next = sequence[i - 1]! - i\n\n // If that's not positive or already seen, go forward\n if (next <= 0 || seen.has(next)) {\n next = sequence[i - 1]! + i\n }\n\n return chain(takeWhile(next, i), (keep) => {\n if (!keep)\n return sequence\n sequence.push(next)\n seen.add(next)\n return loop(i + 1)\n })\n }\n return loop(1)\n })\n },\n 'recaman?': () => true,\n}\n","import type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { SequenceDefinition } from '.'\n\nexport const thueMorseSequence: SequenceDefinition<'thue-morse'> = {\n 'thue-morse-seq': (length) => {\n const thueMorse = []\n for (let i = 0; i < length; i += 1) {\n thueMorse[i] = countSetBits(i) % 2\n }\n return thueMorse\n },\n 'thue-morse-take-while': (takeWhile) => {\n const thueMorse: number[] = []\n function loop(i: number): MaybePromise<number[]> {\n const value = countSetBits(i) % 2\n return chain(takeWhile(value, i), (keep) => {\n if (!keep)\n return thueMorse\n thueMorse.push(value)\n return loop(i + 1)\n })\n }\n return loop(0)\n },\n 'thue-morse?': n => n === 1 || n === 0,\n}\n\nfunction countSetBits(num: number): number {\n let count = 0\n while (num) {\n count += num & 1\n num >>= 1\n }\n return count\n}\n","export const tribonacciNumbers = [\n 0,\n 1,\n 1,\n 2,\n 4,\n 7,\n 13,\n 24,\n 44,\n 81,\n 149,\n 274,\n 504,\n 927,\n 1705,\n 3136,\n 5768,\n 10609,\n 19513,\n 35890,\n 66012,\n 121415,\n 223317,\n 410744,\n 755476,\n 1389537,\n 2555757,\n 4700770,\n 8646064,\n 15902591,\n 29249425,\n 53798080,\n 98950096,\n 181997601,\n 334745777,\n 615693474,\n 1132436852,\n 2082876103,\n 3831006429,\n 7046319384,\n 12960201916,\n 23837527729,\n 43844049029,\n 80641778674,\n 148323355432,\n 272809183135,\n 501774317241,\n 922906855808,\n 1697490356184,\n 3122171529233,\n 5742568741225,\n 10562230626642,\n 19426970897100,\n 35731770264967,\n 65720971788709,\n 120879712950776,\n 222332455004452,\n 408933139743937,\n 752145307699165,\n 1383410902447554,\n 2544489349890656,\n 4680045560037375,\n 8607945812375585,\n]\n","import { DvalaError } from '../../../../errors'\nimport type { SourceCodeInfo } from '../../../../tokenizer/token'\nimport { assertFunctionLike } from '../../../../typeGuards/dvala'\nimport { assertNumber } from '../../../../typeGuards/number'\nimport { assertString } from '../../../../typeGuards/string'\nimport { toFixedArity } from '../../../../utils/arity'\nimport type { MaybePromise } from '../../../../utils/maybePromise'\nimport { chain } from '../../../../utils/maybePromise'\nimport type { BuiltinNormalExpression, BuiltinNormalExpressions } from '../../../../builtin/interface'\nimport { abundantSequence } from './abundant'\nimport { arithmeticNormalExpressions } from './arithmetic'\nimport { bellNumbers } from './bell'\nimport { bernoulliNormalExpressions } from './bernoulli'\nimport { catalanNumbers } from './catalan'\nimport { collatzSequence } from './collatz'\nimport { compositeSequence } from './composite'\nimport { deficientSequence } from './deficient'\nimport { factorialNumbers } from './factorial'\nimport { fibonacciNumbers } from './fibonacci'\nimport { geometricNormalExpressions } from './geometric'\nimport { golombSequence } from './golomb'\nimport { happySequence } from './happy'\nimport { jugglerSequence } from './juggler'\nimport { lookAndSaySequence } from './lookAndSay'\nimport { lucasNumbers } from './lucas'\nimport { luckySequence } from './lucky'\nimport { mersenneNumbers } from './mersenne'\nimport { padovanSequence } from './padovan'\nimport { partitionNumbers } from './partition'\nimport { pellNumbers } from './pell'\nimport { perfectNumbers } from './perfect'\nimport { perfectCubeSequence } from './perfectCube'\nimport { perfectPowerSequence } from './perfectPower'\nimport { perfectSquareSequence } from './perfectSquare'\nimport { poligonalNormalExpressions } from './poligonal'\nimport { primeSequence } from './prime'\nimport { recamanSequence } from './recaman'\nimport { sylvesterNumbers } from './sylvester'\nimport { thueMorseSequence } from './thueMorse'\nimport { tribonacciNumbers } from './tribonacci'\n\ntype SeqKey<T extends string> = `${T}-seq`\ntype TakeWhileKey<T extends string> = `${T}-take-while`\ntype NthKey<T extends string> = `${T}-nth`\ntype PredKey<T extends string> = `${T}?`\n\ntype SeqFunction<Type extends number | string> = (length: number, sourceCodeInfo: SourceCodeInfo | undefined) => Type[]\ntype TakeWhileFunction<Type extends number | string> = (pred: (value: Type, index: number) => MaybePromise<boolean>, sourceCodeInfo: SourceCodeInfo | undefined) => MaybePromise<Type[]>\ntype PredFunction<Type extends number | string> = (n: Type, sourceCodeInfo: SourceCodeInfo | undefined) => boolean\n\nexport type SequenceKeys<T extends string> = SeqKey<T> | TakeWhileKey<T> | NthKey<T> | PredKey<T>\n\nexport type SequenceDefinition<T extends string, Type extends number | string = number> = {\n [key in Exclude<SequenceKeys<T>, NthKey<T>>]: key extends SeqKey<T>\n ? SeqFunction<Type>\n : key extends TakeWhileKey<T>\n ? TakeWhileFunction<Type>\n : PredFunction<Type>\n} & {\n maxLength?: number\n} & (Type extends string ? {\n string: true\n} : {\n string?: never\n}) & {\n noNth?: true\n}\n\nexport type SequenceNormalExpressions<T extends string, Type extends string | number = number> = {\n [key in SequenceKeys<T>]: key extends SeqKey<T>\n ? BuiltinNormalExpression<Type[]>\n : key extends TakeWhileKey<T>\n ? BuiltinNormalExpression<Type[]>\n : key extends NthKey<T>\n ? BuiltinNormalExpression<Type>\n : BuiltinNormalExpression<boolean>\n}\n\nexport const sequenceNormalExpressions: BuiltinNormalExpressions = {}\n\naddSequence(abundantSequence)\naddSequence(collatzSequence)\naddSequence(compositeSequence)\naddSequence(deficientSequence)\naddSequence(golombSequence)\naddSequence(happySequence)\naddSequence(jugglerSequence)\naddSequence(lookAndSaySequence)\naddSequence(luckySequence)\naddSequence(padovanSequence)\naddSequence(perfectSquareSequence)\naddSequence(perfectCubeSequence)\naddSequence(perfectPowerSequence)\naddSequence(primeSequence)\naddSequence(recamanSequence)\naddSequence(thueMorseSequence)\naddNormalExpressions(getFiniteNumberSequence('tribonacci', tribonacciNumbers))\naddNormalExpressions(getFiniteNumberSequence('catalan', catalanNumbers))\naddNormalExpressions(getFiniteNumberSequence('factorial', factorialNumbers))\naddNormalExpressions(getFiniteNumberSequence('fibonacci', fibonacciNumbers))\naddNormalExpressions(getFiniteNumberSequence('lucas', lucasNumbers))\naddNormalExpressions(getFiniteNumberSequence('mersenne', mersenneNumbers))\naddNormalExpressions(getFiniteNumberSequence('partition', partitionNumbers))\naddNormalExpressions(getFiniteNumberSequence('pell', pellNumbers))\naddNormalExpressions(getFiniteNumberSequence('perfect', perfectNumbers))\naddNormalExpressions(getFiniteNumberSequence('sylvester', sylvesterNumbers))\naddNormalExpressions(getFiniteNumberSequence('bell', bellNumbers))\naddNormalExpressions(arithmeticNormalExpressions)\naddNormalExpressions(bernoulliNormalExpressions)\naddNormalExpressions(geometricNormalExpressions)\naddNormalExpressions(poligonalNormalExpressions)\n\nfunction addNormalExpressions(normalExpressions: BuiltinNormalExpressions) {\n for (const [key, value] of Object.entries(normalExpressions)) {\n /* v8 ignore next 3 */\n if (sequenceNormalExpressions[key]) {\n throw new Error(`Duplicate normal expression key found: ${key}`)\n }\n sequenceNormalExpressions[key] = value\n }\n}\n\nfunction getFiniteNumberSequence<T extends string>(name: T, sequence: number[]): SequenceNormalExpressions<T> {\n return {\n [`${name}-seq`]: createSeqNormalExpression(length => sequence.slice(0, length), sequence.length),\n [`${name}-take-while`]: createTakeWhileNormalExpression((takeWhile) => {\n function loop(i: number): MaybePromise<number[]> {\n if (i >= sequence.length)\n return sequence.slice(0, i)\n return chain(takeWhile(sequence[i]!, i), (keep) => {\n if (!keep)\n return sequence.slice(0, i)\n return loop(i + 1)\n })\n }\n return loop(0)\n }, sequence.length),\n [`${name}-nth`]: createNthNormalExpression(() => sequence, sequence.length),\n [`${name}?`]: createNumberPredNormalExpression(n => sequence.includes(n)),\n } as unknown as SequenceNormalExpressions<T>\n}\n\nfunction addSequence<Type extends number | string>(sequence: SequenceDefinition<string, Type>) {\n for (const [key, value] of Object.entries(sequence)) {\n /* v8 ignore next 3 */\n if (sequenceNormalExpressions[key]) {\n throw new Error(`Duplicate normal expression key found: ${key}`)\n }\n if (key.endsWith('seq')) {\n sequenceNormalExpressions[key] = createSeqNormalExpression(value as SeqFunction<Type>, sequence.maxLength)\n if (!sequence.noNth) {\n sequenceNormalExpressions[key.replace(/seq$/, 'nth')] = createNthNormalExpression(value as SeqFunction<Type>, sequence.maxLength)\n }\n }\n else if (key.endsWith('take-while')) {\n sequenceNormalExpressions[key] = createTakeWhileNormalExpression(value as TakeWhileFunction<Type>, sequence.maxLength)\n }\n else if (key.endsWith('?')) {\n if (sequence.string) {\n sequenceNormalExpressions[key] = createStringPredNormalExpression(value as PredFunction<string>)\n }\n else {\n sequenceNormalExpressions[key] = createNumberPredNormalExpression(value as PredFunction<number>)\n }\n }\n }\n}\n\nfunction createSeqNormalExpression<Type extends number | string>(\n seqFunction: SeqFunction<Type>,\n maxLength: number | undefined,\n): BuiltinNormalExpression<Type[]> {\n return {\n evaluate: (params, sourceCodeInfo) => {\n const length = params[0] ?? maxLength\n assertNumber(length, sourceCodeInfo, { integer: true, positive: true, lte: maxLength })\n const result = seqFunction(length, sourceCodeInfo)\n if (typeof result[0] === 'number') {\n /* v8 ignore next 3 */\n if (result.some(n => (n as number) > Number.MAX_SAFE_INTEGER)) {\n throw new DvalaError('Result exceeds maximum safe integer', sourceCodeInfo)\n }\n }\n return result\n },\n arity: typeof maxLength === 'number' ? { max: 1 } : toFixedArity(1),\n }\n}\n\nfunction createTakeWhileNormalExpression<Type extends number | string>(\n takeWhileFunction: TakeWhileFunction<Type>,\n maxLength: number | undefined,\n): BuiltinNormalExpression<Type[]> {\n return {\n evaluate: (params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const fn = params[0]\n assertFunctionLike(fn, sourceCodeInfo)\n const result = takeWhileFunction(\n (value, index) => chain(executeFunction(fn, [value, index], contextStack), val => !!val),\n sourceCodeInfo,\n )\n return chain(result, (resolved) => {\n if (typeof resolved[0] === 'number') {\n /* v8 ignore next 3 */\n if (resolved.some(n => (n as number) > Number.MAX_SAFE_INTEGER)) {\n throw new DvalaError('Result exceeds maximum safe integer', sourceCodeInfo)\n }\n }\n return resolved\n })\n },\n arity: typeof maxLength === 'number' ? { max: 1 } : toFixedArity(1),\n }\n}\n\nfunction createNthNormalExpression<Type extends number | string>(\n seqFunction: SeqFunction<Type>,\n maxLength: number | undefined,\n): BuiltinNormalExpression<Type> {\n return {\n evaluate: (params, sourceCodeInfo) => {\n const n = params[0]\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true, lte: maxLength })\n const sequence = seqFunction(n, sourceCodeInfo)\n if (typeof sequence[0] === 'number') {\n /* v8 ignore next 3 */\n if (sequence.some(val => (val as number) > Number.MAX_SAFE_INTEGER)) {\n throw new DvalaError('Result exceeds maximum safe integer', sourceCodeInfo)\n }\n }\n return sequence[n - 1]!\n },\n arity: toFixedArity(1),\n }\n}\n\nfunction createNumberPredNormalExpression(\n predFunction: PredFunction<number>,\n): BuiltinNormalExpression<boolean> {\n return {\n evaluate: (params, sourceCodeInfo) => {\n const value = params[0]\n assertNumber(value, sourceCodeInfo)\n return predFunction(value, sourceCodeInfo)\n },\n arity: toFixedArity(1),\n }\n}\n\nfunction createStringPredNormalExpression(\n predFunction: PredFunction<string>,\n): BuiltinNormalExpression<boolean> {\n return {\n evaluate: (params, sourceCodeInfo) => {\n const value = params[0]\n assertString(value, sourceCodeInfo)\n return predFunction(value, sourceCodeInfo)\n },\n arity: toFixedArity(1),\n }\n}\n","import { DvalaError } from '../../../errors'\nimport type { Arr } from '../../../interface'\nimport { assertVector } from '../../../typeGuards/annotatedArrays'\nimport { assertArray } from '../../../typeGuards/array'\nimport { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport type { DvalaModule } from '../interface'\nimport { moduleDocs } from './docs'\nimport { combinationsNormalExpressions } from './combinations'\nimport { derangementsNormalExpressions } from './derangements'\nimport { divisorsNormalExpressions, getDivisors, getProperDivisors } from './divisors'\nimport { factorialNormalExpressions, factorialOf } from './factorial'\nimport { partitionsNormalExpressions } from './partitions'\nimport { permutationsNormalExpressions } from './permutations'\nimport { powerSetNormalExpressions } from './powerSet'\nimport { primeFactors, primeFactorsNormalExpressions } from './primeFactors'\nimport { sequenceNormalExpressions } from './sequences'\nimport { perfectPower } from './sequences/perfectPower'\n\nfunction gcd(a: number, b: number): number {\n while (b !== 0) {\n const temp = b\n b = a % b\n a = temp\n }\n return Math.abs(a)\n}\n\nfunction lcm(a: number, b: number): number {\n return Math.floor((a * b) / gcd(a, b))\n}\n\nfunction mobius(n: number): number {\n if (n === 1)\n return 1\n\n const factors = primeFactors(n)\n const uniqueFactors = new Set(factors)\n\n // If n has a repeated prime factor (not square-free)\n if (uniqueFactors.size !== factors.length)\n return 0\n\n // If square-free with even number of prime factors: return 1\n // If square-free with odd number of prime factors: return -1\n return factors.length % 2 === 0 ? 1 : -1\n}\n\n/**\n * Efficiently computes (base^exponent) % modulus using the square-and-multiply algorithm\n * Based on the pseudocode algorithm for modular exponentiation\n *\n * @param base - The base number\n * @param exponent - The exponent (must be non-negative)\n * @param modulus - The modulus (must be positive)\n * @returns The result of (base^exponent) % modulus\n */\nfunction modExp(base: number, exponent: number, modulus: number): number {\n // Edge case: modulus is 1\n if (modulus === 1) {\n return 0\n }\n\n // Assert: (modulus - 1) * (modulus - 1) does not overflow base\n // This is a limitation of using regular JavaScript numbers instead of BigInt\n\n // Initialize result\n let result = 1\n\n // Apply modulo to base first\n base = base % modulus\n\n // Square and multiply algorithm\n while (exponent > 0) {\n // If current bit of exponent is 1, multiply result with current base\n if (exponent % 2 === 1) {\n result = (result * base) % modulus\n }\n\n // Shift exponent right (divide by 2)\n exponent = exponent >> 1\n\n // Square the base for next iteration\n base = (base * base) % modulus\n }\n\n return result\n}\n\n/**\n * Extended Euclidean Algorithm\n * Finds gcd(a,b) and coefficients x,y such that ax + by = gcd(a,b)\n */\nfunction extendedGcd(a: number, b: number): [number, number, number] {\n if (b === 0) {\n return [a, 1, 0]\n }\n\n const [g, x, y] = extendedGcd(b, a % b)\n return [g, y, x - Math.floor(a / b) * y]\n}\n\n/**\n * Modular Multiplicative Inverse\n * Finds x such that (a * x) % m = 1\n */\nfunction modInverse(a: number, m: number): number {\n const [g, x] = extendedGcd(a, m)\n\n if (g !== 1) {\n throw new Error(`Modular inverse does not exist (gcd(${a}, ${m}) = ${g})`)\n }\n\n return ((x % m) + m) % m // Ensure positive result\n}\n\n/**\n * Chinese Remainder Theorem\n * Solve system of congruences: x ≡ remainders[i] (mod moduli[i])\n * Returns the smallest positive integer that satisfies all congruences\n */\nfunction chineseRemainder(remainders: number[], moduli: number[]): number {\n // Verify moduli are pairwise coprime\n for (let i = 0; i < moduli.length; i++) {\n for (let j = i + 1; j < moduli.length; j++) {\n const extGcd = extendedGcd(moduli[i]!, moduli[j]!)[0]\n if (extGcd !== 1) {\n throw new Error(`Moduli must be pairwise coprime, but gcd(${moduli[i]}, ${moduli[j]}) = ${extGcd}`)\n }\n }\n }\n\n // Calculate product of all moduli\n const product = moduli.reduce((acc, val) => acc * val, 1)\n\n let sum = 0\n\n for (let i = 0; i < remainders.length; i++) {\n const ai = remainders[i]!\n const ni = moduli[i]!\n const bi = product / ni\n\n // Find modular multiplicative inverse of bi modulo ni\n const inverse = modInverse(bi, ni)\n\n // Add contribution from this congruence\n sum = (sum + ai * bi * inverse) % product\n }\n\n return sum\n}\n\nexport const combinatoricalNormalExpression: BuiltinNormalExpressions = {\n 'coprime?': {\n evaluate: ([a, b], sourceCodeInfo): boolean => {\n assertNumber(a, sourceCodeInfo, { integer: true })\n assertNumber(b, sourceCodeInfo, { integer: true })\n return gcd(a, b) === 1\n },\n arity: toFixedArity(2),\n },\n 'divisible-by?': {\n evaluate: ([value, divisor], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n assertNumber(divisor, sourceCodeInfo, { integer: true })\n if (divisor === 0)\n return false\n return value % divisor === 0\n },\n arity: toFixedArity(2),\n },\n 'gcd': {\n evaluate: ([a, b], sourceCodeInfo): number => {\n assertNumber(a, sourceCodeInfo)\n assertNumber(b, sourceCodeInfo)\n return gcd(a, b)\n },\n arity: toFixedArity(2),\n },\n 'lcm': {\n evaluate: ([a, b], sourceCodeInfo): number => {\n assertNumber(a, sourceCodeInfo)\n assertNumber(b, sourceCodeInfo)\n return lcm(a, b)\n },\n arity: toFixedArity(2),\n },\n\n 'multinomial': {\n evaluate: ([...args], sourceCodeInfo): number => {\n assertVector(args, sourceCodeInfo)\n const sum = args.reduce((acc: number, curr) => {\n assertNumber(curr, sourceCodeInfo, { integer: true, nonNegative: true })\n return acc + curr\n }, 0)\n return factorialOf(sum) / args.reduce((acc, curr) => acc * factorialOf(curr), 1)\n },\n arity: { min: 1 },\n },\n 'amicable?': {\n evaluate: ([a, b], sourceCodeInfo): boolean => {\n assertNumber(a, sourceCodeInfo, { integer: true, positive: true })\n assertNumber(b, sourceCodeInfo, { integer: true, positive: true })\n const sumA = getProperDivisors(a).reduce((acc, curr) => acc + curr, 0)\n const sumB = getProperDivisors(b).reduce((acc, curr) => acc + curr, 0)\n return sumA === b && sumB === a && a !== b\n },\n arity: toFixedArity(2),\n },\n 'euler-totient': {\n evaluate: ([n], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n let result = n\n for (let p = 2; p * p <= n; p += 1) {\n if (n % p === 0) {\n while (n % p === 0)\n n /= p\n result -= result / p\n }\n }\n if (n > 1)\n result -= result / n\n return result\n },\n arity: toFixedArity(1),\n },\n 'mobius': {\n evaluate: ([n], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n if (n === 1)\n return 1\n\n const factors = primeFactors(n)\n const uniqueFactors = new Set(factors)\n\n // If n has a repeated prime factor (not square-free)\n if (uniqueFactors.size !== factors.length)\n return 0\n\n // If square-free with even number of prime factors: return 1\n // If square-free with odd number of prime factors: return -1\n return factors.length % 2 === 0 ? 1 : -1\n },\n arity: toFixedArity(1),\n },\n 'mertens': {\n evaluate: ([n], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n if (n === 1)\n return 1\n let result = 0\n for (let i = 1; i <= n; i++) {\n const mobiusValue = mobius(i)\n result += mobiusValue// * Math.floor(n / i)\n }\n return result\n },\n arity: toFixedArity(1),\n },\n 'sigma': {\n evaluate: ([n], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n return getDivisors(n).reduce((acc, curr) => acc + curr, 0)\n },\n arity: toFixedArity(1),\n },\n 'carmichael-lambda': {\n evaluate: ([n], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n if (n === 1) {\n return 1\n }\n\n // Count occurrences of each prime factor\n const primes = primeFactors(n)\n const factorMap = new Map<number, number>()\n\n for (const prime of primes) {\n factorMap.set(prime, (factorMap.get(prime) || 0) + 1)\n }\n\n const lambdaValues: number[] = []\n\n // Calculate lambda for each prime power\n for (const [p, k] of factorMap.entries()) {\n if (p === 2) {\n if (k === 1) {\n lambdaValues.push(1) // λ(2) = 1\n }\n else if (k === 2) {\n lambdaValues.push(2) // λ(4) = 2\n }\n else {\n lambdaValues.push(2 ** (k - 2)) // λ(2^k) = 2^(k-2) for k >= 3\n }\n }\n else {\n // For odd prime powers p^k: λ(p^k) = (p-1)*p^(k-1)\n lambdaValues.push((p - 1) * p ** (k - 1))\n }\n }\n\n // Find LCM of all lambda values\n return lambdaValues.reduce((acc, val) => lcm(acc, val), 1)\n },\n arity: toFixedArity(1),\n },\n 'cartesian-product': {\n evaluate: (params, sourceCodeInfo): Arr[] => {\n params.forEach((set) => {\n assertArray(set, sourceCodeInfo)\n })\n const sets = params as Arr[]\n return sets.reduce((acc: Arr[], set) => {\n const result: Arr[] = []\n acc.forEach((arr) => {\n set.forEach((value) => {\n result.push([...arr, value])\n })\n })\n return result\n }, [[]])\n },\n arity: { min: 1 },\n },\n 'perfect-power': {\n evaluate: ([n], sourceCodeInfo): [number, number] | null => {\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n const result = perfectPower(n)\n return result || null\n },\n arity: toFixedArity(1),\n },\n 'mod-exp': {\n evaluate: ([base, exponent, modulus], sourceCodeInfo): number => {\n assertNumber(base, sourceCodeInfo, { finite: true })\n assertNumber(exponent, sourceCodeInfo, { integer: true, positive: true })\n assertNumber(modulus, sourceCodeInfo, { integer: true, positive: true })\n\n return modExp(base, exponent, modulus)\n },\n arity: toFixedArity(3),\n },\n 'mod-inv': {\n evaluate: ([a, m], sourceCodeInfo): number => {\n assertNumber(a, sourceCodeInfo, { integer: true, positive: true })\n assertNumber(m, sourceCodeInfo, { integer: true, positive: true })\n\n try {\n return modInverse(a, m)\n }\n catch (error) {\n throw new DvalaError(error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(2),\n },\n 'extended-gcd': {\n evaluate: ([a, b], sourceCodeInfo): [number, number, number] => {\n assertNumber(a, sourceCodeInfo, { integer: true })\n assertNumber(b, sourceCodeInfo, { integer: true })\n\n return extendedGcd(a, b)\n },\n arity: toFixedArity(2),\n },\n 'chinese-remainder': {\n evaluate: ([remainders, moduli], sourceCodeInfo): number => {\n assertVector(remainders, sourceCodeInfo)\n assertVector(moduli, sourceCodeInfo)\n if (remainders.length !== moduli.length) {\n throw new DvalaError('Remainders and moduli must have the same length.', sourceCodeInfo)\n }\n try {\n return chineseRemainder(remainders, moduli)\n }\n catch (error) {\n throw new DvalaError((error as Error).message, sourceCodeInfo)\n }\n },\n arity: toFixedArity(2),\n },\n 'stirling-first': {\n evaluate: ([n, k], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n assertNumber(k, sourceCodeInfo, { integer: true, positive: true, lte: n })\n\n // Create a table to store results\n const dp: number[][] = Array.from({ length: n + 1 }, () => Array<number>(k + 1).fill(0))\n\n // Base case\n dp[0]![0] = 1\n\n // Fill the table using the recurrence relation\n for (let i = 1; i <= n; i++) {\n for (let j = 1; j <= Math.min(i, k); j++) {\n dp[i]![j] = dp[i - 1]![j - 1]! + (i - 1) * dp[i - 1]![j]!\n }\n }\n\n return dp[n]![k]!\n },\n arity: toFixedArity(2),\n },\n 'stirling-second': {\n evaluate: ([n, k], sourceCodeInfo): number => {\n assertNumber(n, sourceCodeInfo, { integer: true, positive: true })\n assertNumber(k, sourceCodeInfo, { integer: true, positive: true, lte: n })\n if (k === 1)\n return 1 // Only one way to put n objects into one subset\n if (k === n)\n return 1 // Only one way to put n objects into n subsets (one object per subset)\n\n // Create a 2D array for memoization\n const dp: number[][] = Array.from({ length: n + 1 }, () => Array<number>(k + 1).fill(0))\n\n // Initialize base cases\n dp[0]![0] = 1\n\n // Fill the dp table using the recurrence relation:\n // S(n,k) = k * S(n-1,k) + S(n-1,k-1)\n for (let i = 1; i <= n; i++) {\n for (let j = 1; j <= Math.min(i, k); j++) {\n dp[i]![j] = j * dp[i - 1]![j]! + dp[i - 1]![j - 1]!\n }\n }\n\n return dp[n]![k]!\n },\n arity: toFixedArity(2),\n },\n}\n\naddSequences(sequenceNormalExpressions)\naddNormalExpressions(factorialNormalExpressions)\naddNormalExpressions(divisorsNormalExpressions)\naddNormalExpressions(combinationsNormalExpressions)\naddNormalExpressions(permutationsNormalExpressions)\naddNormalExpressions(partitionsNormalExpressions)\naddNormalExpressions(primeFactorsNormalExpressions)\naddNormalExpressions(derangementsNormalExpressions)\naddNormalExpressions(powerSetNormalExpressions)\n\nfunction addSequences(sequences: BuiltinNormalExpressions) {\n for (const [key, value] of Object.entries(sequences)) {\n /* v8 ignore next 3 */\n if (combinatoricalNormalExpression[key]) {\n throw new Error(`Duplicate normal expression key found: ${key}`)\n }\n combinatoricalNormalExpression[key] = value\n }\n}\n\nfunction addNormalExpressions(normalExpressions: BuiltinNormalExpressions) {\n for (const [key, value] of Object.entries(normalExpressions)) {\n /* v8 ignore next 3 */\n if (combinatoricalNormalExpression[key]) {\n throw new Error(`Duplicate normal expression key found: ${key}`)\n }\n combinatoricalNormalExpression[key] = value\n }\n}\n\nfor (const [key, docs] of Object.entries(moduleDocs)) {\n if (combinatoricalNormalExpression[key])\n combinatoricalNormalExpression[key].docs = docs\n}\n\nexport const numberTheoryModule: DvalaModule = {\n name: 'number-theory',\n functions: combinatoricalNormalExpression,\n}\n","import type { SequenceDefinition } from '.'\n\nexport const collatzSequence: Omit<SequenceDefinition<'collatz'>, 'collatz-nth' | 'collatz-take-while' | 'collatz?'> = {\n 'collatz-seq': (start) => {\n let x = start\n const collatz = [x]\n while (x !== 1) {\n if (x % 2 === 0) {\n x /= 2\n }\n else {\n x = 3 * x + 1\n }\n collatz.push(x)\n }\n return collatz\n },\n 'noNth': true,\n}\n","export const catalanNumbers = [\n 1,\n 2,\n 5,\n 14,\n 42,\n 132,\n 429,\n 1430,\n 4862,\n 16796,\n 58786,\n 208012,\n 742900,\n 2674440,\n 9694845,\n 35357670,\n 129644790,\n 477638700,\n 1767263190,\n 6564120420,\n 24466267020,\n 91482563640,\n 343059613650,\n 1289904147324,\n 4861946401452,\n 18367353072152,\n 69533550916004,\n 263747951750360,\n 1002242216651368,\n 3814986502092304,\n]\n","export const fibonacciNumbers = [\n 0,\n 1,\n 1,\n 2,\n 3,\n 5,\n 8,\n 13,\n 21,\n 34,\n 55,\n 89,\n 144,\n 233,\n 377,\n 610,\n 987,\n 1597,\n 2584,\n 4181,\n 6765,\n 10946,\n 17711,\n 28657,\n 46368,\n 75025,\n 121393,\n 196418,\n 317811,\n 514229,\n 832040,\n 1346269,\n 2178309,\n 3524578,\n 5702887,\n 9227465,\n 14930352,\n 24157817,\n 39088169,\n 63245986,\n 102334155,\n 165580141,\n 267914296,\n 433494437,\n 701408733,\n 1134903170,\n 1836311903,\n 2971215073,\n 4807526976,\n 7778742049,\n 12586269025,\n 20365011074,\n 32951280099,\n 53316291173,\n 86267571272,\n 139583862445,\n 225851433717,\n 365435296162,\n 591286729879,\n 956722026041,\n 1548008755920,\n 2504730781961,\n 4052739537881,\n 6557470319842,\n 10610209857723,\n 17167680177565,\n 27777890035288,\n 44945570212853,\n 72723460248141,\n 117669030460994,\n 190392490709135,\n 308061521170129,\n 498454011879264,\n 806515533049393,\n 1304969544928657,\n 2111485077978050,\n 3416454622906707,\n 5527939700884757,\n 8944394323791464,\n]\n","export const lucasNumbers = [\n 2,\n 1,\n 3,\n 4,\n 7,\n 11,\n 18,\n 29,\n 47,\n 76,\n 123,\n 199,\n 322,\n 521,\n 843,\n 1364,\n 2207,\n 3571,\n 5778,\n 9349,\n 15127,\n 24476,\n 39603,\n 64079,\n 103682,\n 167761,\n 271443,\n 439204,\n 710647,\n 1149851,\n 1860498,\n 3010349,\n 4870847,\n 7881196,\n 12752043,\n 20633239,\n 33385282,\n 54018521,\n 87403803,\n 141422324,\n 228826127,\n 370248451,\n 599074578,\n 969323029,\n 1568397607,\n 2537720636,\n 4106118243,\n 6643838879,\n 10749957122,\n 17393796001,\n 28143753123,\n 45537549124,\n 73681302247,\n 119218851371,\n 192900153618,\n 312119004989,\n 505019158607,\n 817138163596,\n 1322157322203,\n 2139295485799,\n 3461452808002,\n 5600748293801,\n 9062201101803,\n 14662949395604,\n 23725150497407,\n 38388099893011,\n 62113250390418,\n 100501350283429,\n 162614600673847,\n 263115950957276,\n 425730551631123,\n 688846502588399,\n 1114577054219522,\n 1803423556807921,\n 2918000611027443,\n 4721424167835364,\n 7639424778862807,\n]\n","export const mersenneNumbers = [3, 7, 31, 127, 2047, 8191, 131071, 524287, 2147483647]\n","export const pellNumbers = [\n 1,\n 2,\n 5,\n 12,\n 29,\n 70,\n 169,\n 408,\n 985,\n 2378,\n 5741,\n 13860,\n 33461,\n 80782,\n 195025,\n 470832,\n 1136689,\n 2744210,\n 6625109,\n 15994428,\n 38613965,\n 93222358,\n 225058681,\n 543339720,\n 1311738121,\n 3166815962,\n 7645370045,\n 18457556052,\n 44560482149,\n 107578520350,\n 259717522849,\n 627013566048,\n 1513744654945,\n 3654502875938,\n 8822750406821,\n 21300003689580,\n 51422757785981,\n 124145519261542,\n 299713796309065,\n 723573111879672,\n 1746860020068409,\n 4217293152016490,\n]\n","export const perfectNumbers = [6, 28, 496, 8128, 33550336, 8589869056, 137438691328]\n","export const sylvesterNumbers = [\n 2,\n 6,\n 42,\n 1806,\n 3263442,\n 10650056950806,\n]\n","export const bellNumbers = [\n 1,\n 2,\n 5,\n 15,\n 52,\n 203,\n 877,\n 4140,\n 21147,\n 115975,\n 678570,\n 4213597,\n 27644437,\n 190899322,\n 1382958545,\n 10480142147,\n 82864869804,\n 682076806159,\n 5832742205057,\n 51724158235372,\n 474869816156751,\n 4506715738447323,\n]\n","import type { SourceCodeInfo } from '../../../tokenizer/token'\nimport { isMatrix, isVector } from '../../../typeGuards/annotatedArrays'\nimport { isNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport { DvalaError } from '../../../errors'\nimport type { BuiltinNormalExpressions } from '../../interface'\nimport type { DvalaModule } from '../interface'\n\ntype NumberVectorOrMatrix = number | number[] | number[][]\n\nfunction getNumberVectorOrMatrixOperation(\n param: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n):\n | ['number', number]\n | ['vector', number[]]\n | ['matrix', number[][]] {\n if (isVector(param)) {\n return ['vector', param]\n }\n if (isMatrix(param)) {\n return ['matrix', param]\n }\n if (!isNumber(param)) {\n throw new DvalaError(`Invalid parameter type: ${typeof param}`, sourceCodeInfo)\n }\n return ['number', param]\n}\n\nfunction unaryMathOp(\n fn: (val: number) => number,\n): (params: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) => NumberVectorOrMatrix {\n return ([param], sourceCodeInfo) => {\n const [operation, operand] = getNumberVectorOrMatrixOperation(param, sourceCodeInfo)\n if (operation === 'number') {\n return fn(operand)\n }\n else if (operation === 'vector') {\n return operand.map(val => fn(val))\n }\n else {\n return operand.map(row => row.map(val => fn(val)))\n }\n }\n}\n\nconst mathUtilsFunctions: BuiltinNormalExpressions = {\n 'sin': {\n evaluate: unaryMathOp(val => Math.sin(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.asin', 'math.sinh', 'math.cos', 'math.tan', 'math.to-rad'],\n examples: [\n `let { sin } = import(math);\nsin(0)`,\n `let { sin } = import(math);\nsin(1)`,\n `let { sin } = import(math);\nsin(PI)`,\n `let { sin } = import(math);\nsin(-0.5)`,\n `let { sin } = import(math);\nsin([1, 2, 3])`,\n `let { sin } = import(math);\nsin([[1, 2], [3, 4]])`,\n ],\n },\n },\n 'asin': {\n evaluate: unaryMathOp(val => Math.asin(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.sin', 'math.asinh', 'math.acos', 'math.atan'],\n examples: [\n `let { asin } = import(math);\nasin(0)`,\n `let { asin } = import(math);\nasin(1)`,\n `let { asin } = import(math);\nasin(-0.5)`,\n `let { asin } = import(math);\nasin([1, 2, 3])`,\n `let { asin } = import(math);\nasin([[1, 2], [3, 4]])`,\n ],\n },\n },\n 'sinh': {\n evaluate: unaryMathOp(val => Math.sinh(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.asinh', 'math.sin', 'math.cosh', 'math.tanh'],\n examples: [\n `let { sinh } = import(math);\nsinh(0)`,\n `let { sinh } = import(math);\nsinh(1)`,\n `let { sinh } = import(math);\nsinh(-0.5)`,\n `let { sinh } = import(math);\nsinh([0.1, 0.2, 0.3])`,\n `let { sinh } = import(math);\nsinh([[0.1, 0.2], [0.3, 0.4]])`,\n ],\n },\n },\n 'asinh': {\n evaluate: unaryMathOp(val => Math.asinh(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.sinh', 'math.asin', 'math.acosh', 'math.atanh'],\n examples: [\n `let { asinh } = import(math);\nasinh(10)`,\n `let { asinh } = import(math);\nasinh(90)`,\n `let { asinh } = import(math);\nasinh(50)`,\n `let { asinh } = import(math);\nasinh([10, 20, 30])`,\n `let { asinh } = import(math);\nasinh([[10, 20], [30, 40]])`,\n ],\n },\n },\n 'cos': {\n evaluate: unaryMathOp(val => Math.cos(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.acos', 'math.cosh', 'math.sin', 'math.tan', 'math.to-rad'],\n examples: [\n `let { cos } = import(math);\ncos(0)`,\n `let { cos } = import(math);\ncos(1)`,\n `let { cos } = import(math);\ncos(PI)`,\n `let { cos } = import(math);\ncos(-0.5)`,\n `let { cos } = import(math);\ncos([1, 2, 3])`,\n `let { cos } = import(math);\ncos([[1, 2], [3, 4]])`,\n ],\n },\n },\n 'acos': {\n evaluate: unaryMathOp(val => Math.acos(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.cos', 'math.acosh', 'math.asin', 'math.atan'],\n examples: [\n `let { acos } = import(math);\nacos(0)`,\n `let { acos } = import(math);\nacos(1)`,\n `let { acos } = import(math);\nacos(-0.5)`,\n `let { acos } = import(math);\nacos([0.1, 0.2, 0.3])`,\n `let { acos } = import(math);\nacos([[0.1, 0.2], [0.3, 0.4]])`,\n ],\n },\n },\n 'cosh': {\n evaluate: unaryMathOp(val => Math.cosh(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.acosh', 'math.cos', 'math.sinh', 'math.tanh'],\n examples: [\n `let { cosh } = import(math);\ncosh(0)`,\n `let { cosh } = import(math);\ncosh(1)`,\n `let { cosh } = import(math);\ncosh(-0.5)`,\n `let { cosh } = import(math);\ncosh([0.1, 0.2, 0.3])`,\n `let { cosh } = import(math);\ncosh([[0.1, 0.2], [0.3, 0.4]])`,\n ],\n },\n },\n 'acosh': {\n evaluate: unaryMathOp(val => Math.acosh(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.cosh', 'math.acos', 'math.asinh', 'math.atanh'],\n examples: [\n `let { acosh } = import(math);\nacosh(1)`,\n `let { acosh } = import(math);\nacosh(2)`,\n `let { acosh } = import(math);\nacosh(100)`,\n `let { acosh } = import(math);\nacosh(50)`,\n `let { acosh } = import(math);\nacosh([1, 2, 3])`,\n `let { acosh } = import(math);\nacosh([[1, 2], [3, 4]])`,\n ],\n },\n },\n 'tan': {\n evaluate: unaryMathOp(val => Math.tan(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.atan', 'math.tanh', 'math.sin', 'math.cos', 'math.to-rad'],\n examples: [\n `let { tan } = import(math);\ntan(0)`,\n `let { tan } = import(math);\ntan(1)`,\n `let { tan } = import(math);\ntan(PI)`,\n `let { tan } = import(math);\ntan(-0.5)`,\n `let { tan } = import(math);\ntan([1, 2, 3])`,\n `let { tan } = import(math);\ntan([[1, 2], [3, 4]])`,\n ],\n },\n },\n 'atan': {\n evaluate: unaryMathOp(val => Math.atan(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.tan', 'math.atanh', 'math.asin', 'math.acos'],\n examples: [\n `let { atan } = import(math);\natan(0)`,\n `let { atan } = import(math);\natan(1)`,\n `let { atan } = import(math);\natan(-0.5)`,\n `let { atan } = import(math);\natan([0.1, 0.2, 0.3])`,\n `let { atan } = import(math);\natan([[0.1, 0.2], [0.3, 0.4]])`,\n ],\n },\n },\n 'tanh': {\n evaluate: unaryMathOp(val => Math.tanh(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.atanh', 'math.tan', 'math.sinh', 'math.cosh'],\n examples: [\n `let { tanh } = import(math);\ntanh(0)`,\n `let { tanh } = import(math);\ntanh(1)`,\n `let { tanh } = import(math);\ntanh(-0.5)`,\n `let { tanh } = import(math);\ntanh(50)`,\n ],\n },\n },\n 'atanh': {\n evaluate: unaryMathOp(val => Math.atanh(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.tanh', 'math.atan', 'math.asinh', 'math.acosh'],\n examples: [\n `let { atanh } = import(math);\natanh(0)`,\n `let { atanh } = import(math);\natanh(0.9)`,\n `let { atanh } = import(math);\natanh(-0.5)`,\n `let { atanh } = import(math);\natanh([0.1, 0.2, 0.3])`,\n `let { atanh } = import(math);\natanh([[0.1, 0.2], [0.3, 0.4]])`,\n ],\n },\n },\n 'ln': {\n evaluate: unaryMathOp(val => Math.log(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.log2', 'math.log10', '^'],\n examples: [\n `let { ln } = import(math);\nln(0.01)`,\n `let { ln } = import(math);\nln(2.5)`,\n `let { ln } = import(math);\nln(E)`,\n `let { ln } = import(math);\nln([1, 2, 3])`,\n `let { ln } = import(math);\nln([[1, 2], [3, 4]])`,\n ],\n },\n },\n 'log2': {\n evaluate: unaryMathOp(val => Math.log2(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.ln', 'math.log10'],\n examples: [\n `let { log2 } = import(math);\nlog2(0.01)`,\n `let { log2 } = import(math);\nlog2(2 ^ 12)`,\n `let { log2 } = import(math);\nlog2(2.5)`,\n `let { log2 } = import(math);\nlog2([1, 2, 3])`,\n `let { log2 } = import(math);\nlog2([[1, 2], [3, 4]])`,\n ],\n },\n },\n 'log10': {\n evaluate: unaryMathOp(val => Math.log10(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.ln', 'math.log2'],\n examples: [\n `let { log10 } = import(math);\nlog10(0.01)`,\n `let { log10 } = import(math);\nlog10(10 ^ 12)`,\n `let { log10 } = import(math);\nlog10(2.5)`,\n `let { log10 } = import(math);\nlog10([1, 2, 3])`,\n `let { log10 } = import(math);\nlog10([[1, 2], [3, 4]])`,\n ],\n },\n },\n 'to-rad': {\n evaluate: unaryMathOp(val => (val * Math.PI) / 180),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.to-deg', 'math.sin', 'math.cos', 'math.tan'],\n examples: [\n `let { to-rad } = import(math);\nto-rad(0)`,\n `let { to-rad } = import(math);\nto-rad(90)`,\n `let { to-rad } = import(math);\nto-rad(180)`,\n `let { to-rad } = import(math);\nto-rad(360)`,\n `let { to-rad } = import(math);\nto-rad([0, 90, 180])`,\n `let { to-rad } = import(math);\nto-rad([[0, 90], [180, 360]])`,\n ],\n },\n },\n 'to-deg': {\n evaluate: unaryMathOp(val => (val * 180) / Math.PI),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n 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.',\n seeAlso: ['math.to-rad'],\n examples: [\n `let { to-deg } = import(math);\nto-deg(0)`,\n `let { to-deg } = import(math);\nto-deg(PI)`,\n `let { to-deg } = import(math);\nto-deg(PI / 2)`,\n `let { to-deg } = import(math);\nto-deg(3 * PI / 2)`,\n `let { to-deg } = import(math);\nto-deg([0, PI, PI / 2])`,\n `let { to-deg } = import(math);\nto-deg([[0, PI], [PI / 2, 3 * PI / 2]])`,\n ],\n },\n },\n}\n\nexport const mathUtilsModule: DvalaModule = {\n name: 'math',\n functions: mathUtilsFunctions,\n}\n","import type { Arr } from '../../../interface'\nimport type {\n ComplementFunction,\n EveryPredFunction,\n FNullFunction,\n FunctionLike,\n JuxtFunction,\n SomePredFunction,\n} from '../../../parser/types'\nimport { getArityFromFunction, getCommonArityFromFunctions, toFixedArity } from '../../../utils/arity'\nimport { FUNCTION_SYMBOL } from '../../../utils/symbols'\nimport type { BuiltinNormalExpressions } from '../../interface'\nimport { asFunctionLike, assertFunctionLike } from '../../../typeGuards/dvala'\nimport { DvalaError } from '../../../errors'\nimport type { DvalaModule } from '../interface'\n\nconst functionalUtilsNormalExpression: BuiltinNormalExpressions = {\n 'juxt': {\n evaluate: (params, sourceCodeInfo): JuxtFunction => {\n params.forEach(param => assertFunctionLike(param, sourceCodeInfo))\n const arity = getCommonArityFromFunctions(params as FunctionLike[])\n if (arity === null) {\n throw new DvalaError('All functions must accept the same number of arguments', sourceCodeInfo)\n }\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Juxt',\n params,\n arity,\n }\n },\n arity: { min: 1 },\n docs: {\n category: 'functional',\n returns: { type: 'function' },\n args: {\n a: { type: 'function' },\n b: { type: 'function' },\n fun: { type: 'function' },\n fns: { type: 'function', rest: true },\n },\n variants: [\n { argumentNames: ['fun'] },\n { argumentNames: ['fun', 'fns'] },\n ],\n 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).`,\n seeAlso: ['comp'],\n examples: [\n `let { juxt } = import(functional);\njuxt(+, *, min, max)(\n 3,\n 4,\n 6,\n)`,\n `let { juxt } = import(functional);\njuxt(\"a\", \"b\")(\n {\n a: 1,\n b: 2,\n c: 3,\n d: 4\n }\n)`,\n `let { juxt } = import(functional);\njuxt(+, *, min, max) apply range(1, 11)`,\n ],\n },\n },\n\n 'complement': {\n evaluate: ([fn], sourceCodeInfo): ComplementFunction => {\n const fun = asFunctionLike(fn, sourceCodeInfo)\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Complement',\n function: fun,\n arity: getArityFromFunction(fun),\n }\n },\n arity: toFixedArity(1),\n docs: {\n category: 'functional',\n returns: { type: 'function' },\n args: { fun: { type: 'function' } },\n variants: [{ argumentNames: ['fun'] }],\n 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.',\n seeAlso: ['comp', 'functional.every-pred', 'functional.some-pred'],\n examples: [\n 'let { complement } = import(functional);\\ncomplement(>)(1, 3)',\n 'let { complement } = import(functional);\\ncomplement(<)(1, 3)',\n 'let { complement } = import(functional);\\ncomplement(+)(1, 3)',\n 'let { complement } = import(functional);\\ncomplement(+)(0, 0)',\n ],\n },\n },\n\n 'every-pred': {\n evaluate: (params, sourceCodeInfo): EveryPredFunction => {\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'EveryPred',\n params,\n arity: { min: 1, max: 1 },\n }\n },\n arity: { min: 1 },\n docs: {\n category: 'functional',\n returns: { type: 'function' },\n args: {\n fun: { type: 'function' },\n fns: { type: 'function', rest: true },\n },\n variants: [\n { argumentNames: ['fun'] },\n { argumentNames: ['fun', 'fns'] },\n ],\n 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\\`.`,\n seeAlso: ['functional.some-pred', 'functional.complement', 'collection.every?'],\n examples: [\n `let { every-pred } = import(functional);\nevery-pred(string?, -> count($) > 3)(\n \"Albert\",\n \"Mojir\"\n)`,\n `let { every-pred } = import(functional);\n(string? every-pred -> count($) > 3)(\n \"Albert\",\n \"M\"\n)`,\n ],\n hideOperatorForm: true,\n },\n },\n\n 'some-pred': {\n evaluate: (params, sourceCodeInfo): SomePredFunction => {\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'SomePred',\n params,\n arity: { min: 1, max: 1 },\n }\n },\n arity: { min: 1 },\n docs: {\n category: 'functional',\n returns: { type: 'function' },\n args: {\n fun: { type: 'function' },\n fns: { type: 'function', rest: true },\n },\n variants: [\n { argumentNames: ['fun'] },\n { argumentNames: ['fun', 'fns'] },\n ],\n 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`.',\n seeAlso: ['functional.every-pred', 'functional.complement', 'collection.any?'],\n examples: [\n 'let { some-pred } = import(functional);\\nsome-pred(string?, -> count($) > 3)(\"Albert\", \"Mojir\")',\n 'let { some-pred } = import(functional);\\nsome-pred(string?, -> count($) > 3)(\"a\", \"M\")',\n 'let { some-pred } = import(functional);\\nsome-pred(string?, -> count($) > 3)(\"a\", [1, 2, 3])',\n 'let { some-pred } = import(functional);\\nsome-pred(string?, -> count($) > 3)([1, 2, 3], [2])',\n ],\n hideOperatorForm: true,\n },\n },\n\n 'fnull': {\n evaluate: ([fn, ...params]: Arr, sourceCodeInfo): FNullFunction => {\n const fun = asFunctionLike(fn, sourceCodeInfo)\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Fnull',\n function: fun,\n params,\n arity: getArityFromFunction(fun),\n }\n },\n arity: { min: 2 },\n docs: {\n category: 'functional',\n returns: { type: 'function' },\n args: {\n a: { type: 'function' },\n b: { type: 'any' },\n fun: { type: 'function' },\n arg: { type: 'any' },\n args: { type: 'any', rest: true },\n },\n variants: [\n { argumentNames: ['fun', 'arg'] },\n { argumentNames: ['fun', 'arg', 'args'] },\n ],\n description: 'Takes a function $fun, and returns a function that calls $fun, replacing a null argument to the corresponding argument.',\n seeAlso: ['identity', 'constantly'],\n examples: [\n 'let { fnull } = import(functional);\\nfnull(inc, 0)(1)',\n 'let { fnull } = import(functional);\\nfnull(inc, 0)(null)',\n 'let { fnull } = import(functional);\\n(inc fnull 0)(null)',\n 'let { fnull } = import(functional);\\nfnull(+, 1, 2)(null, 0)',\n 'let { fnull } = import(functional);\\nfnull(+, 1, 2)(0, null)',\n 'let { fnull } = import(functional);\\nfnull(+, 1, 2)(null, null)',\n 'let { fnull } = import(functional);\\nfnull(+, 1, 2)(null, null, 3, 4)',\n ],\n },\n },\n}\n\nexport const functionalUtilsModule: DvalaModule = {\n name: 'functional',\n functions: functionalUtilsNormalExpression,\n}\n","import { DvalaError } from '../../../errors'\nimport { asNonUndefined } from '../../../typeGuards'\nimport { assertArray } from '../../../typeGuards/array'\nimport { assertNumber } from '../../../typeGuards/number'\nimport { asStringOrNumber, assertString } from '../../../typeGuards/string'\nimport { toNonNegativeInteger } from '../../../utils'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../interface'\nimport type { DvalaModule } from '../interface'\nimport type { SourceCodeInfo } from '../../../tokenizer/token'\n\nconst stringUtilsFunctions: BuiltinNormalExpressions = {\n 'string-repeat': {\n evaluate: ([str, count], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return str.repeat(count)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'string',\n returns: { type: 'number' },\n args: {\n a: { type: 'string' },\n b: { type: 'integer' },\n s: { type: 'string' },\n n: { type: 'integer' },\n },\n variants: [{ argumentNames: ['s', 'n'] }],\n description: 'Repeates $s $n times.',\n seeAlso: ['str', 'repeat'],\n examples: [\n `let { string-repeat } = import(string);\n\"*\" string-repeat 10`,\n `let { string-repeat } = import(string);\nstring-repeat(\"*\", 10)`,\n `let { string-repeat } = import(string);\nstring-repeat(\"***\", 0)`,\n ],\n },\n },\n\n 'from-char-code': {\n evaluate: ([num], sourceCodeInfo): string => {\n assertNumber(num, sourceCodeInfo, { finite: true })\n const int = toNonNegativeInteger(num)\n try {\n return String.fromCodePoint(int)\n }\n catch (error) {\n throw new DvalaError(error as Error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { code: { type: 'number' } },\n variants: [{ argumentNames: ['code'] }],\n description: 'Return character for code point $code.',\n seeAlso: ['string.to-char-code'],\n examples: [\n `let { from-char-code } = import(string);\nfrom-char-code(65)`,\n `let { from-char-code } = import(string);\nfrom-char-code(0)`,\n ],\n },\n },\n\n 'to-char-code': {\n evaluate: ([str], sourceCodeInfo): number => {\n assertString(str, sourceCodeInfo, { nonEmpty: true })\n return asNonUndefined(str.codePointAt(0), sourceCodeInfo)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'number' },\n args: { c: { type: 'string' } },\n variants: [{ argumentNames: ['c'] }],\n description: 'Return code point for first character in $c.',\n seeAlso: ['string.from-char-code'],\n examples: [\n `let { to-char-code } = import(string);\nto-char-code(\"A\")`,\n `let { to-char-code } = import(string);\nto-char-code(\"Albert\")`,\n ],\n },\n },\n\n 'trim-left': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.replace(/^\\s+/, '')\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns a new string with leading whitespaces removed.',\n seeAlso: ['trim', 'string.trim-right'],\n examples: [\n `let { trim-left } = import(string);\ntrim-left(\" Albert \")`,\n `let { trim-left } = import(string);\ntrim-left(\" \")`,\n `let { trim-left } = import(string);\ntrim-left(\"\")`,\n ],\n },\n },\n\n 'trim-right': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.replace(/\\s+$/, '')\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns a new string with trailing whitespaces removed.',\n seeAlso: ['trim', 'string.trim-left'],\n examples: [\n `let { trim-right } = import(string);\ntrim-right(\" Albert \")`,\n `let { trim-right } = import(string);\ntrim-right(\" \")`,\n `let { trim-right } = import(string);\ntrim-right(\"\")`,\n ],\n },\n },\n\n 'split-lines': {\n evaluate: ([str], sourceCodeInfo): string[] => {\n assertString(str, sourceCodeInfo)\n return str.split((/\\r\\n|\\n|\\r/)).filter(line => line !== '')\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Divides $s into an array of substrings, each representing a line.',\n seeAlso: ['split'],\n examples: [\n `let { split-lines } = import(string);\nsplit-lines(\"Albert\\nMojir\\n\")`,\n `let { split-lines } = import(string);\nsplit-lines(\"Albert\\n\\nMojir\")`,\n `let { split-lines } = import(string);\nsplit-lines(\"Albert\\nMojir\\n\\n\")`,\n `let { split-lines } = import(string);\nsplit-lines(\"\")`,\n ],\n },\n },\n\n 'pad-left': {\n evaluate: ([str, length, padString], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n assertNumber(length, sourceCodeInfo, { integer: true })\n\n if (padString !== undefined)\n assertString(padString, sourceCodeInfo)\n\n return str.padStart(length, padString)\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: {\n a: { type: 'string' },\n b: { type: 'integer' },\n s: { type: 'string' },\n length: { type: 'integer' },\n padString: { type: 'string' },\n },\n variants: [\n { argumentNames: ['s', 'length'] },\n { argumentNames: ['s', 'length', 'padString'] },\n ],\n description: 'Pads from the start of $s with `padString` (multiple times, if needed) until the resulting string reaches the given $length.',\n seeAlso: ['string.pad-right'],\n examples: [\n `let { pad-left } = import(string);\n\"Albert\" pad-left 20`,\n `let { pad-left } = import(string);\npad-left(\"Albert\", 20)`,\n `let { pad-left } = import(string);\npad-left(\"Albert\", 20, \"-*-\")`,\n `let { pad-left } = import(string);\npad-left(\"Albert\", 5)`,\n `let { pad-left } = import(string);\npad-left(\"Albert\", -1)`,\n ],\n },\n },\n\n 'pad-right': {\n evaluate: ([str, length, padString], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n assertNumber(length, sourceCodeInfo, { integer: true })\n\n if (padString !== undefined)\n assertString(padString, sourceCodeInfo)\n\n return str.padEnd(length, padString)\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: {\n a: { type: 'string' },\n b: { type: 'integer' },\n s: { type: 'string' },\n length: { type: 'integer' },\n padString: { type: 'string' },\n },\n variants: [\n { argumentNames: ['s', 'length'] },\n { argumentNames: ['s', 'length', 'padString'] },\n ],\n description: 'Pads from the start of $s with `padString` (multiple times, if needed) until the resulting string reaches the given `length`.',\n seeAlso: ['string.pad-left'],\n examples: [\n `let { pad-right } = import(string);\n\"Albert\" pad-right 20`,\n `let { pad-right } = import(string);\npad-right(\"Albert\", 20)`,\n `let { pad-right } = import(string);\npad-right(\"Albert\", 20, \"-*-\")`,\n `let { pad-right } = import(string);\npad-right(\"Albert\", 5)`,\n `let { pad-right } = import(string);\npad-right(\"Albert\", -1)`,\n ],\n },\n },\n\n 'template': {\n evaluate: ([templateString, ...placeholders], sourceCodeInfo): string => {\n assertString(templateString, sourceCodeInfo)\n assertArray(placeholders, sourceCodeInfo)\n const templateStrings = templateString.split('||||')\n if (templateStrings.length <= 1) {\n return applyPlaceholders(templateStrings[0] as string, placeholders, sourceCodeInfo)\n }\n else {\n // Pluralisation\n const count = placeholders[0]\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n const stringPlaceholders = [`${count}`, ...placeholders.slice(1)] as string[]\n if (templateStrings.length === 2) {\n // Exactly two valiants.\n // First variant (singular) for count = 1, Second variant (plural) for count = 0 or count > 1\n\n const placehoder = templateStrings[count === 1 ? 0 : 1] as string\n return applyPlaceholders(placehoder, stringPlaceholders, sourceCodeInfo)\n }\n else {\n // More than two variant:\n // Use count as index\n // If count >= number of variants, use last variant\n\n const placehoder = templateStrings[Math.min(count, templateStrings.length - 1)] as string\n return applyPlaceholders(placehoder, stringPlaceholders, sourceCodeInfo)\n }\n }\n },\n arity: { min: 1, max: 10 },\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: {\n s: { type: 'string' },\n params: { type: 'any', rest: true },\n },\n variants: [{ argumentNames: ['s', 'params'] }],\n description: 'Applies placeholders to a string. Support for basic pluralization - see examples. If pluralization is used, first placeholder must be a number.',\n seeAlso: ['str'],\n examples: [\n `let { template } = import(string);\ntemplate(\"Hi, $1 and $2\", \"Carl\", \"Larry\")`,\n `let { template } = import(string);\ntemplate(\"Hi $1, $2, $3, $4, $5, $6, $7, $8 and $9\", \"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\")`,\n `let { template } = import(string);\ntemplate(\"$1 book||||$1 books\", 0)`,\n `let { template } = import(string);\ntemplate(\"$1 book||||$1 books\", 1)`,\n `let { template } = import(string);\ntemplate(\"$1 book||||$1 books\", 2)`,\n `let { template } = import(string);\ntemplate(\"No book||||$1 book||||$1 books\", 0)`,\n `let { template } = import(string);\ntemplate(\"No book||||$1 book||||$1 books\", 1)`,\n `let { template } = import(string);\ntemplate(\"No book||||$1 book||||$1 books\", 10)`,\n `let { template } = import(string);\ntemplate(\"No book||||One book||||Two books||||Three books||||$1 books\", 0)`,\n `let { template } = import(string);\ntemplate(\"No book||||One book||||Two books||||Three books||||$1 books\", 1)`,\n `let { template } = import(string);\ntemplate(\"No book||||One book||||Two books||||Three books||||$1 books\", 2)`,\n `let { template } = import(string);\ntemplate(\"No book||||One book||||Two books||||Three books||||$1 books\", 3)`,\n `let { template } = import(string);\ntemplate(\"No book||||One book||||Two books||||Three books||||$1 books\", 4)`,\n ],\n hideOperatorForm: true,\n },\n },\n\n 'encode-base64': {\n evaluate: ([value], sourceCodeInfo): string => {\n assertString(value, sourceCodeInfo)\n return btoa(\n encodeURIComponent(value).replace(/%([0-9A-F]{2})/g, (_match, p1) => {\n // eslint-disable-next-line ts/no-unsafe-argument\n return String.fromCharCode(Number.parseInt(p1, 16))\n }),\n )\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns a Base64 encoded string from $s.',\n seeAlso: ['string.decode-base64'],\n examples: [\n `let { encode-base64 } = import(string);\nencode-base64(\"Albert\")`,\n ],\n },\n },\n\n 'decode-base64': {\n evaluate: ([value], sourceCodeInfo): string => {\n assertString(value, sourceCodeInfo)\n try {\n return decodeURIComponent(\n Array.prototype.map\n .call(atob(value), (c) => {\n // eslint-disable-next-line ts/no-unsafe-call, ts/no-unsafe-member-access\n return `%${(`00${c.charCodeAt(0).toString(16)}`).slice(-2)}`\n })\n .join(''),\n )\n }\n catch (error) {\n throw new DvalaError(error as Error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { base64string: { type: 'string' } },\n variants: [{ argumentNames: ['base64string'] }],\n description: 'Returns a Base64 decoded string from $base64string.',\n seeAlso: ['string.encode-base64'],\n examples: [\n `let { decode-base64 } = import(string);\ndecode-base64(\"QWxiZXJ0IPCfkLs=\")`,\n ],\n },\n },\n\n 'encode-uri-component': {\n evaluate: ([value], sourceCodeInfo): string => {\n assertString(value, sourceCodeInfo)\n return encodeURIComponent(value)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns an escaped `URI` string.',\n seeAlso: ['string.decode-uri-component'],\n examples: [\n `let { encode-uri-component } = import(string);\nencode-uri-component(\"Hi everyone!?\")`,\n ],\n },\n },\n\n 'decode-uri-component': {\n evaluate: ([value], sourceCodeInfo): string => {\n assertString(value, sourceCodeInfo)\n try {\n return decodeURIComponent(value)\n }\n catch (error) {\n throw new DvalaError(error as Error, sourceCodeInfo)\n }\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns an un-escaped `URI` string.',\n seeAlso: ['string.encode-uri-component'],\n examples: [\n `let { decode-uri-component } = import(string);\ndecode-uri-component(\"Hi%20everyone!%3F%20%F0%9F%91%8D\")`,\n ],\n },\n },\n\n 'capitalize': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns $s with the first character converted to uppercase and the rest to lowercase.',\n seeAlso: ['lower-case', 'upper-case'],\n examples: [\n `let { capitalize } = import(string);\ncapitalize(\"albert\")`,\n `let { capitalize } = import(string);\ncapitalize(\"ALBERT\")`,\n `let { capitalize } = import(string);\ncapitalize(\"aLBERT\")`,\n `let { capitalize } = import(string);\ncapitalize(\"\")`,\n ],\n },\n },\n}\n\nconst doubleDollarRegexp = /\\$\\$/g\nfunction applyPlaceholders(templateString: string, placeholders: unknown[], sourceCodeInfo?: SourceCodeInfo): string {\n for (let i = 0; i < 9; i += 1) {\n // Matches $1, $2, ..., $9\n // Does not match $$1\n // But does match $$$1, (since the two first '$' will later be raplaced with a single '$'\n const re = new RegExp(`(\\\\$\\\\$|[^$]|^)\\\\$${i + 1}`, 'g')\n if (re.test(templateString)) {\n const placeHolder = asStringOrNumber(placeholders[i], sourceCodeInfo)\n templateString = templateString.replace(re, `$1${placeHolder}`)\n }\n }\n templateString = templateString.replace(doubleDollarRegexp, '$')\n return templateString\n}\n\nexport const stringUtilsModule: DvalaModule = {\n name: 'string',\n functions: stringUtilsFunctions,\n}\n","import type { ContextStack } from '../../../evaluator/ContextStack'\nimport type { ExecuteFunction } from '../../../evaluator/interface'\nimport type { Any, Arr, Coll, Obj } from '../../../interface'\nimport type { SourceCodeInfo } from '../../../tokenizer/token'\nimport { cloneColl, collHasKey, toAny, toNonNegativeInteger } from '../../../utils'\nimport { asColl, assertAny, assertColl, assertFunctionLike, assertObj, isColl, isObj } from '../../../typeGuards/dvala'\nimport type { BuiltinNormalExpressions } from '../../interface'\nimport { assertArray } from '../../../typeGuards/array'\nimport { assertNumber, isNumber } from '../../../typeGuards/number'\nimport { asString, asStringOrNumber, assertString, assertStringOrNumber } from '../../../typeGuards/string'\nimport type { FunctionLike } from '../../../parser/types'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { MaybePromise } from '../../../utils/maybePromise'\nimport { chain, everySequential, filterSequential, mapSequential, reduceSequential, someSequential } from '../../../utils/maybePromise'\nimport type { DvalaModule } from '../interface'\n\n// --- Private helper: get value from collection by key ---\nfunction get(coll: Coll, key: string | number): Any | undefined {\n if (isObj(coll)) {\n if (typeof key === 'string' && collHasKey(coll, key))\n return toAny(coll[key])\n }\n else {\n if (isNumber(key, { nonNegative: true, integer: true }) && key >= 0 && key < coll.length)\n return toAny(coll[key])\n }\n return undefined\n}\n\n// --- Private helper: assoc value into collection ---\nfunction assoc(coll: Coll, key: string | number, value: Any, sourceCodeInfo?: SourceCodeInfo) {\n assertColl(coll, sourceCodeInfo)\n if (Array.isArray(coll) || typeof coll === 'string') {\n assertNumber(key, sourceCodeInfo, { integer: true })\n assertNumber(key, sourceCodeInfo, { gte: 0 })\n assertNumber(key, sourceCodeInfo, { lte: coll.length })\n if (typeof coll === 'string') {\n assertString(value, sourceCodeInfo, { char: true })\n return `${coll.slice(0, key)}${value}${coll.slice(key + 1)}`\n }\n const copy = [...coll]\n copy[key] = value\n return copy\n }\n assertString(key, sourceCodeInfo)\n const copy = { ...coll }\n copy[key] = value\n return copy\n}\n\n// --- Private helper: update value in collection ---\nfunction update(\n coll: Coll,\n key: string | number,\n fn: FunctionLike,\n params: Arr,\n contextStack: ContextStack,\n executeFunction: ExecuteFunction,\n sourceCodeInfo?: SourceCodeInfo,\n): MaybePromise<Coll> {\n if (isObj(coll)) {\n assertString(key, sourceCodeInfo)\n const result = { ...coll }\n return chain(executeFunction(fn, [result[key], ...params], contextStack, sourceCodeInfo), (val) => {\n result[key] = val\n return result\n })\n }\n else {\n assertNumber(key, sourceCodeInfo)\n const intKey = toNonNegativeInteger(key)\n assertNumber(intKey, sourceCodeInfo, { lte: coll.length })\n if (Array.isArray(coll)) {\n return chain(\n mapSequential(Array.from({ length: coll.length + (intKey === coll.length ? 1 : 0) }), (_, index) => {\n if (intKey === index)\n return executeFunction(fn, [coll[index], ...params], contextStack, sourceCodeInfo)\n return coll[index] as Any\n }),\n result => result,\n )\n }\n else {\n const chars = coll.split('')\n return chain(\n mapSequential(Array.from({ length: chars.length + (intKey === chars.length ? 1 : 0) }), (_, index) => {\n if (intKey === index) {\n return chain(\n executeFunction(fn, [chars[index], ...params], contextStack, sourceCodeInfo),\n val => asString(val, sourceCodeInfo, { char: true }),\n )\n }\n return chars[index] as string\n }),\n result => result.join(''),\n )\n }\n }\n}\n\ninterface CollMeta {\n coll: Coll\n parent: Obj | Arr\n}\n\n// --- Private helper: clone and get meta for nested operations ---\nfunction cloneAndGetMeta(\n originalColl: Coll,\n keys: Arr,\n sourceCodeInfo?: SourceCodeInfo,\n): { coll: Coll, innerCollMeta: CollMeta } {\n const coll = cloneColl(originalColl)\n\n const butLastKeys = keys.slice(0, keys.length - 1)\n\n const innerCollMeta = butLastKeys.reduce(\n (result: CollMeta, key) => {\n const resultColl = result.coll\n\n let newResultColl: Coll\n if (Array.isArray(resultColl)) {\n assertNumber(key, sourceCodeInfo)\n newResultColl = asColl(resultColl[key], sourceCodeInfo)\n }\n else {\n assertObj(resultColl, sourceCodeInfo)\n assertString(key, sourceCodeInfo)\n if (!collHasKey(result.coll, key))\n (resultColl)[key] = {}\n\n newResultColl = asColl(resultColl[key], sourceCodeInfo)\n }\n\n return { coll: newResultColl, parent: resultColl }\n },\n { coll, parent: {} },\n )\n return { coll, innerCollMeta }\n}\n\nconst collectionUtilsFunctions: BuiltinNormalExpressions = {\n 'get-in': {\n evaluate: (params, sourceCodeInfo): Any => {\n let coll = toAny(params[0])\n const keys = params[1] ?? [] // null behaves as empty array\n const defaultValue = toAny(params[2])\n assertArray(keys, sourceCodeInfo)\n for (const key of keys) {\n assertStringOrNumber(key, sourceCodeInfo)\n if (isColl(coll)) {\n const nextValue = get(coll, key)\n if (nextValue !== undefined)\n coll = nextValue\n else\n return defaultValue\n }\n else {\n return defaultValue\n }\n }\n return coll\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'collection',\n returns: { type: 'any' },\n args: {\n 'a': { type: 'collection' },\n 'b': { type: 'array' },\n 'not-found': { type: 'any' },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'not-found'] },\n ],\n 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.',\n seeAlso: ['get', 'collection.assoc-in', 'collection.update-in'],\n examples: [\n `\nlet cu = import(collection);\ncu.get-in(\n [[1, 2, 3], [4, { a: \"Kalle\" }, 6]],\n [1, 1, \"a\", 0]\n)`,\n `\nlet cu = import(collection);\ncu.get-in(\n [[1, 2, 3], [4, { a: \"Kalle\" }, 6]],\n [1, 1, \"b\", 0]\n)`,\n `\nlet cu = import(collection);\ncu.get-in(\n [[1, 2, 3], [4, { a: \"Kalle\" }, 6]],\n [1, 1, \"b\", 0],\n \"Lisa\"\n)`,\n ],\n },\n },\n 'assoc-in': {\n evaluate: ([originalColl, keys, value], sourceCodeInfo): Coll => {\n assertColl(originalColl, sourceCodeInfo)\n assertArray(keys, sourceCodeInfo)\n assertAny(value, sourceCodeInfo)\n\n if (keys.length === 1) {\n assertStringOrNumber(keys[0], sourceCodeInfo)\n return assoc(originalColl, keys[0], value, sourceCodeInfo)\n }\n\n const { coll, innerCollMeta } = cloneAndGetMeta(originalColl, keys, sourceCodeInfo)\n\n const lastKey = asStringOrNumber(keys[keys.length - 1], sourceCodeInfo)\n const parentKey = asStringOrNumber(keys[keys.length - 2], sourceCodeInfo)\n\n if (Array.isArray(innerCollMeta.parent)) {\n assertNumber(parentKey, sourceCodeInfo)\n innerCollMeta.parent[parentKey] = assoc(innerCollMeta.coll, lastKey, value, sourceCodeInfo)\n }\n else {\n assertString(parentKey, sourceCodeInfo)\n innerCollMeta.parent[parentKey] = assoc(innerCollMeta.coll, lastKey, value, sourceCodeInfo)\n }\n\n return coll\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n coll: { type: 'collection' },\n ks: { type: ['number', 'string'], array: true },\n value: { type: 'any' },\n },\n variants: [{ argumentNames: ['coll', 'ks', 'value'] }],\n 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.`,\n seeAlso: ['assoc', 'collection.get-in', 'collection.update-in'],\n examples: [\n `\nlet cu = import(collection);\ncu.assoc-in(\n {},\n [\"a\", \"b\", \"c\"],\n \"Albert\"\n)`,\n `\nlet cu = import(collection);\ncu.assoc-in(\n [1, 2, [1, 2, 3]],\n [2, 1],\n \"Albert\"\n)`,\n `\nlet cu = import(collection);\ncu.assoc-in(\n [1, 2, { name: \"albert\" }],\n [2, \"name\", 0],\n \"A\"\n)`,\n ],\n },\n },\n 'update': {\n evaluate: ([coll, key, fn, ...params], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Coll> => {\n assertColl(coll, sourceCodeInfo)\n assertStringOrNumber(key, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n return update(coll, key, fn, params, contextStack, executeFunction, sourceCodeInfo)\n },\n arity: { min: 3 },\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n 'coll': { type: 'collection' },\n 'key': { type: ['string', 'number'] },\n 'fun': { type: 'function' },\n 'fun-args': { type: 'any', rest: true },\n },\n variants: [\n { argumentNames: ['coll', 'value', 'fun'] },\n { argumentNames: ['coll', 'value', 'fun', 'fun-args'] },\n ],\n 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.`,\n seeAlso: ['collection.update-in', 'assoc'],\n examples: [\n `\nlet cu = import(collection);\nlet x = { a: 1, b: 2 };\ncu.update(x, \"a\", inc)`,\n `\nlet cu = import(collection);\nlet x = { a: 1, b: 2 };\ncu.update(\n x,\n \"c\",\n val -> null?(val) ? 0 : inc(val)\n)`,\n ],\n },\n },\n 'update-in': {\n evaluate: ([originalColl, keys, fn, ...params], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Coll> => {\n assertColl(originalColl, sourceCodeInfo)\n assertArray(keys, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n if (keys.length === 1) {\n assertStringOrNumber(keys[0], sourceCodeInfo)\n return update(originalColl, keys[0], fn, params, contextStack, executeFunction, sourceCodeInfo)\n }\n\n const { coll, innerCollMeta } = cloneAndGetMeta(originalColl, keys, sourceCodeInfo)\n\n const lastKey = asStringOrNumber(keys[keys.length - 1], sourceCodeInfo)\n const parentKey = asStringOrNumber(keys[keys.length - 2], sourceCodeInfo)\n\n if (Array.isArray(innerCollMeta.parent)) {\n assertNumber(parentKey, sourceCodeInfo)\n return chain(\n update(innerCollMeta.coll, lastKey, fn, params, contextStack, executeFunction, sourceCodeInfo),\n (updated) => {\n ;(innerCollMeta.parent as Any[])[parentKey] = updated\n return coll\n },\n )\n }\n else {\n assertString(parentKey, sourceCodeInfo)\n return chain(\n update(innerCollMeta.coll, lastKey, fn, params, contextStack, executeFunction, sourceCodeInfo),\n (updated) => {\n ;(innerCollMeta.parent as Record<string, unknown>)[parentKey] = updated\n return coll\n },\n )\n }\n },\n arity: { min: 3 },\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n 'coll': { type: 'collection' },\n 'ks': { type: 'array' },\n 'fun': { type: 'function' },\n 'fun-args': { type: 'any', rest: true },\n },\n variants: [\n { argumentNames: ['coll', 'ks', 'fun'] },\n { argumentNames: ['coll', 'ks', 'fun', 'fun-args'] },\n ],\n 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.`,\n seeAlso: ['collection.update', 'collection.assoc-in', 'collection.get-in'],\n examples: [\n `\nlet cu = import(collection);\ncu.update-in(\n { a: [1, 2, 3] },\n [\"a\", 1],\n -> null?($) ? 0 : inc($)\n)`,\n `\nlet cu = import(collection);\ncu.update-in(\n { a: { foo: \"bar\"} },\n [\"a\", \"foo\"],\n -> null?($) ? \"?\" : \"!\"\n)`,\n `\nlet cu = import(collection);\ncu.update-in(\n { a: { foo: \"bar\"} },\n [\"a\", \"baz\"],\n -> null?($) ? \"?\" : \"!\"\n)`,\n `\nlet cu = import(collection);\ncu.update-in(\n { a: [1, 2, 3] },\n [\"a\", 1],\n *,\n 10,\n 10,\n 10,\n)`,\n ],\n },\n },\n 'filteri': {\n evaluate: ([coll, fn], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Coll> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n if (Array.isArray(coll)) {\n return filterSequential(coll, (elem, index) => executeFunction(fn, [elem, index], contextStack, sourceCodeInfo))\n }\n if (typeof coll === 'string') {\n return chain(\n filterSequential(coll.split(''), (elem, index) => executeFunction(fn, [elem, index], contextStack, sourceCodeInfo)),\n filtered => filtered.join(''),\n )\n }\n return chain(\n filterSequential(Object.entries(coll), ([key, value]) => executeFunction(fn, [value, key], contextStack, sourceCodeInfo)),\n filtered => filtered.reduce((result: Obj, [key, value]) => {\n result[key] = value\n return result\n }, {}),\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: {\n type: 'function',\n description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',\n },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n 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.',\n seeAlso: ['filter', 'collection.mapi'],\n examples: [\n 'let cu = import(collection); cu.filteri([1, 2, 3], (x, i) -> i % 2 == 0)',\n 'let cu = import(collection); cu.filteri([1, 2, 3], (x, i) -> x % 2 == 0)',\n 'let cu = import(collection); cu.filteri([1, 2, 3], (x, i) -> x + i > 3)',\n ],\n },\n },\n 'mapi': {\n evaluate: ([coll, fn], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Coll> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n if (Array.isArray(coll)) {\n return mapSequential(coll, (elem, index) => executeFunction(fn, [elem, index], contextStack, sourceCodeInfo))\n }\n if (typeof coll === 'string') {\n return chain(\n mapSequential(coll.split(''), (elem, index) => executeFunction(fn, [elem, index], contextStack, sourceCodeInfo)),\n mapped => mapped.join(''),\n )\n }\n const entries = Object.entries(coll)\n return reduceSequential(entries, (acc: Obj, [key, value]) => {\n return chain(executeFunction(fn, [value, key], contextStack, sourceCodeInfo), (result) => {\n acc[key] = result\n return acc\n })\n }, {})\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: {\n type: 'function',\n description: 'The function to call for each element in the collection. The function should take two arguments: the element itself and the index.',\n },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n 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.',\n seeAlso: ['map', 'collection.filteri'],\n examples: [\n 'let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x + i)',\n 'let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x * i)',\n 'let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x - i)',\n 'let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x / i)',\n 'let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x % inc(i))',\n ],\n },\n },\n 'reducei': {\n evaluate: ([coll, fn, initial], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n assertAny(initial, sourceCodeInfo)\n\n if (typeof coll === 'string') {\n assertString(initial, sourceCodeInfo)\n if (coll.length === 0)\n return initial\n\n return reduceSequential(\n coll.split('').map((elem, index) => ({ elem, index })),\n (result, { elem, index }) => executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo),\n initial as Any,\n )\n }\n else if (Array.isArray(coll)) {\n if (coll.length === 0)\n return initial\n\n return reduceSequential(\n coll.map((elem, index) => ({ elem, index })),\n (result, { elem, index }) => executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo),\n initial,\n )\n }\n else {\n if (Object.keys(coll).length === 0)\n return initial\n\n return reduceSequential(\n Object.entries(coll),\n (result, [key, elem]) => executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo),\n initial,\n )\n }\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'any' },\n args: {\n coll: { type: 'collection' },\n fun: {\n type: 'function',\n 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.',\n },\n initial: {\n type: 'any',\n description: 'The initial value to use as the accumulator.',\n },\n },\n variants: [{ argumentNames: ['coll', 'fun', 'initial'] }],\n 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.',\n seeAlso: ['reduce', 'collection.reducei-right', 'collection.reductionsi'],\n examples: [\n 'let cu = import(collection); cu.reducei([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',\n 'let cu = import(collection); cu.reducei(\"Albert\", (acc, x, i) -> acc ++ x ++ i, \"\")',\n 'let cu = import(collection); cu.reducei({ a: 1, b: 2 }, -> $1 ++ $3, \"\")',\n ],\n },\n },\n 'reduce-right': {\n evaluate: ([coll, fn, initial], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n assertAny(initial, sourceCodeInfo)\n\n if (typeof coll === 'string') {\n if (coll.length === 0)\n return initial\n\n return reduceSequential(\n Array.from(coll.split('')).reverse(),\n (result, elem) => executeFunction(fn, [result, elem], contextStack, sourceCodeInfo),\n initial,\n )\n }\n else if (Array.isArray(coll)) {\n if (coll.length === 0)\n return initial\n\n return reduceSequential(\n Array.from(coll).reverse(),\n (result, elem) => executeFunction(fn, [result, elem], contextStack, sourceCodeInfo),\n initial,\n )\n }\n else {\n if (Object.keys(coll).length === 0)\n return initial\n\n return reduceSequential(\n Object.entries(coll).reverse(),\n (result, [, elem]) => executeFunction(fn, [result, elem], contextStack, sourceCodeInfo),\n initial,\n )\n }\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'any' },\n args: {\n fun: { type: 'function' },\n coll: { type: 'collection' },\n initial: { type: 'any' },\n },\n variants: [{ argumentNames: ['coll', 'fun', 'initial'] }],\n 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.',\n seeAlso: ['reduce', 'collection.reducei-right'],\n examples: [\n 'let cu = import(collection); cu.reduce-right([\"A\", \"B\", \"C\"], str, \"\")',\n 'let cu = import(collection); cu.reduce-right({ a: 1, b: 2 }, +, 0)',\n ],\n },\n },\n 'reducei-right': {\n evaluate: ([coll, fn, initial], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n assertAny(initial, sourceCodeInfo)\n\n if (typeof coll === 'string') {\n if (coll.length === 0)\n return initial\n\n return reduceSequential(\n Array.from(coll.split('')).reverse().map((elem, _, arr) => ({ elem, index: arr.length - 1 - _ })),\n (result, { elem, index }) => executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo),\n initial,\n )\n }\n else if (Array.isArray(coll)) {\n if (coll.length === 0)\n return initial\n\n return reduceSequential(\n Array.from(coll).reverse().map((elem, _, arr) => ({ elem, index: arr.length - 1 - _ })),\n (result, { elem, index }) => executeFunction(fn, [result, elem, index], contextStack, sourceCodeInfo),\n initial,\n )\n }\n else {\n if (Object.keys(coll).length === 0)\n return initial\n\n return reduceSequential(\n Object.entries(coll).reverse(),\n (result, [key, elem]) => executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo),\n initial,\n )\n }\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'any' },\n args: {\n coll: { type: 'collection' },\n fun: {\n type: 'function',\n 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.',\n },\n initial: {\n type: 'any',\n description: 'The initial value to use as the accumulator.',\n },\n },\n variants: [{ argumentNames: ['coll', 'fun', 'initial'] }],\n 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.',\n seeAlso: ['collection.reducei', 'collection.reduce-right'],\n examples: [\n 'let cu = import(collection); cu.reducei-right([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',\n 'let cu = import(collection); cu.reducei-right(\"Albert\", (acc, x, i) -> acc ++ x ++ i, \"\")',\n 'let cu = import(collection); cu.reducei-right({ a: 1, b: 2 }, -> $1 ++ $3, \"\")',\n ],\n },\n },\n 'reductions': {\n evaluate: ([coll, fn, initial], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n assertAny(initial, sourceCodeInfo)\n\n assertAny(initial, sourceCodeInfo)\n\n const items: Any[] = typeof coll === 'string'\n ? (assertString(initial, sourceCodeInfo), coll.length === 0 ? [] : coll.split(''))\n : Array.isArray(coll)\n ? (coll.length === 0 ? [] : Array.from(coll) as Any[])\n : (Object.keys(coll).length === 0 ? [] : Object.entries(coll).map(([, v]) => v as Any))\n\n if (items.length === 0)\n return [initial]\n\n const resultArray: Any[] = [initial]\n return chain(\n reduceSequential(\n items,\n (result, elem) => {\n return chain(executeFunction(fn, [result, elem], contextStack, sourceCodeInfo), (newVal) => {\n resultArray.push(newVal)\n return newVal\n })\n },\n initial,\n ),\n () => resultArray,\n )\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'any', array: true },\n args: {\n fun: { type: 'function' },\n coll: { type: 'collection' },\n initial: { type: 'any' },\n },\n variants: [{ argumentNames: ['coll', 'fun', 'initial'] }],\n description: 'Returns an array of the intermediate values of the reduction (see `reduce`) of $coll by $fun.',\n seeAlso: ['reduce', 'collection.reductionsi'],\n examples: [\n 'let cu = import(collection); cu.reductions([1, 2, 3], +, 0)',\n 'let cu = import(collection); cu.reductions([1, 2, 3], +, 10)',\n 'let cu = import(collection); cu.reductions([], +, 0)',\n 'let cu = import(collection); cu.reductions({ a: 1, b: 2 }, +, 0)',\n `\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)`,\n ],\n },\n },\n 'reductionsi': {\n evaluate: ([coll, fn, initial], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n assertAny(initial, sourceCodeInfo)\n\n assertAny(initial, sourceCodeInfo)\n\n type IndexedItem = { elem: Any, key: string | number }\n const toIndexedItem = (elem: Any, key: string | number): IndexedItem => ({ elem, key })\n const items: IndexedItem[] = typeof coll === 'string'\n ? (assertString(initial, sourceCodeInfo), coll.length === 0 ? [] : coll.split('').map((elem, index) => toIndexedItem(elem, index)))\n : Array.isArray(coll)\n ? (coll.length === 0 ? [] : coll.map((elem, index) => toIndexedItem(elem as Any, index)))\n : (Object.keys(coll).length === 0 ? [] : Object.entries(coll).map(([key, v]) => toIndexedItem(v as Any, key)))\n\n if (items.length === 0)\n return [initial]\n\n const resultArray: Any[] = [initial]\n return chain(\n reduceSequential(\n items,\n (result, { elem, key }) => {\n return chain(executeFunction(fn, [result, elem, key], contextStack, sourceCodeInfo), (newVal) => {\n resultArray.push(newVal)\n return newVal\n })\n },\n initial,\n ),\n () => resultArray,\n )\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'any', array: true },\n args: {\n coll: { type: 'collection' },\n fun: {\n type: 'function',\n 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.',\n },\n initial: {\n type: 'any',\n description: 'The initial value to use as the accumulator.',\n },\n },\n variants: [{ argumentNames: ['coll', 'fun', 'initial'] }],\n 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.',\n seeAlso: ['collection.reductions', 'collection.reducei'],\n examples: [\n 'let cu = import(collection); cu.reductionsi([1, 2, 3], (acc, x, i) -> acc + x + i, 0)',\n 'let cu = import(collection); cu.reductionsi(\"Albert\", (acc, x, i) -> acc ++ x ++ i, \"\")',\n 'let cu = import(collection); cu.reductionsi({ a: 1, b: 2 }, -> $1 ++ $3, \"\")',\n ],\n },\n },\n 'not-empty': {\n evaluate: ([coll], sourceCodeInfo): Coll | null => {\n if (coll === null)\n return null\n\n assertColl(coll, sourceCodeInfo)\n if (typeof coll === 'string')\n return coll.length > 0 ? coll : null\n\n if (Array.isArray(coll))\n return coll.length > 0 ? coll : null\n\n return Object.keys(coll).length > 0 ? coll : null\n },\n arity: toFixedArity(1),\n docs: {\n category: 'collection',\n returns: { type: 'boolean' },\n args: {\n coll: { type: ['collection', 'null'] },\n },\n variants: [{ argumentNames: ['coll'] }],\n description: 'Returns `null` if $coll is empty or `null`, otherwise $coll.',\n seeAlso: ['empty?', 'not-empty?'],\n examples: [\n 'let cu = import(collection); cu.not-empty([])',\n 'let cu = import(collection); cu.not-empty([1, 2, 3])',\n 'let cu = import(collection); cu.not-empty({})',\n 'let cu = import(collection); cu.not-empty({ a: 2 })',\n 'let cu = import(collection); cu.not-empty(\"\")',\n 'let cu = import(collection); cu.not-empty(\"Albert\")',\n 'let cu = import(collection); cu.not-empty(null)',\n ],\n },\n },\n 'every?': {\n evaluate: ([coll, fn], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<boolean> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n const arr = Array.isArray(coll)\n ? coll\n : typeof coll === 'string'\n ? coll.split('')\n : Object.entries(coll)\n\n return everySequential(arr, elem => executeFunction(fn, [elem], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns `true` if all entries in $a pass the test implemented by $b, otherwise returns `false`.',\n seeAlso: ['collection.any?', 'collection.not-every?', 'collection.not-any?', 'functional.every-pred', 'grid.cell-every?'],\n examples: [\n 'let cu = import(collection); cu.every?([1, 2, 3], number?)',\n 'let cu = import(collection); cu.every?([1, 2, 3], even?)',\n `\nlet cu = import(collection);\ncu.every?(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?,\n)`,\n `\nlet cu = import(collection);\ncu.every?(\n [50, 100, 150, 200],\n -> $ > 10,\n)`,\n 'let cu = import(collection); cu.every?([], number?)',\n 'let cu = import(collection); cu.every?(\"\", number?)',\n 'let cu = import(collection); cu.every?({}, number?)',\n `\nlet cu = import(collection);\ncu.every?(\n { a: 2, b: 4},\n -> even?(second($))\n)`,\n `\nlet cu = import(collection);\ncu.every?(\n { a: 2, b: 3 },\n -> even?(second($))\n)`,\n ],\n },\n },\n 'any?': {\n evaluate: ([coll, fn], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<boolean> => {\n assertFunctionLike(fn, sourceCodeInfo)\n assertColl(coll, sourceCodeInfo)\n\n const arr = Array.isArray(coll)\n ? coll\n : typeof coll === 'string'\n ? coll.split('')\n : Object.entries(coll)\n\n return someSequential(arr, elem => executeFunction(fn, [elem], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns `true` if any element in $a pass the test implemented by $b, otherwise returns `false`.',\n seeAlso: ['collection.every?', 'collection.not-any?', 'collection.not-every?', 'functional.some-pred', 'some', 'grid.some?'],\n examples: [\n `\nlet cu = import(collection);\ncu.any?(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)`,\n `\nlet cu = import(collection);\ncu.any?(\n [50, 100, 150, 200],\n x -> x > 10\n)`,\n 'let cu = import(collection); cu.any?([], number?)',\n 'let cu = import(collection); cu.any?(\"\", number?)',\n 'let cu = import(collection); cu.any?({}, number?)',\n `\nlet cu = import(collection);\ncu.any?(\n { a: 2, b: 3 },\n -> even?(second($))\n)`,\n `\nlet cu = import(collection);\ncu.any?(\n { a: 1, b: 3 },\n -> even?(second($))\n)`,\n ],\n },\n },\n 'not-any?': {\n evaluate: ([coll, fn], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<boolean> => {\n assertFunctionLike(fn, sourceCodeInfo)\n assertColl(coll, sourceCodeInfo)\n\n const arr = Array.isArray(coll)\n ? coll\n : typeof coll === 'string'\n ? coll.split('')\n : Object.entries(coll)\n\n return chain(\n someSequential(arr, elem => executeFunction(fn, [elem], contextStack, sourceCodeInfo)),\n result => !result,\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns `false` if any element in $a pass the test implemented by $b, otherwise returns `true`.',\n seeAlso: ['collection.any?', 'collection.every?', 'collection.not-every?'],\n examples: [\n `\nlet cu = import(collection);\ncu.not-any?(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)`,\n `\nlet cu = import(collection);\ncu.not-any?(\n [50, 100, 150, 200],\n x -> x > 10\n)`,\n 'let cu = import(collection); cu.not-any?([], number?)',\n 'let cu = import(collection); cu.not-any?(\"\", number?)',\n 'let cu = import(collection); cu.not-any?({}, number?)',\n `\nlet cu = import(collection);\ncu.not-any?(\n { a: 2, b: 3 },\n -> even?(second($))\n)`,\n `\nlet cu = import(collection);\ncu.not-any?(\n { a: 1, b: 3 },\n -> even?(second($))\n)`,\n ],\n },\n },\n 'not-every?': {\n evaluate: ([coll, fn], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<boolean> => {\n assertFunctionLike(fn, sourceCodeInfo)\n assertColl(coll, sourceCodeInfo)\n\n const arr = Array.isArray(coll)\n ? coll\n : typeof coll === 'string'\n ? coll.split('')\n : Object.entries(coll)\n\n return chain(\n everySequential(arr, elem => executeFunction(fn, [elem], contextStack, sourceCodeInfo)),\n result => !result,\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns `true` if at least one element in $a does not pass the test implemented by $b, otherwise returns `false`.',\n seeAlso: ['collection.every?', 'collection.any?', 'collection.not-any?'],\n examples: [\n `\nlet cu = import(collection);\ncu.not-every?(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)`,\n `\nlet cu = import(collection);\ncu.not-every?(\n [50, 100, 150, 200],\n x -> x > 10\n)`,\n 'let cu = import(collection); cu.not-every?([], number?)',\n 'let cu = import(collection); cu.not-every?(\"\", number?)',\n 'let cu = import(collection); cu.not-every?({}, number?)',\n `\nlet cu = import(collection);\ncu.not-every?(\n { a: 2, b: 4 },\n -> even?(second($))\n)`,\n `\nlet cu = import(collection);\ncu.not-every?(\n { a: 2, b: 3 },\n -> even?(second($))\n)`,\n ],\n },\n },\n}\n\nexport const collectionUtilsModule: DvalaModule = {\n name: 'collection',\n functions: collectionUtilsFunctions,\n}\n","import type { Any, Arr, Obj, Seq } from '../../../interface'\nimport type { SourceCodeInfo } from '../../../tokenizer/token'\nimport { asArray, assertArray, assertCharArray } from '../../../typeGuards/array'\nimport { asAny, asSeq, assertAny, assertFunctionLike, assertSeq } from '../../../typeGuards/dvala'\nimport { asNumber, assertNumber } from '../../../typeGuards/number'\nimport { assertString, assertStringOrNumber } from '../../../typeGuards/string'\nimport { collHasKey, compare, deepEqual, toNonNegativeInteger } from '../../../utils'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { MaybePromise } from '../../../utils/maybePromise'\nimport { chain, filterSequential, findIndexSequential, mapSequential, reduceSequential } from '../../../utils/maybePromise'\nimport type { BuiltinNormalExpressions } from '../../interface'\nimport type { DvalaModule } from '../interface'\n\nconst sequenceUtilsFunctions: BuiltinNormalExpressions = {\n 'position': {\n evaluate: ([seq, fn]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<number | null> => {\n assertFunctionLike(fn, sourceCodeInfo)\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n const arr = typeof seq === 'string' ? seq.split('') : seq\n return chain(\n findIndexSequential(arr, elem => executeFunction(fn, [elem], contextStack, sourceCodeInfo)),\n index => index !== -1 ? index : null,\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: ['number', 'null'] },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: ['sequence', 'null'] },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['seq', 'fun'] }],\n description: 'Returns the index of the first elements that passes the test implemented by $fun. If no element was found, `null` is returned.',\n seeAlso: ['index-of', 'some', 'find'],\n examples: [\n `\nlet su = import(sequence);\nsu.position(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)`,\n `\nlet su = import(sequence);\nsu.position(\n [5, 10, 15, 20],\n -> $ > 10\n)`,\n `\nlet su = import(sequence);\nsu.position(\n [5, 10, 15, 20],\n -> $ > 100\n)`,\n `\nlet su = import(sequence);\nsu.position(\n null,\n -> $ > 100\n)`,\n ],\n },\n },\n 'last-index-of': {\n evaluate: ([seq, value], sourceCodeInfo): number | null => {\n assertAny(value, sourceCodeInfo)\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n assertString(value, sourceCodeInfo)\n const index = seq.lastIndexOf(value)\n return index !== -1 ? index : null\n }\n else {\n const index = seq.findLastIndex(item => deepEqual(asAny(item, sourceCodeInfo), value), sourceCodeInfo)\n return index !== -1 ? index : null\n }\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: ['number', 'null'] },\n args: {\n a: { type: 'sequence' },\n b: { type: 'any' },\n seq: { type: ['sequence', 'null'] },\n x: { type: 'any' },\n },\n variants: [{ argumentNames: ['seq', 'x'] }],\n description: 'Returns the last index of $x in $seq. If element is not present in $seq `null` is returned.',\n seeAlso: ['index-of'],\n examples: [\n 'let su = import(sequence); su.last-index-of([[1], [2], [1], [2]], [1])',\n 'let su = import(sequence); su.last-index-of([\"Albert\", \"Mojir\", 160, [1, 2]], \"Mojir\")',\n 'let su = import(sequence); su.last-index-of([5, 10, 15, 20, 15], 15)',\n 'let su = import(sequence); su.last-index-of([5, 10, 15, 20], 1)',\n 'let su = import(sequence); su.last-index-of(null, 1)',\n ],\n },\n },\n 'splice': {\n evaluate: (params, sourceCodeInfo): Any => {\n const [seq, start, deleteCount, ...rest] = params\n assertSeq(seq, sourceCodeInfo)\n assertNumber(start, sourceCodeInfo, { integer: true })\n assertNumber(deleteCount, sourceCodeInfo, { integer: true, nonNegative: true })\n\n const from = start < 0 ? seq.length + start : start\n\n if (Array.isArray(seq)) {\n return [...seq.slice(0, from), ...rest, ...seq.slice(from + deleteCount)]\n }\n\n rest.forEach(elem => assertString(elem, sourceCodeInfo))\n return `${seq.substring(0, from)}${rest.join('')}${seq.substring(from + deleteCount)}`\n },\n arity: { min: 3 },\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n seq: { type: 'sequence', rest: true },\n start: { type: 'integer' },\n deleteCount: { type: 'integer' },\n items: { type: 'any', rest: true },\n },\n variants: [\n { argumentNames: ['seq', 'start', 'deleteCount'] },\n { argumentNames: ['seq', 'start', 'deleteCount', 'items'] },\n ],\n 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.',\n seeAlso: ['slice', 'sequence.remove-at'],\n examples: [\n 'let su = import(sequence); su.splice([1, 2, 3, 4, 5], 2, 2, \"x\")',\n 'let su = import(sequence); su.splice([1, 2, 3, 4, 5], -2, 1, \"x\")',\n 'let su = import(sequence); su.splice(\"Albert\", 2, 2, \"fo\")',\n ],\n },\n },\n 'sort-by': {\n evaluate: (params: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Seq> => {\n const [seq, keyfn] = params\n const defaultComparer = params.length === 2\n\n assertSeq(seq, sourceCodeInfo)\n assertFunctionLike(keyfn, sourceCodeInfo)\n const comparer = defaultComparer ? null : params[2]\n\n const isString = typeof seq === 'string'\n const arr = isString ? seq.split('') : [...seq]\n\n // Pre-compute all keys using mapSequential (async-safe)\n return chain(\n mapSequential(arr, elem => executeFunction(keyfn, [elem], contextStack, sourceCodeInfo)),\n (keys) => {\n if (defaultComparer) {\n // Create indexed pairs, sort by pre-computed keys\n const indexed = arr.map((elem, i) => ({ elem, key: keys[i]! }))\n indexed.sort((a, b) => {\n assertStringOrNumber(a.key, sourceCodeInfo)\n assertStringOrNumber(b.key, sourceCodeInfo)\n return compare(a.key, b.key, sourceCodeInfo)\n })\n const sorted = indexed.map(x => x.elem)\n return isString ? (sorted as string[]).join('') : sorted\n }\n else {\n assertFunctionLike(comparer, sourceCodeInfo)\n // Pre-compute keys, then need pairwise comparisons — these may also be async\n // For sort-by with custom comparer, we must use a non-async sort since\n // Array.sort requires sync comparators\n const indexed = arr.map((elem, i) => ({ elem, key: keys[i]! }))\n indexed.sort((a, b) => {\n const compareValue = executeFunction(comparer, [a.key, b.key], contextStack, sourceCodeInfo)\n if (compareValue instanceof Promise) {\n throw new TypeError('Async functions cannot be used as sort-by comparators')\n }\n assertNumber(compareValue, sourceCodeInfo, { finite: true })\n return compareValue\n })\n const sorted = indexed.map(x => x.elem)\n return isString ? (sorted as string[]).join('') : sorted\n }\n },\n )\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'sequence',\n returns: { type: 'any', rest: true },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: 'sequence' },\n keyfn: { type: 'function' },\n comparer: { type: 'function' },\n },\n variants: [\n { argumentNames: ['seq', 'keyfn'] },\n { argumentNames: ['seq', 'keyfn', 'comparer'] },\n ],\n 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`.',\n seeAlso: ['sort', 'compare'],\n examples: [\n 'let su = import(sequence); su.sort-by([\"Albert\", \"Mojir\", \"Nina\"], count)',\n 'let su = import(sequence); su.sort-by([\"Albert\", \"Mojir\", \"Nina\"], count)',\n 'let su = import(sequence); su.sort-by(\"Albert\", lower-case, -> $2 compare $1)',\n ],\n },\n },\n 'unshift': {\n evaluate: ([seq, ...values], sourceCodeInfo): Seq => {\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n assertCharArray(values, sourceCodeInfo)\n return [...values, seq].join('')\n }\n const copy = [...seq]\n copy.unshift(...values)\n return copy\n },\n arity: { min: 2 },\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'any' },\n seq: { type: 'sequence' },\n values: { type: 'any', rest: true },\n },\n variants: [{ argumentNames: ['seq', 'values'] }],\n description: 'Returns copy of $seq with $values added to the beginning.',\n seeAlso: ['push', '++'],\n examples: [\n 'let su = import(sequence); su.unshift([1, 2, 3], 4)',\n 'let su = import(sequence); su.unshift([1, 2, 3], 4)',\n 'let su = import(sequence); su.unshift([1, 2, 3], 4, 5, 6)',\n `\nlet su = import(sequence);\nlet l = [1, 2, 3];\nsu.unshift(l, 4);\nl`,\n ],\n },\n },\n 'distinct': {\n evaluate: ([input], sourceCodeInfo): Seq => {\n assertSeq(input, sourceCodeInfo)\n\n if (Array.isArray(input)) {\n const result: Any[] = []\n for (const item of input) {\n assertAny(item, sourceCodeInfo)\n if (!result.some(existingItem => deepEqual(existingItem, item, sourceCodeInfo))) {\n result.push(item)\n }\n }\n return result\n }\n\n return Array.from(new Set(input.split(''))).join('')\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns a copy of $seq with no duplicates.',\n seeAlso: ['sequence.frequencies'],\n examples: [\n 'let su = import(sequence); su.distinct([[1], [2], [3], [1], [3], [5]])',\n 'let su = import(sequence); su.distinct([1, 2, 3, 1, 3, 5])',\n 'let su = import(sequence); su.distinct(\"Albert Mojir\")',\n 'let su = import(sequence); su.distinct([])',\n 'let su = import(sequence); su.distinct(\"\")',\n ],\n },\n },\n 'remove': {\n evaluate: ([input, fn], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Seq> => {\n assertFunctionLike(fn, sourceCodeInfo)\n assertSeq(input, sourceCodeInfo)\n const arr = Array.isArray(input) ? input : input.split('')\n return chain(\n filterSequential(arr, elem => chain(\n executeFunction(fn, [elem], contextStack, sourceCodeInfo),\n result => !result,\n )),\n filtered => typeof input === 'string' ? filtered.join('') : filtered,\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: 'sequence' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['seq', 'fun'] }],\n description: 'Returns a new sequence of items in $seq for witch `pred(item)` returns a falsy value.',\n seeAlso: ['filter', 'sequence.remove-at'],\n examples: [\n 'let su = import(sequence); su.remove([1, 2, 3, 1, 3, 5], odd?)',\n 'let su = import(sequence); su.remove([1, 2, 3, 1, 3, 5], even?)',\n 'let su = import(sequence); su.remove(\"Albert Mojir\", -> \"aoueiyAOUEIY\" contains? $)',\n ],\n },\n },\n 'remove-at': {\n evaluate: ([input, index], sourceCodeInfo): Seq => {\n assertNumber(index, sourceCodeInfo, { integer: true })\n assertSeq(input, sourceCodeInfo)\n\n const at = index < 0 ? input.length + index : index\n if (at < 0 || at >= input.length)\n return input\n\n if (Array.isArray(input)) {\n return input.filter((_, i) => i !== at)\n }\n return `${input.substring(0, at)}${input.substring(at + 1)}`\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n seq: { type: 'sequence' },\n n: { type: 'number' },\n },\n variants: [{ argumentNames: ['seq', 'n'] }],\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.',\n seeAlso: ['sequence.remove', 'sequence.splice'],\n examples: [\n 'let su = import(sequence); su.remove-at([1, 2, 3, 1, 3, 5], 2)',\n 'let su = import(sequence); su.remove-at(\"Albert\", -2)',\n 'let su = import(sequence); su.remove-at([1, 2, 3, 1, 3, 5], 0)',\n 'let su = import(sequence); su.remove-at([1, 2, 3, 1, 3, 5], -1)',\n 'let su = import(sequence); su.remove-at(\"Albert Mojir\", 6)',\n ],\n },\n },\n 'split-at': {\n evaluate: ([seq, pos], sourceCodeInfo): Seq => {\n assertNumber(pos, sourceCodeInfo, { integer: true })\n assertSeq(seq, sourceCodeInfo)\n\n const at = pos < 0 ? seq.length + pos : pos\n return [seq.slice(0, at), seq.slice(at)]\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n seq: { type: 'sequence' },\n n: { type: 'number' },\n },\n variants: [{ argumentNames: ['seq', 'n'] }],\n description: 'Returns a pair of sequence `[take(pos input), drop(pos input)]`.',\n seeAlso: ['sequence.split-with', 'take', 'drop'],\n examples: [\n 'let su = import(sequence); su.split-at([1, 2, 3, 4, 5], 2)',\n 'let su = import(sequence); su.split-at(\"Albert\", -2)',\n 'let su = import(sequence); su.split-at([1, 2, 3, 4, 5], -2)',\n 'let su = import(sequence); su.split-at(\"Albert\", 2)',\n ],\n },\n },\n\n 'split-with': {\n evaluate: ([seq, fn], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Seq> => {\n assertFunctionLike(fn, sourceCodeInfo)\n assertSeq(seq, sourceCodeInfo)\n const seqIsArray = Array.isArray(seq)\n const arr = seqIsArray ? seq : seq.split('')\n return chain(\n findIndexSequential(arr, elem => chain(\n executeFunction(fn, [elem], contextStack, sourceCodeInfo),\n result => !result,\n )),\n (index) => {\n if (index === -1)\n return [seq, seqIsArray ? [] : '']\n return [seq.slice(0, index), seq.slice(index)]\n },\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: 'sequence' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['seq', 'fun'] }],\n description: 'Returns a pair of sequences `[take-while(input, fun), drop-while(input, fun)]`.',\n seeAlso: ['sequence.split-at', 'take-while', 'drop-while'],\n examples: [\n 'let su = import(sequence); su.split-with([1, 2, 3, 4, 5], odd?)',\n 'let su = import(sequence); su.split-with([1, 2, 3, 4, 5], -> $ > 3)',\n 'let su = import(sequence); su.split-with(\"Albert\", -> $ <= \"o\")',\n ],\n },\n },\n\n 'frequencies': {\n evaluate: ([seq], sourceCodeInfo): Obj => {\n assertSeq(seq, sourceCodeInfo)\n\n const arr = typeof seq === 'string' ? seq.split('') : seq\n\n return arr.reduce((result: Obj, val) => {\n assertString(val, sourceCodeInfo)\n if (collHasKey(result, val))\n result[val] = (result[val] as number) + 1\n else\n result[val] = 1\n\n return result\n }, {})\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'object' },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n 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.',\n seeAlso: ['sequence.group-by', 'sequence.distinct', 'vector.count-values'],\n examples: [\n 'let su = import(sequence); su.frequencies([\"Albert\", \"Mojir\", \"Nina\", \"Mojir\"])',\n 'let su = import(sequence); su.frequencies(\"Pneumonoultramicroscopicsilicovolcanoconiosis\")',\n ],\n },\n },\n\n 'group-by': {\n evaluate: ([seq, fn], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Obj> => {\n assertFunctionLike(fn, sourceCodeInfo)\n assertSeq(seq, sourceCodeInfo)\n const arr = Array.isArray(seq) ? seq : seq.split('')\n\n return reduceSequential(arr, (result: Obj, val) => {\n return chain(executeFunction(fn, [val], contextStack, sourceCodeInfo), (key) => {\n assertString(key, sourceCodeInfo)\n if (!collHasKey(result, key))\n result[key] = []\n\n ;(result[key] as Arr).push(val)\n return result\n })\n }, {})\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'object' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: 'sequence' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['seq', 'fun'] }],\n 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.',\n seeAlso: ['sequence.frequencies', 'sequence.partition-by'],\n examples: [\n 'let su = import(sequence); su.group-by([{ name: \"Albert\" }, { name: \"Albert\" }, { name: \"Mojir\" }], \"name\")',\n 'let su = import(sequence); su.group-by([{name: \"Albert\"}, {name: \"Albert\"}, {name: \"Mojir\"}], \"name\")',\n 'let su = import(sequence); su.group-by(\"Albert Mojir\", -> \"aoueiAOUEI\" contains? $ ? \"vowel\" : \"other\")',\n ],\n },\n },\n\n 'partition': {\n evaluate: (params, sourceCodeInfo): Seq => {\n const seq = asSeq(params[0], sourceCodeInfo)\n const n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo))\n const step = params.length >= 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n\n const pad = params.length === 4\n ? params[3] === null ? [] : asArray(params[3], sourceCodeInfo)\n : undefined\n\n return partitionHelper(n, step, seq, pad, sourceCodeInfo)\n },\n arity: { min: 2, max: 4 },\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'number' },\n seq: { type: 'sequence' },\n n: { type: 'number' },\n step: { type: 'number' },\n pad: { type: 'array' },\n },\n variants: [\n { argumentNames: ['seq', 'n'] },\n { argumentNames: ['seq', 'n', 'step'] },\n { argumentNames: ['seq', 'n', 'step', 'pad'] },\n ],\n 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.',\n seeAlso: ['sequence.partition-all', 'sequence.partition-by'],\n examples: [\n 'let su = import(sequence); su.partition(range(20), 4)',\n 'let su = import(sequence); su.partition(range(20), 4)',\n 'let su = import(sequence); su.partition(range(22), 4)',\n 'let su = import(sequence); su.partition(range(20), 4, 6)',\n 'let su = import(sequence); su.partition(range(20), 4, 3)',\n 'let su = import(sequence); su.partition(range(20), 3, 6, [\"a\"])',\n 'let su = import(sequence); su.partition(range(20), 4, 6, [\"a\"])',\n 'let su = import(sequence); su.partition(range(20), 4, 6, [\"a\", \"b\", \"c\", \"d\"])',\n 'let su = import(sequence); su.partition([\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"], 3, 1)',\n 'let su = import(sequence); su.partition([1, 2, 3, 4], 10)',\n 'let su = import(sequence); su.partition([1, 2, 3, 4], 10, 10)',\n 'let su = import(sequence); su.partition([1, 2, 3, 4], 10, 10, [])',\n 'let su = import(sequence); su.partition([1, 2, 3, 4], 10, 10, null)',\n 'let su = import(sequence); su.partition(\"superfragilistic\", 5)',\n 'let su = import(sequence); su.partition(\"superfragilistic\", 5, 5, null)',\n 'let su = import(sequence); let foo = [5, 6, 7, 8]; su.partition(foo, 2, 1, foo)',\n ],\n },\n },\n\n 'partition-all': {\n evaluate: (params, sourceCodeInfo): Seq => {\n const seq = asSeq(params[0], sourceCodeInfo)\n const n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo))\n const step = params.length === 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n\n\n return partitionHelper(n, step, seq, [], sourceCodeInfo)\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'number' },\n seq: { type: 'sequence' },\n n: { type: 'number' },\n step: { type: 'number' },\n },\n variants: [\n { argumentNames: ['seq', 'n'] },\n { argumentNames: ['seq', 'n', 'step'] },\n ],\n description: 'Returns an array of sequences like partition, but may include partitions with fewer than n items at the end.',\n seeAlso: ['sequence.partition', 'sequence.partition-by'],\n examples: [\n 'let su = import(sequence); su.partition-all([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 4)',\n 'let su = import(sequence); su.partition-all([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 4)',\n 'let su = import(sequence); su.partition([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 4)',\n 'let su = import(sequence); su.partition-all([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 2, 4)',\n ],\n },\n },\n\n 'partition-by': {\n evaluate: ([seq, fn], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Seq> => {\n assertFunctionLike(fn, sourceCodeInfo)\n assertSeq(seq, sourceCodeInfo)\n const isStringSeq = typeof seq === 'string'\n const arr = isStringSeq ? seq.split('') : seq\n\n type Acc = { result: Arr, oldValue: unknown }\n return chain(\n reduceSequential(arr, (acc: Acc, elem) => {\n return chain(executeFunction(fn, [elem], contextStack, sourceCodeInfo), (value) => {\n if (value !== acc.oldValue) {\n acc.result.push([])\n acc.oldValue = value\n }\n ;(acc.result[acc.result.length - 1] as Arr).push(elem)\n return acc\n })\n }, { result: [], oldValue: undefined as unknown }),\n ({ result }) => isStringSeq ? result.map(elem => (elem as Arr).join('')) : result,\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: 'sequence' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['seq', 'fun'] }],\n description: 'Applies $fun to each value in $seq, splitting it each time $fun returns a new value. Returns an array of sequences.',\n seeAlso: ['sequence.partition', 'sequence.partition-all', 'sequence.group-by'],\n examples: [\n 'let su = import(sequence); su.partition-by([1, 2, 3, 4, 5], odd?)',\n 'let su = import(sequence); su.partition-by([1, 2, 3, 4, 5], -> $ == 3)',\n 'let su = import(sequence); su.partition-by([1, 1, 1, 2, 2, 3, 3], odd?)',\n 'let su = import(sequence); su.partition-by(\"Leeeeeerrroyyy\", identity)',\n ],\n },\n },\n 'ends-with?': {\n evaluate: ([str, search], sourceCodeInfo): boolean => {\n assertSeq(str, sourceCodeInfo)\n\n if (typeof str === 'string') {\n assertString(search, sourceCodeInfo)\n return str.endsWith(search)\n }\n\n return deepEqual(asAny(str.at(-1), sourceCodeInfo), asAny(search, sourceCodeInfo), sourceCodeInfo)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'sequence' },\n seq: { type: 'sequence' },\n suffix: { type: 'sequence' },\n },\n variants: [{ argumentNames: ['seq', 'suffix'] }],\n description: 'Returns `true` if $seq ends with $suffix, otherwise `false`.',\n seeAlso: ['sequence.starts-with?'],\n examples: [\n 'let su = import(sequence); su.ends-with?([[1], [2], [3], [4], [5]], [5])',\n 'let su = import(sequence); su.ends-with?([[1], [2], [3], [4], [5]], 5)',\n 'let su = import(sequence); su.ends-with?([1, 2, 3, 4, 5], 5)',\n 'let su = import(sequence); su.ends-with?([1, 2, 3, 4, 5], [5])',\n 'let su = import(sequence); su.ends-with?(\"Albert\", \"rt\")',\n 'let su = import(sequence); su.ends-with?(\"Albert\", \"RT\")',\n ],\n },\n },\n 'starts-with?': {\n evaluate: ([seq, search], sourceCodeInfo): boolean => {\n assertSeq(seq, sourceCodeInfo)\n\n if (typeof seq === 'string') {\n assertString(search, sourceCodeInfo)\n return seq.startsWith(search)\n }\n\n return deepEqual(asAny(seq[0], sourceCodeInfo), asAny(search, sourceCodeInfo), sourceCodeInfo)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'sequence' },\n seq: { type: 'sequence' },\n prefix: { type: 'sequence' },\n },\n variants: [{ argumentNames: ['seq', 'prefix'] }],\n description: 'Returns `true` if $seq starts with $prefix, otherwise `false`.',\n seeAlso: ['sequence.ends-with?'],\n examples: [\n 'let su = import(sequence); su.starts-with?([[1], [2], [3], [4], [5]], [1])',\n 'let su = import(sequence); su.starts-with?([1, 2, 3, 4, 5], 1)',\n 'let su = import(sequence); su.starts-with?([1, 2, 3, 4, 5], [1])',\n 'let su = import(sequence); su.starts-with?(\"Albert\", \"Al\")',\n 'let su = import(sequence); su.starts-with?(\"Albert\", \"al\")',\n ],\n },\n },\n 'interleave': {\n evaluate: ([...seqs], sourceCodeInfo): Seq => {\n const isStringSeq = typeof seqs[0] === 'string'\n\n const seqsArr = isStringSeq\n ? seqs.map((seq) => {\n assertString(seq, sourceCodeInfo)\n return seq.split('')\n })\n : seqs.map((seq) => {\n assertArray(seq, sourceCodeInfo)\n return seq\n })\n\n const maxLength = Math.min(...seqsArr.map(seq => seq.length))\n const result: Arr = []\n for (let i = 0; i < maxLength; i += 1) {\n for (const seq of seqsArr) {\n if (i < seq.length)\n result.push(seq[i])\n }\n }\n return isStringSeq ? result.join('') : result\n },\n arity: { min: 1 },\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'sequence' },\n seqs: { type: 'sequence', rest: true },\n },\n variants: [{ argumentNames: ['seqs'] }],\n 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.',\n seeAlso: ['sequence.interpose', 'zipmap'],\n examples: [\n 'let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6])',\n 'let su = import(sequence); su.interleave(\"Albert\", \".,.,.,\")',\n 'let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6])',\n 'let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [7, 8, 9])',\n 'let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [7, 8])',\n 'let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [7])',\n 'let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [])',\n 'let su = import(sequence); su.interleave([1, 2, 3], [])',\n 'let su = import(sequence); su.interleave([])',\n ],\n },\n },\n 'interpose': {\n evaluate: ([seq, separator], sourceCodeInfo): Seq => {\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n assertString(separator, sourceCodeInfo)\n return seq.split('').join(separator)\n }\n\n if (seq.length === 0)\n return []\n\n const result: Arr = []\n for (let i = 0; i < seq.length - 1; i += 1) {\n result.push(seq[i], separator)\n }\n result.push(seq[seq.length - 1])\n return result\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'any' },\n seq: { type: 'sequence' },\n separator: { type: 'any' },\n },\n variants: [{ argumentNames: ['seq', 'separator'] }],\n description: 'Returns a sequence of the elements of $seq separated by $separator. If $seq is a string, the separator must be a string.',\n seeAlso: ['sequence.interleave', 'join'],\n examples: [\n 'let su = import(sequence); su.interpose(\"Albert\", \"-\")',\n 'let su = import(sequence); su.interpose([1, 2, 3, 4, 5], \"a\")',\n 'let su = import(sequence); su.interpose([\"Albert\", \"Mojir\", \"Nina\"], \", \")',\n 'let su = import(sequence); su.interpose(\"Albert\", \".\")',\n ],\n },\n },\n}\n\nfunction partitionHelper(n: number, step: number, seq: Seq, pad: Arr | undefined, sourceCodeInfo?: SourceCodeInfo) {\n assertNumber(step, sourceCodeInfo, { positive: true })\n const isStringSeq = typeof seq === 'string'\n\n const result: Arr[] = []\n let start = 0\n outer: while (start < seq.length) {\n const innerArr: Arr = []\n for (let i = start; i < start + n; i += 1) {\n if (i >= seq.length) {\n const padIndex = i - seq.length\n if (!pad) {\n start += step\n continue outer\n }\n if (padIndex >= pad.length)\n break\n\n innerArr.push(pad[padIndex])\n }\n else {\n innerArr.push(seq[i])\n }\n }\n result.push(innerArr)\n start += step\n }\n return isStringSeq ? result.map(x => x.join('')) : result\n}\n\nexport const sequenceUtilsModule: DvalaModule = {\n name: 'sequence',\n functions: sequenceUtilsFunctions,\n}\n","import { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { Argument, BuiltinNormalExpressions } from '../../interface'\nimport type { DvalaModule } from '../interface'\n\nfunction getOperatorArgs(a: 'integer', b: 'integer'): Record<string, Argument> {\n return { a: { type: a }, b: { type: b } }\n}\n\nconst bitwiseUtilsNormalExpression: BuiltinNormalExpressions = {\n 'bit-not': {\n evaluate: ([num], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n return ~num\n },\n arity: toFixedArity(1),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { a: { type: 'integer' } },\n variants: [{ argumentNames: ['a'] }],\n description: 'Returns bitwise `not` of $a.',\n seeAlso: ['&', '|', 'xor', 'bitwise.bit-and-not'],\n examples: [\n 'let { bit-not } = import(bitwise);\\nbit-not(0)',\n 'let { bit-not } = import(bitwise);\\nbit-not(255)',\n ],\n },\n },\n 'bit-and-not': {\n evaluate: ([first, ...rest], sourceCodeInfo): number => {\n assertNumber(first, sourceCodeInfo, { integer: true })\n\n return rest.reduce((result: number, value) => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n return result & ~value\n }, first)\n },\n arity: { min: 2 },\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: {\n ...getOperatorArgs('integer', 'integer'),\n c: { type: 'integer', rest: true },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: 'Returns bitwise `and` with complement.',\n seeAlso: ['&', '|', 'xor', 'bitwise.bit-not'],\n examples: [\n 'let { bit-and-not } = import(bitwise);\\n0b0011 bit-and-not 0b0110',\n 'let { bit-and-not } = import(bitwise);\\nbit-and-not(0b0011, 0b0110)',\n 'let { bit-and-not } = import(bitwise);\\nbit-and-not(0b0011, 0b0110, 0b1001)',\n ],\n },\n },\n 'bit-flip': {\n evaluate: ([num, index], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(index, sourceCodeInfo, { integer: true, nonNegative: true })\n\n const mask = 1 << index\n return (num ^= mask)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Flips bit number $b.',\n seeAlso: ['bitwise.bit-set', 'bitwise.bit-clear', 'bitwise.bit-test'],\n examples: [\n 'let { bit-flip } = import(bitwise);\\n0b0011 bit-flip 1',\n 'let { bit-flip } = import(bitwise);\\nbit-flip(0b0011, 1)',\n 'let { bit-flip } = import(bitwise);\\nbit-flip(0b1100, 1)',\n ],\n },\n },\n 'bit-set': {\n evaluate: ([num, index], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(index, sourceCodeInfo, { integer: true, nonNegative: true })\n\n const mask = 1 << index\n return (num |= mask)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Sets bit number $b.',\n seeAlso: ['bitwise.bit-flip', 'bitwise.bit-clear', 'bitwise.bit-test'],\n examples: [\n 'let { bit-set } = import(bitwise);\\n0b0010 bit-set 1',\n 'let { bit-set } = import(bitwise);\\nbit-set(0b0011, 1)',\n 'let { bit-set } = import(bitwise);\\nbit-set(0b1100, 1)',\n ],\n },\n },\n 'bit-clear': {\n evaluate: ([num, index], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(index, sourceCodeInfo, { integer: true, nonNegative: true })\n\n const mask = 1 << index\n return (num &= ~mask)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Clears bit number $b.',\n seeAlso: ['bitwise.bit-flip', 'bitwise.bit-set', 'bitwise.bit-test'],\n examples: [\n 'let { bit-clear } = import(bitwise);\\n0b0011 bit-clear 1',\n 'let { bit-clear } = import(bitwise);\\nbit-clear(0b0011, 1)',\n 'let { bit-clear } = import(bitwise);\\nbit-clear(0b1100, 1)',\n ],\n },\n },\n 'bit-test': {\n evaluate: ([num, index], sourceCodeInfo): boolean => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(index, sourceCodeInfo, { integer: true, nonNegative: true })\n\n const mask = 1 << index\n return !!(num & mask)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'boolean' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Checks if bit number $b is set.',\n seeAlso: ['bitwise.bit-flip', 'bitwise.bit-set', 'bitwise.bit-clear'],\n examples: [\n 'let { bit-test } = import(bitwise);\\n0b0011 bit-test 1',\n 'let { bit-test } = import(bitwise);\\nbit-test(0b0011, 1)',\n 'let { bit-test } = import(bitwise);\\nbit-test(0b1100, 1)',\n ],\n },\n },\n}\n\nexport const bitwiseUtilsModule: DvalaModule = {\n name: 'bitwise',\n functions: bitwiseUtilsNormalExpression,\n}\n","import { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../interface'\nimport type { DvalaModule } from '../interface'\n\n// --- Conversion factor tables ---\n// Each category maps unit abbreviations to a factor relative to a base unit.\n// To convert from unit A to unit B: value * (factorA / factorB)\n// Temperature is special-cased (non-linear).\n\ninterface UnitCategory {\n baseUnit: string\n units: Record<string, number>\n description: string\n}\n\nconst lengthUnits: UnitCategory = {\n baseUnit: 'm',\n description: 'length',\n units: {\n angstrom: 1e-10,\n um: 0.000001,\n mm: 0.001,\n cm: 0.01,\n m: 1,\n km: 1000,\n in: 0.0254,\n ft: 0.3048,\n yd: 0.9144,\n mi: 1609.344,\n nmi: 1852,\n },\n}\n\nconst weightUnits: UnitCategory = {\n baseUnit: 'kg',\n description: 'weight',\n units: {\n mg: 0.000001,\n g: 0.001,\n kg: 1,\n t: 1000,\n oz: 0.028349523125,\n lb: 0.45359237,\n st: 6.35029318,\n },\n}\n\nconst volumeUnits: UnitCategory = {\n baseUnit: 'l',\n description: 'volume',\n units: {\n 'ml': 0.001,\n 'cl': 0.01,\n 'dl': 0.1,\n 'l': 1,\n 'tsp': 0.00492892159375,\n 'tbsp': 0.01478676478125,\n 'fl-oz': 0.0295735295625,\n 'cup': 0.2365882365,\n 'pt': 0.473176473,\n 'qt': 0.946352946,\n 'gal': 3.785411784,\n },\n}\n\nconst timeUnits: UnitCategory = {\n baseUnit: 's',\n description: 'time',\n units: {\n ms: 0.001,\n s: 1,\n min: 60,\n h: 3600,\n day: 86400,\n week: 604800,\n },\n}\n\nconst areaUnits: UnitCategory = {\n baseUnit: 'm2',\n description: 'area',\n units: {\n mm2: 0.000001,\n cm2: 0.0001,\n m2: 1,\n km2: 1000000,\n in2: 0.00064516,\n ft2: 0.09290304,\n yd2: 0.83612736,\n acre: 4046.8564224,\n hectare: 10000,\n },\n}\n\nconst speedUnits: UnitCategory = {\n baseUnit: 'm/s',\n description: 'speed',\n units: {\n 'm/s': 1,\n 'km/h': 1 / 3.6,\n 'mph': 0.44704,\n 'kn': 0.514444,\n 'ft/s': 0.3048,\n },\n}\n\nconst dataUnits: UnitCategory = {\n baseUnit: 'b',\n description: 'data',\n units: {\n b: 1,\n kb: 1000,\n mb: 1000000,\n gb: 1e9,\n tb: 1e12,\n pb: 1e15,\n },\n}\n\nconst pressureUnits: UnitCategory = {\n baseUnit: 'pa',\n description: 'pressure',\n units: {\n pa: 1,\n kpa: 1000,\n bar: 100000,\n atm: 101325,\n psi: 6894.757293168,\n mmhg: 133.322387415,\n },\n}\n\nconst energyUnits: UnitCategory = {\n baseUnit: 'j',\n description: 'energy',\n units: {\n j: 1,\n kj: 1000,\n cal: 4.184,\n kcal: 4184,\n wh: 3600,\n kwh: 3600000,\n btu: 1055.06,\n },\n}\n\nconst powerUnits: UnitCategory = {\n baseUnit: 'w',\n description: 'power',\n units: {\n w: 1,\n kw: 1000,\n mw: 1000000,\n hp: 745.7,\n },\n}\n\nconst frequencyUnits: UnitCategory = {\n baseUnit: 'hz',\n description: 'frequency',\n units: {\n hz: 1,\n khz: 1000,\n mhz: 1000000,\n ghz: 1000000000,\n },\n}\n\nconst angleUnits: UnitCategory = {\n baseUnit: 'rad',\n description: 'angle',\n units: {\n deg: Math.PI / 180,\n rad: 1,\n grad: Math.PI / 200,\n turn: 2 * Math.PI,\n },\n}\n\n// --- Temperature conversion functions ---\n\nfunction celsiusTo(unit: 'c' | 'f' | 'k', value: number): number {\n switch (unit) {\n case 'c': return value\n case 'f': return value * 9 / 5 + 32\n case 'k': return value + 273.15\n }\n}\n\nfunction toCelsius(unit: 'c' | 'f' | 'k', value: number): number {\n switch (unit) {\n case 'c': return value\n case 'f': return (value - 32) * 5 / 9\n case 'k': return value - 273.15\n }\n}\n\nconst temperatureUnits = ['c', 'f', 'k'] as const\n\nconst unitDescriptions: Record<string, string> = {\n // Length\n 'angstrom': 'ångströms',\n 'um': 'micrometers',\n 'mm': 'millimeters',\n 'cm': 'centimeters',\n 'm': 'meters',\n 'km': 'kilometers',\n 'in': 'inches',\n 'ft': 'feet',\n 'yd': 'yards',\n 'mi': 'miles',\n 'nmi': 'nautical miles',\n // Weight\n 'mg': 'milligrams',\n 'g': 'grams',\n 'kg': 'kilograms',\n 't': 'metric tons',\n 'oz': 'ounces',\n 'lb': 'pounds',\n 'st': 'stones',\n // Volume\n 'ml': 'milliliters',\n 'cl': 'centiliters',\n 'dl': 'deciliters',\n 'l': 'liters',\n 'tsp': 'teaspoons',\n 'tbsp': 'tablespoons',\n 'fl-oz': 'fluid ounces',\n 'cup': 'cups',\n 'pt': 'pints',\n 'qt': 'quarts',\n 'gal': 'gallons',\n // Time\n 'ms': 'milliseconds',\n 's': 'seconds',\n 'min': 'minutes',\n 'h': 'hours',\n 'day': 'days',\n 'week': 'weeks',\n // Area\n 'mm2': 'square millimeters',\n 'cm2': 'square centimeters',\n 'm2': 'square meters',\n 'km2': 'square kilometers',\n 'in2': 'square inches',\n 'ft2': 'square feet',\n 'yd2': 'square yards',\n 'acre': 'acres',\n 'hectare': 'hectares',\n // Speed\n 'm/s': 'meters per second',\n 'km/h': 'kilometers per hour',\n 'mph': 'miles per hour',\n 'kn': 'knots',\n 'ft/s': 'feet per second',\n // Data\n 'b': 'bytes',\n 'kb': 'kilobytes',\n 'mb': 'megabytes',\n 'gb': 'gigabytes',\n 'tb': 'terabytes',\n 'pb': 'petabytes',\n // Pressure\n 'pa': 'pascals',\n 'kpa': 'kilopascals',\n 'bar': 'bars',\n 'atm': 'atmospheres',\n 'psi': 'pounds per square inch',\n 'mmhg': 'millimeters of mercury',\n // Energy\n 'j': 'joules',\n 'kj': 'kilojoules',\n 'cal': 'calories',\n 'kcal': 'kilocalories',\n 'wh': 'watt-hours',\n 'kwh': 'kilowatt-hours',\n 'btu': 'British thermal units',\n // Power\n 'w': 'watts',\n 'kw': 'kilowatts',\n 'mw': 'megawatts',\n 'hp': 'horsepower',\n // Frequency\n 'hz': 'hertz',\n 'khz': 'kilohertz',\n 'mhz': 'megahertz',\n 'ghz': 'gigahertz',\n // Angle\n 'deg': 'degrees',\n 'rad': 'radians',\n 'grad': 'gradians',\n 'turn': 'turns',\n // Temperature\n 'c': 'Celsius',\n 'f': 'Fahrenheit',\n 'k': 'Kelvin',\n}\n\n// --- Generate linear conversion functions ---\n\nfunction generateLinearConversions(category: UnitCategory): BuiltinNormalExpressions {\n const result: BuiltinNormalExpressions = {}\n const unitNames = Object.keys(category.units)\n\n for (const from of unitNames) {\n for (const to of unitNames) {\n if (from === to)\n continue\n\n const fromFactor = category.units[from]!\n const toFactor = category.units[to]!\n const conversionFactor = fromFactor / toFactor\n const fnName = `${from}->${to}`\n const fromDesc = unitDescriptions[from]!\n const toDesc = unitDescriptions[to]!\n\n const seeAlso = [\n `convert.${to}->${from}`,\n ...unitNames\n .filter(u => u !== from && u !== to)\n .map(u => `convert.${from}->${u}`),\n ]\n\n result[fnName] = {\n evaluate: ([value], sourceCodeInfo): number => {\n assertNumber(value, sourceCodeInfo)\n return value * conversionFactor\n },\n arity: toFixedArity(1),\n docs: {\n category: 'convert',\n returns: { type: 'number' },\n args: {\n value: { type: 'number', description: `Value in ${fromDesc}` },\n },\n variants: [{ argumentNames: ['value'] }],\n description: `Converts a value from ${fromDesc} (\\`${from}\\`) to ${toDesc} (\\`${to}\\`).`,\n seeAlso,\n examples: [\n `let { ${fnName} } = import(convert);\n${fnName}(1)`,\n ],\n },\n }\n }\n }\n return result\n}\n\n// --- Generate temperature conversion functions ---\n\nfunction generateTemperatureConversions(): BuiltinNormalExpressions {\n const result: BuiltinNormalExpressions = {}\n\n for (const from of temperatureUnits) {\n for (const to of temperatureUnits) {\n if (from === to)\n continue\n\n const fnName = `${from}->${to}`\n const fromDesc = unitDescriptions[from]!\n const toDesc = unitDescriptions[to]!\n\n const seeAlso = [\n `convert.${to}->${from}`,\n ...temperatureUnits\n .filter(u => u !== from && u !== to)\n .map(u => `convert.${from}->${u}`),\n ]\n\n result[fnName] = {\n evaluate: ([value], sourceCodeInfo): number => {\n assertNumber(value, sourceCodeInfo)\n const celsius = toCelsius(from, value)\n return celsiusTo(to, celsius)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'convert',\n returns: { type: 'number' },\n args: {\n value: { type: 'number', description: `Value in ${fromDesc}` },\n },\n variants: [{ argumentNames: ['value'] }],\n description: `Converts a temperature from ${fromDesc} (\\`${from}\\`) to ${toDesc} (\\`${to}\\`).`,\n seeAlso,\n examples: [\n `let { ${fnName} } = import(convert);\n${fnName}(100)`,\n ],\n },\n }\n }\n }\n return result\n}\n\n// --- Assemble all conversion functions ---\n\nconst convertFunctions: BuiltinNormalExpressions = {\n ...generateLinearConversions(lengthUnits),\n ...generateLinearConversions(weightUnits),\n ...generateLinearConversions(volumeUnits),\n ...generateLinearConversions(timeUnits),\n ...generateLinearConversions(areaUnits),\n ...generateLinearConversions(speedUnits),\n ...generateLinearConversions(dataUnits),\n ...generateLinearConversions(pressureUnits),\n ...generateLinearConversions(energyUnits),\n ...generateLinearConversions(powerUnits),\n ...generateLinearConversions(frequencyUnits),\n ...generateLinearConversions(angleUnits),\n ...generateTemperatureConversions(),\n}\n\nexport const convertModule: DvalaModule = {\n name: 'convert',\n functions: convertFunctions,\n}\n","import type { DvalaModule } from './builtin/modules/interface'\nimport { assertModule } from './builtin/modules/assertion'\nimport { gridModule } from './builtin/modules/grid'\nimport { randomModule } from './builtin/modules/random'\nimport { vectorModule } from './builtin/modules/vector'\nimport { linearAlgebraModule } from './builtin/modules/linear-algebra'\nimport { matrixModule } from './builtin/modules/matrix'\nimport { numberTheoryModule } from './builtin/modules/number-theory'\nimport { mathUtilsModule } from './builtin/modules/math'\nimport { functionalUtilsModule } from './builtin/modules/functional'\nimport { stringUtilsModule } from './builtin/modules/string'\nimport { collectionUtilsModule } from './builtin/modules/collection'\nimport { sequenceUtilsModule } from './builtin/modules/sequence'\nimport { bitwiseUtilsModule } from './builtin/modules/bitwise'\nimport { convertModule } from './builtin/modules/convert'\n\nexport const allBuiltinModules: DvalaModule[] = [\n assertModule,\n gridModule,\n randomModule,\n vectorModule,\n linearAlgebraModule,\n matrixModule,\n numberTheoryModule,\n mathUtilsModule,\n functionalUtilsModule,\n stringUtilsModule,\n collectionUtilsModule,\n sequenceUtilsModule,\n bitwiseUtilsModule,\n convertModule,\n]\n","import fs from 'node:fs'\nimport path from 'node:path'\nimport { DvalaError } from '../errors'\nimport { Dvala } from '../Dvala/Dvala'\nimport { allBuiltinModules } from '../allModules'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { getCodeMarker } from '../utils/debug/getCodeMarker'\n\ninterface TestChunk {\n name: string\n program: string\n directive: 'SKIP' | null\n}\n\ninterface RunTestParams {\n testPath: string\n testNamePattern?: RegExp\n}\n\ninterface TestResult {\n /**\n * Test report\n * http://testanything.org/\n */\n tap: string\n success: boolean\n}\n\nexport function runTest({ testPath: filePath, testNamePattern }: RunTestParams): TestResult {\n const includedFilePaths = getIncludedFilePaths(filePath)\n const testResult: TestResult = {\n tap: 'TAP version 13\\n',\n success: true,\n }\n try {\n const testChunks = getTestChunks(filePath)\n testResult.tap += `1..${testChunks.length}\\n`\n testChunks.forEach((testChunkProgram, index) => {\n const testNumber = index + 1\n if (testNamePattern && !testNamePattern.test(testChunkProgram.name)) {\n testResult.tap += `ok ${testNumber} ${testChunkProgram.name} # skip - Not matching testNamePattern ${testNamePattern}\\n`\n }\n else if (testChunkProgram.directive === 'SKIP') {\n testResult.tap += `ok ${testNumber} ${testChunkProgram.name} # skip\\n`\n }\n else {\n try {\n const dvala = new Dvala({ debug: true, modules: allBuiltinModules })\n const bindings = getBindings(includedFilePaths, dvala)\n dvala.run(testChunkProgram.program, {\n bindings,\n filePath,\n })\n testResult.tap += `ok ${testNumber} ${testChunkProgram.name}\\n`\n }\n catch (error) {\n testResult.success = false\n testResult.tap += `not ok ${testNumber} ${testChunkProgram.name}${getErrorYaml(error)}`\n }\n }\n })\n }\n catch (error: unknown) {\n testResult.tap += `Bail out! ${getErrorMessage(error)}\\n`\n testResult.success = false\n }\n return testResult\n}\n\nfunction readDvalaFile(dvalaPath: string): string {\n if (!dvalaPath.endsWith('.dvala'))\n throw new Error(`Expected .dvala file, got ${dvalaPath}`)\n\n return fs.readFileSync(dvalaPath, { encoding: 'utf-8' })\n}\n\nfunction getBindings(includedFilePaths: string[], dvala: Dvala): Record<string, unknown> {\n return includedFilePaths.reduce((acc: Record<string, unknown>, filePath) => {\n const fileContent = readDvalaFile(filePath)\n const result = dvala.run(fileContent, { filePath, bindings: acc })\n if (result !== null && typeof result === 'object' && !Array.isArray(result)) {\n // First definition wins (preserves old context layer lookup order)\n for (const [key, value] of Object.entries(result as Record<string, unknown>)) {\n if (!(key in acc)) {\n acc[key] = value\n }\n }\n }\n return acc\n }, {})\n}\n\nfunction getIncludedFilePaths(absoluteFilePath: string): string[] {\n const result: string[] = []\n getIncludesRecursively(absoluteFilePath, result)\n return result.reduce((acc: string[], entry: string) => {\n if (!acc.includes(entry))\n acc.push(entry)\n\n return acc\n }, [])\n\n function getIncludesRecursively(filePath: string, includedFilePaths: string[]): void {\n const includeFilePaths = readIncludeDirectives(filePath)\n includeFilePaths.forEach((includeFilePath) => {\n getIncludesRecursively(includeFilePath, includedFilePaths)\n includedFilePaths.push(includeFilePath)\n })\n }\n}\n\nfunction readIncludeDirectives(filePath: string): string[] {\n const fileContent = readDvalaFile(filePath)\n const dirname = path.dirname(filePath)\n let okToInclude = true\n return fileContent.split('\\n').reduce((acc: string[], line) => {\n const includeMatch = line.match(/^\\s*\\/{2}\\s*@include\\s*(\\S+)\\s*$/)\n if (includeMatch) {\n if (!okToInclude)\n throw new Error(`@include must be in the beginning of file: ${filePath}:${line + 1}`)\n\n const relativeFilePath = includeMatch[1] as string\n acc.push(path.resolve(dirname, relativeFilePath))\n }\n if (!line.match(/^\\s*\\/.*$/))\n okToInclude = false\n\n return acc\n }, [])\n}\n\n// Splitting test file based on @test annotations\nfunction getTestChunks(testPath: string): TestChunk[] {\n const testProgram = readDvalaFile(testPath)\n let currentTest: TestChunk | undefined\n let setupCode = ''\n return testProgram.split('\\n').reduce((result: TestChunk[], line, index) => {\n const currentLineNbr = index + 1\n // eslint-disable-next-line regexp/no-super-linear-backtracking\n const testNameAnnotationMatch = line.match(/^\\s*\\/{2}\\s*@(?:(skip)-)?test\\s*(.*)$/)\n if (testNameAnnotationMatch) {\n const directive = (testNameAnnotationMatch[1] ?? '').toUpperCase()\n const testName = testNameAnnotationMatch[2]\n if (!testName)\n throw new Error(`Missing test name on line ${currentLineNbr}`)\n\n if (result.find(chunk => chunk.name === testName))\n throw new Error(`Duplicate test name ${testName}`)\n\n currentTest = {\n directive: (directive || null) as TestChunk['directive'],\n name: testName,\n // Adding new-lines to make dvala debug information report correct rows\n program:\n setupCode + [...Array(currentLineNbr + 2 - setupCode.split('\\n').length).keys()].map(() => '').join('\\n'),\n }\n result.push(currentTest)\n return result\n }\n if (!currentTest)\n setupCode += `${line}\\n`\n else\n currentTest.program += `${line}\\n`\n\n return result\n }, [])\n}\n\nexport function getErrorYaml(error: unknown): string {\n const message = getErrorMessage(error)\n /* v8 ignore next 7 */\n if (!isAbstractDvalaError(error)) {\n return `\n ---\n message: ${JSON.stringify(message)}\n ...\n`\n }\n\n const sourceCodeInfo = error.sourceCodeInfo\n /* v8 ignore next 8 */\n if (!sourceCodeInfo || typeof sourceCodeInfo === 'string') {\n return `\n ---\n message: ${JSON.stringify(message)}\n error: ${JSON.stringify(error.name)}\n ...\n`\n }\n\n const formattedMessage = message.includes('\\n')\n ? `|\\n ${message.split(/\\r?\\n/).join('\\n ')}`\n : JSON.stringify(message)\n return `\n ---\n error: ${JSON.stringify(error.name)}\n message: ${formattedMessage}\n location: ${JSON.stringify(getLocation(sourceCodeInfo))}\n code:\n - \"${sourceCodeInfo.code}\"\n - \"${getCodeMarker(sourceCodeInfo)}\"\n ...\n`\n}\n\nfunction getLocation(sourceCodeInfo: SourceCodeInfo): string {\n const terms: string[] = []\n if (sourceCodeInfo.filePath)\n terms.push(sourceCodeInfo.filePath)\n\n if (sourceCodeInfo.position) {\n terms.push(`${sourceCodeInfo.position.line}`)\n terms.push(`${sourceCodeInfo.position.column}`)\n }\n\n return terms.join(':')\n}\n\nfunction getErrorMessage(error: unknown): string {\n if (!isAbstractDvalaError(error)) {\n // error should always be an Error (other cases is just for kicks)\n /* v8 ignore next 1 */\n return typeof error === 'string' ? error : error instanceof Error ? error.message : 'Unknown error'\n }\n return error.shortMessage\n}\n\nfunction isAbstractDvalaError(error: unknown): error is DvalaError {\n return error instanceof DvalaError\n}\n"],"names":["getCodeMarker","sourceCodeInfo","position","code","leftPadding","column","rightPadding","length","repeat","Math","max","RecurSignal","Error","params","constructor","super","Object","setPrototypeOf","this","prototype","name","DvalaError","shortMessage","err","message","location","line","filePath","getDvalaErrorMessage","UserDefinedError","userMessage","AssertionError","UndefinedSymbolError","symbol","symbolName","specialExpressionTypes","array","cond","block","doseq","for","if","let","loop","object","recur","match","throw","try","unless","import","effect","perform","parallel","race","NodeTypes","Number","String","NormalExpression","SpecialExpression","UserDefinedSymbol","NormalBuiltinSymbol","SpecialBuiltinSymbol","ReservedSymbol","Binding","Spread","NodeTypesSet","Set","values","getNodeTypeName","type","keys","find","key","functionTypeSet","FUNCTION_SYMBOL","REGEXP_SYMBOL","EFFECT_SYMBOL","isDvalaFunction","func","has","isFunctionType","functionType","isNode","value","Array","isArray","isNodeType","valueToString","RegExp","toString","JSON","stringify","getSourceCodeInfo","anyValue","getAssertionError","typeName","isUserDefinedSymbolNode","node","asUserDefinedSymbolNode","assertUserDefinedSymbolNode","isNormalBuiltinSymbolNode","isSpecialBuiltinSymbolNode","isNormalExpressionNodeWithName","isNormalExpressionNode","nodeType","isSymbolNode","isSpreadNode","getUndefinedSymbols","ast","contextStack","builtin","evaluateNode","nodes","body","unresolvedSymbols","subNode","findUnresolvedSymbolsInNode","forEach","add","symbolNode","lookUp","normalExpressionNode","expressionNode","specialExpressionNode","specialExpressionType","castedGetUndefinedSymbols","specialExpressions","asNonUndefined","assertNonUndefined","undefined","isNonUndefined","isUnknownRecord","isAny","asAny","assertAny","isSeq","asSeq","assertSeq","isObj","isRegularExpression","isEffectRef","assertObj","isColl","asColl","assertColl","regexp","assertStringOrRegularExpression","isStringOrRegularExpression","asFunctionLike","assertFunctionLike","isFunctionLike","isString","options","nonEmpty","char","assertString","asString","isStringOrNumber","asStringOrNumber","assertStringOrNumber","assertionNormalExpression","assert","evaluate","arity","min","docs","category","description","returns","args","variants","argumentNames","examples","seeAlso","hideOperatorForm","isNumber","isNaN","integer","isInteger","finite","isFinite","zero","nonZero","positive","negative","nonPositive","nonNegative","gt","gte","lt","lte","assertNumber","sign","getSignString","numberType","range","getRangeString","filter","x","join","getNumberTypeName","asNumber","arityAcceptsMin","nbrOfParams","getArityFromFunction","param","toFixedArity","assertNumberOfParams","getOperatorArgs","a","b","bitwiseNormalExpression","num","count","first","rest","reduce","result","c","xor","collHasKey","coll","getOwnPropertyDescriptor","compare","deepEqual","approxEqual","i","s","f","aKeys","bKeys","toNonNegativeInteger","ceil","toAny","clone","entries","entry","val","map","item","cloneColl","joinSets","results","symbols","addToSet","target","source","EPSILON","epsilon","diff","abs","approxZero","smartTrim","str","minIndent","lines","split","shift","pop","indent","acc","lineIndent","Infinity","slice","trimEnd","assertArray","assertStringArray","every","v","isStringArray","assertCharArray","isCharArray","chain","fn","Promise","then","mapSequential","arr","chainRemainingMap","push","async","currentPromise","startIndex","reduceSequential","initial","next","chainRemainingReduce","forEachSequential","chainRemainingForEach","tryCatch","tryFn","catchFn","catch","error","someSequential","chainRemainingSome","everySequential","chainRemainingEvery","filterSequential","chainRemainingFilter","findIndexSequential","chainRemainingFindIndex","collectionNormalExpression","executeFunction","elem","keep","filtered","fun","at","colls","obj","objKeys","includes","mapObjects","seqs","isStr","len","seq","paramArray","mapped","p","resolvedMapped","get","defaultValue","assoc","copy","kvs","concat","assign","arrayNormalExpression","second","third","from","to","step","flatten","depth","actualDepth","POSITIVE_INFINITY","flat","mapcat","windowSize","windows","window","subArrays","subArr","sequenceNormalExpression","nth","n","last","substring","index","indexOf","findIndex","reverse","start","stop","some","found","sort","_contextStack","_executeFunction","defaultComparer","comparer","compareValue","TypeError","take","input","drop","taken","annotatedArrays","WeakSet","vectors","notVectors","matrices","notMatrices","grids","notGrids","annotate","isVector","isMatrix","isGrid","vector","assertVector","assert2dVector","is2dVector","assert3dVector","is3dVector","assertNonEmptyVector","grid","nbrOfCols","row","assertGrid","matrix","cell","assertMatrix","assertSquareMatrix","getNumberVectorOrMatrixOperation","hasVector","hasMatrix","rows","cold","unaryMathOp","operation","operands","binaryMathOp","j","reduceMathOp","identity","m","mathNormalExpression","inc","dec","xs","firstVector","firstMatrix","quot","trunc","mod","floor","sqrt","cbrt","round","decimals","factor","isEqual","firstAny","miscNormalExpression","ys","isIdentical","currentValue","not","ms","Date","toISOString","dateTime","valueOf","iso","console","log","pure","boolean","parse","objectNormalExpression","vals","dissoc","newObj","merge","objs","res","merged","r","zipmap","predicatesNormalExpression","NEGATIVE_INFINITY","table","regexpNormalExpression","sourceArg","flagsArg","flags","e","pattern","text","assertRegularExpression","exec","replace","matcher","replaceAll","blankRegexp","stringNormalExpression","number","toLowerCase","toUpperCase","trim","stringList","delimiter","stringOrRegExpValue","limit","test","functionalNormalExpression","apply","comp","fns","constantly","generateDocString","reference","title","_isOperator","functionForms","variant","argName","operatorForm","signature","arg","argStrings","example","argType","typeString","vectorNormalExpression","sum","prod","mean","median","sorted","mid","calcMedian","expressions","normalExpressionReference","doc","docString","getMetaNormalExpression","expression","normalExpressions","normalExpressionTypes","allNormalExpressions","andSpecialExpression","evaluateAsNormalExpression","condSpecialExpression","customVariants","details","bindingTargetTypes","walkDefaults","bindingTarget","onDefault","element","evaluateBindingNodeValues","record","createRecord","assertUnknownRecord","capturedKeys","restElement","existingVal","resolvedVal","restValues","restIndex","elements","getAllBindingTargetNames","names","getNamesFromBindingTarget","tryMatch","tryMatchRecord","matched","literalNode","literalValue","defaultNode","arrayTarget","el","matchSpecialExpression","guard","newContext","caseContextStack","create","definedSpecialExpression","doSpecialExpression","lambdaSpecialExpression","self","newContextStack","overloadResult","getFunctionUnresolvedSymbols","ifSpecialExpression","unlessSpecialExpression","letSpecialExpression","bindingNode","bindingResult","addValues","loopSpecialExpression","bindingNodes","context","analyze","loopNode","loopBindings","loopBindingNode","letBindings","whenNode","whileNode","letBindingNode","letTarget","letValue","forDocs","forSpecialExpression","doseqDocs","doseqSpecialExpression","orSpecialExpression","qqSpecialExpression","recurSpecialExpression","throwSpecialExpression","expr","trySpecialExpression","tryExpression","errorSymbol","catchExpression","withHandlers","tryResult","catchResult","withResult","effectExpr","handlerFn","arraySpecialExpression","effectSpecialExpression","objectSpecialExpression","kvps","parallelSpecialExpression","branch","performSpecialExpression","argExprs","raceSpecialExpression","normalExpressionKeys","specialExpressionKeys","phi","numberReservedSymbolRecord","E","PI","PHI","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","MAX_VALUE","MIN_VALUE","NaN","reservedSymbolRecord","true","false","null","do","else","case","each","in","when","while","function","as","end","with","_","SuspensionSignal","k","meta","_brand","isSuspensionSignal","internMap","Map","getEffectRef","ref","set","ContextStackImpl","_contexts","globalContext","nativeJsFunctions","modules","valueModules","contexts","hostValues","getContextsRaw","getHostValues","getGlobalContextIndex","fromDeserialized","cs","globalContextIndex","setContextsFromDeserialized","getModule","getValueModule","registerValueModule","currentContext","shadowedName","getShadowedBuiltinName","getValue","contextEntry","nativeJsFunction","hostValue","evaluateSymbol","specialExpression","specialBuiltinSymbolType","normalExpression","normalBuiltinSymbolType","lookUpResult","assertNotShadowingBuiltin","createContextStack","bindings","identifier","jsFunction","nativeFn","globalModuleScope","describeSerializationIssue","path","partial","fnIssue","paramIssue","juxt","everyPred","somePred","fnull","issue","serializeSuspension","csMap","nextId","collectContextStacks","ctx","serializeValue","__csRef","serializedContextStacks","id","ctxIdx","serialized","serializedK","serializedMeta","blobData","version","contextStacks","standardEffectHandlers","_args","now","random","resolve","setTimeout","evaluateNodeRecursive","evaluateReservedSymbol","paramNodes","placeholders","paramNode","spreadValue","evaluateParamsRecursive","nameSymbol","resolvedFn","executeFunctionRecursive","evaluateNormalExpressionRecursive","resolved","env","runSyncTrampoline","runAsyncTrampoline","executeDvalaFunctionRecursive","evaluateArrayAsFunction","evaluateObjectAsFunction","evaluateStringAsFunction","evaluateNumberAsFunction","executeUserDefinedRecursive","actualParams","paramsCopy","placeholderIndex","splice","executePartialRecursive","currentParams","finalArr","executeCompRecursive","executeJuxtRecursive","checks","check","executeEveryPredRecursive","executeSomePredRecursive","fnulledParams","executeFnullRecursive","executeBuiltinRecursive","executeSpecialBuiltinRecursive","dvalaModule","moduleName","functions","functionName","executeModuleRecursive","executeNativeJsFunctionRecursive","setupAndExecute","evaluatedFunction","evaluatedfunction","nbrOfNonRestArgs","paramSetup","defaultSetup","paramIndex","valueRecord","argIndex","restArgument","restSetup","newContextStack2","bodyResult","_acc","reservedName","stepNode","argNodes","nanFrame","evalArgsFrame","dispatchCall","firstArg","newK","stepNormalExpression","conditionNode","thenNode","elseNode","inverted","frame","firstNode","nextNode","advanceQq","skipUndefinedQq","cases","phase","matchValueNode","matchValue","newEnv","bindingContext","returnResult","bindingLevel","levelStates","withHandlerNodes","withFrame","handlers","handlerNode","effectRef","catchFrame","catchNode","handleRecur","singleFrame","isFirstSpread","isSpread","currentKey","evaluatedFunc","functionContext","new","evaluateFunction","valueModule","allNodes","branches","stepSpecialExpression","builtinType","wrapMaybePromiseAsStep","dispatchFunction","setupUserDefinedCall","dispatchDvalaFunction","bodyNodes","bodyEnv","fnBodyFrame","bodyIndex","outerEnv","applyFrame","_value","newFrame","applySequence","condition","applyIfBranch","nextIndex","applyCond","processMatchCase","applyMatch","applyAnd","applyOr","applyQq","isNextSpread","applyArrayBuild","valueNode","applyObjectBuild","br","applyLetBind","vr","loopEnv","applyLoopBind","_frame","applyLoopIterate","handleForAbort","collection","binding","processForLetBindings","processForGuards","advanceForElement","processForNextLevel","applyForLoop","unwindToTryCatch","applyThrow","applyRecur","assertEffectRef","applyPerformArgs","applyTryWith","resumeK","applyEffectResume","branchCount","completedBranches","suspendedBranches","applyParallelResume","currentArgNode","nextArg","applyEvalArgs","applyCallFn","applyFnBody","applyBindingDefault","applyNanCheck","stepInfo","extractBindings","awaitFrame","applyDebugStep","currentLevel","currentState","nextElementIndex","letIndex","bindingIndex","bindingValue","nextLevel","catchContext","remainingK","rebindAll","innermostContext","newIterateFrame","dispatchPerform","signal","handler","skipEnd","handlerK","standardHandler","effectName","throwSuspension","runBranch","debugMode","tick","blob","runEffectLoop","effectSignal","AbortController","branchPromises","allSettled","errors","status","reason","resultArray","executeParallelBranches","parentSignal","branchControllers","onParentAbort","ctrl","abort","addEventListener","once","winnerIndex","winnerValue","branchSignal","suspendedMetas","messages","removeEventListener","executeRaceBranches","completedIndices","suspendedIndices","currentBranchIndex","updatedCompleted","nextSuspended","handleParallelResume","buildInitialStep","sequenceFrame","binaryOperators","symbolicOperators","nonFunctionOperatorSet","isFunctionOperator","operator","binaryOperatorSet","isBinaryOperator","symbolicOperatorSet","isSymbolicOperator","illegalSymbolCharacters","illegalFirstSymbolCharacters","illegalSymbolCharacterSet","illegalFirstSymbolCharacterSet","whitespaceRegExp","NO_MATCH","tokenizeString","escaping","tokenizeToken","decimalNumberRegExp","octalNumberRegExp","hexNumberRegExp","binaryNumberRegExp","postNumberRegExp","tokenizeSymbol","initialPosition","endsWith","tokenizers","symbolMeta","startsWith","nextThreeChars","stringLength","token","baseChar","nextChar","negate","plusPrefix","hasDecimalPoint","hasExponent","threeChars","twoChars","oneChar","createSourceCodeInfo","lastLine","lineNbr","getSourceCodeLine","getCurrentToken","nbrOfCharacters","tokenizeShebang","tokenizer","isSymbolToken","asSymbolToken","throwUnexpectedToken","assertSymbolToken","isReservedSymbolToken","assertReservedSymbolToken","asReservedSymbolToken","isOperatorToken","operatorName","assertOperatorToken","isNumberToken","isBasePrefixedNumberToken","isLParenToken","assertLParenToken","isRParenToken","assertRParenToken","isLBracketToken","asLBracketToken","assertLBracketToken","isRBracketToken","assertRBracketToken","isLBraceToken","asLBraceToken","assertLBraceToken","isRBraceToken","isStringToken","isA_BinaryOperatorToken","expected","expectedValue","actual","actualOutput","minifyTokenStream","tokenStream","removeWhiteSpace","tokens","isSingleLineCommentToken","isMultiLineCommentToken","isShebangToken","isWhitespaceToken","dvalaCommands","AutoCompleter","originalProgram","originalPosition","prefixProgram","suffixProgram","searchString","suggestions","suggestionIndex","dvala","partialProgram","lastToken","tokenize","generateSuggestions","getNextSuggestion","getAutoCompleteSuggestionResult","getNextSuggestionSymbol","getPreviousSuggestion","getPreviousSuggestionSymbol","suggestion","program","getSuggestions","getSearchString","blacklist","startsWithCaseSensitive","generateWithPredicate","startsWithCaseInsensitive","includesCaseSensitive","includesCaseInsensitive","shouldInclude","localeCompare","isDvalaBundle","fileModules","withSourceCodeInfo","stringToSymbolNode","stringFromQuotedSymbol","backslash","singleQuote","normalChar","normalExpressionNames","specialExpressionNames","getSymbolName","createNamedNormalExpressionNode","isAtExpressionEnd","isAtEnd","tryPeek","fromBinaryOperatorToNode","left","right","ParserContext","storedPosition","parseExpression","advance","peek","peekSourceCodeInfo","currentToken","storePosition","restorePosition","peekAhead","getPosition","getTokenAt","pos","getPrecedence","operatorSign","parseImplicitBlock","ends","isImplicitBlockEnd","assertImplicitBlockEnd","parseString","doubleQuote","newline","tab","carriageReturn","backspace","formFeed","parseDo","allowDocString","isDocStringToken","stringToken","stringNode","parseDocString","parseSymbol","parseNumber","numberString","parseBindingTarget","requireDefaultValue","noRest","allowLiteralPatterns","firstToken","isLiteralToken","parseOptionalDefaulValue","keySymbol","keyName","parseLet","parseForLoopBinding","parseBinding","modifiers","assertInternalLoopBindingDelimiter","letNode","existingBoundNames","flatMap","isInternalLoopBindingDelimiter","symbolsString","parseReservedSymbol","isNumberReservedSymbol","placeholderRegexp","parseLambdaFunction","functionArguments","defaults","parseFunctionArguments","parsedDo","parseFunctionCall","nextToken","parseEffectArgs","parseObject","parseOperand","operand","lamdaFunction","startPos","endPos","dollar1","parseShorthandLambdaFunction","parseArray","tokenType","endStringPosition","lastIndexOf","regexpString","optionsString","optionsNode","parseRegexpShorthand","parseOperandPart","symbolToken","createAccessorNode","precedence","isUnless","thenExpression","elseExpression","parseIfOrUnless","caseExpression","parseCond","valueExpression","parseMatch","isDoseq","forLoopBindings","loopBinding","newBoundNames","parseForOrDoseq","parseLoop","parseTry","newPrecedece","newPrecedence","operatorSymbol","trueNode","falseNode","createParserContext","Cache","cache","firstEntry","lastEntry","_size","maxSize","getContent","size","clear","newEntry","nextEntry","dropFirstEntry","Dvala","astCache","astCacheSize","debug","config","initialCache","cacheEntry","nsList","ns","getRuntimeInfo","run","programOrBundle","runBundle","generateAst","evaluateAsync","fnParams","bundle","savedPure","programOrAst","tokenizeParams","hasDebugData","tokenDescriptor","minify","transformSymbols","transformer","tokenStram","transformSymbolTokens","untokenize","fnName","generateApplyFunctionCall","paramsString","cachedAst","getAutoCompleter","moduleDocs","assertNormalExpression","throwMessage","errorMessage","assertModule","col","shape","g","fill","cols","generate","reshape","transpose","rotate","crop","begin","deleteCount","items","gridFunctions","predicate","cells","transposed","generator","__","flatTable","times","height","width","y","rowStart","colStart","rowEnd","colEnd","trMatrix","rowDeleteCount","colDeleteCount","initialValue","accumulator","flatArray","fromArray","gridModule","prob","stdDev","lambda","scale","alpha","charSet","randomFunctions","probability","randomIndex","copyArray","shuffledArray","u1","u2","cos","u","L","exp","randomGamma","chars","padStart","d","randn","randomModule","variance","stdev","iqr","span","skewness","kurtosis","rms","mad","medad","entropy","mode","linspace","cumsum","cumprod","quartiles","percentile","quantile","histogram","bins","ecdf","threshold","outliers","bincount","minSize","weights","winsorize","mse","rmse","mae","smape","q1Index","q1","q3Index","q3","lowerBound","upperBound","calcPercentile","data","sortedData","lowerIndex","upperIndex","weight","midIndex","q2","lowerHalf","upperHalf","midLower","midUpper","calcMean","geometricMeanReductionFunction","medianReductionFunction","calcVariance","optionalMean","varianceReductionFunction","sampleVarianceReductionFunction","calcSampleVariance","minLength","calcStdDev","stdevReductionFunction","sampleStdevReductionFunction","calcSampleStdDev","iqrReductionFunction","spanReductionFunction","skewnessReductionFunction","sampleSkewnessReductionFunction","sumSquaredDiffs","sumCubedDiffs","sampleVariance","sampleStdDev","sampleSkewness","kurtosisReductionFunction","eccessKurtosisReductionFunction","excessKurtosis","sampleKurtosisReductionFunction","sampleKurtosis","sampleExcessKurtosisReductionFunction","sampleExcessKurtosis","rmsReductionFunction","madReductionFunction","calcMad","calcMedad","medadReductionFunction","giniCoefficientReductionFunction","entropyReductionFunction","frequencies","total","frequency","log2","calculateEntropy","reductionFunctionNormalExpressions","addReductionFunctions","reductionFn","baseKey","movingKey","centeredMovingKey","runningKey","createReductionNormalExpression","createMovingNormalExpression","createCenteredMovingNormalExpression","padding","createRunningNormalExpression","reductionFunction","halfWindowSize","paddedVector","nullsCount","vectorFunctions","frequencyMap","maxFrequency","modes","countDiff","numPoints","binSize","binStart","binEnd","calcHistogram","hasOutliers","maxValue","outputLength","counts","lowerQuantile","upperQuantile","vectorA","vectorB","denom","sequences","vectorModule","reflect","refract","axis","eta","lerp","t","rotate2d","rotate3d","radians","dot","cross","angle","projection","cov","corr","autocorrelation","lag","rref","solve","polar","gaussJordanElimination","rank","rowsProcessed","pivotRow","pivotValue","areVectorsCollinear","isZeroVector","vec","component","ratio","pearsonCorr","meanA","meanB","sumNumerator","sumSquareA","sumSquareB","diffA","diffB","calcFractionalRanks","indices","ranks","currentRank","averageRank","calcCovariance","segmentA","segmentB","getUnit","vector1","vector2","subtract","scalar","linearAlgebraNormalExpression","cosTheta","sinTheta","sin","w","dotProduct","normal","unitNormal","normalizedV","normalizedNormal","discriminant","norm","magnitudeA","magnitudeB","acos","areVectorsParallel","ranksA","ranksB","concordant","discordant","tiesInA","tiesInB","isTieA","isTieB","n1","n2","kendallTau","absLag","numerator","laggedIndex","denominator","overlapLength","extractOverlappingSegments","stdA","stdB","calcCorrelation","A","augmented","echelon","atan2","theta","linearAlgebraModule","mul","det","inv","adj","cofactor","minor","trace","hilbert","vandermonde","band","lband","uband","determinant","maxRow","minorRow","adjugate","isSquare","isIdentity","matrixMultiply","B","C","aik","matrixNormalExpression","matrix1","matrix2","inverseMatrix","inverse","cofactors","isSymetric","isUpperTriangular","isLowerTriangular","isTriangular","isTriangularUpper","isTriangularLower","isDiagonal","isOrthogonal","isSquareMatrix","maxBand","lower","upper","isBanded","rowSum","numRows","numCols","maxColSum","colSum","norm1","maxVal","rowMax","matrixModule","takeWhile","term","sides","combinations","derangements","divisors","factorial","partitions","permutations","gcd","lcm","multinomial","mobius","mertens","sigma","sets","base","exponent","modulus","remainders","moduli","binomialCoefficient","current","subCombinations","subComb","combinationsNormalExpressions","derangementsNormalExpressions","used","temp","generateDerangements","getAllDerangements","countDerangements","calcUnsortedDivisors","getDivisors","getProperDivisors","divisorsNormalExpressions","factorialNumbers","factorialOf","factorialNormalExpressions","partitionNumbers","partitionsNormalExpressions","generatePartitions","remaining","subPermutations","subPerm","permutationsNormalExpressions","powerSetNormalExpressions","newSubsets","subset","powerSet","primeFactors","factors","divisor","primeFactorsNormalExpressions","distinctFactors","isAbundant","curr","abundantSequence","abundants","arithmeticNormalExpressions","arithmetic","roundedPosition","calculatedValue","isInArithmeticSequence","getBernoulliSeq","bernoulli","bernoulliNormalExpressions","newValue","generateBernoulli","isPrime","primeSequence","primes","isComposite","compositeSequence","composites","isDeficient","deficientSequence","deficients","geometricNormalExpressions","geometric","initialTerm","logResult","roundedLogResult","expectedSign","isInGeometricSequence","golombSequence","golomb","getGolombSeq","pred","keepFirst","golombNumber","generateGolombSeq","isHappyNumber","seen","getSumOfSquaredDigits","digit","happySequence","happyNumbers","jugglerSequence","juggler","noNth","getNextLookAndSayTerm","lookAndSaySequence","string","lookAndSay","isLookAndSay","generateLuckyNumbers","numbers","filteredNumbers","luckyNumbers","luckyNumber","newFiltered","luckySequence","initialSize","sieveIndex","sieveValue","getLuckyNumbers","l","padovanSequence","padovan","padovanNumbers","isSafeInteger","isPadovan","keep0","keep1","keep2","perfectCubeSequence","perfectcubes","perfectPower","maxK","roundedB","perfectPowerSequence","perfectPowers","perfectSquareSequence","perfectSquares","poligonalNormalExpressions","polygonal","sqrtPart","recamanSequence","sequence","generateRecamanSequence","thueMorseSequence","thueMorse","countSetBits","sequenceNormalExpressions","addNormalExpressions","getFiniteNumberSequence","createSeqNormalExpression","createTakeWhileNormalExpression","createNthNormalExpression","createNumberPredNormalExpression","addSequence","maxLength","createStringPredNormalExpression","seqFunction","takeWhileFunction","predFunction","extendedGcd","modInverse","collatz","combinatoricalNormalExpression","sumA","sumB","factorMap","prime","lambdaValues","modExp","extGcd","product","ai","ni","bi","chineseRemainder","dp","addSequences","numberTheoryModule","mathUtilsModule","asin","sinh","asinh","cosh","acosh","tan","atan","tanh","atanh","ln","log10","functionalUtilsModule","aMin","aMax","bMin","bMax","getCommonArityFromFunctions","complement","stringUtilsFunctions","int","fromCodePoint","codePointAt","padString","padEnd","template","templateString","templateStrings","applyPlaceholders","stringPlaceholders","btoa","encodeURIComponent","_match","p1","fromCharCode","parseInt","decodeURIComponent","call","atob","charCodeAt","base64string","capitalize","charAt","doubleDollarRegexp","re","placeHolder","stringUtilsModule","update","intKey","cloneAndGetMeta","originalColl","innerCollMeta","resultColl","newResultColl","parent","collectionUtilsModule","nextValue","lastKey","parentKey","ks","updated","filteri","mapi","reducei","reductions","newVal","reductionsi","toIndexedItem","sequenceUtilsFunctions","findLastIndex","keyfn","indexed","unshift","distinct","existingItem","remove","seqIsArray","partition","pad","asArray","partitionHelper","isStringSeq","oldValue","search","suffix","prefix","interleave","seqsArr","interpose","separator","outer","innerArr","padIndex","sequenceUtilsModule","bitwiseUtilsModule","angleUnits","baseUnit","units","deg","rad","grad","turn","celsiusTo","unit","toCelsius","temperatureUnits","unitDescriptions","angstrom","um","mm","cm","km","ft","yd","mi","nmi","mg","kg","oz","lb","st","ml","cl","dl","tsp","tbsp","cup","pt","qt","gal","h","day","week","mm2","cm2","m2","km2","in2","ft2","yd2","acre","hectare","mph","kn","kb","mb","gb","tb","pb","pa","kpa","bar","atm","psi","mmhg","kj","cal","kcal","wh","kwh","btu","kw","mw","hp","hz","khz","mhz","ghz","generateLinearConversions","unitNames","conversionFactor","fromDesc","toDesc","allBuiltinModules","celsius","generateTemperatureConversions","readDvalaFile","dvalaPath","fs","readFileSync","encoding","getErrorYaml","getErrorMessage","isAbstractDvalaError","formattedMessage","terms","getLocation","testPath","testNamePattern","includedFilePaths","absoluteFilePath","getIncludesRecursively","includeFilePaths","fileContent","dirname","okToInclude","includeMatch","relativeFilePath","readIncludeDirectives","includeFilePath","getIncludedFilePaths","testResult","tap","success","testChunks","testProgram","currentTest","setupCode","currentLineNbr","testNameAnnotationMatch","directive","testName","chunk","getTestChunks","testChunkProgram","testNumber","getBindings"],"mappings":"6DAEM,SAAUA,EAAcC,GAC5B,IAAKA,EAAeC,WAAaD,EAAeE,KAC9C,MAAO,GAET,MAAMC,EAAcH,EAAeC,SAASG,OAAS,EAC/CC,EAAeL,EAAeE,KAAKI,OAASH,EAAc,EAChE,MAAO,GAAG,IAAII,OAAOC,KAAKC,IAAIN,EAAa,OAAO,IAAII,OAAOC,KAAKC,IAAIJ,EAAc,KACtF,CCQM,MAAOK,UAAoBC,MACxBC,OACP,WAAAC,CAAYD,GACVE,MAAM,kBAAkBF,KACxBG,OAAOC,eAAeC,KAAMP,EAAYQ,WACxCD,KAAKE,KAAO,cACZF,KAAKL,OAASA,CACf,EAGG,MAAOQ,UAAmBT,MACdX,eACAqB,aAChB,WAAAR,CAAYS,EAActB,GACxB,MAAMuB,EAAUD,aAAeX,MAC3BW,EAAIC,QACJ,GAAGD,IAEPR,MA/BJ,SAA8BS,EAAiBvB,GAC7C,IAAKA,EACH,OAAOuB,EAET,MAAMC,EAAW,GAAGxB,EAAeC,SAASwB,QAAQzB,EAAeC,SAASG,SAM5E,MAAO,GAAGmB,IALWvB,EAAe0B,SAChC,KAAK1B,EAAe0B,YAAYF,IAChC,cAAcA,QACIxB,EAAeE,SACbH,EAA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AAQtd,EAAgB,CAAEmL,QAAQ,EAAMF,SAAS,EAAMM,UAAU,IACvEk4C,GAAqBnmC,GAAQhd,OAAS,GAE/C6J,MAAO2C,GAAa,KCtDX+2C,GAAmB,CAC9B,EACA,EACA,EACA,EACA,GACA,IACA,IACA,KACA,MACA,OACA,QACA,SACA,UACA,WACA,YACA,aACA,cACA,eACA,iBCdI,SAAUC,GAAYluC,GAC1B,GAAIA,EAAI,EACN,MAAM,IAAIjV,MAAM,iDAElB,GAAU,IAANiV,GAAiB,IAANA,EACb,OAAO,EAET,GAAIA,GAAK,GACP,OAAOiuC,GAAiBjuC,GAE1B,IAAInI,EAASo2C,GAAiB,IAC9B,IAAK,IAAI31C,EAAI,GAAIA,GAAK0H,EAAG1H,IACvBT,GAAUS,EAEZ,OAAOT,CACT,CAEO,MAAMs2C,GAAuD,CAClEhC,UAAW,CACT73C,SAAU,EAAE0L,GAAI5V,KACd+L,GAAa6J,EAAG5V,EAAgB,CAAEiL,SAAS,EAAMS,aAAa,EAAMI,IAAK,MAClEg4C,GAAYluC,IAErBzL,MAAO2C,GAAa,KC5BXk3C,GAAmB,CAC9B,EACA,EACA,EACA,EACA,EACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,OACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,QACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,SACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,UACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,WACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,YACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,aACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,cACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,eACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,iBACA,iBACA,iBACA,iBACA,iBACA,iBACA,iBACA,iBACA,iBACA,kBCzQK,MAAMC,GAAwD,CACnEjC,WAAc,CACZ93C,SAAU,EAAE0L,GAAI5V,KACd+L,GAAa6J,EAAG5V,EAAgB,CAAEiL,SAAS,EAAMS,aAAa,IA/BpE,SAAoBkK,GAElB,GAAIA,GAAK,EACP,MAAO,CAAC,IACV,GAAU,IAANA,EACF,MAAO,CAAC,CAAC,IAEX,MAAMnI,EAAqB,GAkB3B,OAfA,SAASy2C,EAA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B,GAAYpB,IACZoB,GAAYjF,IACZiF,GAAYb,IACZa,GAAYV,IACZI,GAAqBC,GAAwB,aDhGZ,CAC/B,EACA,EACA,EACA,EACA,EACA,EACA,GACA,GACA,GACA,GACA,IACA,IACA,IACA,IACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,OACA,QACA,QACA,QACA,QACA,SACA,SACA,SACA,SACA,UACA,UACA,UACA,WACA,WACA,WACA,WACA,YACA,YACA,YACA,YACA,aACA,aACA,aACA,aACA,cACA,cACA,cACA,cACA,eACA,eACA,eACA,eACA,eACA,gBACA,gBACA,gBACA,gBACA,iBACA,oBCkCFD,GAAqBC,GAAwB,UGjGf,CAC5B,EACA,EACA,EACA,GACA,GACA,IACA,IACA,KACA,KACA,MACA,MACA,OACA,OACA,QACA,QACA,SACA,UACA,UACA,WACA,WACA,YACA,YACA,aACA,cACA,cACA,eACA,eACA,eACA,gBACA,mBHoEFD,GAAqBC,GAAwB,YAAa9G,KAC1D6G,GAAqBC,GAAwB,YInGb,CAC9B,EACA,EACA,EACA,EACA,EACA,EACA,EACA,GACA,GACA,GACA,GACA,GACA,IACA,IACA,IACA,IACA,IACA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,OACA,OACA,QACA,QACA,QACA,QACA,QACA,SACA,SACA,SACA,SACA,UACA,UACA,UACA,UACA,UACA,WACA,WACA,WACA,WACA,WACA,YACA,YACA,YACA,YACA,YACA,aACA,aACA,aACA,aACA,aACA,cACA,cACA,cACA,cACA,cACA,cACA,eACA,eACA,eACA,eACA,eACA,gBACA,gBACA,gBACA,gBACA,gBACA,gBACA,iBACA,oBJqBFD,GAAqBC,GAAwB,QKpGjB,CAC1B,EACA,EACA,EACA,EACA,EACA,GACA,GACA,GACA,GACA,GACA,IACA,IACA,IACA,IACA,IACA,KACA,KACA,KACA,KACA,KACA,MACA,MACA,MACA,MACA,OACA,OACA,OACA,OACA,OACA,QACA,QACA,QACA,QACA,QACA,SACA,SACA,SACA,SACA,SACA,UACA,UACA,UACA,UACA,UACA,WACA,WACA,WACA,WACA,YACA,YACA,YACA,YACA,YACA,aACA,aACA,aACA,aACA,aACA,cACA,cACA,cACA,cACA,cACA,cACA,eACA,eACA,eACA,eACA,eACA,eACA,gBACA,gBACA,gBACA,gBACA,gBACA,iBACA,oBLwBFD,GAAqBC,GAAwB,WMrGd,CAAC,EAAG,EAAG,GAAI,IAAK,KAAM,KAAM,OAAQ,OAAQ,cNsG3ED,GAAqBC,GAAwB,YAAa3G,KAC1D0G,GAAqBC,GAAwB,OOvGlB,CACzB,EACA,EACA,EACA,GACA,GACA,GACA,IACA,IACA,IACA,KACA,KACA,MACA,MACA,MACA,OACA,OACA,QACA,QACA,QACA,SACA,SACA,SACA,UACA,UACA,WACA,WACA,WACA,YACA,YACA,aACA,aACA,aACA,cACA,cACA,cACA,eACA,eACA,eACA,gBACA,gBACA,gBACA,mBP8DFD,GAAqBC,GAAwB,UQxGf,CAAC,EAAG,GAAI,IAAK,KAAM,SAAU,WAAY,gBRyGvED,GAAqBC,GAAwB,YSzGb,CAC9B,EACA,EACA,GACA,KACA,QACA,iBToGFD,GAAqBC,GAAwB,OU1GlB,CACzB,EACA,EACA,EACA,GACA,GACA,IACA,IACA,KACA,MACA,OACA,OACA,QACA,SACA,UACA,WACA,YACA,YACA,aACA,cACA,eACA,gBACA,oBVqFFD,GAAqBtF,IACrBsF,GAAqB/E,IACrB+E,GAAqBnE,IACrBmE,GAAqBV,IC2Cd,MAAMyB,GAA2D,CACtE,WAAY,CACVvhD,SAAU,EAAE+C,EAAGC,GAAIlN,KACjB+L,GAAakB,EAAGjN,EAAgB,CAAEiL,SAAS,IAC3Cc,GAAamB,EAAGlN,EAAgB,CAAEiL,SAAS,IACtB,IAAdi3C,GAAIj1C,EAAGC,IAEhB/C,MAAO2C,GAAa,IAEtB,gBAAiB,CACf5C,SAAU,EAAE/E,EAAO0/C,GAAU7kD,KAC3B+L,GAAa5G,EAAO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