@mojir/dvala 0.0.9 → 0.0.12

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 (1139) hide show
  1. package/dist/cli/cli.js +33054 -36909
  2. package/package.json +194 -31
  3. package/dist/bundler.esm.js +0 -2
  4. package/dist/bundler.esm.js.map +0 -1
  5. package/dist/bundler.js +0 -2
  6. package/dist/bundler.js.map +0 -1
  7. package/dist/cli/cli/src/cli.d.ts +0 -2
  8. package/dist/cli/cli/src/cliDocumentation/formatCliDescription.d.ts +0 -3
  9. package/dist/cli/cli/src/cliDocumentation/getCliArgumentInfo.d.ts +0 -3
  10. package/dist/cli/cli/src/cliDocumentation/getCliDocumentation.d.ts +0 -2
  11. package/dist/cli/cli/src/cliDocumentation/getCliFunctionExamples.d.ts +0 -3
  12. package/dist/cli/cli/src/cliDocumentation/getCliFunctionSignature.d.ts +0 -3
  13. package/dist/cli/cli/src/cliDocumentation/getCliTitle.d.ts +0 -3
  14. package/dist/cli/cli/src/cliDocumentation/getCliType.d.ts +0 -3
  15. package/dist/cli/cli/src/cliFormatterRules.d.ts +0 -13
  16. package/dist/cli/cli/src/colorizer.d.ts +0 -939
  17. package/dist/cli/cli/src/createReadlineInterface.d.ts +0 -5
  18. package/dist/cli/cli/src/js-interop/Cli/Fs/index.d.ts +0 -2
  19. package/dist/cli/cli/src/js-interop/Cli/Proc/index.d.ts +0 -3
  20. package/dist/cli/cli/src/js-interop/Cli/index.d.ts +0 -2
  21. package/dist/cli/common/createFormatter.d.ts +0 -6
  22. package/dist/cli/common/utils.d.ts +0 -2
  23. package/dist/cli/reference/api.d.ts +0 -73
  24. package/dist/cli/reference/datatype.d.ts +0 -3
  25. package/dist/cli/reference/examples.d.ts +0 -11
  26. package/dist/cli/reference/index.d.ts +0 -195
  27. package/dist/cli/reference/shorthand.d.ts +0 -3
  28. package/dist/cli/src/AutoCompleter/AutoCompleter.d.ts +0 -27
  29. package/dist/cli/src/Cache.d.ts +0 -16
  30. package/dist/cli/src/allModules.d.ts +0 -2
  31. package/dist/cli/src/builtin/bindingNode.d.ts +0 -11
  32. package/dist/cli/src/builtin/core/array.d.ts +0 -2
  33. package/dist/cli/src/builtin/core/assertion.d.ts +0 -2
  34. package/dist/cli/src/builtin/core/bitwise.d.ts +0 -2
  35. package/dist/cli/src/builtin/core/collection.d.ts +0 -2
  36. package/dist/cli/src/builtin/core/functional.d.ts +0 -2
  37. package/dist/cli/src/builtin/core/math.d.ts +0 -2
  38. package/dist/cli/src/builtin/core/meta.d.ts +0 -3
  39. package/dist/cli/src/builtin/core/misc.d.ts +0 -2
  40. package/dist/cli/src/builtin/core/object.d.ts +0 -2
  41. package/dist/cli/src/builtin/core/predicates.d.ts +0 -2
  42. package/dist/cli/src/builtin/core/regexp.d.ts +0 -2
  43. package/dist/cli/src/builtin/core/sequence.d.ts +0 -2
  44. package/dist/cli/src/builtin/core/string.d.ts +0 -2
  45. package/dist/cli/src/builtin/core/vector.d.ts +0 -2
  46. package/dist/cli/src/builtin/index.d.ts +0 -13
  47. package/dist/cli/src/builtin/interface.d.ts +0 -113
  48. package/dist/cli/src/builtin/modules/assertion/docs.d.ts +0 -2
  49. package/dist/cli/src/builtin/modules/assertion/index.d.ts +0 -2
  50. package/dist/cli/src/builtin/modules/bitwise/index.d.ts +0 -2
  51. package/dist/cli/src/builtin/modules/collection/index.d.ts +0 -2
  52. package/dist/cli/src/builtin/modules/convert/index.d.ts +0 -2
  53. package/dist/cli/src/builtin/modules/functional/index.d.ts +0 -2
  54. package/dist/cli/src/builtin/modules/grid/docs.d.ts +0 -2
  55. package/dist/cli/src/builtin/modules/grid/fromArray.d.ts +0 -8
  56. package/dist/cli/src/builtin/modules/grid/index.d.ts +0 -2
  57. package/dist/cli/src/builtin/modules/grid/transpose.d.ts +0 -2
  58. package/dist/cli/src/builtin/modules/interface.d.ts +0 -28
  59. package/dist/cli/src/builtin/modules/linear-algebra/docs.d.ts +0 -2
  60. package/dist/cli/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +0 -1
  61. package/dist/cli/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +0 -2
  62. package/dist/cli/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +0 -8
  63. package/dist/cli/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +0 -4
  64. package/dist/cli/src/builtin/modules/linear-algebra/helpers/dot.d.ts +0 -1
  65. package/dist/cli/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +0 -7
  66. package/dist/cli/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +0 -2
  67. package/dist/cli/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +0 -1
  68. package/dist/cli/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +0 -10
  69. package/dist/cli/src/builtin/modules/linear-algebra/helpers/length.d.ts +0 -1
  70. package/dist/cli/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +0 -1
  71. package/dist/cli/src/builtin/modules/linear-algebra/helpers/scale.d.ts +0 -1
  72. package/dist/cli/src/builtin/modules/linear-algebra/helpers/solve.d.ts +0 -8
  73. package/dist/cli/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +0 -1
  74. package/dist/cli/src/builtin/modules/linear-algebra/index.d.ts +0 -4
  75. package/dist/cli/src/builtin/modules/math/index.d.ts +0 -2
  76. package/dist/cli/src/builtin/modules/matrix/docs.d.ts +0 -2
  77. package/dist/cli/src/builtin/modules/matrix/helpers/adjugate.d.ts +0 -1
  78. package/dist/cli/src/builtin/modules/matrix/helpers/band.d.ts +0 -9
  79. package/dist/cli/src/builtin/modules/matrix/helpers/cofactor.d.ts +0 -1
  80. package/dist/cli/src/builtin/modules/matrix/helpers/determinant.d.ts +0 -6
  81. package/dist/cli/src/builtin/modules/matrix/helpers/inverse.d.ts +0 -6
  82. package/dist/cli/src/builtin/modules/matrix/helpers/isBanded.d.ts +0 -11
  83. package/dist/cli/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +0 -10
  84. package/dist/cli/src/builtin/modules/matrix/helpers/isIdentity.d.ts +0 -1
  85. package/dist/cli/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +0 -1
  86. package/dist/cli/src/builtin/modules/matrix/helpers/isSquare.d.ts +0 -1
  87. package/dist/cli/src/builtin/modules/matrix/helpers/isSymetric.d.ts +0 -8
  88. package/dist/cli/src/builtin/modules/matrix/helpers/isTriangular.d.ts +0 -13
  89. package/dist/cli/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +0 -7
  90. package/dist/cli/src/builtin/modules/matrix/helpers/minor.d.ts +0 -1
  91. package/dist/cli/src/builtin/modules/matrix/helpers/norm1.d.ts +0 -1
  92. package/dist/cli/src/builtin/modules/matrix/helpers/trace.d.ts +0 -8
  93. package/dist/cli/src/builtin/modules/matrix/index.d.ts +0 -4
  94. package/dist/cli/src/builtin/modules/number-theory/binomialCefficient.d.ts +0 -1
  95. package/dist/cli/src/builtin/modules/number-theory/combinations.d.ts +0 -2
  96. package/dist/cli/src/builtin/modules/number-theory/derangements.d.ts +0 -2
  97. package/dist/cli/src/builtin/modules/number-theory/divisors.d.ts +0 -4
  98. package/dist/cli/src/builtin/modules/number-theory/docs.d.ts +0 -2
  99. package/dist/cli/src/builtin/modules/number-theory/factorial.d.ts +0 -3
  100. package/dist/cli/src/builtin/modules/number-theory/index.d.ts +0 -4
  101. package/dist/cli/src/builtin/modules/number-theory/partitions.d.ts +0 -2
  102. package/dist/cli/src/builtin/modules/number-theory/permutations.d.ts +0 -2
  103. package/dist/cli/src/builtin/modules/number-theory/powerSet.d.ts +0 -2
  104. package/dist/cli/src/builtin/modules/number-theory/primeFactors.d.ts +0 -11
  105. package/dist/cli/src/builtin/modules/number-theory/sequences/abundant.d.ts +0 -2
  106. package/dist/cli/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +0 -2
  107. package/dist/cli/src/builtin/modules/number-theory/sequences/bell.d.ts +0 -1
  108. package/dist/cli/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +0 -2
  109. package/dist/cli/src/builtin/modules/number-theory/sequences/catalan.d.ts +0 -1
  110. package/dist/cli/src/builtin/modules/number-theory/sequences/collatz.d.ts +0 -2
  111. package/dist/cli/src/builtin/modules/number-theory/sequences/composite.d.ts +0 -3
  112. package/dist/cli/src/builtin/modules/number-theory/sequences/deficient.d.ts +0 -2
  113. package/dist/cli/src/builtin/modules/number-theory/sequences/factorial.d.ts +0 -1
  114. package/dist/cli/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +0 -1
  115. package/dist/cli/src/builtin/modules/number-theory/sequences/geometric.d.ts +0 -2
  116. package/dist/cli/src/builtin/modules/number-theory/sequences/golomb.d.ts +0 -2
  117. package/dist/cli/src/builtin/modules/number-theory/sequences/happy.d.ts +0 -2
  118. package/dist/cli/src/builtin/modules/number-theory/sequences/index.d.ts +0 -27
  119. package/dist/cli/src/builtin/modules/number-theory/sequences/juggler.d.ts +0 -2
  120. package/dist/cli/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +0 -2
  121. package/dist/cli/src/builtin/modules/number-theory/sequences/lucas.d.ts +0 -1
  122. package/dist/cli/src/builtin/modules/number-theory/sequences/lucky.d.ts +0 -2
  123. package/dist/cli/src/builtin/modules/number-theory/sequences/mersenne.d.ts +0 -1
  124. package/dist/cli/src/builtin/modules/number-theory/sequences/padovan.d.ts +0 -2
  125. package/dist/cli/src/builtin/modules/number-theory/sequences/partition.d.ts +0 -1
  126. package/dist/cli/src/builtin/modules/number-theory/sequences/pell.d.ts +0 -1
  127. package/dist/cli/src/builtin/modules/number-theory/sequences/perfect.d.ts +0 -1
  128. package/dist/cli/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +0 -2
  129. package/dist/cli/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +0 -10
  130. package/dist/cli/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +0 -2
  131. package/dist/cli/src/builtin/modules/number-theory/sequences/poligonal.d.ts +0 -2
  132. package/dist/cli/src/builtin/modules/number-theory/sequences/prime.d.ts +0 -3
  133. package/dist/cli/src/builtin/modules/number-theory/sequences/recaman.d.ts +0 -9
  134. package/dist/cli/src/builtin/modules/number-theory/sequences/sylvester.d.ts +0 -1
  135. package/dist/cli/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +0 -2
  136. package/dist/cli/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +0 -1
  137. package/dist/cli/src/builtin/modules/sequence/index.d.ts +0 -2
  138. package/dist/cli/src/builtin/modules/string/index.d.ts +0 -2
  139. package/dist/cli/src/builtin/modules/vector/bincount.d.ts +0 -9
  140. package/dist/cli/src/builtin/modules/vector/calcMad.d.ts +0 -1
  141. package/dist/cli/src/builtin/modules/vector/calcMean.d.ts +0 -1
  142. package/dist/cli/src/builtin/modules/vector/calcMedad.d.ts +0 -1
  143. package/dist/cli/src/builtin/modules/vector/calcMedian.d.ts +0 -1
  144. package/dist/cli/src/builtin/modules/vector/calcStdDev.d.ts +0 -2
  145. package/dist/cli/src/builtin/modules/vector/calcVariance.d.ts +0 -2
  146. package/dist/cli/src/builtin/modules/vector/docs.d.ts +0 -2
  147. package/dist/cli/src/builtin/modules/vector/entropy.d.ts +0 -8
  148. package/dist/cli/src/builtin/modules/vector/histogram.d.ts +0 -9
  149. package/dist/cli/src/builtin/modules/vector/index.d.ts +0 -2
  150. package/dist/cli/src/builtin/modules/vector/mode.d.ts +0 -6
  151. package/dist/cli/src/builtin/modules/vector/outliers.d.ts +0 -7
  152. package/dist/cli/src/builtin/modules/vector/percentile.d.ts +0 -7
  153. package/dist/cli/src/builtin/modules/vector/quartiles.d.ts +0 -1
  154. package/dist/cli/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +0 -2
  155. package/dist/cli/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +0 -2
  156. package/dist/cli/src/builtin/modules/vector/reductionFunctions/index.d.ts +0 -13
  157. package/dist/cli/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +0 -2
  158. package/dist/cli/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +0 -5
  159. package/dist/cli/src/builtin/modules/vector/reductionFunctions/mad.d.ts +0 -2
  160. package/dist/cli/src/builtin/modules/vector/reductionFunctions/mean.d.ts +0 -4
  161. package/dist/cli/src/builtin/modules/vector/reductionFunctions/medad.d.ts +0 -2
  162. package/dist/cli/src/builtin/modules/vector/reductionFunctions/median.d.ts +0 -2
  163. package/dist/cli/src/builtin/modules/vector/reductionFunctions/prod.d.ts +0 -2
  164. package/dist/cli/src/builtin/modules/vector/reductionFunctions/rms.d.ts +0 -2
  165. package/dist/cli/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +0 -3
  166. package/dist/cli/src/builtin/modules/vector/reductionFunctions/span.d.ts +0 -2
  167. package/dist/cli/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +0 -3
  168. package/dist/cli/src/builtin/modules/vector/reductionFunctions/sum.d.ts +0 -2
  169. package/dist/cli/src/builtin/modules/vector/reductionFunctions/variance.d.ts +0 -3
  170. package/dist/cli/src/builtin/normalExpressions/index.d.ts +0 -9
  171. package/dist/cli/src/builtin/normalExpressions/initCoreDvala.d.ts +0 -1
  172. package/dist/cli/src/builtin/specialExpressionTypes.d.ts +0 -24
  173. package/dist/cli/src/builtin/specialExpressions/and.d.ts +0 -6
  174. package/dist/cli/src/builtin/specialExpressions/array.d.ts +0 -6
  175. package/dist/cli/src/builtin/specialExpressions/block.d.ts +0 -7
  176. package/dist/cli/src/builtin/specialExpressions/cond.d.ts +0 -6
  177. package/dist/cli/src/builtin/specialExpressions/defined.d.ts +0 -5
  178. package/dist/cli/src/builtin/specialExpressions/effect.d.ts +0 -5
  179. package/dist/cli/src/builtin/specialExpressions/functions.d.ts +0 -6
  180. package/dist/cli/src/builtin/specialExpressions/if.d.ts +0 -6
  181. package/dist/cli/src/builtin/specialExpressions/import.d.ts +0 -6
  182. package/dist/cli/src/builtin/specialExpressions/let.d.ts +0 -6
  183. package/dist/cli/src/builtin/specialExpressions/loop.d.ts +0 -6
  184. package/dist/cli/src/builtin/specialExpressions/loops.d.ts +0 -9
  185. package/dist/cli/src/builtin/specialExpressions/match.d.ts +0 -7
  186. package/dist/cli/src/builtin/specialExpressions/object.d.ts +0 -6
  187. package/dist/cli/src/builtin/specialExpressions/or.d.ts +0 -6
  188. package/dist/cli/src/builtin/specialExpressions/parallel.d.ts +0 -6
  189. package/dist/cli/src/builtin/specialExpressions/perform.d.ts +0 -6
  190. package/dist/cli/src/builtin/specialExpressions/qq.d.ts +0 -6
  191. package/dist/cli/src/builtin/specialExpressions/race.d.ts +0 -6
  192. package/dist/cli/src/builtin/specialExpressions/recur.d.ts +0 -5
  193. package/dist/cli/src/builtin/specialExpressions/unless.d.ts +0 -6
  194. package/dist/cli/src/builtin/utils.d.ts +0 -6
  195. package/dist/cli/src/bundler/index.d.ts +0 -9
  196. package/dist/cli/src/bundler/interface.d.ts +0 -15
  197. package/dist/cli/src/bundler.d.ts +0 -3
  198. package/dist/cli/src/cli.d.ts +0 -2
  199. package/dist/cli/src/cliDocumentation/formatCliDescription.d.ts +0 -3
  200. package/dist/cli/src/cliDocumentation/getCliArgumentInfo.d.ts +0 -3
  201. package/dist/cli/src/cliDocumentation/getCliDocumentation.d.ts +0 -2
  202. package/dist/cli/src/cliDocumentation/getCliFunctionExamples.d.ts +0 -3
  203. package/dist/cli/src/cliDocumentation/getCliFunctionSignature.d.ts +0 -3
  204. package/dist/cli/src/cliDocumentation/getCliTitle.d.ts +0 -3
  205. package/dist/cli/src/cliDocumentation/getCliType.d.ts +0 -3
  206. package/dist/cli/src/cliFormatterRules.d.ts +0 -13
  207. package/dist/cli/src/colorizer.d.ts +0 -939
  208. package/dist/cli/src/constants/constants.d.ts +0 -19
  209. package/dist/cli/src/createDvala.d.ts +0 -47
  210. package/dist/cli/src/createReadlineInterface.d.ts +0 -5
  211. package/dist/cli/src/errors.d.ts +0 -24
  212. package/dist/cli/src/evaluator/ContextStack.d.ts +0 -70
  213. package/dist/cli/src/evaluator/contentHash.d.ts +0 -21
  214. package/dist/cli/src/evaluator/dedupSubTrees.d.ts +0 -37
  215. package/dist/cli/src/evaluator/effectRef.d.ts +0 -27
  216. package/dist/cli/src/evaluator/effectTypes.d.ts +0 -181
  217. package/dist/cli/src/evaluator/frames.d.ts +0 -513
  218. package/dist/cli/src/evaluator/interface.d.ts +0 -14
  219. package/dist/cli/src/evaluator/standardEffects.d.ts +0 -50
  220. package/dist/cli/src/evaluator/step.d.ts +0 -175
  221. package/dist/cli/src/evaluator/suspension.d.ts +0 -86
  222. package/dist/cli/src/evaluator/trampoline.d.ts +0 -133
  223. package/dist/cli/src/getUndefinedSymbols/index.d.ts +0 -7
  224. package/dist/cli/src/initReferenceData.d.ts +0 -1
  225. package/dist/cli/src/interface.d.ts +0 -7
  226. package/dist/cli/src/js-interop/Cli/Fs/index.d.ts +0 -2
  227. package/dist/cli/src/js-interop/Cli/Proc/index.d.ts +0 -3
  228. package/dist/cli/src/js-interop/Cli/index.d.ts +0 -2
  229. package/dist/cli/src/parser/ParserContext.d.ts +0 -20
  230. package/dist/cli/src/parser/getPrecedence.d.ts +0 -3
  231. package/dist/cli/src/parser/helpers.d.ts +0 -19
  232. package/dist/cli/src/parser/index.d.ts +0 -5
  233. package/dist/cli/src/parser/subParsers/parseArray.d.ts +0 -3
  234. package/dist/cli/src/parser/subParsers/parseBindingTarget.d.ts +0 -8
  235. package/dist/cli/src/parser/subParsers/parseCond.d.ts +0 -4
  236. package/dist/cli/src/parser/subParsers/parseDo.d.ts +0 -3
  237. package/dist/cli/src/parser/subParsers/parseExpression.d.ts +0 -5
  238. package/dist/cli/src/parser/subParsers/parseForOrDoseq.d.ts +0 -4
  239. package/dist/cli/src/parser/subParsers/parseFunction.d.ts +0 -4
  240. package/dist/cli/src/parser/subParsers/parseFunctionCall.d.ts +0 -3
  241. package/dist/cli/src/parser/subParsers/parseIfOrUnless.d.ts +0 -5
  242. package/dist/cli/src/parser/subParsers/parseImplicitBlock.d.ts +0 -5
  243. package/dist/cli/src/parser/subParsers/parseLet.d.ts +0 -4
  244. package/dist/cli/src/parser/subParsers/parseLoop.d.ts +0 -4
  245. package/dist/cli/src/parser/subParsers/parseMatch.d.ts +0 -4
  246. package/dist/cli/src/parser/subParsers/parseNumber.d.ts +0 -3
  247. package/dist/cli/src/parser/subParsers/parseObject.d.ts +0 -3
  248. package/dist/cli/src/parser/subParsers/parseOperand.d.ts +0 -3
  249. package/dist/cli/src/parser/subParsers/parseRegexpShorthand.d.ts +0 -3
  250. package/dist/cli/src/parser/subParsers/parseReservedSymbol.d.ts +0 -3
  251. package/dist/cli/src/parser/subParsers/parseString.d.ts +0 -4
  252. package/dist/cli/src/parser/subParsers/parseSymbol.d.ts +0 -3
  253. package/dist/cli/src/parser/types.d.ts +0 -128
  254. package/dist/cli/src/symbolPatterns.d.ts +0 -2
  255. package/dist/cli/src/testFramework/index.d.ts +0 -15
  256. package/dist/cli/src/tokenizer/minifyTokenStream.d.ts +0 -4
  257. package/dist/cli/src/tokenizer/operators.d.ts +0 -12
  258. package/dist/cli/src/tokenizer/reservedNames.d.ts +0 -65
  259. package/dist/cli/src/tokenizer/token.d.ts +0 -82
  260. package/dist/cli/src/tokenizer/tokenize.d.ts +0 -7
  261. package/dist/cli/src/tokenizer/tokenizers.d.ts +0 -13
  262. package/dist/cli/src/tooling.d.ts +0 -51
  263. package/dist/cli/src/transformer/index.d.ts +0 -2
  264. package/dist/cli/src/typeGuards/annotatedCollections.d.ts +0 -16
  265. package/dist/cli/src/typeGuards/array.d.ts +0 -9
  266. package/dist/cli/src/typeGuards/astNode.d.ts +0 -19
  267. package/dist/cli/src/typeGuards/dvala.d.ts +0 -26
  268. package/dist/cli/src/typeGuards/dvalaFunction.d.ts +0 -9
  269. package/dist/cli/src/typeGuards/index.d.ts +0 -7
  270. package/dist/cli/src/typeGuards/number.d.ts +0 -66
  271. package/dist/cli/src/typeGuards/string.d.ts +0 -15
  272. package/dist/cli/src/untokenizer/index.d.ts +0 -2
  273. package/dist/cli/src/utils/arity.d.ts +0 -10
  274. package/dist/cli/src/utils/debug/debugTools.d.ts +0 -1
  275. package/dist/cli/src/utils/debug/getCodeMarker.d.ts +0 -2
  276. package/dist/cli/src/utils/debug/getSourceCodeInfo.d.ts +0 -2
  277. package/dist/cli/src/utils/docString/generateDocString.d.ts +0 -4
  278. package/dist/cli/src/utils/getAssertionError.d.ts +0 -3
  279. package/dist/cli/src/utils/index.d.ts +0 -14
  280. package/dist/cli/src/utils/maybePromise.d.ts +0 -54
  281. package/dist/cli/src/utils/symbols.d.ts +0 -3
  282. package/dist/common/createFormatter.d.ts +0 -6
  283. package/dist/common/utils.d.ts +0 -2
  284. package/dist/debug.esm.js +0 -2
  285. package/dist/debug.esm.js.map +0 -1
  286. package/dist/debug.js +0 -2
  287. package/dist/debug.js.map +0 -1
  288. package/dist/dvala.iife.js +0 -2
  289. package/dist/dvala.iife.js.map +0 -1
  290. package/dist/full.esm.js +0 -2
  291. package/dist/full.esm.js.map +0 -1
  292. package/dist/full.js +0 -2
  293. package/dist/full.js.map +0 -1
  294. package/dist/index.esm.js +0 -2
  295. package/dist/index.esm.js.map +0 -1
  296. package/dist/index.js +0 -2
  297. package/dist/index.js.map +0 -1
  298. package/dist/mcp-server/common/utils.d.ts +0 -2
  299. package/dist/mcp-server/mcp-server/src/server.d.ts +0 -1
  300. package/dist/mcp-server/reference/api.d.ts +0 -73
  301. package/dist/mcp-server/reference/datatype.d.ts +0 -3
  302. package/dist/mcp-server/reference/examples.d.ts +0 -11
  303. package/dist/mcp-server/reference/index.d.ts +0 -195
  304. package/dist/mcp-server/reference/shorthand.d.ts +0 -3
  305. package/dist/mcp-server/server.js +0 -36330
  306. package/dist/mcp-server/src/AutoCompleter/AutoCompleter.d.ts +0 -27
  307. package/dist/mcp-server/src/Cache.d.ts +0 -16
  308. package/dist/mcp-server/src/allModules.d.ts +0 -2
  309. package/dist/mcp-server/src/builtin/bindingNode.d.ts +0 -11
  310. package/dist/mcp-server/src/builtin/core/array.d.ts +0 -2
  311. package/dist/mcp-server/src/builtin/core/assertion.d.ts +0 -2
  312. package/dist/mcp-server/src/builtin/core/bitwise.d.ts +0 -2
  313. package/dist/mcp-server/src/builtin/core/collection.d.ts +0 -2
  314. package/dist/mcp-server/src/builtin/core/functional.d.ts +0 -2
  315. package/dist/mcp-server/src/builtin/core/math.d.ts +0 -2
  316. package/dist/mcp-server/src/builtin/core/meta.d.ts +0 -3
  317. package/dist/mcp-server/src/builtin/core/misc.d.ts +0 -2
  318. package/dist/mcp-server/src/builtin/core/object.d.ts +0 -2
  319. package/dist/mcp-server/src/builtin/core/predicates.d.ts +0 -2
  320. package/dist/mcp-server/src/builtin/core/regexp.d.ts +0 -2
  321. package/dist/mcp-server/src/builtin/core/sequence.d.ts +0 -2
  322. package/dist/mcp-server/src/builtin/core/string.d.ts +0 -2
  323. package/dist/mcp-server/src/builtin/core/vector.d.ts +0 -2
  324. package/dist/mcp-server/src/builtin/index.d.ts +0 -13
  325. package/dist/mcp-server/src/builtin/interface.d.ts +0 -113
  326. package/dist/mcp-server/src/builtin/modules/assertion/docs.d.ts +0 -2
  327. package/dist/mcp-server/src/builtin/modules/assertion/index.d.ts +0 -2
  328. package/dist/mcp-server/src/builtin/modules/bitwise/index.d.ts +0 -2
  329. package/dist/mcp-server/src/builtin/modules/collection/index.d.ts +0 -2
  330. package/dist/mcp-server/src/builtin/modules/convert/index.d.ts +0 -2
  331. package/dist/mcp-server/src/builtin/modules/functional/index.d.ts +0 -2
  332. package/dist/mcp-server/src/builtin/modules/grid/docs.d.ts +0 -2
  333. package/dist/mcp-server/src/builtin/modules/grid/fromArray.d.ts +0 -8
  334. package/dist/mcp-server/src/builtin/modules/grid/index.d.ts +0 -2
  335. package/dist/mcp-server/src/builtin/modules/grid/transpose.d.ts +0 -2
  336. package/dist/mcp-server/src/builtin/modules/interface.d.ts +0 -28
  337. package/dist/mcp-server/src/builtin/modules/linear-algebra/docs.d.ts +0 -2
  338. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +0 -1
  339. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +0 -2
  340. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +0 -8
  341. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +0 -4
  342. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/dot.d.ts +0 -1
  343. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +0 -7
  344. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +0 -2
  345. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +0 -1
  346. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +0 -10
  347. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/length.d.ts +0 -1
  348. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +0 -1
  349. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/scale.d.ts +0 -1
  350. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/solve.d.ts +0 -8
  351. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +0 -1
  352. package/dist/mcp-server/src/builtin/modules/linear-algebra/index.d.ts +0 -4
  353. package/dist/mcp-server/src/builtin/modules/math/index.d.ts +0 -2
  354. package/dist/mcp-server/src/builtin/modules/matrix/docs.d.ts +0 -2
  355. package/dist/mcp-server/src/builtin/modules/matrix/helpers/adjugate.d.ts +0 -1
  356. package/dist/mcp-server/src/builtin/modules/matrix/helpers/band.d.ts +0 -9
  357. package/dist/mcp-server/src/builtin/modules/matrix/helpers/cofactor.d.ts +0 -1
  358. package/dist/mcp-server/src/builtin/modules/matrix/helpers/determinant.d.ts +0 -6
  359. package/dist/mcp-server/src/builtin/modules/matrix/helpers/inverse.d.ts +0 -6
  360. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isBanded.d.ts +0 -11
  361. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +0 -10
  362. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isIdentity.d.ts +0 -1
  363. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +0 -1
  364. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isSquare.d.ts +0 -1
  365. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isSymetric.d.ts +0 -8
  366. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isTriangular.d.ts +0 -13
  367. package/dist/mcp-server/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +0 -7
  368. package/dist/mcp-server/src/builtin/modules/matrix/helpers/minor.d.ts +0 -1
  369. package/dist/mcp-server/src/builtin/modules/matrix/helpers/norm1.d.ts +0 -1
  370. package/dist/mcp-server/src/builtin/modules/matrix/helpers/trace.d.ts +0 -8
  371. package/dist/mcp-server/src/builtin/modules/matrix/index.d.ts +0 -4
  372. package/dist/mcp-server/src/builtin/modules/number-theory/binomialCefficient.d.ts +0 -1
  373. package/dist/mcp-server/src/builtin/modules/number-theory/combinations.d.ts +0 -2
  374. package/dist/mcp-server/src/builtin/modules/number-theory/derangements.d.ts +0 -2
  375. package/dist/mcp-server/src/builtin/modules/number-theory/divisors.d.ts +0 -4
  376. package/dist/mcp-server/src/builtin/modules/number-theory/docs.d.ts +0 -2
  377. package/dist/mcp-server/src/builtin/modules/number-theory/factorial.d.ts +0 -3
  378. package/dist/mcp-server/src/builtin/modules/number-theory/index.d.ts +0 -4
  379. package/dist/mcp-server/src/builtin/modules/number-theory/partitions.d.ts +0 -2
  380. package/dist/mcp-server/src/builtin/modules/number-theory/permutations.d.ts +0 -2
  381. package/dist/mcp-server/src/builtin/modules/number-theory/powerSet.d.ts +0 -2
  382. package/dist/mcp-server/src/builtin/modules/number-theory/primeFactors.d.ts +0 -11
  383. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/abundant.d.ts +0 -2
  384. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +0 -2
  385. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/bell.d.ts +0 -1
  386. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +0 -2
  387. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/catalan.d.ts +0 -1
  388. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/collatz.d.ts +0 -2
  389. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/composite.d.ts +0 -3
  390. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/deficient.d.ts +0 -2
  391. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/factorial.d.ts +0 -1
  392. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +0 -1
  393. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/geometric.d.ts +0 -2
  394. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/golomb.d.ts +0 -2
  395. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/happy.d.ts +0 -2
  396. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/index.d.ts +0 -27
  397. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/juggler.d.ts +0 -2
  398. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +0 -2
  399. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/lucas.d.ts +0 -1
  400. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/lucky.d.ts +0 -2
  401. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/mersenne.d.ts +0 -1
  402. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/padovan.d.ts +0 -2
  403. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/partition.d.ts +0 -1
  404. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/pell.d.ts +0 -1
  405. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/perfect.d.ts +0 -1
  406. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +0 -2
  407. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +0 -10
  408. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +0 -2
  409. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/poligonal.d.ts +0 -2
  410. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/prime.d.ts +0 -3
  411. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/recaman.d.ts +0 -9
  412. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/sylvester.d.ts +0 -1
  413. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +0 -2
  414. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +0 -1
  415. package/dist/mcp-server/src/builtin/modules/sequence/index.d.ts +0 -2
  416. package/dist/mcp-server/src/builtin/modules/string/index.d.ts +0 -2
  417. package/dist/mcp-server/src/builtin/modules/vector/bincount.d.ts +0 -9
  418. package/dist/mcp-server/src/builtin/modules/vector/calcMad.d.ts +0 -1
  419. package/dist/mcp-server/src/builtin/modules/vector/calcMean.d.ts +0 -1
  420. package/dist/mcp-server/src/builtin/modules/vector/calcMedad.d.ts +0 -1
  421. package/dist/mcp-server/src/builtin/modules/vector/calcMedian.d.ts +0 -1
  422. package/dist/mcp-server/src/builtin/modules/vector/calcStdDev.d.ts +0 -2
  423. package/dist/mcp-server/src/builtin/modules/vector/calcVariance.d.ts +0 -2
  424. package/dist/mcp-server/src/builtin/modules/vector/docs.d.ts +0 -2
  425. package/dist/mcp-server/src/builtin/modules/vector/entropy.d.ts +0 -8
  426. package/dist/mcp-server/src/builtin/modules/vector/histogram.d.ts +0 -9
  427. package/dist/mcp-server/src/builtin/modules/vector/index.d.ts +0 -2
  428. package/dist/mcp-server/src/builtin/modules/vector/mode.d.ts +0 -6
  429. package/dist/mcp-server/src/builtin/modules/vector/outliers.d.ts +0 -7
  430. package/dist/mcp-server/src/builtin/modules/vector/percentile.d.ts +0 -7
  431. package/dist/mcp-server/src/builtin/modules/vector/quartiles.d.ts +0 -1
  432. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +0 -2
  433. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +0 -2
  434. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/index.d.ts +0 -13
  435. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +0 -2
  436. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +0 -5
  437. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/mad.d.ts +0 -2
  438. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/mean.d.ts +0 -4
  439. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/medad.d.ts +0 -2
  440. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/median.d.ts +0 -2
  441. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/prod.d.ts +0 -2
  442. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/rms.d.ts +0 -2
  443. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +0 -3
  444. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/span.d.ts +0 -2
  445. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +0 -3
  446. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/sum.d.ts +0 -2
  447. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/variance.d.ts +0 -3
  448. package/dist/mcp-server/src/builtin/normalExpressions/index.d.ts +0 -9
  449. package/dist/mcp-server/src/builtin/normalExpressions/initCoreDvala.d.ts +0 -1
  450. package/dist/mcp-server/src/builtin/specialExpressionTypes.d.ts +0 -24
  451. package/dist/mcp-server/src/builtin/specialExpressions/and.d.ts +0 -6
  452. package/dist/mcp-server/src/builtin/specialExpressions/array.d.ts +0 -6
  453. package/dist/mcp-server/src/builtin/specialExpressions/block.d.ts +0 -7
  454. package/dist/mcp-server/src/builtin/specialExpressions/cond.d.ts +0 -6
  455. package/dist/mcp-server/src/builtin/specialExpressions/defined.d.ts +0 -5
  456. package/dist/mcp-server/src/builtin/specialExpressions/effect.d.ts +0 -5
  457. package/dist/mcp-server/src/builtin/specialExpressions/functions.d.ts +0 -6
  458. package/dist/mcp-server/src/builtin/specialExpressions/if.d.ts +0 -6
  459. package/dist/mcp-server/src/builtin/specialExpressions/import.d.ts +0 -6
  460. package/dist/mcp-server/src/builtin/specialExpressions/let.d.ts +0 -6
  461. package/dist/mcp-server/src/builtin/specialExpressions/loop.d.ts +0 -6
  462. package/dist/mcp-server/src/builtin/specialExpressions/loops.d.ts +0 -9
  463. package/dist/mcp-server/src/builtin/specialExpressions/match.d.ts +0 -7
  464. package/dist/mcp-server/src/builtin/specialExpressions/object.d.ts +0 -6
  465. package/dist/mcp-server/src/builtin/specialExpressions/or.d.ts +0 -6
  466. package/dist/mcp-server/src/builtin/specialExpressions/parallel.d.ts +0 -6
  467. package/dist/mcp-server/src/builtin/specialExpressions/perform.d.ts +0 -6
  468. package/dist/mcp-server/src/builtin/specialExpressions/qq.d.ts +0 -6
  469. package/dist/mcp-server/src/builtin/specialExpressions/race.d.ts +0 -6
  470. package/dist/mcp-server/src/builtin/specialExpressions/recur.d.ts +0 -5
  471. package/dist/mcp-server/src/builtin/specialExpressions/unless.d.ts +0 -6
  472. package/dist/mcp-server/src/builtin/utils.d.ts +0 -6
  473. package/dist/mcp-server/src/bundler/interface.d.ts +0 -15
  474. package/dist/mcp-server/src/constants/constants.d.ts +0 -19
  475. package/dist/mcp-server/src/createDvala.d.ts +0 -47
  476. package/dist/mcp-server/src/errors.d.ts +0 -24
  477. package/dist/mcp-server/src/evaluator/ContextStack.d.ts +0 -70
  478. package/dist/mcp-server/src/evaluator/contentHash.d.ts +0 -21
  479. package/dist/mcp-server/src/evaluator/dedupSubTrees.d.ts +0 -37
  480. package/dist/mcp-server/src/evaluator/effectRef.d.ts +0 -27
  481. package/dist/mcp-server/src/evaluator/effectTypes.d.ts +0 -181
  482. package/dist/mcp-server/src/evaluator/frames.d.ts +0 -513
  483. package/dist/mcp-server/src/evaluator/interface.d.ts +0 -14
  484. package/dist/mcp-server/src/evaluator/standardEffects.d.ts +0 -50
  485. package/dist/mcp-server/src/evaluator/step.d.ts +0 -175
  486. package/dist/mcp-server/src/evaluator/suspension.d.ts +0 -86
  487. package/dist/mcp-server/src/evaluator/trampoline.d.ts +0 -133
  488. package/dist/mcp-server/src/getUndefinedSymbols/index.d.ts +0 -7
  489. package/dist/mcp-server/src/initReferenceData.d.ts +0 -1
  490. package/dist/mcp-server/src/interface.d.ts +0 -7
  491. package/dist/mcp-server/src/parser/ParserContext.d.ts +0 -20
  492. package/dist/mcp-server/src/parser/getPrecedence.d.ts +0 -3
  493. package/dist/mcp-server/src/parser/helpers.d.ts +0 -19
  494. package/dist/mcp-server/src/parser/index.d.ts +0 -5
  495. package/dist/mcp-server/src/parser/subParsers/parseArray.d.ts +0 -3
  496. package/dist/mcp-server/src/parser/subParsers/parseBindingTarget.d.ts +0 -8
  497. package/dist/mcp-server/src/parser/subParsers/parseCond.d.ts +0 -4
  498. package/dist/mcp-server/src/parser/subParsers/parseDo.d.ts +0 -3
  499. package/dist/mcp-server/src/parser/subParsers/parseExpression.d.ts +0 -5
  500. package/dist/mcp-server/src/parser/subParsers/parseForOrDoseq.d.ts +0 -4
  501. package/dist/mcp-server/src/parser/subParsers/parseFunction.d.ts +0 -4
  502. package/dist/mcp-server/src/parser/subParsers/parseFunctionCall.d.ts +0 -3
  503. package/dist/mcp-server/src/parser/subParsers/parseIfOrUnless.d.ts +0 -5
  504. package/dist/mcp-server/src/parser/subParsers/parseImplicitBlock.d.ts +0 -5
  505. package/dist/mcp-server/src/parser/subParsers/parseLet.d.ts +0 -4
  506. package/dist/mcp-server/src/parser/subParsers/parseLoop.d.ts +0 -4
  507. package/dist/mcp-server/src/parser/subParsers/parseMatch.d.ts +0 -4
  508. package/dist/mcp-server/src/parser/subParsers/parseNumber.d.ts +0 -3
  509. package/dist/mcp-server/src/parser/subParsers/parseObject.d.ts +0 -3
  510. package/dist/mcp-server/src/parser/subParsers/parseOperand.d.ts +0 -3
  511. package/dist/mcp-server/src/parser/subParsers/parseRegexpShorthand.d.ts +0 -3
  512. package/dist/mcp-server/src/parser/subParsers/parseReservedSymbol.d.ts +0 -3
  513. package/dist/mcp-server/src/parser/subParsers/parseString.d.ts +0 -4
  514. package/dist/mcp-server/src/parser/subParsers/parseSymbol.d.ts +0 -3
  515. package/dist/mcp-server/src/parser/types.d.ts +0 -128
  516. package/dist/mcp-server/src/tokenizer/minifyTokenStream.d.ts +0 -4
  517. package/dist/mcp-server/src/tokenizer/operators.d.ts +0 -12
  518. package/dist/mcp-server/src/tokenizer/reservedNames.d.ts +0 -65
  519. package/dist/mcp-server/src/tokenizer/token.d.ts +0 -82
  520. package/dist/mcp-server/src/tokenizer/tokenize.d.ts +0 -7
  521. package/dist/mcp-server/src/tokenizer/tokenizers.d.ts +0 -13
  522. package/dist/mcp-server/src/tooling.d.ts +0 -51
  523. package/dist/mcp-server/src/transformer/index.d.ts +0 -2
  524. package/dist/mcp-server/src/typeGuards/annotatedCollections.d.ts +0 -16
  525. package/dist/mcp-server/src/typeGuards/array.d.ts +0 -9
  526. package/dist/mcp-server/src/typeGuards/astNode.d.ts +0 -19
  527. package/dist/mcp-server/src/typeGuards/dvala.d.ts +0 -26
  528. package/dist/mcp-server/src/typeGuards/dvalaFunction.d.ts +0 -9
  529. package/dist/mcp-server/src/typeGuards/index.d.ts +0 -7
  530. package/dist/mcp-server/src/typeGuards/number.d.ts +0 -66
  531. package/dist/mcp-server/src/typeGuards/string.d.ts +0 -15
  532. package/dist/mcp-server/src/untokenizer/index.d.ts +0 -2
  533. package/dist/mcp-server/src/utils/arity.d.ts +0 -10
  534. package/dist/mcp-server/src/utils/debug/debugTools.d.ts +0 -1
  535. package/dist/mcp-server/src/utils/debug/getCodeMarker.d.ts +0 -2
  536. package/dist/mcp-server/src/utils/debug/getSourceCodeInfo.d.ts +0 -2
  537. package/dist/mcp-server/src/utils/docString/generateDocString.d.ts +0 -4
  538. package/dist/mcp-server/src/utils/getAssertionError.d.ts +0 -3
  539. package/dist/mcp-server/src/utils/index.d.ts +0 -14
  540. package/dist/mcp-server/src/utils/maybePromise.d.ts +0 -54
  541. package/dist/mcp-server/src/utils/symbols.d.ts +0 -3
  542. package/dist/modules/assertion.esm.js +0 -2
  543. package/dist/modules/assertion.esm.js.map +0 -1
  544. package/dist/modules/assertion.js +0 -2
  545. package/dist/modules/assertion.js.map +0 -1
  546. package/dist/modules/bitwise.esm.js +0 -2
  547. package/dist/modules/bitwise.esm.js.map +0 -1
  548. package/dist/modules/bitwise.js +0 -2
  549. package/dist/modules/bitwise.js.map +0 -1
  550. package/dist/modules/cli/src/cli.d.ts +0 -2
  551. package/dist/modules/cli/src/cliDocumentation/formatCliDescription.d.ts +0 -3
  552. package/dist/modules/cli/src/cliDocumentation/getCliArgumentInfo.d.ts +0 -3
  553. package/dist/modules/cli/src/cliDocumentation/getCliDocumentation.d.ts +0 -2
  554. package/dist/modules/cli/src/cliDocumentation/getCliFunctionExamples.d.ts +0 -3
  555. package/dist/modules/cli/src/cliDocumentation/getCliFunctionSignature.d.ts +0 -3
  556. package/dist/modules/cli/src/cliDocumentation/getCliTitle.d.ts +0 -3
  557. package/dist/modules/cli/src/cliDocumentation/getCliType.d.ts +0 -3
  558. package/dist/modules/cli/src/cliFormatterRules.d.ts +0 -13
  559. package/dist/modules/cli/src/colorizer.d.ts +0 -939
  560. package/dist/modules/cli/src/createReadlineInterface.d.ts +0 -5
  561. package/dist/modules/cli/src/js-interop/Cli/Fs/index.d.ts +0 -2
  562. package/dist/modules/cli/src/js-interop/Cli/Proc/index.d.ts +0 -3
  563. package/dist/modules/cli/src/js-interop/Cli/index.d.ts +0 -2
  564. package/dist/modules/collection.esm.js +0 -2
  565. package/dist/modules/collection.esm.js.map +0 -1
  566. package/dist/modules/collection.js +0 -2
  567. package/dist/modules/collection.js.map +0 -1
  568. package/dist/modules/common/createFormatter.d.ts +0 -6
  569. package/dist/modules/common/utils.d.ts +0 -2
  570. package/dist/modules/convert.esm.js +0 -2
  571. package/dist/modules/convert.esm.js.map +0 -1
  572. package/dist/modules/convert.js +0 -2
  573. package/dist/modules/convert.js.map +0 -1
  574. package/dist/modules/functional.esm.js +0 -2
  575. package/dist/modules/functional.esm.js.map +0 -1
  576. package/dist/modules/functional.js +0 -2
  577. package/dist/modules/functional.js.map +0 -1
  578. package/dist/modules/grid.esm.js +0 -2
  579. package/dist/modules/grid.esm.js.map +0 -1
  580. package/dist/modules/grid.js +0 -2
  581. package/dist/modules/grid.js.map +0 -1
  582. package/dist/modules/linear-algebra.esm.js +0 -2
  583. package/dist/modules/linear-algebra.esm.js.map +0 -1
  584. package/dist/modules/linear-algebra.js +0 -2
  585. package/dist/modules/linear-algebra.js.map +0 -1
  586. package/dist/modules/math.esm.js +0 -2
  587. package/dist/modules/math.esm.js.map +0 -1
  588. package/dist/modules/math.js +0 -2
  589. package/dist/modules/math.js.map +0 -1
  590. package/dist/modules/matrix.esm.js +0 -2
  591. package/dist/modules/matrix.esm.js.map +0 -1
  592. package/dist/modules/matrix.js +0 -2
  593. package/dist/modules/matrix.js.map +0 -1
  594. package/dist/modules/number-theory.esm.js +0 -2
  595. package/dist/modules/number-theory.esm.js.map +0 -1
  596. package/dist/modules/number-theory.js +0 -2
  597. package/dist/modules/number-theory.js.map +0 -1
  598. package/dist/modules/reference/api.d.ts +0 -73
  599. package/dist/modules/reference/datatype.d.ts +0 -3
  600. package/dist/modules/reference/index.d.ts +0 -195
  601. package/dist/modules/reference/shorthand.d.ts +0 -3
  602. package/dist/modules/sequence.esm.js +0 -2
  603. package/dist/modules/sequence.esm.js.map +0 -1
  604. package/dist/modules/sequence.js +0 -2
  605. package/dist/modules/sequence.js.map +0 -1
  606. package/dist/modules/src/AutoCompleter/AutoCompleter.d.ts +0 -27
  607. package/dist/modules/src/Cache.d.ts +0 -16
  608. package/dist/modules/src/allModules.d.ts +0 -2
  609. package/dist/modules/src/builtin/bindingNode.d.ts +0 -11
  610. package/dist/modules/src/builtin/core/array.d.ts +0 -2
  611. package/dist/modules/src/builtin/core/assertion.d.ts +0 -2
  612. package/dist/modules/src/builtin/core/bitwise.d.ts +0 -2
  613. package/dist/modules/src/builtin/core/collection.d.ts +0 -2
  614. package/dist/modules/src/builtin/core/functional.d.ts +0 -2
  615. package/dist/modules/src/builtin/core/math.d.ts +0 -2
  616. package/dist/modules/src/builtin/core/meta.d.ts +0 -3
  617. package/dist/modules/src/builtin/core/misc.d.ts +0 -2
  618. package/dist/modules/src/builtin/core/object.d.ts +0 -2
  619. package/dist/modules/src/builtin/core/predicates.d.ts +0 -2
  620. package/dist/modules/src/builtin/core/regexp.d.ts +0 -2
  621. package/dist/modules/src/builtin/core/sequence.d.ts +0 -2
  622. package/dist/modules/src/builtin/core/string.d.ts +0 -2
  623. package/dist/modules/src/builtin/core/vector.d.ts +0 -2
  624. package/dist/modules/src/builtin/index.d.ts +0 -13
  625. package/dist/modules/src/builtin/interface.d.ts +0 -113
  626. package/dist/modules/src/builtin/modules/assertion/docs.d.ts +0 -2
  627. package/dist/modules/src/builtin/modules/assertion/index.d.ts +0 -2
  628. package/dist/modules/src/builtin/modules/bitwise/index.d.ts +0 -2
  629. package/dist/modules/src/builtin/modules/collection/index.d.ts +0 -2
  630. package/dist/modules/src/builtin/modules/convert/index.d.ts +0 -2
  631. package/dist/modules/src/builtin/modules/functional/index.d.ts +0 -2
  632. package/dist/modules/src/builtin/modules/grid/docs.d.ts +0 -2
  633. package/dist/modules/src/builtin/modules/grid/fromArray.d.ts +0 -8
  634. package/dist/modules/src/builtin/modules/grid/index.d.ts +0 -2
  635. package/dist/modules/src/builtin/modules/grid/transpose.d.ts +0 -2
  636. package/dist/modules/src/builtin/modules/interface.d.ts +0 -28
  637. package/dist/modules/src/builtin/modules/linear-algebra/docs.d.ts +0 -2
  638. package/dist/modules/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +0 -1
  639. package/dist/modules/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +0 -2
  640. package/dist/modules/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +0 -8
  641. package/dist/modules/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +0 -4
  642. package/dist/modules/src/builtin/modules/linear-algebra/helpers/dot.d.ts +0 -1
  643. package/dist/modules/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +0 -7
  644. package/dist/modules/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +0 -2
  645. package/dist/modules/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +0 -1
  646. package/dist/modules/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +0 -10
  647. package/dist/modules/src/builtin/modules/linear-algebra/helpers/length.d.ts +0 -1
  648. package/dist/modules/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +0 -1
  649. package/dist/modules/src/builtin/modules/linear-algebra/helpers/scale.d.ts +0 -1
  650. package/dist/modules/src/builtin/modules/linear-algebra/helpers/solve.d.ts +0 -8
  651. package/dist/modules/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +0 -1
  652. package/dist/modules/src/builtin/modules/linear-algebra/index.d.ts +0 -4
  653. package/dist/modules/src/builtin/modules/math/index.d.ts +0 -2
  654. package/dist/modules/src/builtin/modules/matrix/docs.d.ts +0 -2
  655. package/dist/modules/src/builtin/modules/matrix/helpers/adjugate.d.ts +0 -1
  656. package/dist/modules/src/builtin/modules/matrix/helpers/band.d.ts +0 -9
  657. package/dist/modules/src/builtin/modules/matrix/helpers/cofactor.d.ts +0 -1
  658. package/dist/modules/src/builtin/modules/matrix/helpers/determinant.d.ts +0 -6
  659. package/dist/modules/src/builtin/modules/matrix/helpers/diagonal.d.ts +0 -1
  660. package/dist/modules/src/builtin/modules/matrix/helpers/inverse.d.ts +0 -6
  661. package/dist/modules/src/builtin/modules/matrix/helpers/isBanded.d.ts +0 -11
  662. package/dist/modules/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +0 -10
  663. package/dist/modules/src/builtin/modules/matrix/helpers/isIdentity.d.ts +0 -1
  664. package/dist/modules/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +0 -1
  665. package/dist/modules/src/builtin/modules/matrix/helpers/isSquare.d.ts +0 -1
  666. package/dist/modules/src/builtin/modules/matrix/helpers/isSymetric.d.ts +0 -8
  667. package/dist/modules/src/builtin/modules/matrix/helpers/isTriangular.d.ts +0 -13
  668. package/dist/modules/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +0 -7
  669. package/dist/modules/src/builtin/modules/matrix/helpers/minor.d.ts +0 -1
  670. package/dist/modules/src/builtin/modules/matrix/helpers/norm1.d.ts +0 -1
  671. package/dist/modules/src/builtin/modules/matrix/helpers/trace.d.ts +0 -8
  672. package/dist/modules/src/builtin/modules/matrix/index.d.ts +0 -4
  673. package/dist/modules/src/builtin/modules/number-theory/binomialCefficient.d.ts +0 -1
  674. package/dist/modules/src/builtin/modules/number-theory/combinations.d.ts +0 -2
  675. package/dist/modules/src/builtin/modules/number-theory/derangements.d.ts +0 -2
  676. package/dist/modules/src/builtin/modules/number-theory/divisors.d.ts +0 -4
  677. package/dist/modules/src/builtin/modules/number-theory/docs.d.ts +0 -2
  678. package/dist/modules/src/builtin/modules/number-theory/factorial.d.ts +0 -3
  679. package/dist/modules/src/builtin/modules/number-theory/index.d.ts +0 -4
  680. package/dist/modules/src/builtin/modules/number-theory/partitions.d.ts +0 -2
  681. package/dist/modules/src/builtin/modules/number-theory/permutations.d.ts +0 -2
  682. package/dist/modules/src/builtin/modules/number-theory/powerSet.d.ts +0 -2
  683. package/dist/modules/src/builtin/modules/number-theory/primeFactors.d.ts +0 -11
  684. package/dist/modules/src/builtin/modules/number-theory/sequences/abundant.d.ts +0 -2
  685. package/dist/modules/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +0 -2
  686. package/dist/modules/src/builtin/modules/number-theory/sequences/bell.d.ts +0 -1
  687. package/dist/modules/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +0 -2
  688. package/dist/modules/src/builtin/modules/number-theory/sequences/catalan.d.ts +0 -1
  689. package/dist/modules/src/builtin/modules/number-theory/sequences/collatz.d.ts +0 -2
  690. package/dist/modules/src/builtin/modules/number-theory/sequences/composite.d.ts +0 -3
  691. package/dist/modules/src/builtin/modules/number-theory/sequences/deficient.d.ts +0 -2
  692. package/dist/modules/src/builtin/modules/number-theory/sequences/factorial.d.ts +0 -1
  693. package/dist/modules/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +0 -1
  694. package/dist/modules/src/builtin/modules/number-theory/sequences/geometric.d.ts +0 -2
  695. package/dist/modules/src/builtin/modules/number-theory/sequences/golomb.d.ts +0 -2
  696. package/dist/modules/src/builtin/modules/number-theory/sequences/happy.d.ts +0 -2
  697. package/dist/modules/src/builtin/modules/number-theory/sequences/index.d.ts +0 -27
  698. package/dist/modules/src/builtin/modules/number-theory/sequences/juggler.d.ts +0 -2
  699. package/dist/modules/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +0 -2
  700. package/dist/modules/src/builtin/modules/number-theory/sequences/lucas.d.ts +0 -1
  701. package/dist/modules/src/builtin/modules/number-theory/sequences/lucky.d.ts +0 -2
  702. package/dist/modules/src/builtin/modules/number-theory/sequences/mersenne.d.ts +0 -1
  703. package/dist/modules/src/builtin/modules/number-theory/sequences/padovan.d.ts +0 -2
  704. package/dist/modules/src/builtin/modules/number-theory/sequences/partition.d.ts +0 -1
  705. package/dist/modules/src/builtin/modules/number-theory/sequences/pell.d.ts +0 -1
  706. package/dist/modules/src/builtin/modules/number-theory/sequences/perfect.d.ts +0 -1
  707. package/dist/modules/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +0 -2
  708. package/dist/modules/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +0 -10
  709. package/dist/modules/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +0 -2
  710. package/dist/modules/src/builtin/modules/number-theory/sequences/poligonal.d.ts +0 -2
  711. package/dist/modules/src/builtin/modules/number-theory/sequences/prime.d.ts +0 -3
  712. package/dist/modules/src/builtin/modules/number-theory/sequences/recaman.d.ts +0 -9
  713. package/dist/modules/src/builtin/modules/number-theory/sequences/sylvester.d.ts +0 -1
  714. package/dist/modules/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +0 -2
  715. package/dist/modules/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +0 -1
  716. package/dist/modules/src/builtin/modules/sequence/index.d.ts +0 -2
  717. package/dist/modules/src/builtin/modules/string/index.d.ts +0 -2
  718. package/dist/modules/src/builtin/modules/vector/bincount.d.ts +0 -9
  719. package/dist/modules/src/builtin/modules/vector/calcMad.d.ts +0 -1
  720. package/dist/modules/src/builtin/modules/vector/calcMean.d.ts +0 -1
  721. package/dist/modules/src/builtin/modules/vector/calcMedad.d.ts +0 -1
  722. package/dist/modules/src/builtin/modules/vector/calcMedian.d.ts +0 -1
  723. package/dist/modules/src/builtin/modules/vector/calcStdDev.d.ts +0 -2
  724. package/dist/modules/src/builtin/modules/vector/calcVariance.d.ts +0 -2
  725. package/dist/modules/src/builtin/modules/vector/docs.d.ts +0 -2
  726. package/dist/modules/src/builtin/modules/vector/entropy.d.ts +0 -8
  727. package/dist/modules/src/builtin/modules/vector/histogram.d.ts +0 -9
  728. package/dist/modules/src/builtin/modules/vector/index.d.ts +0 -2
  729. package/dist/modules/src/builtin/modules/vector/mode.d.ts +0 -6
  730. package/dist/modules/src/builtin/modules/vector/outliers.d.ts +0 -7
  731. package/dist/modules/src/builtin/modules/vector/percentile.d.ts +0 -7
  732. package/dist/modules/src/builtin/modules/vector/quartiles.d.ts +0 -1
  733. package/dist/modules/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +0 -2
  734. package/dist/modules/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +0 -2
  735. package/dist/modules/src/builtin/modules/vector/reductionFunctions/index.d.ts +0 -13
  736. package/dist/modules/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +0 -2
  737. package/dist/modules/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +0 -5
  738. package/dist/modules/src/builtin/modules/vector/reductionFunctions/mad.d.ts +0 -2
  739. package/dist/modules/src/builtin/modules/vector/reductionFunctions/mean.d.ts +0 -4
  740. package/dist/modules/src/builtin/modules/vector/reductionFunctions/medad.d.ts +0 -2
  741. package/dist/modules/src/builtin/modules/vector/reductionFunctions/median.d.ts +0 -2
  742. package/dist/modules/src/builtin/modules/vector/reductionFunctions/prod.d.ts +0 -2
  743. package/dist/modules/src/builtin/modules/vector/reductionFunctions/rms.d.ts +0 -2
  744. package/dist/modules/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +0 -3
  745. package/dist/modules/src/builtin/modules/vector/reductionFunctions/span.d.ts +0 -2
  746. package/dist/modules/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +0 -3
  747. package/dist/modules/src/builtin/modules/vector/reductionFunctions/sum.d.ts +0 -2
  748. package/dist/modules/src/builtin/modules/vector/reductionFunctions/variance.d.ts +0 -3
  749. package/dist/modules/src/builtin/normalExpressions/index.d.ts +0 -9
  750. package/dist/modules/src/builtin/normalExpressions/initCoreDvala.d.ts +0 -1
  751. package/dist/modules/src/builtin/specialExpressionTypes.d.ts +0 -24
  752. package/dist/modules/src/builtin/specialExpressions/and.d.ts +0 -6
  753. package/dist/modules/src/builtin/specialExpressions/array.d.ts +0 -6
  754. package/dist/modules/src/builtin/specialExpressions/block.d.ts +0 -7
  755. package/dist/modules/src/builtin/specialExpressions/cond.d.ts +0 -6
  756. package/dist/modules/src/builtin/specialExpressions/defined.d.ts +0 -5
  757. package/dist/modules/src/builtin/specialExpressions/effect.d.ts +0 -5
  758. package/dist/modules/src/builtin/specialExpressions/functions.d.ts +0 -6
  759. package/dist/modules/src/builtin/specialExpressions/if.d.ts +0 -6
  760. package/dist/modules/src/builtin/specialExpressions/import.d.ts +0 -6
  761. package/dist/modules/src/builtin/specialExpressions/let.d.ts +0 -6
  762. package/dist/modules/src/builtin/specialExpressions/loop.d.ts +0 -6
  763. package/dist/modules/src/builtin/specialExpressions/loops.d.ts +0 -9
  764. package/dist/modules/src/builtin/specialExpressions/match.d.ts +0 -7
  765. package/dist/modules/src/builtin/specialExpressions/object.d.ts +0 -6
  766. package/dist/modules/src/builtin/specialExpressions/or.d.ts +0 -6
  767. package/dist/modules/src/builtin/specialExpressions/parallel.d.ts +0 -6
  768. package/dist/modules/src/builtin/specialExpressions/perform.d.ts +0 -6
  769. package/dist/modules/src/builtin/specialExpressions/qq.d.ts +0 -6
  770. package/dist/modules/src/builtin/specialExpressions/race.d.ts +0 -6
  771. package/dist/modules/src/builtin/specialExpressions/recur.d.ts +0 -5
  772. package/dist/modules/src/builtin/specialExpressions/unless.d.ts +0 -6
  773. package/dist/modules/src/builtin/utils.d.ts +0 -6
  774. package/dist/modules/src/bundler/index.d.ts +0 -9
  775. package/dist/modules/src/bundler/interface.d.ts +0 -15
  776. package/dist/modules/src/bundler.d.ts +0 -3
  777. package/dist/modules/src/constants/constants.d.ts +0 -19
  778. package/dist/modules/src/createDvala.d.ts +0 -47
  779. package/dist/modules/src/debug.d.ts +0 -115
  780. package/dist/modules/src/errors.d.ts +0 -24
  781. package/dist/modules/src/evaluator/ContextStack.d.ts +0 -70
  782. package/dist/modules/src/evaluator/contentHash.d.ts +0 -21
  783. package/dist/modules/src/evaluator/dedupSubTrees.d.ts +0 -37
  784. package/dist/modules/src/evaluator/effectRef.d.ts +0 -27
  785. package/dist/modules/src/evaluator/effectTypes.d.ts +0 -181
  786. package/dist/modules/src/evaluator/frames.d.ts +0 -513
  787. package/dist/modules/src/evaluator/interface.d.ts +0 -14
  788. package/dist/modules/src/evaluator/serialization.d.ts +0 -38
  789. package/dist/modules/src/evaluator/standardEffects.d.ts +0 -50
  790. package/dist/modules/src/evaluator/step.d.ts +0 -175
  791. package/dist/modules/src/evaluator/suspension.d.ts +0 -86
  792. package/dist/modules/src/evaluator/trampoline.d.ts +0 -133
  793. package/dist/modules/src/full.d.ts +0 -16
  794. package/dist/modules/src/getUndefinedSymbols/index.d.ts +0 -7
  795. package/dist/modules/src/index.d.ts +0 -21
  796. package/dist/modules/src/initReferenceData.d.ts +0 -1
  797. package/dist/modules/src/interface.d.ts +0 -7
  798. package/dist/modules/src/modules/assertion.d.ts +0 -2
  799. package/dist/modules/src/modules/bitwise.d.ts +0 -2
  800. package/dist/modules/src/modules/collection.d.ts +0 -2
  801. package/dist/modules/src/modules/convert.d.ts +0 -2
  802. package/dist/modules/src/modules/functional.d.ts +0 -2
  803. package/dist/modules/src/modules/grid.d.ts +0 -2
  804. package/dist/modules/src/modules/linear-algebra.d.ts +0 -2
  805. package/dist/modules/src/modules/math.d.ts +0 -2
  806. package/dist/modules/src/modules/matrix.d.ts +0 -2
  807. package/dist/modules/src/modules/number-theory.d.ts +0 -2
  808. package/dist/modules/src/modules/sequence.d.ts +0 -2
  809. package/dist/modules/src/modules/string.d.ts +0 -2
  810. package/dist/modules/src/modules/vector.d.ts +0 -2
  811. package/dist/modules/src/parser/ParserContext.d.ts +0 -20
  812. package/dist/modules/src/parser/getPrecedence.d.ts +0 -3
  813. package/dist/modules/src/parser/helpers.d.ts +0 -19
  814. package/dist/modules/src/parser/index.d.ts +0 -5
  815. package/dist/modules/src/parser/subParsers/parseArray.d.ts +0 -3
  816. package/dist/modules/src/parser/subParsers/parseBindingTarget.d.ts +0 -8
  817. package/dist/modules/src/parser/subParsers/parseCond.d.ts +0 -4
  818. package/dist/modules/src/parser/subParsers/parseDo.d.ts +0 -3
  819. package/dist/modules/src/parser/subParsers/parseExpression.d.ts +0 -5
  820. package/dist/modules/src/parser/subParsers/parseForOrDoseq.d.ts +0 -4
  821. package/dist/modules/src/parser/subParsers/parseFunction.d.ts +0 -4
  822. package/dist/modules/src/parser/subParsers/parseFunctionCall.d.ts +0 -3
  823. package/dist/modules/src/parser/subParsers/parseIfOrUnless.d.ts +0 -5
  824. package/dist/modules/src/parser/subParsers/parseImplicitBlock.d.ts +0 -5
  825. package/dist/modules/src/parser/subParsers/parseLet.d.ts +0 -4
  826. package/dist/modules/src/parser/subParsers/parseLoop.d.ts +0 -4
  827. package/dist/modules/src/parser/subParsers/parseMatch.d.ts +0 -4
  828. package/dist/modules/src/parser/subParsers/parseNumber.d.ts +0 -3
  829. package/dist/modules/src/parser/subParsers/parseObject.d.ts +0 -3
  830. package/dist/modules/src/parser/subParsers/parseOperand.d.ts +0 -3
  831. package/dist/modules/src/parser/subParsers/parseRegexpShorthand.d.ts +0 -3
  832. package/dist/modules/src/parser/subParsers/parseReservedSymbol.d.ts +0 -3
  833. package/dist/modules/src/parser/subParsers/parseString.d.ts +0 -4
  834. package/dist/modules/src/parser/subParsers/parseSymbol.d.ts +0 -3
  835. package/dist/modules/src/parser/types.d.ts +0 -128
  836. package/dist/modules/src/resume.d.ts +0 -41
  837. package/dist/modules/src/symbolPatterns.d.ts +0 -2
  838. package/dist/modules/src/testFramework/index.d.ts +0 -15
  839. package/dist/modules/src/tokenizer/minifyTokenStream.d.ts +0 -4
  840. package/dist/modules/src/tokenizer/operators.d.ts +0 -12
  841. package/dist/modules/src/tokenizer/reservedNames.d.ts +0 -65
  842. package/dist/modules/src/tokenizer/token.d.ts +0 -82
  843. package/dist/modules/src/tokenizer/tokenize.d.ts +0 -7
  844. package/dist/modules/src/tokenizer/tokenizers.d.ts +0 -13
  845. package/dist/modules/src/tooling.d.ts +0 -51
  846. package/dist/modules/src/transformer/index.d.ts +0 -2
  847. package/dist/modules/src/typeGuards/annotatedCollections.d.ts +0 -16
  848. package/dist/modules/src/typeGuards/array.d.ts +0 -9
  849. package/dist/modules/src/typeGuards/astNode.d.ts +0 -19
  850. package/dist/modules/src/typeGuards/dvala.d.ts +0 -26
  851. package/dist/modules/src/typeGuards/dvalaFunction.d.ts +0 -9
  852. package/dist/modules/src/typeGuards/index.d.ts +0 -7
  853. package/dist/modules/src/typeGuards/number.d.ts +0 -66
  854. package/dist/modules/src/typeGuards/string.d.ts +0 -15
  855. package/dist/modules/src/untokenizer/index.d.ts +0 -2
  856. package/dist/modules/src/utils/arity.d.ts +0 -10
  857. package/dist/modules/src/utils/debug/debugTools.d.ts +0 -1
  858. package/dist/modules/src/utils/debug/getCodeMarker.d.ts +0 -2
  859. package/dist/modules/src/utils/debug/getSourceCodeInfo.d.ts +0 -2
  860. package/dist/modules/src/utils/docString/generateDocString.d.ts +0 -4
  861. package/dist/modules/src/utils/getAssertionError.d.ts +0 -3
  862. package/dist/modules/src/utils/index.d.ts +0 -14
  863. package/dist/modules/src/utils/maybePromise.d.ts +0 -54
  864. package/dist/modules/src/utils/symbols.d.ts +0 -3
  865. package/dist/modules/string.esm.js +0 -2
  866. package/dist/modules/string.esm.js.map +0 -1
  867. package/dist/modules/string.js +0 -2
  868. package/dist/modules/string.js.map +0 -1
  869. package/dist/modules/vector.esm.js +0 -2
  870. package/dist/modules/vector.esm.js.map +0 -1
  871. package/dist/modules/vector.js +0 -2
  872. package/dist/modules/vector.js.map +0 -1
  873. package/dist/reference/api.d.ts +0 -73
  874. package/dist/reference/datatype.d.ts +0 -3
  875. package/dist/reference/index.d.ts +0 -195
  876. package/dist/reference/shorthand.d.ts +0 -3
  877. package/dist/src/AutoCompleter/AutoCompleter.d.ts +0 -27
  878. package/dist/src/Cache.d.ts +0 -16
  879. package/dist/src/allModules.d.ts +0 -2
  880. package/dist/src/builtin/bindingNode.d.ts +0 -11
  881. package/dist/src/builtin/core/array.d.ts +0 -2
  882. package/dist/src/builtin/core/assertion.d.ts +0 -2
  883. package/dist/src/builtin/core/bitwise.d.ts +0 -2
  884. package/dist/src/builtin/core/collection.d.ts +0 -2
  885. package/dist/src/builtin/core/functional.d.ts +0 -2
  886. package/dist/src/builtin/core/math.d.ts +0 -2
  887. package/dist/src/builtin/core/meta.d.ts +0 -3
  888. package/dist/src/builtin/core/misc.d.ts +0 -2
  889. package/dist/src/builtin/core/object.d.ts +0 -2
  890. package/dist/src/builtin/core/predicates.d.ts +0 -2
  891. package/dist/src/builtin/core/regexp.d.ts +0 -2
  892. package/dist/src/builtin/core/sequence.d.ts +0 -2
  893. package/dist/src/builtin/core/string.d.ts +0 -2
  894. package/dist/src/builtin/core/vector.d.ts +0 -2
  895. package/dist/src/builtin/index.d.ts +0 -13
  896. package/dist/src/builtin/interface.d.ts +0 -113
  897. package/dist/src/builtin/modules/assertion/docs.d.ts +0 -2
  898. package/dist/src/builtin/modules/assertion/index.d.ts +0 -2
  899. package/dist/src/builtin/modules/bitwise/index.d.ts +0 -2
  900. package/dist/src/builtin/modules/collection/index.d.ts +0 -2
  901. package/dist/src/builtin/modules/convert/index.d.ts +0 -2
  902. package/dist/src/builtin/modules/functional/index.d.ts +0 -2
  903. package/dist/src/builtin/modules/grid/docs.d.ts +0 -2
  904. package/dist/src/builtin/modules/grid/fromArray.d.ts +0 -8
  905. package/dist/src/builtin/modules/grid/index.d.ts +0 -2
  906. package/dist/src/builtin/modules/grid/transpose.d.ts +0 -2
  907. package/dist/src/builtin/modules/interface.d.ts +0 -28
  908. package/dist/src/builtin/modules/linear-algebra/docs.d.ts +0 -2
  909. package/dist/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +0 -1
  910. package/dist/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +0 -2
  911. package/dist/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +0 -8
  912. package/dist/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +0 -4
  913. package/dist/src/builtin/modules/linear-algebra/helpers/dot.d.ts +0 -1
  914. package/dist/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +0 -7
  915. package/dist/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +0 -2
  916. package/dist/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +0 -1
  917. package/dist/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +0 -10
  918. package/dist/src/builtin/modules/linear-algebra/helpers/length.d.ts +0 -1
  919. package/dist/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +0 -1
  920. package/dist/src/builtin/modules/linear-algebra/helpers/scale.d.ts +0 -1
  921. package/dist/src/builtin/modules/linear-algebra/helpers/solve.d.ts +0 -8
  922. package/dist/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +0 -1
  923. package/dist/src/builtin/modules/linear-algebra/index.d.ts +0 -4
  924. package/dist/src/builtin/modules/math/index.d.ts +0 -2
  925. package/dist/src/builtin/modules/matrix/docs.d.ts +0 -2
  926. package/dist/src/builtin/modules/matrix/helpers/adjugate.d.ts +0 -1
  927. package/dist/src/builtin/modules/matrix/helpers/band.d.ts +0 -9
  928. package/dist/src/builtin/modules/matrix/helpers/cofactor.d.ts +0 -1
  929. package/dist/src/builtin/modules/matrix/helpers/determinant.d.ts +0 -6
  930. package/dist/src/builtin/modules/matrix/helpers/diagonal.d.ts +0 -1
  931. package/dist/src/builtin/modules/matrix/helpers/inverse.d.ts +0 -6
  932. package/dist/src/builtin/modules/matrix/helpers/isBanded.d.ts +0 -11
  933. package/dist/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +0 -10
  934. package/dist/src/builtin/modules/matrix/helpers/isIdentity.d.ts +0 -1
  935. package/dist/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +0 -1
  936. package/dist/src/builtin/modules/matrix/helpers/isSquare.d.ts +0 -1
  937. package/dist/src/builtin/modules/matrix/helpers/isSymetric.d.ts +0 -8
  938. package/dist/src/builtin/modules/matrix/helpers/isTriangular.d.ts +0 -13
  939. package/dist/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +0 -7
  940. package/dist/src/builtin/modules/matrix/helpers/minor.d.ts +0 -1
  941. package/dist/src/builtin/modules/matrix/helpers/norm1.d.ts +0 -1
  942. package/dist/src/builtin/modules/matrix/helpers/trace.d.ts +0 -8
  943. package/dist/src/builtin/modules/matrix/index.d.ts +0 -4
  944. package/dist/src/builtin/modules/number-theory/binomialCefficient.d.ts +0 -1
  945. package/dist/src/builtin/modules/number-theory/combinations.d.ts +0 -2
  946. package/dist/src/builtin/modules/number-theory/derangements.d.ts +0 -2
  947. package/dist/src/builtin/modules/number-theory/divisors.d.ts +0 -4
  948. package/dist/src/builtin/modules/number-theory/docs.d.ts +0 -2
  949. package/dist/src/builtin/modules/number-theory/factorial.d.ts +0 -3
  950. package/dist/src/builtin/modules/number-theory/index.d.ts +0 -4
  951. package/dist/src/builtin/modules/number-theory/partitions.d.ts +0 -2
  952. package/dist/src/builtin/modules/number-theory/permutations.d.ts +0 -2
  953. package/dist/src/builtin/modules/number-theory/powerSet.d.ts +0 -2
  954. package/dist/src/builtin/modules/number-theory/primeFactors.d.ts +0 -11
  955. package/dist/src/builtin/modules/number-theory/sequences/abundant.d.ts +0 -2
  956. package/dist/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +0 -2
  957. package/dist/src/builtin/modules/number-theory/sequences/bell.d.ts +0 -1
  958. package/dist/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +0 -2
  959. package/dist/src/builtin/modules/number-theory/sequences/catalan.d.ts +0 -1
  960. package/dist/src/builtin/modules/number-theory/sequences/collatz.d.ts +0 -2
  961. package/dist/src/builtin/modules/number-theory/sequences/composite.d.ts +0 -3
  962. package/dist/src/builtin/modules/number-theory/sequences/deficient.d.ts +0 -2
  963. package/dist/src/builtin/modules/number-theory/sequences/factorial.d.ts +0 -1
  964. package/dist/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +0 -1
  965. package/dist/src/builtin/modules/number-theory/sequences/geometric.d.ts +0 -2
  966. package/dist/src/builtin/modules/number-theory/sequences/golomb.d.ts +0 -2
  967. package/dist/src/builtin/modules/number-theory/sequences/happy.d.ts +0 -2
  968. package/dist/src/builtin/modules/number-theory/sequences/index.d.ts +0 -27
  969. package/dist/src/builtin/modules/number-theory/sequences/juggler.d.ts +0 -2
  970. package/dist/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +0 -2
  971. package/dist/src/builtin/modules/number-theory/sequences/lucas.d.ts +0 -1
  972. package/dist/src/builtin/modules/number-theory/sequences/lucky.d.ts +0 -2
  973. package/dist/src/builtin/modules/number-theory/sequences/mersenne.d.ts +0 -1
  974. package/dist/src/builtin/modules/number-theory/sequences/padovan.d.ts +0 -2
  975. package/dist/src/builtin/modules/number-theory/sequences/partition.d.ts +0 -1
  976. package/dist/src/builtin/modules/number-theory/sequences/pell.d.ts +0 -1
  977. package/dist/src/builtin/modules/number-theory/sequences/perfect.d.ts +0 -1
  978. package/dist/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +0 -2
  979. package/dist/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +0 -10
  980. package/dist/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +0 -2
  981. package/dist/src/builtin/modules/number-theory/sequences/poligonal.d.ts +0 -2
  982. package/dist/src/builtin/modules/number-theory/sequences/prime.d.ts +0 -3
  983. package/dist/src/builtin/modules/number-theory/sequences/recaman.d.ts +0 -9
  984. package/dist/src/builtin/modules/number-theory/sequences/sylvester.d.ts +0 -1
  985. package/dist/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +0 -2
  986. package/dist/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +0 -1
  987. package/dist/src/builtin/modules/sequence/index.d.ts +0 -2
  988. package/dist/src/builtin/modules/string/index.d.ts +0 -2
  989. package/dist/src/builtin/modules/vector/bincount.d.ts +0 -9
  990. package/dist/src/builtin/modules/vector/calcMad.d.ts +0 -1
  991. package/dist/src/builtin/modules/vector/calcMean.d.ts +0 -1
  992. package/dist/src/builtin/modules/vector/calcMedad.d.ts +0 -1
  993. package/dist/src/builtin/modules/vector/calcMedian.d.ts +0 -1
  994. package/dist/src/builtin/modules/vector/calcStdDev.d.ts +0 -2
  995. package/dist/src/builtin/modules/vector/calcVariance.d.ts +0 -2
  996. package/dist/src/builtin/modules/vector/docs.d.ts +0 -2
  997. package/dist/src/builtin/modules/vector/entropy.d.ts +0 -8
  998. package/dist/src/builtin/modules/vector/histogram.d.ts +0 -9
  999. package/dist/src/builtin/modules/vector/index.d.ts +0 -2
  1000. package/dist/src/builtin/modules/vector/mode.d.ts +0 -6
  1001. package/dist/src/builtin/modules/vector/outliers.d.ts +0 -7
  1002. package/dist/src/builtin/modules/vector/percentile.d.ts +0 -7
  1003. package/dist/src/builtin/modules/vector/quartiles.d.ts +0 -1
  1004. package/dist/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +0 -2
  1005. package/dist/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +0 -2
  1006. package/dist/src/builtin/modules/vector/reductionFunctions/index.d.ts +0 -13
  1007. package/dist/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +0 -2
  1008. package/dist/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +0 -5
  1009. package/dist/src/builtin/modules/vector/reductionFunctions/mad.d.ts +0 -2
  1010. package/dist/src/builtin/modules/vector/reductionFunctions/mean.d.ts +0 -4
  1011. package/dist/src/builtin/modules/vector/reductionFunctions/medad.d.ts +0 -2
  1012. package/dist/src/builtin/modules/vector/reductionFunctions/median.d.ts +0 -2
  1013. package/dist/src/builtin/modules/vector/reductionFunctions/prod.d.ts +0 -2
  1014. package/dist/src/builtin/modules/vector/reductionFunctions/rms.d.ts +0 -2
  1015. package/dist/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +0 -3
  1016. package/dist/src/builtin/modules/vector/reductionFunctions/span.d.ts +0 -2
  1017. package/dist/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +0 -3
  1018. package/dist/src/builtin/modules/vector/reductionFunctions/sum.d.ts +0 -2
  1019. package/dist/src/builtin/modules/vector/reductionFunctions/variance.d.ts +0 -3
  1020. package/dist/src/builtin/normalExpressions/index.d.ts +0 -9
  1021. package/dist/src/builtin/normalExpressions/initCoreDvala.d.ts +0 -1
  1022. package/dist/src/builtin/specialExpressionTypes.d.ts +0 -24
  1023. package/dist/src/builtin/specialExpressions/and.d.ts +0 -6
  1024. package/dist/src/builtin/specialExpressions/array.d.ts +0 -6
  1025. package/dist/src/builtin/specialExpressions/block.d.ts +0 -7
  1026. package/dist/src/builtin/specialExpressions/cond.d.ts +0 -6
  1027. package/dist/src/builtin/specialExpressions/defined.d.ts +0 -5
  1028. package/dist/src/builtin/specialExpressions/effect.d.ts +0 -5
  1029. package/dist/src/builtin/specialExpressions/functions.d.ts +0 -6
  1030. package/dist/src/builtin/specialExpressions/if.d.ts +0 -6
  1031. package/dist/src/builtin/specialExpressions/import.d.ts +0 -6
  1032. package/dist/src/builtin/specialExpressions/let.d.ts +0 -6
  1033. package/dist/src/builtin/specialExpressions/loop.d.ts +0 -6
  1034. package/dist/src/builtin/specialExpressions/loops.d.ts +0 -9
  1035. package/dist/src/builtin/specialExpressions/match.d.ts +0 -7
  1036. package/dist/src/builtin/specialExpressions/object.d.ts +0 -6
  1037. package/dist/src/builtin/specialExpressions/or.d.ts +0 -6
  1038. package/dist/src/builtin/specialExpressions/parallel.d.ts +0 -6
  1039. package/dist/src/builtin/specialExpressions/perform.d.ts +0 -6
  1040. package/dist/src/builtin/specialExpressions/qq.d.ts +0 -6
  1041. package/dist/src/builtin/specialExpressions/race.d.ts +0 -6
  1042. package/dist/src/builtin/specialExpressions/recur.d.ts +0 -5
  1043. package/dist/src/builtin/specialExpressions/unless.d.ts +0 -6
  1044. package/dist/src/builtin/utils.d.ts +0 -6
  1045. package/dist/src/bundler/index.d.ts +0 -9
  1046. package/dist/src/bundler/interface.d.ts +0 -15
  1047. package/dist/src/bundler.d.ts +0 -3
  1048. package/dist/src/constants/constants.d.ts +0 -19
  1049. package/dist/src/createDvala.d.ts +0 -47
  1050. package/dist/src/debug.d.ts +0 -115
  1051. package/dist/src/errors.d.ts +0 -24
  1052. package/dist/src/evaluator/ContextStack.d.ts +0 -70
  1053. package/dist/src/evaluator/contentHash.d.ts +0 -21
  1054. package/dist/src/evaluator/dedupSubTrees.d.ts +0 -37
  1055. package/dist/src/evaluator/effectRef.d.ts +0 -27
  1056. package/dist/src/evaluator/effectTypes.d.ts +0 -181
  1057. package/dist/src/evaluator/frames.d.ts +0 -513
  1058. package/dist/src/evaluator/interface.d.ts +0 -14
  1059. package/dist/src/evaluator/serialization.d.ts +0 -38
  1060. package/dist/src/evaluator/standardEffects.d.ts +0 -50
  1061. package/dist/src/evaluator/step.d.ts +0 -175
  1062. package/dist/src/evaluator/suspension.d.ts +0 -86
  1063. package/dist/src/evaluator/trampoline.d.ts +0 -133
  1064. package/dist/src/full.d.ts +0 -16
  1065. package/dist/src/getUndefinedSymbols/index.d.ts +0 -7
  1066. package/dist/src/index.d.ts +0 -21
  1067. package/dist/src/initReferenceData.d.ts +0 -1
  1068. package/dist/src/interface.d.ts +0 -7
  1069. package/dist/src/modules/assertion.d.ts +0 -2
  1070. package/dist/src/modules/bitwise.d.ts +0 -2
  1071. package/dist/src/modules/collection.d.ts +0 -2
  1072. package/dist/src/modules/convert.d.ts +0 -2
  1073. package/dist/src/modules/functional.d.ts +0 -2
  1074. package/dist/src/modules/grid.d.ts +0 -2
  1075. package/dist/src/modules/linear-algebra.d.ts +0 -2
  1076. package/dist/src/modules/math.d.ts +0 -2
  1077. package/dist/src/modules/matrix.d.ts +0 -2
  1078. package/dist/src/modules/number-theory.d.ts +0 -2
  1079. package/dist/src/modules/sequence.d.ts +0 -2
  1080. package/dist/src/modules/string.d.ts +0 -2
  1081. package/dist/src/modules/vector.d.ts +0 -2
  1082. package/dist/src/parser/ParserContext.d.ts +0 -20
  1083. package/dist/src/parser/getPrecedence.d.ts +0 -3
  1084. package/dist/src/parser/helpers.d.ts +0 -19
  1085. package/dist/src/parser/index.d.ts +0 -5
  1086. package/dist/src/parser/subParsers/parseArray.d.ts +0 -3
  1087. package/dist/src/parser/subParsers/parseBindingTarget.d.ts +0 -8
  1088. package/dist/src/parser/subParsers/parseCond.d.ts +0 -4
  1089. package/dist/src/parser/subParsers/parseDo.d.ts +0 -3
  1090. package/dist/src/parser/subParsers/parseExpression.d.ts +0 -5
  1091. package/dist/src/parser/subParsers/parseForOrDoseq.d.ts +0 -4
  1092. package/dist/src/parser/subParsers/parseFunction.d.ts +0 -4
  1093. package/dist/src/parser/subParsers/parseFunctionCall.d.ts +0 -3
  1094. package/dist/src/parser/subParsers/parseIfOrUnless.d.ts +0 -5
  1095. package/dist/src/parser/subParsers/parseImplicitBlock.d.ts +0 -5
  1096. package/dist/src/parser/subParsers/parseLet.d.ts +0 -4
  1097. package/dist/src/parser/subParsers/parseLoop.d.ts +0 -4
  1098. package/dist/src/parser/subParsers/parseMatch.d.ts +0 -4
  1099. package/dist/src/parser/subParsers/parseNumber.d.ts +0 -3
  1100. package/dist/src/parser/subParsers/parseObject.d.ts +0 -3
  1101. package/dist/src/parser/subParsers/parseOperand.d.ts +0 -3
  1102. package/dist/src/parser/subParsers/parseRegexpShorthand.d.ts +0 -3
  1103. package/dist/src/parser/subParsers/parseReservedSymbol.d.ts +0 -3
  1104. package/dist/src/parser/subParsers/parseString.d.ts +0 -4
  1105. package/dist/src/parser/subParsers/parseSymbol.d.ts +0 -3
  1106. package/dist/src/parser/types.d.ts +0 -128
  1107. package/dist/src/resume.d.ts +0 -41
  1108. package/dist/src/symbolPatterns.d.ts +0 -2
  1109. package/dist/src/testFramework/index.d.ts +0 -15
  1110. package/dist/src/tokenizer/minifyTokenStream.d.ts +0 -4
  1111. package/dist/src/tokenizer/operators.d.ts +0 -12
  1112. package/dist/src/tokenizer/reservedNames.d.ts +0 -65
  1113. package/dist/src/tokenizer/token.d.ts +0 -82
  1114. package/dist/src/tokenizer/tokenize.d.ts +0 -7
  1115. package/dist/src/tokenizer/tokenizers.d.ts +0 -13
  1116. package/dist/src/tooling.d.ts +0 -51
  1117. package/dist/src/transformer/index.d.ts +0 -2
  1118. package/dist/src/typeGuards/annotatedCollections.d.ts +0 -16
  1119. package/dist/src/typeGuards/array.d.ts +0 -9
  1120. package/dist/src/typeGuards/astNode.d.ts +0 -19
  1121. package/dist/src/typeGuards/dvala.d.ts +0 -26
  1122. package/dist/src/typeGuards/dvalaFunction.d.ts +0 -9
  1123. package/dist/src/typeGuards/index.d.ts +0 -7
  1124. package/dist/src/typeGuards/number.d.ts +0 -66
  1125. package/dist/src/typeGuards/string.d.ts +0 -15
  1126. package/dist/src/untokenizer/index.d.ts +0 -2
  1127. package/dist/src/utils/arity.d.ts +0 -10
  1128. package/dist/src/utils/debug/debugTools.d.ts +0 -1
  1129. package/dist/src/utils/debug/getCodeMarker.d.ts +0 -2
  1130. package/dist/src/utils/debug/getSourceCodeInfo.d.ts +0 -2
  1131. package/dist/src/utils/docString/generateDocString.d.ts +0 -4
  1132. package/dist/src/utils/getAssertionError.d.ts +0 -3
  1133. package/dist/src/utils/index.d.ts +0 -14
  1134. package/dist/src/utils/maybePromise.d.ts +0 -54
  1135. package/dist/src/utils/symbols.d.ts +0 -3
  1136. package/dist/testFramework.esm.js +0 -2
  1137. package/dist/testFramework.esm.js.map +0 -1
  1138. package/dist/testFramework.js +0 -2
  1139. package/dist/testFramework.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"testFramework.esm.js","sources":["../src/utils/debug/getCodeMarker.ts","../src/errors.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/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/builtin/core/collection.ts","../src/builtin/core/array.ts","../src/builtin/core/sequence.ts","../src/typeGuards/annotatedCollections.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/utils/maybePromise.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/array.ts","../src/builtin/specialExpressions/effect.ts","../src/builtin/specialExpressions/object.ts","../src/builtin/specialExpressions/import.ts","../src/builtin/specialExpressions/parallel.ts","../src/builtin/specialExpressions/perform.ts","../src/builtin/specialExpressions/race.ts","../src/builtin/specialExpressionTypes.ts","../src/builtin/index.ts","../src/tokenizer/operators.ts","../src/tokenizer/reservedNames.ts","../src/tokenizer/tokenizers.ts","../src/tokenizer/tokenize.ts","../src/AutoCompleter/AutoCompleter.ts","../src/typeGuards/astNode.ts","../src/evaluator/ContextStack.ts","../src/evaluator/interface.ts","../src/getUndefinedSymbols/index.ts","../src/tokenizer/token.ts","../src/parser/helpers.ts","../src/parser/ParserContext.ts","../src/parser/getPrecedence.ts","../src/parser/subParsers/parseImplicitBlock.ts","../src/parser/subParsers/parseDo.ts","../src/parser/subParsers/parseSymbol.ts","../src/parser/subParsers/parseString.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/index.ts","../src/tokenizer/minifyTokenStream.ts","../src/evaluator/effectTypes.ts","../src/evaluator/effectRef.ts","../src/evaluator/contentHash.ts","../src/evaluator/dedupSubTrees.ts","../src/evaluator/suspension.ts","../src/evaluator/standardEffects.ts","../src/evaluator/trampoline.ts","../src/builtin/normalExpressions/initCoreDvala.ts","../src/builtin/core/collection.dvala","../src/builtin/core/sequence.dvala","../src/builtin/core/array.dvala","../src/builtin/core/functional.dvala","../src/builtin/core/object.dvala","../src/Cache.ts","../src/bundler/interface.ts","../src/createDvala.ts","../src/tooling.ts","../src/builtin/modules/assertion/docs.ts","../src/builtin/modules/assertion/index.ts","../src/builtin/modules/assertion/assertion.dvala","../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/grid/grid.dvala","../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/vector/vector.dvala","../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/linear-algebra/linear-algebra.dvala","../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/matrix/matrix.dvala","../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/number-theory/number-theory.dvala","../src/builtin/modules/interface.ts","../src/builtin/modules/math/index.ts","../src/builtin/modules/math/math.dvala","../src/builtin/modules/functional/index.ts","../src/builtin/modules/functional/functional.dvala","../src/builtin/modules/string/index.ts","../src/builtin/modules/string/string.dvala","../src/builtin/modules/collection/index.ts","../src/builtin/modules/collection/collection.dvala","../src/builtin/modules/sequence/index.ts","../src/builtin/modules/sequence/sequence.dvala","../src/builtin/modules/bitwise/index.ts","../src/builtin/modules/bitwise/bitwise.dvala","../src/builtin/modules/convert/index.ts","../src/allModules.ts","../src/builtin/modules/convert/convert.dvala","../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 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 'EffectMatcher',\n 'Builtin',\n 'SpecialBuiltin',\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 { 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, 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('UserDefinedFunction', 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 || isEffect(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 isEffect(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 asEffect(value: unknown, sourceCodeInfo?: SourceCodeInfo): EffectRef {\n assertEffect(value, sourceCodeInfo)\n return value\n}\nexport function assertEffect(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is EffectRef {\n if (!isEffect(value))\n throw getAssertionError('Effect', 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 'do assert(0, \"Expected a positive value\") with case effect(dvala.error) then ([msg]) -> msg 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","import type { Any, Arr, Coll, Obj } from '../../interface'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { collHasKey, deepEqual, toAny } from '../../utils'\nimport { asAny, assertAny, assertColl, assertObj, 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 { toFixedArity } from '../../utils/arity'\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: () => { throw new Error('filter is implemented in Dvala') },\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: () => { throw new Error('map is implemented in Dvala') },\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: () => { throw new Error('reduce is implemented in Dvala') },\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 { toFixedArity } from '../../utils/arity'\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 depth: { type: 'integer', description: 'The depth level specifying how deep a nested array structure should be flattened. Defaults to `Infinity`.' },\n },\n variants: [{ argumentNames: ['x'] }, { argumentNames: ['x', 'depth'] }],\n description: 'Takes a nested array $x and flattens it.',\n seeAlso: ['mapcat'],\n examples: [\n 'flatten([1, 2, [3, 4], 5])',\n 'flatten([1, [2, [3, [4]]]], 1)',\n 'flatten([1, [2, [3, [4]]]], 2)',\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: () => { throw new Error('mapcat is implemented in Dvala') },\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: () => { throw new Error('moving-fn is implemented in Dvala') },\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: () => { throw new Error('running-fn is implemented in Dvala') },\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, assertSeq } from '../../typeGuards/dvala'\nimport { assertNumber } from '../../typeGuards/number'\nimport { assertString } from '../../typeGuards/string'\nimport { deepEqual, toAny } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\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' },\n start: { type: 'integer', description: 'Defaults to `0`.' },\n stop: { type: 'integer', description: 'Defaults to length of sequence + 1.' },\n },\n variants: [\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: () => { throw new Error('some is implemented in Dvala') },\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: () => { throw new Error('sort is implemented in Dvala') },\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: () => { throw new Error('take-while is implemented in Dvala') },\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: () => { throw new Error('drop-while is implemented in Dvala') },\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 annotatedVectors = new WeakSet<unknown[]>()\nconst annotadedNonVectors = new WeakSet<unknown[]>()\nconst annotadedMatrices = new WeakSet<unknown[]>()\nconst annotatedNonMatrices = new WeakSet<unknown[]>()\nconst annotatedGrids = new WeakSet<unknown[]>()\nconst annotatedNonGrids = 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 (annotatedVectors.has(vector)) {\n return true\n }\n if (annotadedNonVectors.has(vector)) {\n return false\n }\n\n if (vector.every(elem => isNumber(elem))) {\n annotatedArrays.add(vector)\n annotatedVectors.add(vector)\n return true\n }\n annotadedNonVectors.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, typePred?: (elem: unknown) => boolean): grid is unknown[][] {\n if (!Array.isArray(grid)) {\n return false\n }\n if (annotatedGrids.has(grid)) {\n return true\n }\n if (annotatedNonGrids.has(grid)) {\n return false\n }\n if (grid.length === 0) {\n annotatedNonGrids.add(grid)\n return false\n }\n if (!Array.isArray(grid[0])) {\n annotatedNonGrids.add(grid)\n return false\n }\n const nbrOfCols = grid[0].length\n if (nbrOfCols === 0) {\n annotatedNonGrids.add(grid)\n return false\n }\n for (const row of grid) {\n if (!Array.isArray(row)) {\n annotatedNonGrids.add(grid)\n return false\n }\n if (row.length !== nbrOfCols) {\n annotatedNonGrids.add(grid)\n return false\n }\n if (typePred && row.some(cell => !typePred(cell))) {\n // typePred failure is a type constraint issue, not a structural one.\n // Don't cache in annotatedNonGrids — the value IS structurally a grid,\n // just not one where all cells satisfy the predicate.\n return false\n }\n }\n annotatedArrays.add(grid)\n annotatedGrids.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 (!isGrid(matrix, isNumber)) {\n if (Array.isArray(matrix)) {\n annotatedNonMatrices.add(matrix)\n }\n return false\n }\n annotadedMatrices.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/annotatedCollections'\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 { DvalaError } from '../../errors'\nimport type { Any } from '../../interface'\nimport type { EffectMatcherFunction } from '../../parser/types'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { asAny, asEffect, assertAny, isEffect, isRegularExpression } from '../../typeGuards/dvala'\nimport { isDvalaFunction } from '../../typeGuards/dvalaFunction'\nimport { assertNumber } from '../../typeGuards/number'\nimport { asStringOrNumber, assertString, assertStringOrNumber } from '../../typeGuards/string'\nimport { compare, deepEqual } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport { FUNCTION_SYMBOL } from '../../utils/symbols'\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 '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 'effect-name': {\n evaluate: ([first], sourceCodeInfo): string => {\n return asEffect(first, sourceCodeInfo).name\n },\n arity: toFixedArity(1),\n docs: {\n category: 'meta',\n returns: { type: 'string' },\n args: {\n e: { type: 'any', description: 'An effect reference.' },\n },\n variants: [{ argumentNames: ['e'] }],\n description: 'Returns the name of an effect reference as a string.',\n seeAlso: ['effect-matcher', 'effect?'],\n examples: [\n 'effect-name(effect(dvala.error))',\n 'effect-name(effect(llm.complete))',\n ],\n },\n },\n 'effect-matcher': {\n evaluate: ([pattern], sourceCodeInfo): EffectMatcherFunction => {\n if (typeof pattern === 'string') {\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'EffectMatcher',\n matchType: 'string',\n pattern,\n flags: '',\n arity: toFixedArity(1),\n }\n }\n if (isRegularExpression(pattern)) {\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'EffectMatcher',\n matchType: 'regexp',\n pattern: pattern.s,\n flags: pattern.f,\n arity: toFixedArity(1),\n }\n }\n throw new DvalaError('effect-matcher expects a string or regexp pattern', sourceCodeInfo)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'meta',\n returns: { type: 'function' },\n args: {\n pattern: { type: ['string', 'regexp'], description: 'A wildcard pattern or regexp to match against effect names.' },\n },\n variants: [{ argumentNames: ['pattern'] }],\n description: 'Returns a predicate function that matches effects by name. If $pattern is a string, uses wildcard matching: no wildcard means exact match, `.*` suffix matches the prefix and all descendants (dot boundary enforced), and `*` alone matches everything. If $pattern is a regexp, tests the effect name against the regexp.',\n seeAlso: ['effect-name', 'effect?'],\n examples: [\n 'let pred = effect-matcher(\"dvala.*\"); pred(effect(dvala.error))',\n 'let pred = effect-matcher(\"dvala.*\"); pred(effect(custom.foo))',\n 'let pred = effect-matcher(\"*\"); pred(effect(anything))',\n ],\n },\n },\n 'type-of': {\n evaluate: ([value]): string => {\n if (value === null || value === undefined)\n return 'null'\n if (typeof value === 'boolean')\n return 'boolean'\n if (typeof value === 'number')\n return 'number'\n if (typeof value === 'string')\n return 'string'\n if (isEffect(value))\n return 'effect'\n if (isRegularExpression(value))\n return 'regexp'\n if (isDvalaFunction(value))\n return 'function'\n if (Array.isArray(value))\n return 'array'\n return 'object'\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'string' },\n args: {\n x: { type: 'any', description: 'The value to inspect.' },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns a string representing the type of $x. Possible return values are `\"number\"`, `\"string\"`, `\"boolean\"`, `\"null\"`, `\"array\"`, `\"object\"`, `\"function\"`, `\"regexp\"`, and `\"effect\"`.',\n seeAlso: ['number?', 'string?', 'boolean?', 'null?', 'array?', 'object?', 'function?', 'regexp?', 'effect?'],\n examples: [\n 'type-of(42)',\n 'type-of(\"hello\")',\n 'type-of(true)',\n 'type-of(null)',\n 'type-of([1, 2, 3])',\n 'type-of({ a: 1 })',\n 'type-of((x) -> x + 1)',\n 'type-of(regexp(\"^start\"))',\n 'type-of(effect(dvala.io.println))',\n ],\n },\n },\n}\n","import type { Any, Arr, Obj } from '../../interface'\nimport { assertArray, assertStringArray } from '../../typeGuards/array'\nimport { assertObj } from '../../typeGuards/dvala'\nimport { asString, assertString } from '../../typeGuards/string'\nimport { collHasKey, toAny } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\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: () => { throw new Error('merge-with is implemented in Dvala') },\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, isEffect, isObj, isRegularExpression, isSeq } from '../../typeGuards/dvala'\nimport { assertNumber, isNumber } from '../../typeGuards/number'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { isGrid, isMatrix, isVector } from '../../typeGuards/annotatedCollections'\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?', 'type-of'],\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?', 'type-of'],\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?', 'type-of'],\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?', 'type-of'],\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?', 'type-of'],\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?', 'type-of'],\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?', 'type-of'],\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?', 'type-of'],\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 'effect?': {\n evaluate: ([value]): boolean => isEffect(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 an effect, otherwise `false`.',\n seeAlso: ['effect', 'effect-name', 'effect-matcher', 'perform', 'type-of'],\n examples: [\n 'effect?(effect(dvala.io.println))',\n 'effect?(42)',\n 'effect?(\"hello\")',\n 'effect?(null)',\n 'effect?({})',\n 'effect?([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' },\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: 'string' },\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: 'string' },\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', array: true },\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 } 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 { FUNCTION_SYMBOL } from '../../utils/symbols'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { assertFunctionLike } from '../../typeGuards/dvala'\n\nexport const functionalNormalExpression: BuiltinNormalExpressions = {\n '|>': {\n evaluate: () => { throw new Error('|> is implemented in Dvala') },\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: (): never => { throw new Error('apply is implemented in Dvala') },\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, EffectReference, FunctionReference, TypedValue } from '../../../reference'\n\ntype DocStringSource = FunctionReference | EffectReference\n\nexport function generateDocString(reference: DocStringSource): 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 isEffectRef(ref: DocStringSource): ref is EffectReference {\n return 'effect' in ref\n}\n\nfunction signature(reference: DocStringSource): string[] {\n const { title, variants, args, returns } = reference\n const isOperator = !isEffectRef(reference) && reference._isOperator\n\n const functionForms = variants.map((variant) => {\n if (isEffectRef(reference)) {\n // Effect form: perform(effect(name), arg1, arg2)\n const argsStr = variant.argumentNames.length > 0\n ? `, ${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 ` perform(effect(${title})${argsStr}) -> ${type(returns)}`\n }\n\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/annotatedCollections'\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 { EffectReference, 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> = {}\nconst effectReference: Record<string, EffectReference> = {}\n\nexport function setNormalExpressionReference(reference: Record<CoreNormalExpressionName, FunctionReference>) {\n Object.assign(normalExpressionReference, reference)\n}\n\nexport function setEffectReference(reference: Record<string, EffectReference>) {\n Object.assign(effectReference, reference)\n}\n\nconst expressions: BuiltinNormalExpressions = {\n // Core categories\n ...assertionNormalExpression,\n ...bitwiseNormalExpression,\n ...collectionNormalExpression,\n ...arrayNormalExpression,\n ...sequenceNormalExpression,\n ...mathNormalExpression,\n ...getMetaNormalExpression(normalExpressionReference, effectReference),\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 { EffectReference, FunctionReference } from '../../../reference'\nimport { assertNonUndefined } from '../../typeGuards'\nimport { assertFunctionLike, isEffect } from '../../typeGuards/dvala'\nimport { isDvalaFunction } from '../../typeGuards/dvalaFunction'\nimport { assertString } from '../../typeGuards/string'\nimport { toFixedArity } from '../../utils/arity'\nimport { generateDocString } from '../../utils/docString/generateDocString'\nimport type { Any } from '../../interface'\nimport type { Arity, BuiltinNormalExpressions } from '../interface'\nimport { FUNCTION_SYMBOL } from '../../utils/symbols'\n\nexport function getMetaNormalExpression(\n normalExpressionReference: Record<string, FunctionReference>,\n effectReference: Record<string, EffectReference>,\n): BuiltinNormalExpressions {\n return {\n 'doc': {\n evaluate: ([value], sourceCodeInfo): string => {\n assertNonUndefined(normalExpressionReference)\n\n // Handle effects\n if (isEffect(value)) {\n const key = `-effect-${value.name}`\n const ref = effectReference[key]\n return ref ? generateDocString(ref) : ''\n }\n\n // Handle functions\n assertFunctionLike(value, sourceCodeInfo)\n if (!isDvalaFunction(value)) {\n return ''\n }\n if (value.functionType === 'Builtin') {\n const reference = normalExpressionReference[value.name]\n return reference ? generateDocString(reference) : ''\n }\n if (value.functionType === 'UserDefined') {\n return value.docString\n }\n return ''\n },\n arity: toFixedArity(1),\n docs: {\n category: 'meta',\n returns: { type: 'string' },\n args: { value: { type: ['function', 'effect'] } },\n variants: [{ argumentNames: ['value'] }],\n description: 'Returns documentation string of the $value. Works on functions and effects.',\n seeAlso: ['arity', 'with-doc'],\n examples: [\n 'doc(+)',\n 'doc(effect(dvala.io.println))',\n 'let add = (x, y) -> x + y with-doc \"Adds two numbers.\";\\ndoc(add)',\n ],\n },\n },\n 'with-doc': {\n evaluate: ([fn, docString], sourceCodeInfo): Any => {\n assertFunctionLike(fn, sourceCodeInfo)\n assertString(docString, sourceCodeInfo)\n if (!isDvalaFunction(fn) || fn.functionType !== 'UserDefined') {\n throw new Error('with-doc can only be used with user-defined functions')\n }\n return {\n ...fn,\n [FUNCTION_SYMBOL]: true,\n docString,\n }\n },\n arity: toFixedArity(2),\n docs: {\n category: 'meta',\n returns: { type: 'function' },\n args: {\n a: { type: 'function' },\n b: { type: 'string' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns a new function with the documentation string $b attached. The original function is not modified.',\n seeAlso: ['doc'],\n examples: [\n '((x, y) -> x + y) with-doc \"Adds two numbers.\"',\n 'let add = (x, y) -> x + y;\\nadd with-doc \"Adds x and y.\"',\n ],\n },\n },\n 'arity': {\n evaluate: ([value], sourceCodeInfo): Arity | Any => {\n // Handle effects\n if (isEffect(value)) {\n const key = `-effect-${value.name}`\n const ref = effectReference[key]\n if (!ref)\n return {}\n // Derive arity from variants\n const argCounts = ref.variants.map(v => v.argumentNames.length)\n const min = Math.min(...argCounts)\n const max = Math.max(...argCounts)\n return { min, max }\n }\n\n // Handle functions\n assertFunctionLike(value, sourceCodeInfo)\n return isDvalaFunction(value) ? value.arity : toFixedArity(1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'meta',\n returns: { type: 'object' },\n args: { value: { type: ['function', 'effect'] } },\n variants: [{ argumentNames: ['value'] }],\n description: 'Returns arity of the $value. 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. Also works on effects.',\n seeAlso: ['doc'],\n examples: [\n 'arity(+)',\n 'arity(defined?)',\n 'arity(effect(dvala.random.int))',\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 \"FALSE\"\n case true then \"TRUE\"\nend`,\n `\ncond\n case false then \"FALSE\"\n case null then \"null\"\nend ?? \"TRUE\"`,\n `\ncond\n case false then \"FALSE\"\n case null then \"null\"\nend ?? \"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 { 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 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 EffectMatcherFunction extends GenericDvalaFunction {\n functionType: 'EffectMatcher'\n matchType: 'string' | 'regexp'\n pattern: string // For string: the pattern string; for regexp: the source\n flags: string // For regexp: the flags; for string: empty string\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['??']\n}\n\nexport interface ModuleFunction extends GenericDvalaFunction {\n functionType: 'Module'\n moduleName: string\n functionName: string\n}\n\nexport type DvalaFunction =\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 | EffectMatcherFunction\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","/**\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 { 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 { 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 DoNode = SpecialExpressionNode<[typeof specialExpressionTypes['block'], AstNode[], WithHandler[] | undefined]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['do body end', 'do body with case effect(name) then handler end'],\n details: [\n ['body', 'expressions', 'The expressions to evaluate.'],\n ['effect(name)', 'expression', 'An expression evaluating to an effect value.'],\n ['handler', 'expression', 'A function (args) -> result that handles the effect. Its return value resumes the perform call.'],\n ],\n description: 'Evaluates `body`. Resulting value is the value of the last expression. '\n + 'Effect handlers can be installed via `with` to intercept `perform` calls.',\n examples: [\n `\ndo\n let a = 1 + 2 + 3 + 4;\n let b = -> $ * ( $ + 1 );\n b(a)\nend`,\n `\ndo\n perform(effect(dvala.io.println), \"hello\")\nwith\n case effect(dvala.io.println) then ([msg]) -> null\nend`,\n ],\n}\n\nexport const doSpecialExpression: BuiltinSpecialExpression<Any, DoNode> = {\n arity: {},\n docs,\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const bodyResult = getUndefinedSymbols(node[1][1], contextStack.create({}), builtin, evaluateNode)\n const withHandlers = node[1][2]\n if (!withHandlers || withHandlers.length === 0) {\n return bodyResult\n }\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 return joinSets(bodyResult, withResult)\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]>\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 \"TRUE\"\nelse\n \"FALSE\"\nend`,\n 'if false then \"TRUE\" else \"FALSE\" end',\n 'if true then \"TRUE\" end',\n 'if false then \"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 \"TRUE\"\nelse\n \"FALSE\"\nend`,\n 'unless false then \"TRUE\" else \"FALSE\" end',\n 'unless true then \"TRUE\" end',\n 'unless false then \"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 );\nb(a)`],\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]) -> perform(effect(dvala.io.println), 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 if zero?(n) then\n 0\n else\n n + recur(n - 1)\n end\nend;\nfoo(3)`,\n `\n((n) -> do\n if zero?(n) then\n 0\n else\n n + recur(n - 1)\n end\nend)(3)`,\n `\nloop (n = 3, acc = 0) -> do\n if zero?(n) then\n acc\n else\n recur(n - 1, acc + n)\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 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.io.println`.'],\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.io.println)',\n '==(effect(llm.complete), effect(llm.complete))',\n ],\n seeAlso: ['effect?'],\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 { 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 { 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 `do/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 `\ndo\n perform(effect(dvala.io.println), \"hello\")\nwith\n case effect(dvala.io.println) then ([msg]) -> msg\nend\n`,\n ],\n seeAlso: ['effect?'],\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","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 'unless': 16,\n 'import': 17,\n 'effect': 18,\n 'perform': 19,\n 'parallel': 20,\n 'race': 21,\n} as const\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 { 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 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['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 { 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 '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 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 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","import { isSymbolicOperator } from './operators'\nimport type { BasePrefixedNumberToken, 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\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 tokenizeString,\n tokenizeRegexpShorthand,\n tokenizeBasePrefixedNumber,\n tokenizeNumber,\n tokenizeOperator,\n tokenizeSymbol,\n] as const satisfies Tokenizer<Token>[]\n","import { 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: string | undefined): 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 { normalExpressionKeys, specialExpressionKeys } from '../builtin'\nimport { tokenize } from '../tokenizer/tokenize'\nimport { reservedSymbolRecord } from '../tokenizer/reservedNames'\n\nexport interface AutoCompleterParams {\n bindings?: Record<string, unknown>\n}\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, params: AutoCompleterParams = {}) {\n const partialProgram = this.originalProgram.slice(0, this.originalPosition)\n const tokenStream = tokenize(partialProgram, false, undefined)\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: AutoCompleterParams): 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: AutoCompleterParams, 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.bindings ?? {})\n .filter(shouldInclude)\n .forEach(suggestion => suggestions.add(suggestion))\n\n return [...suggestions].sort((a, b) => a.localeCompare(b))\n }\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 { 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 { DvalaModule } from '../builtin/modules/interface'\nimport type { 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\ninterface CreateContextStackParams {\n globalContext?: Context\n contexts?: Context[]\n bindings?: Record<string, unknown>\n globalModuleScope?: boolean\n}\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 modules: Map<string, DvalaModule>\n private valueModules: Map<string, unknown>\n public pure: boolean\n constructor({\n contexts,\n values: hostValues,\n modules,\n valueModules,\n pure,\n }: {\n contexts: Context[]\n values?: Record<string, unknown>\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.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 /** Get the top-level module scope as plain key→value bindings. */\n public getModuleScopeBindings(): Record<string, unknown> {\n const scope = this._contexts[0]!\n const result: Record<string, unknown> = {}\n for (const [k, v] of Object.entries(scope))\n result[k] = v.value\n return result\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`, `modules`) come from resume options.\n */\n public static fromDeserialized(params: {\n contexts: Context[]\n globalContextIndex: number\n values?: Record<string, unknown>\n modules?: Map<string, DvalaModule>\n pure: boolean\n }): ContextStackImpl {\n const cs = new ContextStackImpl({\n contexts: params.contexts,\n values: params.values,\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 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 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 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['??']: {\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: CreateContextStackParams = {}, 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 let hostValues: Record<string, unknown> | 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 assertNotShadowingBuiltin(identifier)\n if (!hostValues) {\n hostValues = {}\n }\n hostValues[identifier] = entry\n }\n }\n\n const contextStack = new ContextStackImpl({\n contexts,\n values: hostValues,\n modules,\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","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, undefined]] 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 { 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 '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 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 | 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 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 { 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', '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' | '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, undefined]], 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 type { DoNode, WithHandler } from '../../builtin/specialExpressions/block'\nimport { specialExpressionTypes } from '../../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../../constants/constants'\nimport { DvalaError } from '../../errors'\nimport { asReservedSymbolToken, assertReservedSymbolToken, isOperatorToken, isReservedSymbolToken } from '../../tokenizer/token'\nimport type { AstNode } from '../types'\nimport type { ParserContext } from '../ParserContext'\nimport { withSourceCodeInfo } from '../helpers'\nimport { parseImplicitBlock } from './parseImplicitBlock'\n\nexport function parseDo(ctx: ParserContext): DoNode {\n const token = asReservedSymbolToken(ctx.tryPeek(), 'do')\n ctx.advance()\n\n const expressions: AstNode[] = []\n while (!ctx.isAtEnd() && !isReservedSymbolToken(ctx.tryPeek(), 'end') && !isReservedSymbolToken(ctx.tryPeek(), 'with')) {\n expressions.push(ctx.parseExpression())\n if (isOperatorToken(ctx.tryPeek(), ';')) {\n ctx.advance()\n }\n else if (!isReservedSymbolToken(ctx.tryPeek(), 'end') && !isReservedSymbolToken(ctx.tryPeek(), 'with')) {\n throw new DvalaError('Expected end', ctx.peekSourceCodeInfo())\n }\n }\n\n // Parse optional with-handlers\n let withHandlers: WithHandler[] | undefined\n if (isReservedSymbolToken(ctx.tryPeek(), 'with')) {\n ctx.advance()\n withHandlers = []\n while (!ctx.isAtEnd() && !isReservedSymbolToken(ctx.tryPeek(), 'end')) {\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', 'end'])\n withHandlers.push([effectExpr, handlerFn])\n }\n }\n\n assertReservedSymbolToken(ctx.tryPeek(), 'end')\n ctx.advance()\n return withSourceCodeInfo([NodeTypes.SpecialExpression, [specialExpressionTypes.block, expressions, withHandlers]], token[2]) satisfies DoNode\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 { 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 { 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 if (isReservedSymbolToken(ctx.peek(), 'do')) {\n const doNode = parseDo(ctx)\n const withHandlers = doNode[1][2]\n if (withHandlers && withHandlers.length > 0) {\n // do...with...end: preserve the full DoNode as a single expression so\n // the with-handlers are not lost.\n nodes = [doNode]\n }\n else {\n // Plain do...end: unwrap body expressions for multi-statement lambdas.\n nodes = doNode[1][1]\n }\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 ],\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 if (isReservedSymbolToken(ctx.peek(), 'do')) {\n const doNode = parseDo(ctx)\n const withHandlers = doNode[1][2]\n if (withHandlers && withHandlers.length > 0) {\n // do...with...end: preserve the full DoNode so the with-handlers are not lost.\n nodes = [doNode]\n }\n else {\n // Plain do...end: unwrap body expressions.\n nodes = doNode[1][1]\n }\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 ]]], 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 { 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.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.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'\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 }\n }\n else if (isReservedSymbolToken(token, 'do')) {\n left = parseDo(ctx)\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 { 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 { 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","/**\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// Snapshot — captured continuation point\n// ---------------------------------------------------------------------------\n\n/**\n * A captured continuation point. Created by `suspend()` or `checkpoint()`.\n * The `continuation` field is opaque — hosts should not inspect or modify it.\n */\nexport interface Snapshot {\n /** Opaque serialized continuation. Do not inspect or modify. */\n readonly continuation: unknown\n\n /** Wall-clock timestamp (Date.now()) when snapshot was taken. */\n readonly timestamp: number\n\n /** Stable sequence number (0-based, never reused within an execution lineage). */\n readonly index: number\n\n /** UUID identifying the run() or resume() call that created this snapshot. */\n readonly runId: string\n\n /** Optional domain metadata from the perform call or suspend call. */\n readonly meta?: Any\n}\n\n// ---------------------------------------------------------------------------\n// Run ID generation\n// ---------------------------------------------------------------------------\n\n/**\n * Generate a UUID for identifying a run() or resume() call.\n * Uses crypto.randomUUID() when available, falls back to a simple generator.\n */\nexport function generateRunId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID()\n }\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0\n return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16)\n })\n}\n\n// ---------------------------------------------------------------------------\n// Snapshot state — mutable state owned by a single run()/resume() call\n// ---------------------------------------------------------------------------\n\n/**\n * Mutable snapshot state that lives for the duration of a single\n * `runEffectLoop` invocation. Threaded through tick → dispatchPerform →\n * dispatchHostHandler so that host handlers can access and create snapshots.\n */\nexport interface SnapshotState {\n /** Accumulated snapshots, oldest first. */\n readonly snapshots: Snapshot[]\n\n /** High-water mark counter for snapshot indices (never reused, even across rollbacks). */\n nextSnapshotIndex: number\n\n /** UUID identifying this run()/resume() call. */\n readonly runId: string\n\n /** Maximum number of snapshots to retain. Oldest are evicted when exceeded. */\n readonly maxSnapshots?: number\n}\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`, `suspend`, `fail`, or `next`,\n * exactly once. Calling more than one, or calling any more than once, is a\n * programming error.\n */\nexport interface EffectContext {\n /** Full dotted name of the performed effect (useful for wildcard handlers). */\n effectName: string\n\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 * Propagate as a Dvala-level error. If `msg` is provided it overrides the\n * default error message. The error flows through `dvala.error` handlers.\n */\n fail: (msg?: string) => void\n\n /**\n * Suspend the program. The entire execution state is captured and returned\n * in `RunResult` as `{ type: 'suspended', snapshot }`.\n * `meta` is passed through to `Snapshot.meta` for domain context\n * (e.g., assignee, deadline, priority).\n */\n suspend: (meta?: Any) => void\n\n /**\n * Pass to the next registered handler whose pattern matches this effect.\n * If no further handler matches, the effect is unhandled.\n */\n next: () => void\n\n /** All snapshots taken so far, oldest first. Read-only view. */\n snapshots: readonly Snapshot[]\n\n /**\n * Explicitly capture a snapshot at the current continuation point.\n * Returns the new Snapshot. This is the host-side equivalent of\n * `perform(effect(dvala.checkpoint))`.\n */\n checkpoint: (meta?: Any) => Snapshot\n\n /**\n * Abandon current execution and resume from a previous snapshot.\n * All snapshots after the target are discarded.\n */\n resumeFrom: (snapshot: Snapshot, value: Any) => void\n}\n\n/** A function that handles an effect by calling `resume`, `suspend`, `fail`, or `next`. */\nexport type EffectHandler = (ctx: EffectContext) => void | Promise<void>\n\n/** Map from effect pattern (e.g. `'llm.complete'`, `'dvala.*'`, `'*'`) to its handler. */\nexport type Handlers = Record<string, EffectHandler>\n\n// ---------------------------------------------------------------------------\n// Pattern matching utilities for wildcard host handlers\n// ---------------------------------------------------------------------------\n\n/**\n * Test whether a handler pattern key matches a given effect name.\n *\n * Rules:\n * - No wildcard → exact match only\n * - `.*` suffix → matches the named effect itself AND all descendants\n * (dot boundary enforced: `dvala.*` matches `dvala.error` but NOT `dvalaXXX`)\n * - `*` alone → matches everything\n */\nexport function effectNameMatchesPattern(effectName: string, pattern: string): boolean {\n if (pattern === '*') {\n return true\n }\n if (pattern.endsWith('.*')) {\n const prefix = pattern.slice(0, -2) // e.g. \"dvala.*\" → \"dvala\"\n return effectName === prefix || effectName.startsWith(`${prefix}.`)\n }\n return effectName === pattern\n}\n\n/**\n * Find all matching async handlers for an effect name, in registration order.\n * Returns an array of `[pattern, handler]` pairs.\n */\nexport function findMatchingHandlers(\n effectName: string,\n handlers: Handlers | undefined,\n): Array<[string, EffectHandler]> {\n if (!handlers) {\n return []\n }\n const result: Array<[string, EffectHandler]> = []\n for (const [pattern, handler] of Object.entries(handlers)) {\n if (effectNameMatchesPattern(effectName, pattern)) {\n result.push([pattern, handler])\n }\n }\n return result\n}\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, definedBindings?: Record<string, unknown> }\n | { type: 'suspended', snapshot: Snapshot }\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 /** Accumulated snapshots at the point of suspension. */\n public readonly snapshots: Snapshot[],\n /** High-water mark for snapshot indices at the point of suspension. */\n public readonly nextSnapshotIndex: number,\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// ---------------------------------------------------------------------------\n// ResumeFrom signal — used internally by the trampoline\n// ---------------------------------------------------------------------------\n\n/**\n * Thrown (as a promise rejection) by `resumeFrom()` inside a host handler.\n * Caught by the effect trampoline loop — NOT by Dvala-level try/catch.\n * Carries the serialized continuation from the target snapshot, the value\n * to resume with, and the snapshot index for trimming.\n */\nexport class ResumeFromSignal {\n public readonly _brand = 'ResumeFromSignal' as const\n constructor(\n /** The serialized continuation from the target snapshot. */\n public readonly continuation: unknown,\n /** The value to feed into the restored continuation. */\n public readonly value: Any,\n /** Snapshots with index > trimToIndex will be discarded. */\n public readonly trimToIndex: number,\n ) {}\n}\n\nexport function isResumeFromSignal(value: unknown): value is ResumeFromSignal {\n return value instanceof ResumeFromSignal\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","/**\n * Content-addressable hashing for JSON-compatible value trees.\n *\n * Uses FNV-1a (32-bit) for fast, deterministic hashing. The hash is\n * computed bottom-up (Merkle-style): child hashes feed directly into\n * the parent hash as integers, avoiding intermediate string allocation.\n *\n * The hash is returned as a number (the raw 32-bit FNV-1a result).\n */\n\n// FNV-1a constants (32-bit)\nconst FNV_OFFSET_BASIS = 0x811C9DC5\nconst FNV_PRIME = 0x01000193\n\n/**\n * Mix a single byte into an FNV-1a hash state.\n */\nfunction fnvMixByte(hash: number, byte: number): number {\n return Math.imul(hash ^ (byte & 0xFF), FNV_PRIME)\n}\n\n/**\n * Mix a 32-bit integer (4 bytes, little-endian) into an FNV-1a hash state.\n */\nfunction fnvMixInt(hash: number, value: number): number {\n hash = fnvMixByte(hash, value)\n hash = fnvMixByte(hash, value >>> 8)\n hash = fnvMixByte(hash, value >>> 16)\n hash = fnvMixByte(hash, value >>> 24)\n return hash\n}\n\n/**\n * Mix a string into an FNV-1a hash state byte-by-byte (charCode).\n */\nfunction fnvMixString(hash: number, str: string): number {\n for (let i = 0; i < str.length; i++) {\n const code = str.charCodeAt(i)\n hash = fnvMixByte(hash, code)\n hash = fnvMixByte(hash, code >>> 8)\n }\n return hash\n}\n\n// Type tags to distinguish different value types in the hash\nconst TAG_NULL = 0\nconst TAG_BOOLEAN_TRUE = 1\nconst TAG_BOOLEAN_FALSE = 2\nconst TAG_NUMBER = 3\nconst TAG_STRING = 4\nconst TAG_ARRAY = 5\nconst TAG_OBJECT = 6\nconst TAG_UNDEFINED = 7\n\n/**\n * Compute a deterministic content hash for any JSON-compatible value tree.\n *\n * Properties:\n * - Identical structures produce identical hashes\n * - Object key order does not affect the hash (keys are sorted)\n * - Returns a 32-bit integer (FNV-1a)\n *\n * Supports: null, undefined, boolean, number, string, arrays, plain objects.\n * Does not support: class instances, functions, symbols, bigint, etc.\n */\nexport function contentHash(value: unknown): number {\n let hash = FNV_OFFSET_BASIS\n\n if (value === null) {\n hash = fnvMixByte(hash, TAG_NULL)\n return hash >>> 0\n }\n\n if (value === undefined) {\n hash = fnvMixByte(hash, TAG_UNDEFINED)\n return hash >>> 0\n }\n\n const type = typeof value\n\n if (type === 'boolean') {\n hash = fnvMixByte(hash, value ? TAG_BOOLEAN_TRUE : TAG_BOOLEAN_FALSE)\n return hash >>> 0\n }\n\n if (type === 'number') {\n hash = fnvMixByte(hash, TAG_NUMBER)\n // Use the string representation to handle NaN, Infinity consistently.\n // Special-case -0 since String(-0) === \"0\".\n hash = fnvMixString(hash, Object.is(value, -0) ? '-0' : String(value))\n return hash >>> 0\n }\n\n if (type === 'string') {\n hash = fnvMixByte(hash, TAG_STRING)\n hash = fnvMixString(hash, value as string)\n return hash >>> 0\n }\n\n if (Array.isArray(value)) {\n hash = fnvMixByte(hash, TAG_ARRAY)\n hash = fnvMixInt(hash, value.length)\n for (let i = 0; i < value.length; i++) {\n hash = fnvMixInt(hash, contentHash(value[i]))\n }\n return hash >>> 0\n }\n\n // Plain object\n hash = fnvMixByte(hash, TAG_OBJECT)\n const keys = Object.keys(value as Record<string, unknown>).sort()\n hash = fnvMixInt(hash, keys.length)\n for (const key of keys) {\n hash = fnvMixString(hash, key)\n hash = fnvMixInt(hash, contentHash((value as Record<string, unknown>)[key]))\n }\n return hash >>> 0\n}\n","/**\n * Sub-tree deduplication for serialized continuation blobs.\n *\n * Identifies structurally identical sub-trees across multiple root objects,\n * stores each unique sub-tree once in a shared pool, and replaces duplicates\n * with compact references (`{ __poolRef: id }`).\n *\n * Works bottom-up: children are deduplicated before parents, so a parent\n * node that contains pool references can itself be pooled if it appears\n * multiple times with the same pool references.\n */\n\nimport { contentHash } from './contentHash'\n\n// ---------------------------------------------------------------------------\n// Pool reference marker\n// ---------------------------------------------------------------------------\n\ninterface PoolRef { __poolRef: number }\n\nexport function isPoolRef(value: unknown): value is PoolRef {\n return value !== null\n && typeof value === 'object'\n && '__poolRef' in value\n && typeof (value as PoolRef).__poolRef === 'number'\n && Object.keys(value as object).length === 1\n}\n\n// ---------------------------------------------------------------------------\n// Deep structural equality\n// ---------------------------------------------------------------------------\n\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (a === b)\n return true\n if (a === null || b === null)\n return false\n if (typeof a !== typeof b)\n return false\n\n if (Array.isArray(a)) {\n if (!Array.isArray(b))\n return false\n if (a.length !== b.length)\n return false\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i]))\n return false\n }\n return true\n }\n\n if (typeof a !== 'object')\n return false\n\n const aObj = a as Record<string, unknown>\n const bObj = b as Record<string, unknown>\n const aKeys = Object.keys(aObj)\n const bKeys = Object.keys(bObj)\n if (aKeys.length !== bKeys.length)\n return false\n for (const key of aKeys) {\n if (!(key in bObj))\n return false\n if (!deepEqual(aObj[key], bObj[key]))\n return false\n }\n return true\n}\n\n// ---------------------------------------------------------------------------\n// Size estimation\n// ---------------------------------------------------------------------------\n\nfunction estimateSize(value: unknown): number {\n if (value === null)\n return 4\n if (value === undefined)\n return 9\n\n const type = typeof value\n if (type === 'boolean')\n return value ? 4 : 5\n if (type === 'number')\n return String(value).length\n if (type === 'string')\n return (value as string).length + 2\n\n if (Array.isArray(value)) {\n let size = 2 // [ ]\n for (let i = 0; i < value.length; i++) {\n size += estimateSize(value[i]) + 1 // +1 for comma\n }\n return size\n }\n\n const obj = value as Record<string, unknown>\n const keys = Object.keys(obj)\n let size = 2 // { }\n for (const key of keys) {\n size += key.length + 2 + 1 + estimateSize(obj[key]) + 1 // \"key\": value,\n }\n return size\n}\n\n// ---------------------------------------------------------------------------\n// Sub-tree info collected during the walk\n// ---------------------------------------------------------------------------\n\ninterface SubTreeInfo {\n hash: number\n value: unknown\n size: number\n /** Locations where this sub-tree appears (for replacement) */\n locations: Array<{ parent: unknown[] | Record<string, unknown>, key: number | string }>\n}\n\n// ---------------------------------------------------------------------------\n// dedupSubTrees\n// ---------------------------------------------------------------------------\n\n/**\n * Deduplicate identical sub-trees across multiple root values.\n *\n * @param roots - Array of root values to scan for duplicates\n * @param threshold - Minimum estimated byte size for a sub-tree to be pooled (default 200)\n * @returns Object with rewritten roots and the shared pool\n */\nexport function dedupSubTrees(\n roots: unknown[],\n threshold: number = 200,\n): { roots: unknown[], pool: Record<number, unknown> } {\n // Phase 1: Deep-clone roots so we can mutate them in-place\n const clonedRoots = roots.map(r => deepClone(r))\n\n // Phase 2: Walk all roots bottom-up, collecting hash → SubTreeInfo[]\n // Group by hash; entries with the same hash get structural equality checked.\n const hashGroups = new Map<number, SubTreeInfo[]>()\n\n for (let rootIdx = 0; rootIdx < clonedRoots.length; rootIdx++) {\n walkAndCollect(clonedRoots[rootIdx], hashGroups, null, rootIdx)\n }\n\n // Phase 3: Find groups with multiple occurrences that meet the threshold\n const pool: Record<number, unknown> = {}\n let nextId = 0\n\n // Process groups sorted by size descending — pool larger sub-trees first\n const groups = Array.from(hashGroups.values())\n .flat()\n .filter(info => info.locations.length > 1 && info.size >= threshold)\n .sort((a, b) => b.size - a.size)\n\n // Track which pool IDs have been assigned to which sub-tree values\n const alreadyPooled = new Map<SubTreeInfo, number>()\n\n for (const info of groups) {\n if (alreadyPooled.has(info))\n continue\n\n const id = nextId++\n pool[id] = info.value\n alreadyPooled.set(info, id)\n\n // Replace all locations with pool refs\n for (const loc of info.locations) {\n if (Array.isArray(loc.parent)) {\n loc.parent[loc.key as number] = { __poolRef: id }\n }\n else {\n (loc.parent)[loc.key as string] = { __poolRef: id }\n }\n }\n }\n\n return { roots: clonedRoots, pool }\n}\n\n/**\n * Walk a value tree bottom-up, collecting sub-tree info.\n * Only arrays and objects are candidates for pooling (primitives are too small).\n */\nfunction walkAndCollect(\n value: unknown,\n hashGroups: Map<number, SubTreeInfo[]>,\n parentInfo: { parent: unknown[] | Record<string, unknown>, key: number | string } | null,\n _rootIdx: number,\n): number {\n if (value === null || typeof value !== 'object') {\n return contentHash(value)\n }\n\n if (Array.isArray(value)) {\n // Walk children first (bottom-up)\n for (let i = 0; i < value.length; i++) {\n walkAndCollect(value[i], hashGroups, { parent: value, key: i }, _rootIdx)\n }\n }\n else {\n const obj = value as Record<string, unknown>\n for (const key of Object.keys(obj)) {\n walkAndCollect(obj[key], hashGroups, { parent: obj, key }, _rootIdx)\n }\n }\n\n // Compute hash for this node (after children may have been replaced by pool refs)\n const hash = contentHash(value)\n const size = estimateSize(value)\n\n // Only track if it meets minimum size and has a parent (root nodes aren't replaced)\n if (parentInfo && size >= 1) {\n let group = hashGroups.get(hash)\n if (!group) {\n group = []\n hashGroups.set(hash, group)\n }\n\n // Find an existing info entry with structural equality\n let found: SubTreeInfo | undefined\n for (const existing of group) {\n if (deepEqual(existing.value, value)) {\n found = existing\n break\n }\n }\n\n if (found) {\n found.locations.push(parentInfo)\n }\n else {\n group.push({\n hash,\n value: deepClone(value),\n size,\n locations: [parentInfo],\n })\n }\n }\n\n return hash\n}\n\n// ---------------------------------------------------------------------------\n// expandPoolRefs\n// ---------------------------------------------------------------------------\n\n/**\n * Recursively expand all `{ __poolRef: id }` markers in a value tree,\n * replacing them with the corresponding pool values.\n *\n * Pool values themselves may contain pool refs (nested pooling),\n * which are expanded recursively.\n *\n * @throws Error if a pool ref references an unknown ID\n */\nexport function expandPoolRefs(value: unknown, pool: Record<number, unknown>): unknown {\n if (value === null || typeof value !== 'object') {\n return value\n }\n\n if (isPoolRef(value)) {\n const id = value.__poolRef\n if (!(id in pool)) {\n throw new Error(`Unknown pool ref: ${id}`)\n }\n // Recursively expand the pool entry itself (it may contain nested refs)\n return expandPoolRefs(pool[id], pool)\n }\n\n if (Array.isArray(value)) {\n return value.map(item => expandPoolRefs(item, pool))\n }\n\n const obj = value as Record<string, unknown>\n const result: Record<string, unknown> = {}\n for (const key of Object.keys(obj)) {\n result[key] = expandPoolRefs(obj[key], pool)\n }\n return result\n}\n\n// ---------------------------------------------------------------------------\n// Deep clone utility\n// ---------------------------------------------------------------------------\n\nfunction deepClone(value: unknown): unknown {\n if (value === null || typeof value !== 'object') {\n return value\n }\n\n if (Array.isArray(value)) {\n return value.map(item => deepClone(item))\n }\n\n const obj = value as Record<string, unknown>\n const result: Record<string, unknown> = {}\n for (const key of Object.keys(obj)) {\n result[key] = deepClone(obj[key])\n }\n return result\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, modules) on each instance\n */\n\nimport { DvalaError } from '../errors'\nimport type { Any } from '../interface'\n\nimport type { DvalaModule } from '../builtin/modules/interface'\nimport { ContextStackImpl } from './ContextStack'\nimport { dedupSubTrees, expandPoolRefs } from './dedupSubTrees'\nimport type { Context } from './interface'\nimport type { Snapshot } from './effectTypes'\nimport type { ContinuationStack } from './frames'\n\n// ---------------------------------------------------------------------------\n// Constants\n// ---------------------------------------------------------------------------\n\nconst SUSPENSION_VERSION = 2\n\n// Default size threshold for sub-tree pooling (bytes)\nconst DEFAULT_DEDUP_THRESHOLD = 200\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 snapshots?: unknown[] // Snapshot[] preserved across suspend/resume\n nextSnapshotIndex?: number\n pool?: Record<number, unknown> // Shared sub-tree pool (v2+)\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 a plain\n * JSON-compatible object tree.\n *\n * The returned object is the \"continuation\" stored inside a `Snapshot`.\n * It is intentionally typed as `SuspensionBlobData` internally but\n * exposed as `unknown` via the `Snapshot` interface.\n *\n * Validates that all values are serializable.\n * Throws a descriptive `DvalaError` if non-serializable values are found.\n */\nexport function serializeToObject(k: ContinuationStack, meta?: Any): SuspensionBlobData {\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 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 blobData\n}\n\n/**\n * Build a complete suspension blob that includes both the continuation\n * and the accumulated snapshot state. Snapshots are already plain\n * JSON-compatible objects (their `continuation` fields were produced by\n * earlier `serializeToObject` calls), so they're embedded as-is.\n *\n * Runs sub-tree deduplication across all serialized continuations to\n * reduce blob size when snapshots share identical AST sub-trees.\n */\nexport function serializeSuspensionBlob(\n k: ContinuationStack,\n snapshots: unknown[],\n nextSnapshotIndex: number,\n meta?: Any,\n): SuspensionBlobData {\n const base = serializeToObject(k, meta)\n\n if (snapshots.length > 0) {\n base.snapshots = snapshots\n }\n base.nextSnapshotIndex = nextSnapshotIndex\n\n // Run dedup across all serialized data to find shared sub-trees.\n // Collect all top-level objects that may share sub-trees:\n // contextStacks, k, meta, and each snapshot's continuation.\n const roots: unknown[] = [base.contextStacks, base.k]\n if (base.meta !== undefined) {\n roots.push(base.meta)\n }\n if (base.snapshots) {\n for (const snapshot of base.snapshots) {\n roots.push(snapshot)\n }\n }\n\n const { roots: dedupedRoots, pool } = dedupSubTrees(roots, DEFAULT_DEDUP_THRESHOLD)\n\n // Reassemble the blob with deduplicated data\n let rootIdx = 0\n base.contextStacks = dedupedRoots[rootIdx++] as SerializedContextStack[]\n base.k = dedupedRoots[rootIdx++]\n if (base.meta !== undefined) {\n base.meta = dedupedRoots[rootIdx++] as Any\n }\n if (base.snapshots) {\n for (let i = 0; i < base.snapshots.length; i++) {\n base.snapshots[i] = dedupedRoots[rootIdx++]\n }\n }\n\n if (Object.keys(pool).length > 0) {\n base.pool = pool\n }\n\n return base\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 modules?: Map<string, DvalaModule>\n}\n\n/**\n * Deserialize a plain object (as produced by `serializeToObject`) back into\n * 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 deserializeFromObject(\n blobData: unknown,\n options?: DeserializeOptions,\n): { k: ContinuationStack, meta?: Any, snapshots: Snapshot[], nextSnapshotIndex: number } {\n let data = blobData as SuspensionBlobData\n\n if (data.version !== SUSPENSION_VERSION) {\n throw new DvalaError(\n `Unsupported suspension blob version: ${data.version} (expected ${SUSPENSION_VERSION})`,\n undefined,\n )\n }\n\n // If the blob has a pool (v2+), expand all pool refs before processing\n if (data.pool && Object.keys(data.pool).length > 0) {\n const pool = data.pool\n data = {\n ...data,\n contextStacks: expandPoolRefs(data.contextStacks, pool) as SerializedContextStack[],\n k: expandPoolRefs(data.k, pool),\n ...(data.meta !== undefined ? { meta: expandPoolRefs(data.meta, pool) as Any } : {}),\n ...(data.snapshots ? { snapshots: data.snapshots.map(s => expandPoolRefs(s, pool)) } : {}),\n }\n delete data.pool\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 data.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\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 data.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(data.k) as ContinuationStack\n\n // Resolve meta\n const resolvedMeta = data.meta !== undefined ? resolveValue(data.meta) as Any : undefined\n\n return {\n k: resolvedK,\n meta: resolvedMeta,\n snapshots: (data.snapshots ?? []) as Snapshot[],\n nextSnapshotIndex: data.nextSnapshotIndex ?? 0,\n }\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 * Each standard effect has co-located documentation (FunctionDocs) and arity,\n * mirroring the structure of builtin normal expressions and module functions.\n *\n * Sync effects work in both `runSync` and `run`.\n * Async effects (`dvala.sleep`, `dvala.io.read-line` in Node, `dvala.io.read-stdin`) only work in `run` —\n * `runSync` will throw when a Promise surfaces.\n */\n\nimport { DvalaError } from '../errors'\nimport type { Arity, FunctionDocs } from '../builtin/interface'\nimport type { Any, Arr, UnknownRecord } from '../interface'\nimport { isEffect, isRegularExpression } from '../typeGuards/dvala'\nimport { isDvalaFunction } from '../typeGuards/dvalaFunction'\nimport { assertNumberOfParams, toFixedArity } from '../utils/arity'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport type { ContinuationStack } from './frames'\nimport type { Step } from './step'\n\n/* eslint-disable node/prefer-global/process -- isomorphic module: uses `typeof process` for Node/browser feature detection */\n\n// ---------------------------------------------------------------------------\n// Standard effect definition 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 StandardEffectHandlerFn = (args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo) => Step | Promise<Step>\n\n/**\n * A standard effect definition — mirrors BuiltinNormalExpression structure.\n * Each effect has a handler function, arity for validation, and co-located docs.\n */\nexport interface StandardEffectDefinition {\n handler: StandardEffectHandlerFn\n arity: Arity\n docs: FunctionDocs\n}\n\n// ---------------------------------------------------------------------------\n// Shared helpers\n// ---------------------------------------------------------------------------\n\nfunction isNode(): boolean {\n return typeof process !== 'undefined' && typeof process.stdout?.write === 'function'\n}\n\n/**\n * Format a Dvala value for text output (stdout/stderr).\n * - Strings are printed as-is (no quotes).\n * - Numbers, booleans, null: String() coercion.\n * - Functions: `<function name>` or `<builtin function name>`.\n * - Effects: `<effect name>`.\n * - RegExps (Dvala regular expressions): `/pattern/flags`.\n * - Arrays and objects: JSON.stringify with 2-space indent (Infinity → \"∞\").\n */\nfunction formatForOutput(value: unknown): string {\n if (typeof value === 'string')\n return value\n\n if (value === null)\n return 'null'\n\n if (typeof value === 'number' || typeof value === 'boolean')\n return String(value)\n\n if (isDvalaFunction(value)) {\n if (value.functionType === 'Builtin')\n return `<builtin function ${value.normalBuiltinSymbolType}>`\n return `<function ${(value as unknown as UnknownRecord).n ?? '\\u03BB'}>`\n }\n\n if (isEffect(value))\n return `<effect ${value.name}>`\n\n if (isRegularExpression(value))\n return `/${value.s}/${value.f}`\n\n if (typeof value === 'object' && value instanceof RegExp)\n return `${value}`\n\n // Arrays and objects — JSON.stringify with infinity handling\n return JSON.stringify(replaceSpecialValues(value), null, 2)\n}\n\nfunction replaceSpecialValues(value: unknown): unknown {\n if (value === Number.POSITIVE_INFINITY)\n return '∞'\n if (value === Number.NEGATIVE_INFINITY)\n return '-∞'\n if (isDvalaFunction(value))\n return formatForOutput(value)\n if (isEffect(value))\n return formatForOutput(value)\n if (isRegularExpression(value))\n return formatForOutput(value)\n if (Array.isArray(value))\n return value.map(replaceSpecialValues)\n if (typeof value === 'object' && value !== null) {\n const result: Record<string, unknown> = {}\n for (const [key, val] of Object.entries(value))\n result[key] = replaceSpecialValues(val)\n return result\n }\n return value\n}\n\nfunction printHandler(args: Arr, k: ContinuationStack): Step {\n const value = args[0] as Any\n const str = formatForOutput(value)\n if (isNode()) {\n process.stdout.write(str)\n }\n else {\n // eslint-disable-next-line no-console\n console.log(str)\n }\n return { type: 'Value', value, k }\n}\n\nfunction printlnHandler(args: Arr, k: ContinuationStack): Step {\n const value = args[0] as Any\n const str = formatForOutput(value)\n if (isNode()) {\n process.stdout.write(`${str}\\n`)\n }\n else if (typeof globalThis.alert === 'function') {\n // eslint-disable-next-line no-alert\n globalThis.alert(str)\n }\n else {\n // eslint-disable-next-line no-console\n console.log(str)\n }\n return { type: 'Value', value, k }\n}\n\nfunction generateUUID(): 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\n// ---------------------------------------------------------------------------\n// Standard effect definitions (handler + arity + docs)\n// ---------------------------------------------------------------------------\n\nconst standardEffects: Record<string, StandardEffectDefinition> = {\n\n // ── I/O ──────────────────────────────────────────────────────────────────\n\n 'dvala.io.print': {\n handler: printHandler,\n arity: toFixedArity(1),\n docs: {\n category: 'effect',\n description: 'Writes a value to stdout without a trailing newline. Accepts any value — strings are printed as-is, other values are auto-formatted. In Node.js uses `process.stdout.write(str)`, in browsers uses `console.log(str)`. Resumes with the original value (identity).',\n returns: { type: 'any' },\n args: {\n value: { type: 'any', description: 'Value to print.' },\n },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'perform(effect(dvala.io.print), \"hello\")',\n 'perform(effect(dvala.io.print), 42)',\n ],\n seeAlso: ['-effect-dvala.io.println', '-effect-dvala.io.error', '-effect-dvala.io.read-line', 'perform', 'effect'],\n },\n },\n\n 'dvala.io.println': {\n handler: printlnHandler,\n arity: toFixedArity(1),\n docs: {\n category: 'effect',\n description: 'Writes a value to stdout followed by a newline. Accepts any value — strings are printed as-is, other values are auto-formatted. In Node.js uses `process.stdout.write(str + \"\\\\n\")`, in browsers uses `alert(str)`. Resumes with the original value (identity).',\n returns: { type: 'any' },\n args: {\n value: { type: 'any', description: 'Value to print.' },\n },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'perform(effect(dvala.io.println), \"hello\")',\n 'perform(effect(dvala.io.println), [1, 2, 3])',\n ],\n seeAlso: ['-effect-dvala.io.print', '-effect-dvala.io.error', '-effect-dvala.io.read-line', 'perform', 'effect'],\n },\n },\n\n 'dvala.io.error': {\n handler: (args: Arr, k: ContinuationStack): Step => {\n const value = args[0] as Any\n const str = formatForOutput(value)\n if (isNode()) {\n process.stderr.write(`${str}\\n`)\n }\n else {\n console.error(str)\n }\n return { type: 'Value', value, k }\n },\n arity: toFixedArity(1),\n docs: {\n category: 'effect',\n description: 'Writes a value to stderr followed by a newline. Accepts any value — strings are printed as-is, other values are auto-formatted. In Node.js uses `process.stderr.write(str + \"\\\\n\")`, in browsers uses `console.error(str)`. Resumes with the original value (identity).',\n returns: { type: 'any' },\n args: {\n value: { type: 'any', description: 'Value to write to stderr.' },\n },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'perform(effect(dvala.io.error), \"something went wrong\")',\n ],\n seeAlso: ['-effect-dvala.io.print', '-effect-dvala.io.println', 'perform', 'effect'],\n },\n },\n\n 'dvala.io.read-line': {\n handler: (args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo): Step => {\n const message = typeof args[0] === 'string' ? args[0] : ''\n\n // Browser: window.prompt (synchronous)\n if (typeof globalThis.prompt === 'function') {\n // eslint-disable-next-line no-alert\n const result = globalThis.prompt(message)\n return { type: 'Value', value: result ?? null, k }\n }\n\n throw new DvalaError('dvala.io.read-line is not supported in this environment. In Node.js, register a \"dvala.io.read-line\" host handler.', sourceCodeInfo)\n },\n arity: { min: 0, max: 1 },\n docs: {\n category: 'effect',\n description: 'Reads one line of user input. In browsers uses `window.prompt()`. In Node.js uses `readline`. Resumes with the user\\'s input string, or `null` on cancel.',\n returns: { type: ['string', 'null'] },\n args: {\n message: { type: 'string', description: 'Optional prompt message to display.' },\n },\n variants: [\n { argumentNames: [] },\n { argumentNames: ['message'] },\n ],\n examples: [\n 'effect(dvala.io.read-line)',\n ],\n seeAlso: ['-effect-dvala.io.read-stdin', '-effect-dvala.io.print', '-effect-dvala.io.println', 'perform', 'effect'],\n },\n },\n\n 'dvala.io.read-stdin': {\n handler: (_args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo): Promise<Step> => {\n if (!isNode() || !process.stdin) {\n throw new DvalaError('dvala.io.read-stdin is not supported in this environment. Node.js is required.', sourceCodeInfo)\n }\n return new Promise<Step>((resolve, reject) => {\n const chunks: string[] = []\n process.stdin.setEncoding('utf-8')\n process.stdin.on('data', (chunk: string) => chunks.push(chunk))\n process.stdin.on('end', () => resolve({ type: 'Value', value: chunks.join(''), k }))\n process.stdin.on('error', (err: Error) => reject(err))\n process.stdin.resume()\n })\n },\n arity: toFixedArity(0),\n docs: {\n category: 'effect',\n description: 'Reads all of stdin until EOF (Node.js only). Resumes with the full stdin content as a string.',\n returns: { type: 'string' },\n args: {},\n variants: [{ argumentNames: [] }],\n examples: [\n 'effect(dvala.io.read-stdin)',\n ],\n seeAlso: ['-effect-dvala.io.read-line', 'perform', 'effect'],\n },\n },\n\n // ── Random ───────────────────────────────────────────────────────────────\n\n 'dvala.random': {\n handler: (_args: Arr, k: ContinuationStack): Step => {\n return { type: 'Value', value: Math.random(), k }\n },\n arity: toFixedArity(0),\n docs: {\n category: 'effect',\n description: 'Returns a random floating-point number in the range [0, 1). Equivalent to `Math.random()` in JavaScript.',\n returns: { type: 'number' },\n args: {},\n variants: [{ argumentNames: [] }],\n examples: [\n 'perform(effect(dvala.random))',\n ],\n seeAlso: ['-effect-dvala.random.int', '-effect-dvala.random.uuid', '-effect-dvala.random.item', '-effect-dvala.random.shuffle', 'perform', 'effect'],\n },\n },\n\n 'dvala.random.uuid': {\n handler: (_args: Arr, k: ContinuationStack): Step => {\n return { type: 'Value', value: generateUUID(), k }\n },\n arity: toFixedArity(0),\n docs: {\n category: 'effect',\n description: 'Generates a UUID v4 string.',\n returns: { type: 'string' },\n args: {},\n variants: [{ argumentNames: [] }],\n examples: [\n 'perform(effect(dvala.random.uuid))',\n ],\n seeAlso: ['-effect-dvala.random', 'perform', 'effect'],\n },\n },\n\n 'dvala.random.int': {\n handler: (args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo): Step => {\n const min = args[0]\n const max = args[1]\n if (typeof min !== 'number' || !Number.isInteger(min)) {\n throw new DvalaError(`dvala.random.int: min must be an integer, got ${typeof min === 'number' ? min : typeof min}`, sourceCodeInfo)\n }\n if (typeof max !== 'number' || !Number.isInteger(max)) {\n throw new DvalaError(`dvala.random.int: max must be an integer, got ${typeof max === 'number' ? max : typeof max}`, sourceCodeInfo)\n }\n if (max <= min) {\n throw new DvalaError(`dvala.random.int: max (${max}) must be greater than min (${min})`, sourceCodeInfo)\n }\n return { type: 'Value', value: Math.floor(Math.random() * (max - min)) + min, k }\n },\n arity: toFixedArity(2),\n docs: {\n category: 'effect',\n description: 'Returns a random integer in the range [min, max).',\n returns: { type: 'integer' },\n args: {\n min: { type: 'integer', description: 'Minimum value (inclusive).' },\n max: { type: 'integer', description: 'Maximum value (exclusive). Must be greater than min.' },\n },\n variants: [{ argumentNames: ['min', 'max'] }],\n examples: [\n 'perform(effect(dvala.random.int), 1, 100)',\n ],\n seeAlso: ['-effect-dvala.random', '-effect-dvala.random.item', 'perform', 'effect'],\n },\n },\n\n 'dvala.random.item': {\n handler: (args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo): Step => {\n const array = args[0]\n if (!Array.isArray(array)) {\n throw new DvalaError(`dvala.random.item: argument must be an array, got ${typeof array}`, sourceCodeInfo)\n }\n if (array.length === 0) {\n throw new DvalaError('dvala.random.item: cannot pick from an empty array', sourceCodeInfo)\n }\n const index = Math.floor(Math.random() * array.length)\n return { type: 'Value', value: array[index] as Any, k }\n },\n arity: toFixedArity(1),\n docs: {\n category: 'effect',\n description: 'Picks a random element from a non-empty array.',\n returns: { type: 'any' },\n args: {\n array: { type: 'array', description: 'Non-empty array to pick from.' },\n },\n variants: [{ argumentNames: ['array'] }],\n examples: [\n 'perform(effect(dvala.random.item), [\"a\", \"b\", \"c\"])',\n ],\n seeAlso: ['-effect-dvala.random', '-effect-dvala.random.shuffle', '-effect-dvala.random.int', 'perform', 'effect'],\n },\n },\n\n 'dvala.random.shuffle': {\n handler: (args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo): Step => {\n const array = args[0]\n if (!Array.isArray(array)) {\n throw new DvalaError(`dvala.random.shuffle: argument must be an array, got ${typeof array}`, sourceCodeInfo)\n }\n const shuffled: Arr = Array.from(array) as Arr\n for (let i = shuffled.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1))\n const tmp = shuffled[i]\n shuffled[i] = shuffled[j]!\n shuffled[j] = tmp!\n }\n return { type: 'Value', value: shuffled, k }\n },\n arity: toFixedArity(1),\n docs: {\n category: 'effect',\n description: 'Returns a new array with the elements of the input array in random order. Uses the Fisher-Yates shuffle algorithm.',\n returns: { type: 'array' },\n args: {\n array: { type: 'array', description: 'Array to shuffle.' },\n },\n variants: [{ argumentNames: ['array'] }],\n examples: [\n 'perform(effect(dvala.random.shuffle), [1, 2, 3, 4, 5])',\n ],\n seeAlso: ['-effect-dvala.random', '-effect-dvala.random.item', 'perform', 'effect'],\n },\n },\n\n // ── Time ─────────────────────────────────────────────────────────────────\n\n 'dvala.time.now': {\n handler: (_args: Arr, k: ContinuationStack): Step => {\n return { type: 'Value', value: Date.now(), k }\n },\n arity: toFixedArity(0),\n docs: {\n category: 'effect',\n description: 'Returns the current timestamp in milliseconds since the Unix epoch. Equivalent to `Date.now()` in JavaScript.',\n returns: { type: 'number' },\n args: {},\n variants: [{ argumentNames: [] }],\n examples: [\n 'perform(effect(dvala.time.now))',\n ],\n seeAlso: ['-effect-dvala.time.zone', '-effect-dvala.sleep', 'perform', 'effect'],\n },\n },\n\n 'dvala.time.zone': {\n handler: (_args: Arr, k: ContinuationStack): Step => {\n return { type: 'Value', value: Intl.DateTimeFormat().resolvedOptions().timeZone, k }\n },\n arity: toFixedArity(0),\n docs: {\n category: 'effect',\n description: 'Returns the current IANA timezone string, e.g. `\"Europe/Stockholm\"` or `\"America/New_York\"`.',\n returns: { type: 'string' },\n args: {},\n variants: [{ argumentNames: [] }],\n examples: [\n 'perform(effect(dvala.time.zone))',\n ],\n seeAlso: ['-effect-dvala.time.now', 'perform', 'effect'],\n },\n },\n\n // ── Snapshot ──────────────────────────────────────────────────────────────\n\n 'dvala.checkpoint': {\n // The actual snapshot capture is handled as a special case in dispatchPerform\n // (unconditional capture before normal dispatch). This handler is the standard\n // fallback when no local do...with or host handler intercepts the effect.\n handler: (_args: Arr, k: ContinuationStack): Step => {\n return { type: 'Value', value: null, k }\n },\n arity: { min: 0, max: 1 },\n docs: {\n category: 'effect',\n description: 'Captures a snapshot of the current program state (continuation stack). The snapshot is stored in an in-memory list accessible via `ctx.snapshots` in host handlers. Optionally accepts a metadata value for domain context (e.g., step labels, timestamps). The standard fallback resumes with `null`, but host handlers can override the resume value. The snapshot is always captured regardless of whether a handler intercepts.',\n returns: { type: 'null' },\n args: {\n meta: { type: 'any', description: 'Optional metadata to attach to the snapshot.' },\n },\n variants: [\n { argumentNames: [] },\n { argumentNames: ['meta'] },\n ],\n examples: [\n 'perform(effect(dvala.checkpoint))',\n 'perform(effect(dvala.checkpoint), { step: \"analysis-done\" })',\n ],\n seeAlso: ['perform', 'effect'],\n },\n },\n\n // ── Async ────────────────────────────────────────────────────────────────\n\n 'dvala.sleep': {\n handler: (args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo): Promise<Step> => {\n const ms = args[0]\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 arity: toFixedArity(1),\n docs: {\n category: 'effect',\n description: 'Waits for the specified number of milliseconds before resuming. Resumes with `null`. Only works in async execution (`run`) — `runSync` will throw when a Promise surfaces.',\n returns: { type: 'null' },\n args: {\n ms: { type: 'number', description: 'The number of milliseconds to sleep. Must be a non-negative number.' },\n },\n variants: [{ argumentNames: ['ms'] }],\n examples: [\n 'effect(dvala.sleep)',\n ],\n seeAlso: ['-effect-dvala.time.now', 'perform', 'effect'],\n },\n },\n\n}\n\n// ---------------------------------------------------------------------------\n// Public API\n// ---------------------------------------------------------------------------\n\n/** All standard effect names. */\nexport const standardEffectNames: ReadonlySet<string> = new Set(Object.keys(standardEffects))\n\n/** All standard effect definitions (for reference data generation). */\nexport const allStandardEffectDefinitions: Readonly<Record<string, StandardEffectDefinition>> = standardEffects\n\n/**\n * Look up a standard effect definition by name.\n * Returns undefined if the effect is not a standard effect.\n */\nexport function getStandardEffectDefinition(effectName: string): StandardEffectDefinition | undefined {\n return standardEffects[effectName]\n}\n\n/**\n * Look up a standard effect handler by name.\n * Validates arity before calling the handler.\n * Returns undefined if the effect is not a standard effect.\n */\nexport function getStandardEffectHandler(effectName: string): ((args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo) => Step | Promise<Step>) | undefined {\n const def = standardEffects[effectName]\n if (!def)\n return undefined\n\n return (args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo) => {\n assertNumberOfParams(def.arity, args.length, sourceCodeInfo)\n return def.handler(args, k, sourceCodeInfo)\n }\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 { parse } from '../parser'\nimport type {\n Ast,\n AstNode,\n BindingNode,\n BindingTarget,\n CompFunction,\n DvalaFunction,\n EffectMatcherFunction,\n EffectRef,\n EvaluatedFunction,\n EveryPredFunction,\n FNullFunction,\n FunctionLike,\n JuxtFunction,\n ModuleFunction,\n NormalBuiltinFunction,\n NormalExpressionNode,\n NumberNode,\n PartialFunction,\n ReservedSymbolNode,\n SomePredFunction,\n SpecialBuiltinFunction,\n SpecialExpressionNode,\n StringNode,\n SymbolNode,\n UserDefinedFunction,\n} from '../parser/types'\nimport { bindingTargetTypes } from '../parser/types'\nimport { minifyTokenStream } from '../tokenizer/minifyTokenStream'\nimport { reservedSymbolRecord } from '../tokenizer/reservedNames'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { tokenize } from '../tokenizer/tokenize'\nimport { asNonUndefined, isUnknownRecord } from '../typeGuards'\nimport { annotate } from '../typeGuards/annotatedCollections'\nimport { isNormalBuiltinSymbolNode, isNormalExpressionNodeWithName, isSpreadNode, isUserDefinedSymbolNode } from '../typeGuards/astNode'\nimport { asAny, asFunctionLike, assertEffect, assertSeq, isAny, isEffect, isObj } from '../typeGuards/dvala'\nimport { isDvalaFunction, isUserDefinedFunction } 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 { EffectContext, EffectHandler, Handlers, RunResult, Snapshot, SnapshotState } from './effectTypes'\nimport { ResumeFromSignal, SuspensionSignal, effectNameMatchesPattern, findMatchingHandlers, generateRunId, isResumeFromSignal, isSuspensionSignal } from './effectTypes'\nimport type { ContextStack } from './ContextStack'\nimport { getEffectRef } from './effectRef'\nimport type { DeserializeOptions } from './suspension'\nimport { deserializeFromObject, serializeSuspensionBlob, serializeToObject } 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 ImportMergeFrame,\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 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 if (normalExpression.dvalaImpl) {\n return executeUserDefinedRecursive(normalExpression.dvalaImpl, params, contextStack, 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 'EffectMatcher':\n return executeEffectMatcherRecursive(fn, params, sourceCodeInfo)\n case 'Builtin': {\n const normalExpression = builtin.allNormalExpressions[fn.normalBuiltinSymbolType]!\n if (normalExpression.dvalaImpl) {\n return executeUserDefinedRecursive(normalExpression.dvalaImpl, params, contextStack, sourceCodeInfo)\n }\n return executeBuiltinRecursive(fn, params, contextStack, sourceCodeInfo)\n }\n case 'SpecialBuiltin':\n return executeSpecialBuiltinRecursive(fn, params, contextStack, sourceCodeInfo)\n case 'Module':\n return executeModuleRecursive(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 executeEffectMatcherRecursive(fn: EffectMatcherFunction, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n assertNumberOfParams({ min: 1, max: 1 }, params.length, fn.sourceCodeInfo ?? sourceCodeInfo)\n const effectRef = params[0]\n assertEffect(effectRef, sourceCodeInfo)\n const effectName = effectRef.name\n if (fn.matchType === 'string') {\n return effectNameMatchesPattern(effectName, fn.pattern)\n }\n const regexp = new RegExp(fn.pattern, fn.flags)\n return regexp.test(effectName)\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 if (normalExpression.dvalaImpl) {\n return executeUserDefinedRecursive(normalExpression.dvalaImpl, params, contextStack, 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 if (expression.dvalaImpl) {\n return executeUserDefinedRecursive(expression.dvalaImpl, params, contextStack, sourceCodeInfo)\n }\n return expression.evaluate(params, sourceCodeInfo, contextStack, { executeFunction: executeFunctionRecursive })\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, do...with...end) ---\n case specialExpressionTypes.block: {\n const nodes = node[1][1] as AstNode[]\n const withHandlerNodes = node[1][2] as [AstNode, AstNode][] | undefined\n const newContext: Context = {}\n const newEnv = env.create(newContext)\n\n // Build the continuation for the body\n let bodyK = k\n if (withHandlerNodes && withHandlerNodes.length > 0) {\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 bodyK = [withFrame, ...k]\n }\n\n if (nodes.length === 0) {\n return { type: 'Value', value: null, k: bodyK }\n }\n if (nodes.length === 1) {\n return { type: 'Eval', node: nodes[0]!, env: newEnv, k: bodyK }\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, ...bodyK] }\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 // --- 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 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: Obj = {}\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 if (dvalaModule.source) {\n const nodes = parse(minifyTokenStream(tokenize(dvalaModule.source, false, undefined), { removeWhiteSpace: true }))\n const sourceEnv = env.create({})\n const mergeFrame: ImportMergeFrame = { type: 'ImportMerge', tsFunctions: result, moduleName, module: dvalaModule, env, sourceCodeInfo }\n if (nodes.length === 1) {\n return { type: 'Eval', node: nodes[0]!, env: sourceEnv, k: [mergeFrame, ...k] }\n }\n const sequenceFrame: SequenceFrame = { type: 'Sequence', nodes, index: 1, env: sourceEnv }\n return { type: 'Eval', node: nodes[0]!, env: sourceEnv, k: [sequenceFrame, mergeFrame, ...k] }\n }\n env.registerValueModule(moduleName, result)\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 if (normalExpression.dvalaImpl) {\n return setupUserDefinedCall(normalExpression.dvalaImpl, params, env, sourceCodeInfo, k)\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 'EffectMatcher':\n case 'SpecialBuiltin': {\n const result = executeDvalaFunctionRecursive(fn, params, env, sourceCodeInfo)\n return wrapMaybePromiseAsStep(result, k)\n }\n case 'Module': {\n const dvalaModule = env.getModule(fn.moduleName)\n const expression = dvalaModule?.functions[fn.functionName]\n if (expression?.dvalaImpl) {\n assertNumberOfParams(expression.arity, params.length, sourceCodeInfo)\n return setupUserDefinedCall(expression.dvalaImpl, params, env, sourceCodeInfo, k)\n }\n const result = executeDvalaFunctionRecursive(fn, params, env, sourceCodeInfo)\n return wrapMaybePromiseAsStep(result, k)\n }\n case 'Builtin': {\n const normalExpression = builtin.allNormalExpressions[fn.normalBuiltinSymbolType]!\n if (normalExpression.dvalaImpl) {\n return setupUserDefinedCall(normalExpression.dvalaImpl, params, env, sourceCodeInfo, k)\n }\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 'Recur':\n return applyRecur(frame, value, k)\n case 'PerformArgs':\n return applyPerformArgs(frame, 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 case 'ImportMerge': {\n const dvalaFunctions = isObj(value) ? value : {}\n // Set dvalaImpl on module expressions for functions overridden by .dvala source\n for (const [name, fn] of Object.entries(dvalaFunctions)) {\n const expression = frame.module.functions[name]\n if (expression && isUserDefinedFunction(fn)) {\n expression.dvalaImpl = fn\n }\n }\n // Merge: .dvala functions that DON'T have a matching TS expression override entirely\n // (they are module-only .dvala functions). Functions WITH a TS expression keep\n // the Module function value (arity checking preserved) and dispatch via dvalaImpl.\n const dvalaOnlyFunctions: Obj = {}\n for (const [name, fn] of Object.entries(dvalaFunctions)) {\n if (!frame.module.functions[name]) {\n dvalaOnlyFunctions[name] = fn\n }\n }\n const merged = { ...frame.tsFunctions, ...dvalaOnlyFunctions }\n frame.env.registerValueModule(frame.moduleName, merged)\n return { type: 'Value', value: merged, k }\n }\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 // Use env.create(frame.context) to ensure post-deserialization correctness:\n // after serialize/deserialize, frame.context and the context inside frame.env\n // may be separate objects, so mutations to frame.context won't be visible\n // through frame.env. Pushing frame.context on top guarantees current values.\n const bodyEnv = env.create(frame.context)\n return { type: 'Eval', node: body, env: bodyEnv, k: [newFrame, ...k] }\n}\n\n/**\n * Search the continuation stack for the nearest TryCatchFrame.\n * Since TryCatchFrame has been removed, this now always re-throws the error.\n * Kept as a helper for the transition period while `throw` still exists.\n */\n/**\n * Try to route a DvalaError through the 'dvala.error' algebraic effect.\n *\n * Mirrors the dispatch logic in `dispatchPerform` but returns `null` instead\n * of throwing when no handler matches, so the caller can fall back to\n * re-throwing the error as a JS exception.\n *\n * Search order:\n * 1. Local `TryWithFrame` handlers (innermost first)\n * 2. Host handlers registered for `'dvala.error'`\n */\nfunction tryDispatchDvalaError(\n error: DvalaError,\n k: ContinuationStack,\n handlers?: Handlers,\n signal?: AbortSignal,\n snapshotState?: SnapshotState,\n): Step | Promise<Step> | null {\n const effect = getEffectRef('dvala.error')\n const args: Arr = [error.shortMessage]\n\n // Check local TryWithFrame handlers (same logic as dispatchPerform)\n for (let i = 0; i < k.length; i++) {\n const frame = k[i]!\n if (frame.type === 'TryWith') {\n for (const handler of frame.handlers) {\n if (handlerMatchesEffect(handler, effect, frame.env, error.sourceCodeInfo)) {\n return invokeMatchedHandler(handler, frame, args, k, i, error.sourceCodeInfo)\n }\n }\n }\n }\n\n // Check host handlers for 'dvala.error' (supports wildcards like 'dvala.*' or '*')\n const matchingHostHandlers = findMatchingHandlers('dvala.error', handlers)\n if (matchingHostHandlers.length > 0) {\n return dispatchHostHandler('dvala.error', matchingHostHandlers, args, k, signal, error.sourceCodeInfo, snapshotState)\n }\n\n return null\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 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 assertEffect(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, sourceCodeInfo: frame.sourceCodeInfo }\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), ...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 */\n\n/**\n * Check if a handler's case clause matches the given effect.\n * Supports two forms:\n * - EffectRef: exact name match (`case effect(dvala.error)`)\n * - Predicate function: called with the effect, truthy = match (`case my-predicate`)\n *\n * Predicate functions must be synchronous — async predicates throw an error.\n */\nfunction handlerMatchesEffect(\n handler: EvaluatedWithHandler,\n effect: EffectRef,\n env: ContextStack,\n sourceCodeInfo?: SourceCodeInfo,\n): boolean {\n if (isEffect(handler.effectRef)) {\n return handler.effectRef.name === effect.name\n }\n if (isDvalaFunction(handler.effectRef)) {\n const result = executeFunctionRecursive(handler.effectRef, [effect], env, sourceCodeInfo)\n if (result instanceof Promise) {\n throw new DvalaError('Effect handler predicates must be synchronous', sourceCodeInfo)\n }\n return !!result\n }\n return false\n}\n\n/**\n * Invoke a matched handler for a performed effect.\n * Builds the handler continuation and dispatches the handler function.\n */\nfunction invokeMatchedHandler(\n handler: EvaluatedWithHandler,\n frame: TryWithFrame,\n args: Arr,\n k: ContinuationStack,\n frameIndex: number,\n sourceCodeInfo?: SourceCodeInfo,\n): Step | Promise<Step> {\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 so errors and effects from the\n // handler propagate upward past the current do...with block.\n const outerK = k.slice(frameIndex + 1)\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 — return value is the resume value\n return dispatchFunction(fnLike, [args], [], frame.env, sourceCodeInfo, handlerK)\n}\n\nfunction dispatchPerform(effect: EffectRef, args: Arr, k: ContinuationStack, sourceCodeInfo?: SourceCodeInfo, handlers?: Handlers, signal?: AbortSignal, snapshotState?: SnapshotState): Step | Promise<Step> {\n // dvala.checkpoint — unconditional snapshot capture before normal dispatch.\n // The snapshot is always captured regardless of whether any handler intercepts.\n if (effect.name === 'dvala.checkpoint' && snapshotState) {\n const meta = args[0] as Any | undefined\n const continuation = serializeToObject(k)\n const snapshot: Snapshot = {\n continuation,\n timestamp: Date.now(),\n index: snapshotState.nextSnapshotIndex++,\n runId: snapshotState.runId,\n ...(meta !== undefined ? { meta } : {}),\n }\n snapshotState.snapshots.push(snapshot)\n if (snapshotState.maxSnapshots !== undefined && snapshotState.snapshots.length > snapshotState.maxSnapshots) {\n snapshotState.snapshots.shift()\n }\n }\n\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 (handlerMatchesEffect(handler, effect, frame.env, sourceCodeInfo)) {\n return invokeMatchedHandler(handler, frame, args, k, i, sourceCodeInfo)\n }\n }\n }\n }\n\n // No matching local handler found — dispatch to host handler if available.\n const matchingHostHandlers = findMatchingHandlers(effect.name, handlers)\n if (matchingHostHandlers.length > 0) {\n return dispatchHostHandler(effect.name, matchingHostHandlers, args, k, signal, sourceCodeInfo, snapshotState)\n }\n\n // No host handler — check standard effects (dvala.io.println, dvala.time.now, etc.).\n const standardHandler = getStandardEffectHandler(effect.name)\n if (standardHandler) {\n return standardHandler(args, k, sourceCodeInfo)\n }\n\n // dvala.error is special — when unhandled, throw UserDefinedError\n // so the error message propagates as a proper user error.\n if (effect.name === 'dvala.error') {\n const message = typeof args[0] === 'string' ? args[0] : String(args[0] ?? 'Unknown error')\n throw new UserDefinedError(message, 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 host-provided JavaScript handlers (middleware chain).\n *\n * Creates an `EffectContext` with `resume`, `suspend`, `fail`, and `next`\n * callbacks, then calls the first matching handler. If the handler calls\n * `next()`, the next handler in the chain is invoked with the same context\n * shape. If no more handlers remain after `next()`, the effect is unhandled.\n *\n * Each handler must call exactly one of `resume`, `suspend`, `fail`, or\n * `next` before its promise resolves (async) or before returning (sync).\n *\n * - `resume(value)` — resolves with a `ValueStep` that continues evaluation.\n * - `suspend(meta?)` — throws a `SuspensionSignal`.\n * - `fail(msg?)` — produces an `ErrorStep` routed through `dvala.error`.\n * - `next()` — pass to the next matching handler in the chain.\n *\n * Handlers may return `void` (synchronous) or `Promise<void>` (async).\n * When all handlers in a chain are synchronous, this function returns\n * a `Step` synchronously, allowing use from the sync trampoline.\n */\nfunction dispatchHostHandler(\n effectName: string,\n matchingHandlers: Array<[string, EffectHandler]>,\n args: Arr,\n k: ContinuationStack,\n signal: AbortSignal | undefined,\n sourceCodeInfo: SourceCodeInfo | undefined,\n snapshotState?: SnapshotState,\n): Step | Promise<Step> {\n const effectSignal = signal ?? new AbortController().signal\n const argsArray = Array.from(args) as Any[]\n\n type HandlerOutcome =\n | { kind: 'step', step: Step }\n | { kind: 'asyncResume', promise: Promise<Any> }\n | { kind: 'throw', error: unknown }\n | { kind: 'next' }\n\n function resolveOutcome(o: HandlerOutcome, nextIndex: number): Step | Promise<Step> {\n switch (o.kind) {\n case 'step': return o.step\n case 'asyncResume': return o.promise.then(\n (v): Step => ({ type: 'Value', value: v, k }),\n (e): Step => ({ type: 'Error', error: e instanceof DvalaError ? e : new DvalaError(e instanceof Error ? e : `${e}`, sourceCodeInfo), k }),\n )\n case 'throw': throw o.error\n case 'next': return tryHandler(nextIndex)\n }\n }\n\n // Recursive helper: try handler at `index`, with `next()` advancing to `index + 1`.\n function tryHandler(index: number): Step | Promise<Step> {\n if (index >= matchingHandlers.length) {\n if (effectName === 'dvala.error') {\n const message = typeof argsArray[0] === 'string' ? argsArray[0] : String(argsArray[0] ?? 'Unknown error')\n throw new UserDefinedError(message, sourceCodeInfo)\n }\n throw new DvalaError(`Unhandled effect: '${effectName}'`, sourceCodeInfo)\n }\n\n const [, handler] = matchingHandlers[index]!\n\n let outcome: HandlerOutcome | undefined\n let settled = false\n\n function assertNotSettled(operation: string): void {\n if (settled) {\n throw new DvalaError(`Effect handler called ${operation}() after already calling another operation`, sourceCodeInfo)\n }\n settled = true\n }\n\n const ctx: EffectContext = {\n effectName,\n args: argsArray,\n signal: effectSignal,\n resume: (value: Any | Promise<Any>) => {\n assertNotSettled('resume')\n if (value instanceof Promise) {\n outcome = { kind: 'asyncResume', promise: value }\n }\n else {\n outcome = { kind: 'step', step: { type: 'Value', value, k } }\n }\n },\n fail: (msg?: string) => {\n assertNotSettled('fail')\n const errorMsg = msg ?? `Effect handler failed for '${effectName}'`\n outcome = { kind: 'step', step: { type: 'Error', error: new DvalaError(errorMsg, sourceCodeInfo), k } }\n },\n suspend: (meta?: Any) => {\n assertNotSettled('suspend')\n outcome = {\n kind: 'throw',\n error: new SuspensionSignal(\n k,\n snapshotState ? snapshotState.snapshots : [],\n snapshotState ? snapshotState.nextSnapshotIndex : 0,\n meta,\n ),\n }\n },\n next: () => {\n assertNotSettled('next')\n outcome = { kind: 'next' }\n },\n get snapshots(): Snapshot[] { return snapshotState ? [...snapshotState.snapshots] : [] },\n checkpoint: (meta?: Any): Snapshot => {\n if (!snapshotState) {\n throw new DvalaError('checkpoint is not available outside effect-enabled execution', sourceCodeInfo)\n }\n const continuation = serializeToObject(k)\n const snapshot: Snapshot = {\n continuation,\n timestamp: Date.now(),\n index: snapshotState.nextSnapshotIndex++,\n runId: snapshotState.runId,\n ...(meta !== undefined ? { meta } : {}),\n }\n snapshotState.snapshots.push(snapshot)\n if (snapshotState.maxSnapshots !== undefined && snapshotState.snapshots.length > snapshotState.maxSnapshots) {\n snapshotState.snapshots.shift()\n }\n return snapshot\n },\n resumeFrom: (snapshot: Snapshot, value: Any) => {\n if (settled) {\n throw new DvalaError('Effect handler called resumeFrom() after already calling another operation', sourceCodeInfo)\n }\n if (!snapshotState) {\n throw new DvalaError('resumeFrom is not available outside effect-enabled execution', sourceCodeInfo)\n }\n const found = snapshotState.snapshots.find(s => s.index === snapshot.index && s.runId === snapshot.runId)\n if (!found) {\n throw new DvalaError(`Invalid snapshot: no snapshot with index ${snapshot.index} found in current run`, sourceCodeInfo)\n }\n settled = true\n outcome = { kind: 'throw', error: new ResumeFromSignal(found.continuation, value, found.index) }\n },\n }\n\n const handlerResult = handler(ctx)\n\n if (!(handlerResult instanceof Promise)) {\n // Synchronous handler — outcome must already be set\n if (!outcome) {\n throw new DvalaError(`Effect handler for '${effectName}' did not call resume(), fail(), suspend(), or next()`, sourceCodeInfo)\n }\n return resolveOutcome(outcome, index + 1)\n }\n\n // Async handler\n if (outcome) {\n // Handler settled synchronously before the async part\n handlerResult.catch(() => {}) // suppress unhandled rejection\n return resolveOutcome(outcome, index + 1)\n }\n\n // Not yet settled — wait for the handler's promise\n return handlerResult.then(\n () => {\n if (!outcome) {\n throw new DvalaError(`Effect handler for '${effectName}' did not call resume(), fail(), suspend(), or next()`, sourceCodeInfo)\n }\n return resolveOutcome(outcome, index + 1)\n },\n (e) => {\n if (outcome) {\n // Already settled — return that result, ignore the rejection\n return resolveOutcome(outcome, index + 1)\n }\n if (isSuspensionSignal(e) || isResumeFromSignal(e)) {\n // eslint-disable-next-line ts/no-throw-literal -- SuspensionSignal/ResumeFromSignal is a signaling mechanism\n throw e\n }\n const errorStep: Step = {\n type: 'Error',\n error: e instanceof DvalaError ? e : new DvalaError(e instanceof Error ? e : `${e}`, sourceCodeInfo),\n k,\n }\n return errorStep\n },\n )\n }\n\n return tryHandler(0)\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, [], 0, 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, snapshot: Snapshot }> = []\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, snapshot: r.snapshot })\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.snapshot.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.snapshot.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.snapshot.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 => ({\n type: 'Error' as const,\n error: error instanceof DvalaError ? error : new DvalaError(`${error}`, undefined),\n k,\n }),\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, snapshotState?: SnapshotState): 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, step.sourceCodeInfo, handlers, signal, snapshotState)\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 case 'Error': {\n const effectStep = tryDispatchDvalaError(step.error, step.k, handlers, signal, snapshotState)\n if (effectStep !== null) {\n return effectStep\n }\n\n throw step.error\n }\n }\n }\n catch (error) {\n // SuspensionSignal must propagate out of tick to the effect trampoline loop\n // (runEffectLoop).\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 // Route DvalaError through the 'dvala.error' algebraic effect so that\n // do...with handlers can intercept runtime errors.\n if (error instanceof DvalaError) {\n // For Value steps, step.k[0] is the frame that was being applied when\n // the error was thrown (e.g. LetDestructFrame, etc.).\n // Strip it so that resumeK in tryDispatchDvalaError does not include\n // the failing frame — otherwise the handler's return value would flow\n // back through it, potentially re-triggering the same error in an\n // infinite loop.\n // For Eval/Apply steps, step.k already excludes the frame that caused\n // the error, so no stripping is needed.\n const kForDispatch = step.type === 'Value'\n ? step.k.slice(1)\n : step.k\n const effectStep = tryDispatchDvalaError(error, kForDispatch, handlers, signal, snapshotState)\n if (effectStep !== null) {\n return effectStep\n }\n }\n // Fallback: no handler matched — re-throw the error as a JS exception.\n throw error\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, effectHandlers?: Handlers): 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, effectHandlers)\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 maxSnapshots?: number,\n deserializeOptions?: DeserializeOptions,\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, undefined, maxSnapshots, deserializeOptions)\n}\n\n/**\n * Evaluate an AST synchronously with effect handler support.\n *\n * Uses the sync trampoline with `effectHandlers` threaded through `tick`.\n * Throws if an async operation is encountered (e.g., an async handler\n * is used). Handlers may call `resume(value)`, `fail(msg?)`, or `next()`.\n * Calling `suspend()` will throw a runtime error.\n */\nexport function evaluateWithSyncEffects(\n ast: Ast,\n contextStack: ContextStack,\n effectHandlers?: Handlers,\n): Any {\n const initial = buildInitialStep(ast.body, contextStack)\n try {\n return runSyncTrampoline(initial, effectHandlers)\n }\n catch (error) {\n if (error instanceof DvalaError && error.message.includes('Unexpected async operation')) {\n const freshInitial = buildInitialStep(ast.body, contextStack)\n return runSyncTrampoline(freshInitial, effectHandlers)\n }\n throw error\n }\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 initialSnapshotState?: { snapshots: Snapshot[], nextSnapshotIndex: number, maxSnapshots?: number },\n deserializeOptions?: DeserializeOptions,\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, initialSnapshotState, initialSnapshotState?.maxSnapshots, deserializeOptions)\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 initialSnapshotState?: { snapshots: Snapshot[], nextSnapshotIndex: number },\n maxSnapshots?: number,\n deserializeOptions?: DeserializeOptions,\n): Promise<RunResult> {\n const debugMode = handlers != null && 'dvala.debug.step' in handlers\n const snapshotState: SnapshotState = {\n snapshots: initialSnapshotState ? initialSnapshotState.snapshots : [],\n nextSnapshotIndex: initialSnapshotState ? initialSnapshotState.nextSnapshotIndex : 0,\n runId: generateRunId(),\n ...(maxSnapshots !== undefined ? { maxSnapshots } : {}),\n }\n\n let step: Step | Promise<Step> = initial\n\n for (;;) {\n try {\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, snapshotState)\n }\n }\n catch (error) {\n if (isResumeFromSignal(error)) {\n const { k: restoredK } = deserializeFromObject(error.continuation as Record<string, unknown>, deserializeOptions)\n // Discard all snapshots with index > trimToIndex\n const cutIdx = snapshotState.snapshots.findIndex(s => s.index > error.trimToIndex)\n if (cutIdx !== -1) {\n snapshotState.snapshots.splice(cutIdx)\n }\n // Re-enter the loop with the restored continuation — nextSnapshotIndex is NOT reset\n step = { type: 'Value', value: error.value, k: restoredK }\n continue\n }\n if (isSuspensionSignal(error)) {\n const continuation = serializeSuspensionBlob(\n error.k,\n error.snapshots,\n error.nextSnapshotIndex,\n error.meta,\n )\n const snapshot: Snapshot = {\n continuation,\n timestamp: Date.now(),\n index: snapshotState.nextSnapshotIndex++,\n runId: snapshotState.runId,\n meta: error.meta,\n }\n return { type: 'suspended', snapshot }\n }\n if (error instanceof DvalaError) {\n return { type: 'error', error }\n }\n return { type: 'error', error: new DvalaError(`${error}`, undefined) }\n }\n }\n}\n","import { createContextStack } from '../../evaluator/ContextStack'\nimport { evaluate } from '../../evaluator/trampoline'\nimport type { Any } from '../../interface'\nimport { parse } from '../../parser'\nimport type { UserDefinedFunction } from '../../parser/types'\nimport { minifyTokenStream } from '../../tokenizer/minifyTokenStream'\nimport { tokenize } from '../../tokenizer/tokenize'\nimport { isDvalaFunction } from '../../typeGuards/dvalaFunction'\nimport { isObj } from '../../typeGuards/dvala'\nimport collectionSource from '../core/collection.dvala'\nimport sequenceSource from '../core/sequence.dvala'\nimport arraySource from '../core/array.dvala'\nimport functionalSource from '../core/functional.dvala'\nimport objectSource from '../core/object.dvala'\nimport { normalExpressions } from '.'\n\nconst coreDvalaSources: Record<string, string> = {\n collection: collectionSource,\n sequence: sequenceSource,\n array: arraySource,\n functional: functionalSource,\n object: objectSource,\n}\n\nlet initialized = false\n\nexport function initCoreDvalaSources(): void {\n if (initialized)\n return\n initialized = true\n\n for (const [, source] of Object.entries(coreDvalaSources)) {\n const tokens = tokenize(source, false, undefined)\n const minified = minifyTokenStream(tokens, { removeWhiteSpace: true })\n const body = parse(minified)\n const ast = { body, hasDebugData: false }\n const contextStack = createContextStack()\n const result = evaluate(ast, contextStack) as Any\n\n if (result instanceof Promise) {\n throw new TypeError('Core dvala sources must be synchronous')\n }\n\n if (!isObj(result)) {\n continue\n }\n\n const obj = result\n for (const [name, fn] of Object.entries(obj)) {\n const expression = normalExpressions[name]\n if (expression && isDvalaFunction(fn) && (fn as { functionType: string }).functionType === 'UserDefined') {\n expression.dvalaImpl = fn as UserDefinedFunction\n }\n }\n }\n}\n","{\n map: (first-coll, ...args) -> do\n let fn = last(args);\n let other-colls = slice(args, 0, count(args) - 1);\n let all-colls = [first-coll, ...other-colls];\n\n cond\n case object?(first-coll) then do\n let expected-keys = keys(first-coll) |> sort;\n doseq (obj in other-colls) -> do\n if not(object?(obj)) then\n perform(effect(dvala.error), \"Expected object\")\n end;\n let obj-keys = keys(obj) |> sort;\n if not(obj-keys == expected-keys) then\n perform(effect(dvala.error), ++(\n \"All objects must have the same keys. Expected: \",\n join(expected-keys, \", \"),\n \". Found: \",\n join(obj-keys, \", \")\n ))\n end\n end;\n reduce(keys(first-coll), (acc, k) -> do\n let a = for (coll in all-colls) -> coll(k);\n assoc(acc, k, apply(fn, a))\n end, {})\n end\n\n case string?(first-coll) then do\n doseq (s in other-colls) -> do\n if not(string?(s)) then\n perform(effect(dvala.error), \"Expected string\")\n end\n end;\n let len = reduce(other-colls, (m, s) -> min(m, count(s)), count(first-coll));\n let mapped = for (i in range(len)) -> do\n let a = for (coll in all-colls) -> nth(coll, i);\n apply(fn, a)\n end;\n reduce(mapped, (acc, ch) -> do\n if not(string?(ch)) then\n perform(effect(dvala.error), \"Expected string\")\n end;\n ++(acc, ch)\n end, \"\")\n end\n\n case true then do\n doseq (x in other-colls) -> do\n if not(array?(x)) then\n perform(effect(dvala.error), \"Expected array\")\n end\n end;\n let len = reduce(other-colls, (m, x) -> min(m, count(x)), count(first-coll));\n for (i in range(len)) -> do\n let a = for (coll in all-colls) -> nth(coll, i);\n apply(fn, a)\n end\n end\n end\n end,\n\n filter: (coll, fn) -> do\n cond\n case array?(coll) then\n reduce(coll, (acc, elem) -> if fn(elem) then [...acc, elem] else acc end, [])\n\n case string?(coll) then\n reduce(coll, (acc, ch) -> if fn(ch) then ++(acc, ch) else acc end, \"\")\n\n case object?(coll) then\n reduce(keys(coll), (acc, k) -> do\n if fn(coll(k)) then\n assoc(acc, k, coll(k))\n else\n acc\n end\n end, {})\n\n case true then\n perform(effect(dvala.error), \"Expected collection\")\n end\n end,\n\n reduce: (coll, fn, initial) -> do\n cond\n case string?(coll) then\n loop (acc = initial, i = 0) -> do\n if i >= count(coll) then\n acc\n else\n recur(fn(acc, nth(coll, i)), i + 1)\n end\n end\n\n case array?(coll) then\n loop (acc = initial, i = 0) -> do\n if i >= count(coll) then\n acc\n else\n recur(fn(acc, nth(coll, i)), i + 1)\n end\n end\n\n case object?(coll) then do\n let values = vals(coll);\n loop (acc = initial, i = 0) -> do\n if i >= count(values) then\n acc\n else\n recur(fn(acc, nth(values, i)), i + 1)\n end\n end\n end\n\n case true then\n perform(effect(dvala.error), \"Expected collection\")\n end\n end\n}","{\n some: (seq, fn) -> do\n if null?(seq) then null\n else do\n loop (i = 0) -> do\n if i >= count(seq) then\n null\n else do\n let elem = nth(seq, i);\n if fn(elem) then elem\n else recur(i + 1)\n end\n end\n end\n end\n end\n end\n end,\n\n take-while: (seq, fn) -> do\n let is-str = string?(seq);\n let len = count(seq);\n let idx = loop (i = 0) -> do\n if i >= len then\n len\n else if fn(nth(seq, i)) then\n recur(i + 1)\n else\n i\n end\n end\n end;\n slice(seq, 0, idx)\n end,\n\n drop-while: (seq, fn) -> do\n let is-str = string?(seq);\n let len = count(seq);\n let idx = loop (i = 0) -> do\n if i >= len then\n len\n else if fn(nth(seq, i)) then\n recur(i + 1)\n else\n i\n end\n end\n end;\n slice(seq, idx)\n end,\n\n sort: (seq, ...args) -> do\n let cmp = if count(args) == 0 then compare else first(args) end;\n let is-str = string?(seq);\n let arr = if is-str then split(seq, \"\") else seq end;\n let len = count(arr);\n\n // merge two sorted arrays\n let merge-arrays = (left, right) -> do\n let left-len = count(left);\n let right-len = count(right);\n loop (result = [], li = 0, ri = 0) -> do\n if li >= left-len then\n ++(result, slice(right, ri))\n else if ri >= right-len then\n ++(result, slice(left, li))\n else do\n let l = nth(left, li);\n let r = nth(right, ri);\n if cmp(l, r) <= 0 then\n recur(push(result, l), li + 1, ri)\n else\n recur(push(result, r), li, ri + 1)\n end\n end\n end\n end\n end\n end;\n\n // recursive merge-sort\n let merge-sort = (a) -> do\n let n = count(a);\n if n <= 1 then a\n else do\n let mid = floor(n / 2);\n let left = merge-sort(slice(a, 0, mid));\n let right = merge-sort(slice(a, mid));\n merge-arrays(left, right)\n end\n end\n end;\n\n let sorted = merge-sort(arr);\n if is-str then join(sorted, \"\") else sorted end\n end\n}\n","{\n mapcat: (arr, fn) -> do\n flatten(map(arr, fn), 1)\n end,\n\n moving-fn: (arr, window-size, fn) -> do\n if window-size > count(arr) then\n perform(effect(dvala.error), \"Expected window-size <= array length\")\n end;\n for (i in range(count(arr) - window-size + 1)) -> do\n fn(slice(arr, i, i + window-size))\n end\n end,\n\n running-fn: (arr, fn) -> do\n for (i in range(count(arr))) -> do\n fn(slice(arr, 0, i + 1))\n end\n end\n}\n","{\n \"|>\": (a, b) -> b(a),\n\n apply: (fn, ...args) -> do\n let arr = last(args);\n let leading = slice(args, 0, count(args) - 1);\n fn(...leading, ...arr)\n end\n}\n","{\n merge-with: (...args) -> do\n let fn = last(args);\n let objs = slice(args, 0, count(args) - 1);\n if not(function?(fn)) then\n perform(effect(dvala.error), str(\"Expected function, got: \", type(fn)))\n end;\n if count(objs) == 0 then\n perform(effect(dvala.error), \"Expected at least one object argument\")\n end;\n reduce(rest(objs), (result, obj) -> do\n if not(object?(obj)) then\n perform(effect(dvala.error), str(\"Expected object, got: \", type(obj)))\n end;\n reduce(keys(obj), (res, key) -> do\n if contains?(res, key) then\n assoc(res, key, fn(get(res, key), get(obj, key)))\n else\n assoc(res, key, get(obj, key))\n end\n end, result)\n end, do\n let f = first(objs);\n if not(object?(f)) then\n perform(effect(dvala.error), str(\"Expected object, got: \", type(f)))\n end;\n f\n end)\n end\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","/**\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 { AutoCompleter } from './AutoCompleter/AutoCompleter'\nimport type { AutoCompleterParams } from './AutoCompleter/AutoCompleter'\nimport { DvalaError } from './errors'\nimport type { DvalaModule } from './builtin/modules/interface'\nimport { createContextStack } from './evaluator/ContextStack'\nimport { evaluate, evaluateWithEffects, evaluateWithSyncEffects } from './evaluator/trampoline'\nimport { tokenize } from './tokenizer/tokenize'\nimport { minifyTokenStream } from './tokenizer/minifyTokenStream'\nimport { parse } from './parser'\nimport type { Ast } from './parser/types'\nimport { initCoreDvalaSources } from './builtin/normalExpressions/initCoreDvala'\nimport { Cache } from './Cache'\nimport type { DvalaBundle } from './bundler/interface'\nimport { isDvalaBundle } from './bundler/interface'\nimport type { Handlers, RunResult } from './evaluator/effectTypes'\nimport { getUndefinedSymbols as standaloneGetUndefinedSymbols } from './tooling'\nimport { EFFECT_SYMBOL, FUNCTION_SYMBOL, REGEXP_SYMBOL } from './utils/symbols'\n\nexport interface CreateDvalaOptions {\n modules?: DvalaModule[]\n bindings?: Record<string, unknown>\n effectHandlers?: Handlers\n cache?: number\n /** Enable debug tokenization: captures source positions for better error messages. */\n debug?: boolean\n}\n\n/**\n * Options for `run()`. When `pure` is `true`, `effectHandlers` cannot be provided.\n */\nexport type DvalaRunOptions =\n | { bindings?: Record<string, unknown>, pure: true, effectHandlers?: never, filePath?: string }\n | { bindings?: Record<string, unknown>, pure?: false, effectHandlers?: Handlers, filePath?: string }\n\n/**\n * Options for `runAsync()`. When `pure` is `true`, `effectHandlers` cannot be provided.\n */\nexport type DvalaRunAsyncOptions =\n | { bindings?: Record<string, unknown>, pure: true, effectHandlers?: never, maxSnapshots?: number }\n | { bindings?: Record<string, unknown>, pure?: false, effectHandlers?: Handlers, maxSnapshots?: number }\n\nexport interface DvalaRunner {\n run: (source: string | DvalaBundle, options?: DvalaRunOptions) => unknown\n runAsync: (source: string | DvalaBundle, options?: DvalaRunAsyncOptions) => Promise<RunResult>\n getUndefinedSymbols: (source: string) => Set<string>\n getAutoCompleter: (program: string, position: number) => AutoCompleter\n}\n\nfunction assertSerializableBindings(bindings: Record<string, unknown> | undefined): void {\n if (!bindings)\n return\n for (const [key, val] of Object.entries(bindings))\n assertSerializable(val, `bindings[\"${key}\"]`)\n}\n\nfunction assertSerializable(val: unknown, path: string): void {\n if (val === null || val === undefined)\n return\n if (typeof val === 'boolean' || typeof val === 'string')\n return\n if (typeof val === 'number') {\n if (!Number.isFinite(val))\n throw new TypeError(`${path} is not serializable (${val})`)\n return\n }\n if (typeof val === 'function')\n throw new TypeError(`${path} is not serializable (function)`)\n if (typeof val === 'object') {\n if (FUNCTION_SYMBOL in val || REGEXP_SYMBOL in val || EFFECT_SYMBOL in val)\n return\n if (Array.isArray(val)) {\n val.forEach((item, i) => assertSerializable(item, `${path}[${i}]`))\n return\n }\n if (Object.getPrototypeOf(val) !== Object.prototype)\n throw new TypeError(`${path} is not serializable (not a plain object)`)\n for (const [k, v] of Object.entries(val as Record<string, unknown>))\n assertSerializable(v, `${path}.${k}`)\n return\n }\n throw new TypeError(`${path} is not serializable`)\n}\n\nexport function createDvala(options?: CreateDvalaOptions): DvalaRunner {\n initCoreDvalaSources()\n\n const modules = options?.modules\n ? new Map(options.modules.map(m => [m.name, m]))\n : undefined\n const factoryBindings = options?.bindings\n const factoryEffectHandlers = options?.effectHandlers\n const debug = options?.debug ?? false\n const cache = options?.cache ? new Cache(options.cache) : null\n\n function buildAst(source: string, filePath?: string): Ast {\n if (!filePath && cache) {\n const cached = cache.get(source)\n if (cached)\n return cached\n }\n const tokenStream = tokenize(source, debug, filePath)\n const minified = minifyTokenStream(tokenStream, { removeWhiteSpace: true })\n const ast: Ast = { body: parse(minified), hasDebugData: debug }\n if (!filePath)\n cache?.set(source, ast)\n return ast\n }\n\n function mergeBindings(runBindings?: Record<string, unknown>): Record<string, unknown> | undefined {\n if (!factoryBindings && !runBindings)\n return undefined\n return { ...factoryBindings, ...runBindings }\n }\n\n function mergeEffectHandlers(runEffectHandlers?: Handlers): Handlers | undefined {\n if (!factoryEffectHandlers && !runEffectHandlers)\n return undefined\n // Run handlers first (checked first), factory handlers fill in the rest.\n // For same key, run overrides factory.\n const result: Handlers = { ...runEffectHandlers }\n if (factoryEffectHandlers) {\n for (const [k, v] of Object.entries(factoryEffectHandlers)) {\n if (!(k in result))\n result[k] = v\n }\n }\n return result\n }\n\n function assertNotPureWithHandlers(\n pure: boolean,\n effectHandlers: Handlers | undefined,\n ): void {\n if (!pure)\n return\n const hasEffectHandlers = effectHandlers && Object.keys(effectHandlers).length > 0\n if (hasEffectHandlers) {\n throw new TypeError('Cannot use pure mode with effect handlers')\n }\n }\n\n return {\n run(source: string | DvalaBundle, runOptions?: DvalaRunOptions): unknown {\n assertSerializableBindings(runOptions?.bindings)\n const bindings = mergeBindings(runOptions?.bindings)\n const effectHandlers = mergeEffectHandlers(runOptions?.effectHandlers)\n const pure = runOptions?.pure ?? false\n\n assertNotPureWithHandlers(pure, effectHandlers)\n\n const contextStack = createContextStack({ bindings }, modules, pure)\n\n if (isDvalaBundle(source)) {\n const savedPure = contextStack.pure\n contextStack.pure = true\n for (const [name, fileSource] of source.fileModules) {\n const fileAst = buildAst(fileSource)\n const moduleContextStack = contextStack.create({})\n contextStack.registerValueModule(name, evaluate(fileAst, moduleContextStack))\n }\n contextStack.pure = savedPure\n const ast = buildAst(source.program)\n const result = evaluate(ast, contextStack)\n if (result instanceof Promise)\n throw new TypeError('Unexpected async result in run(). Use runAsync() for async operations.')\n return result\n }\n\n const ast = buildAst(source, runOptions?.filePath)\n\n if (effectHandlers) {\n return evaluateWithSyncEffects(ast, contextStack, effectHandlers)\n }\n\n const result = evaluate(ast, contextStack)\n if (result instanceof Promise) {\n throw new TypeError('Unexpected async result in run(). Use runAsync() for async operations.')\n }\n return result\n },\n\n async runAsync(source: string | DvalaBundle, runOptions?: DvalaRunAsyncOptions): Promise<RunResult> {\n assertSerializableBindings(runOptions?.bindings)\n const bindings = mergeBindings(runOptions?.bindings)\n const effectHandlers = mergeEffectHandlers(runOptions?.effectHandlers)\n const pure = runOptions?.pure ?? false\n\n assertNotPureWithHandlers(pure, effectHandlers)\n\n try {\n const contextStack = createContextStack({ bindings }, modules, pure)\n\n if (isDvalaBundle(source)) {\n const savedPure = contextStack.pure\n contextStack.pure = true\n for (const [name, fileSource] of source.fileModules) {\n const fileAst = buildAst(fileSource)\n const moduleContextStack = contextStack.create({})\n contextStack.registerValueModule(name, evaluate(fileAst, moduleContextStack))\n }\n contextStack.pure = savedPure\n }\n\n const programSource = isDvalaBundle(source) ? source.program : source\n const ast = buildAst(programSource)\n const result = await evaluateWithEffects(ast, contextStack, effectHandlers, runOptions?.maxSnapshots, {\n values: bindings,\n modules,\n })\n if (result.type === 'completed') {\n return { ...result, definedBindings: contextStack.getModuleScopeBindings() }\n }\n return result\n }\n catch (error) {\n if (error instanceof DvalaError) {\n return { type: 'error', error }\n }\n if (error instanceof TypeError) {\n throw error\n }\n return { type: 'error', error: new DvalaError(`${error}`, undefined) }\n }\n },\n\n getUndefinedSymbols(source: string): Set<string> {\n const modulesList = modules ? [...modules.values()] : undefined\n return standaloneGetUndefinedSymbols(source, { bindings: factoryBindings, modules: modulesList })\n },\n\n getAutoCompleter(program: string, position: number): AutoCompleter {\n const params: AutoCompleterParams = { bindings: factoryBindings }\n return new AutoCompleter(program, position, params)\n },\n }\n}\n","/**\n * Standalone tooling functions for tokenizing, parsing, and analysis.\n *\n * These are thin wrappers around internal utilities that do not require\n * a Dvala instance.\n */\n\nimport { builtin } from './builtin'\nimport { AutoCompleter } from './AutoCompleter/AutoCompleter'\nimport type { AutoCompleterParams } from './AutoCompleter/AutoCompleter'\nimport { createContextStack } from './evaluator/ContextStack'\nimport { evaluateNode } from './evaluator/trampoline'\nimport { getUndefinedSymbols as getUndefinedSymbolsInternal } from './getUndefinedSymbols'\nimport type { DvalaModule } from './builtin/modules/interface'\nimport { tokenize } from './tokenizer/tokenize'\nimport type { TokenStream } from './tokenizer/tokenize'\nimport { minifyTokenStream } from './tokenizer/minifyTokenStream'\nimport { parse } from './parser'\nimport type { Ast } from './parser/types'\nimport { transformSymbolTokens } from './transformer'\nimport { untokenize } from './untokenizer'\n\nexport type { TokenStream }\n\n/**\n * Tokenize a Dvala source string into a token stream.\n * Pass `debug: true` to capture source positions (needed for the debugger).\n */\nexport function tokenizeSource(source: string, debug = false, filePath?: string): TokenStream {\n return tokenize(source, debug, filePath)\n}\n\n/**\n * Parse a token stream into an AST.\n * The stream is automatically minified (whitespace removed) before parsing.\n */\nexport function parseTokenStream(tokenStream: TokenStream): Ast {\n const minified = minifyTokenStream(tokenStream, { removeWhiteSpace: true })\n return { body: parse(minified), hasDebugData: tokenStream.hasDebugData }\n}\n\n/**\n * Convert a token stream back to source code.\n */\nexport { untokenize }\n\n/**\n * Transform all symbol tokens in a token stream using the provided function.\n */\nexport function transformSymbols(tokenStream: TokenStream, transformer: (symbol: string) => string): TokenStream {\n return transformSymbolTokens(tokenStream, transformer)\n}\n\n/**\n * Get all undefined symbols in a Dvala program.\n *\n * @param source - Dvala source code\n * @param options - optional context to treat as defined\n * @param options.bindings - host bindings to treat as defined\n * @param options.modules - modules to treat as available\n */\nexport function getUndefinedSymbols(\n source: string,\n options?: { bindings?: Record<string, unknown>, modules?: DvalaModule[] },\n): Set<string> {\n const modulesMap = options?.modules\n ? new Map(options.modules.map(m => [m.name, m]))\n : undefined\n const contextStack = createContextStack({ bindings: options?.bindings }, modulesMap)\n const tokenStream = tokenize(source, false, undefined)\n const minified = minifyTokenStream(tokenStream, { removeWhiteSpace: true })\n const ast: Ast = { body: parse(minified), hasDebugData: false }\n return getUndefinedSymbolsInternal(ast, contextStack, builtin, evaluateNode)\n}\n\n/**\n * Create an auto-completer for the given program at the given cursor position.\n *\n * @param program - Full Dvala source code\n * @param position - Cursor position (character offset)\n * @param params - Optional params (bindings to include as suggestions)\n */\nexport function getAutoCompleter(program: string, position: number, params: AutoCompleterParams = {}): AutoCompleter {\n return new AutoCompleter(program, position, params)\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);\\ndo assert!=(0, 0, \"Expected different values\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert!= } = import(assertion);\\ndo assert!=(0, 0) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert!= } = import(assertion);\\ndo 0 assert!= 0 with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert!= } = import(assertion);\\ndo assert!=(0, 1) with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert=({ \"a\": 1 }, { \"a\": 2 }, \"Expected equal values\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert= } = import(assertion);\\ndo assert=({ \"a\": 1 }, { \"a\": 2 }) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert= } = import(assertion);\\ndo assert=({ \"a\": 1 }, { \"a\": 1 }) with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-gt(0, 1, \"Expected greater value\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-gt } = import(assertion);\\ndo assert-gt(0, 0) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-gt } = import(assertion);\\ndo assert-gt(1, 0) with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-lt(1, 0, \"Expected smaller value value\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-lt } = import(assertion);\\ndo assert-lt(1, 1) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-lt } = import(assertion);\\ndo assert-lt(0, 1) with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-gte(0, 1, \"Expected greater value\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-gte } = import(assertion);\\ndo assert-gte(0, 1) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-gte } = import(assertion);\\ndo assert-gte(1, 1) with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-lte(1, 0, \"Expected smaller value value\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-lte } = import(assertion);\\ndo assert-lte(1, 0) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-lte } = import(assertion);\\ndo assert-lte(1, 1) with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-true(false, \"Expected true\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-true } = import(assertion);\\ndo assert-true(false) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-true } = import(assertion);\\ndo assert-true(true) with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-false(true, \"Expected false\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-false } = import(assertion);\\ndo assert-false(true) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-false } = import(assertion);\\ndo assert-false(false) with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-truthy(false, \"Expected truthy\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-truthy } = import(assertion);\\ndo assert-truthy(false) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-truthy } = import(assertion);\\ndo assert-truthy(0) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-truthy } = import(assertion);\\ndo assert-truthy(null) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-truthy } = import(assertion);\\ndo assert-truthy(\"\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-truthy } = import(assertion);\\ndo assert-truthy(true) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-truthy } = import(assertion);\\ndo assert-truthy(1) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-truthy } = import(assertion);\\ndo assert-truthy(\"x\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-truthy } = import(assertion);\\ndo assert-truthy([]) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-truthy } = import(assertion);\\ndo assert-truthy(nd) with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-falsy(true, \"Expected falsy\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-falsy } = import(assertion);\\ndo assert-falsy(\"x\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-falsy } = import(assertion);\\ndo assert-falsy([]) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-falsy } = import(assertion);\\ndo assert-falsy(nd) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-falsy } = import(assertion);\\ndo assert-falsy(1) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-falsy } = import(assertion);\\ndo assert-falsy(false) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-falsy } = import(assertion);\\ndo assert-falsy(0) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-falsy } = import(assertion);\\ndo assert-falsy(null) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-falsy } = import(assertion);\\ndo assert-falsy(\"\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-null(null) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-null } = import(assertion);\\ndo assert-null(true, \"Expected null\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-null } = import(assertion);\\ndo assert-null(\"x\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-null } = import(assertion);\\ndo assert-null([]) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-null } = import(assertion);\\ndo assert-null(nd) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-null } = import(assertion);\\ndo assert-null(1) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-null } = import(assertion);\\ndo assert-null(false) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-null } = import(assertion);\\ndo assert-null(0) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-null } = import(assertion);\\ndo assert-null(\"\") with case effect(dvala.error) then ([msg]) -> msg 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(-> perform(effect(dvala.error), \"Error\"))',\n 'let { assert-throws } = import(assertion);\\ndo assert-throws(-> identity(\"Error\")) with case effect(dvala.error) then ([msg]) -> msg 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 'fun',\n 'error-message',\n ],\n },\n {\n argumentNames: [\n 'fun',\n 'error-message',\n 'message',\n ],\n },\n ],\n examples: [\n 'let { assert-throws-error } = import(assertion);\\ndo assert-throws-error(-> perform(effect(dvala.error), \"Error\"), \"Error\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-throws-error } = import(assertion);\\ndo assert-throws-error(-> identity(\"Error\"), \"Error\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-not-throws(-> identity(\"Error\")) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-not-throws } = import(assertion);\\ndo assert-not-throws(-> perform(effect(dvala.error), \"Error\")) with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-array([1, 2, 3]) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-array } = import(assertion);\\ndo assert-array(\"string\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-array } = import(assertion);\\ndo assert-array(42, \"Expected an array\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-boolean(true) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-boolean } = import(assertion);\\ndo assert-boolean(false) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-boolean } = import(assertion);\\ndo assert-boolean(1, \"Expected a boolean\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-collection([1, 2]) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-collection } = import(assertion);\\ndo assert-collection({ a: 1 }) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-collection } = import(assertion);\\ndo assert-collection(\"hello\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-collection } = import(assertion);\\ndo assert-collection(42, \"Expected a collection\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-function(-> $ + 1) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-function } = import(assertion);\\ndo assert-function(42, \"Expected a function\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-grid([[1, 2], [3, 4]]) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-grid } = import(assertion);\\ndo assert-grid([1, 2], \"Expected a grid\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-integer(42) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-integer } = import(assertion);\\ndo assert-integer(3.14, \"Expected an integer\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-matrix([[1, 2], [3, 4]]) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-matrix } = import(assertion);\\ndo assert-matrix([1, 2], \"Expected a matrix\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-number(42) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-number } = import(assertion);\\ndo assert-number(\"hello\", \"Expected a number\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-object({ a: 1 }) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-object } = import(assertion);\\ndo assert-object([1, 2], \"Expected an object\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-regexp(#\"^start\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-regexp } = import(assertion);\\ndo assert-regexp(\"hello\", \"Expected a regexp\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-sequence([1, 2]) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-sequence } = import(assertion);\\ndo assert-sequence(\"hello\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-sequence } = import(assertion);\\ndo assert-sequence({ a: 1 }, \"Expected a sequence\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-string(\"hello\") with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-string } = import(assertion);\\ndo assert-string(42, \"Expected a string\") with case effect(dvala.error) then ([msg]) -> msg 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);\\ndo assert-vector([1, 2, 3]) with case effect(dvala.error) then ([msg]) -> msg end',\n 'let { assert-vector } = import(assertion);\\ndo assert-vector([\"a\", \"b\"], \"Expected a vector\") with case effect(dvala.error) then ([msg]) -> msg 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/annotatedCollections'\nimport { chain, tryCatch } from '../../../utils/maybePromise'\nimport type { MaybePromise } from '../../../utils/maybePromise'\nimport type { DvalaModule } from '../interface'\nimport assertionModuleSource from './assertion.dvala'\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 source: assertionModuleSource,\n docs: moduleDocs,\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 generator: {\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 'generator',\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 'f': {\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 'f',\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 'f': {\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 'f',\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/annotatedCollections'\nimport { assertArray } from '../../../typeGuards/array'\nimport { assertAny } from '../../../typeGuards/dvala'\nimport { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../../builtin/interface'\nimport type { DvalaModule } from '../interface'\nimport gridModuleSource from './grid.dvala'\nimport { moduleDocs } from './docs'\nimport { fromArray } from './fromArray'\nimport { transpose } from './transpose'\n\nconst gridFunctions: BuiltinNormalExpressions = {\n 'cell-every?': {\n evaluate: () => {\n throw new Error('cell-every?: Dvala implementation should be used instead')\n },\n arity: toFixedArity(2),\n },\n 'some?': {\n evaluate: () => {\n throw new Error('some?: Dvala implementation should be used instead')\n },\n arity: toFixedArity(2),\n },\n 'every-row?': {\n evaluate: () => {\n throw new Error('every-row?: Dvala implementation should be used instead')\n },\n arity: toFixedArity(2),\n },\n 'some-row?': {\n evaluate: () => {\n throw new Error('some-row?: Dvala implementation should be used instead')\n },\n arity: toFixedArity(2),\n },\n 'every-col?': {\n evaluate: () => {\n throw new Error('every-col?: Dvala implementation should be used instead')\n },\n arity: toFixedArity(2),\n },\n 'some-col?': {\n evaluate: () => {\n throw new Error('some-col?: Dvala implementation should be used instead')\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: () => {\n throw new Error('generate: Dvala implementation should be used instead')\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: () => {\n throw new Error('cell-map: Dvala implementation should be used instead')\n },\n arity: { min: 2 },\n },\n 'cell-mapi': {\n evaluate: () => {\n throw new Error('cell-mapi: Dvala implementation should be used instead')\n },\n arity: toFixedArity(2),\n },\n 'cell-reduce': {\n evaluate: () => {\n throw new Error('cell-reduce: Dvala implementation should be used instead')\n },\n arity: toFixedArity(3),\n },\n 'cell-reducei': {\n evaluate: () => {\n throw new Error('cell-reducei: Dvala implementation should be used instead')\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 source: gridModuleSource,\n docs: moduleDocs,\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","do\nlet _transpose = (g) ->\n map(range(count(first(g))), (i) ->\n map(range(count(g)), (j) -> nth(nth(g, j), i))\n );\n{\n \"cell-every?\": (grid, predicate) -> do\n let cells = flatten(grid, 1);\n loop(i = 0) ->\n cond\n case i >= count(cells) then true\n case not(predicate(nth(cells, i))) then false\n case true then recur(i + 1)\n end\n end,\n \"some?\": (grid, predicate) -> do\n let cells = flatten(grid, 1);\n loop(i = 0) ->\n cond\n case i >= count(cells) then false\n case predicate(nth(cells, i)) then true\n case true then recur(i + 1)\n end\n end,\n\n \"every-row?\": (grid, predicate) ->\n loop(i = 0) ->\n cond\n case i >= count(grid) then true\n case not(predicate(nth(grid, i))) then false\n case true then recur(i + 1)\n end,\n\n \"some-row?\": (grid, predicate) ->\n loop(i = 0) ->\n cond\n case i >= count(grid) then false\n case predicate(nth(grid, i)) then true\n case true then recur(i + 1)\n end,\n\n \"every-col?\": (grid, predicate) -> do\n let cols = _transpose(grid);\n loop(i = 0) ->\n cond\n case i >= count(cols) then true\n case not(predicate(nth(cols, i))) then false\n case true then recur(i + 1)\n end\n end,\n\n \"some-col?\": (grid, predicate) -> do\n let cols = _transpose(grid);\n loop(i = 0) ->\n cond\n case i >= count(cols) then false\n case predicate(nth(cols, i)) then true\n case true then recur(i + 1)\n end\n end,\n\n \"generate\": (rows, cols, generator) ->\n map(range(rows), (i) -> map(range(cols), (j) -> generator(i, j))),\n\n \"cell-map\": (...params) -> do\n let fn = last(params);\n let grids = drop-last(params, 1);\n let rows = count(first(grids));\n let cols = count(first(first(grids)));\n map(range(rows), (i) ->\n map(range(cols), (j) ->\n apply(fn, map(grids, (g) -> nth(nth(g, i), j)))\n )\n )\n end,\n\n \"cell-mapi\": (grid, fn) -> do\n let rows = count(grid);\n let cols = count(first(grid));\n map(range(rows), (i) ->\n map(range(cols), (j) ->\n fn(nth(nth(grid, i), j), i, j)\n )\n )\n end,\n\n \"cell-reduce\": (grid, fn, initial-value) ->\n reduce(flatten(grid, 1), fn, initial-value),\n\n \"cell-reducei\": (grid, fn, initial-value) -> do\n let rows = count(grid);\n let cols = count(first(grid));\n loop(acc = initial-value, i = 0, j = 0) ->\n cond\n case i >= rows then acc\n case j >= cols then recur(acc, i + 1, 0)\n case true then recur(fn(acc, nth(nth(grid, i), j), i, j), i, j + 1)\n end\n end\n}\nend;","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: 'number',\n array: true,\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: 'number',\n array: true,\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: 'number',\n array: true,\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 array: true,\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/annotatedCollections'\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/annotatedCollections'\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'\nimport vectorModuleSource from './vector.dvala'\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 source: vectorModuleSource,\n docs: moduleDocs,\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 array: true,\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 array: true,\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 array: true,\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 array: true,\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 array: true,\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 array: true,\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: 'number',\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: 'number',\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/annotatedCollections'\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'\nimport linearAlgebraModuleSource from './linear-algebra.dvala'\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 source: linearAlgebraModuleSource,\n docs: moduleDocs,\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/annotatedCollections'\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'\nimport matrixModuleSource from './matrix.dvala'\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 source: matrixModuleSource,\n docs: moduleDocs,\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: 'number',\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: 'number',\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.',\n },\n },\n variants: [\n {\n argumentNames: [\n 'length',\n ],\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', 'null'],\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 m: {\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/annotatedCollections'\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 numberTheoryModuleSource from './number-theory.dvala'\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 source: numberTheoryModuleSource,\n docs: moduleDocs,\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 { BuiltinNormalExpressions, FunctionDocs } from '../../builtin/interface'\n\n/**\n * Represents a Dvala module that can be imported dynamically.\n * Modules contain a collection of functions that are not part of the core bundle.\n */\nexport interface DvalaModule {\n /** The name of the module (e.g., 'grid', 'vec', 'mat') */\n name: string\n /** The functions provided by this module, keyed by their short name (e.g., 'transpose') */\n functions: BuiltinNormalExpressions\n /**\n * Optional Dvala source code that is evaluated at import time.\n * The source must evaluate to an object mapping function names to functions.\n * These are merged with (and may override) the TypeScript `functions`.\n */\n source?: string\n /**\n * Docs for all functions in this module, including any defined in `source`.\n * The reference system uses this record as the sole source of truth for\n * function names and documentation. Not required for user-defined modules.\n */\n docs?: Record<string, FunctionDocs>\n}\n\n/**\n * Derives a docs record from a BuiltinNormalExpressions map.\n * Use this for modules whose docs are co-located inline on each function.\n */\nexport function moduleDocsFromFunctions(functions: BuiltinNormalExpressions): Record<string, FunctionDocs> {\n return Object.fromEntries(\n Object.entries(functions).map(([k, v]) => {\n if (!v.docs)\n throw new Error(`Missing docs for function \"${k}\"`)\n return [k, v.docs]\n }),\n )\n}\n","import type { SourceCodeInfo } from '../../../tokenizer/token'\nimport { isMatrix, isVector } from '../../../typeGuards/annotatedCollections'\nimport { isNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport { DvalaError } from '../../../errors'\nimport type { BuiltinNormalExpressions } from '../../interface'\nimport { moduleDocsFromFunctions } from '../interface'\nimport type { DvalaModule } from '../interface'\nimport mathModuleSource from './math.dvala'\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 source: mathModuleSource,\n docs: moduleDocsFromFunctions(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 { moduleDocsFromFunctions } from '../interface'\nimport type { DvalaModule } from '../interface'\nimport functionalModuleSource from './functional.dvala'\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 source: functionalModuleSource,\n docs: moduleDocsFromFunctions(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 { moduleDocsFromFunctions } from '../interface'\nimport type { SourceCodeInfo } from '../../../tokenizer/token'\nimport stringModuleSource from './string.dvala'\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: 'string' },\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', array: true },\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 source: stringModuleSource,\n docs: moduleDocsFromFunctions(stringUtilsFunctions),\n}\n","{}","import type { Any, Arr, Coll, Obj } from '../../../interface'\nimport type { SourceCodeInfo } from '../../../tokenizer/token'\nimport { cloneColl, collHasKey, toAny } from '../../../utils'\nimport { asColl, assertAny, assertColl, assertObj, isColl, isObj } from '../../../typeGuards/dvala'\nimport type { BuiltinNormalExpressions } from '../../interface'\nimport { assertArray } from '../../../typeGuards/array'\nimport { assertNumber, isNumber } from '../../../typeGuards/number'\nimport { asStringOrNumber, assertString, assertStringOrNumber } from '../../../typeGuards/string'\nimport { toFixedArity } from '../../../utils/arity'\nimport { moduleDocsFromFunctions } from '../interface'\nimport type { DvalaModule } from '../interface'\nimport collectionModuleSource from './collection.dvala'\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\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: () => { throw new Error('update: Dvala implementation should be used instead') },\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', 'key', 'fun'] },\n { argumentNames: ['coll', 'key', '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: () => { throw new Error('update-in: Dvala implementation should be used instead') },\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: () => { throw new Error('filteri: Dvala implementation should be used instead') },\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: () => { throw new Error('mapi: Dvala implementation should be used instead') },\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: () => { throw new Error('reducei: Dvala implementation should be used instead') },\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: () => { throw new Error('reduce-right: Dvala implementation should be used instead') },\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: () => { throw new Error('reducei-right: Dvala implementation should be used instead') },\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: () => { throw new Error('reductions: Dvala implementation should be used instead') },\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: () => { throw new Error('reductionsi: Dvala implementation should be used instead') },\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: 'any' },\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: () => { throw new Error('every?: Dvala implementation should be used instead') },\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: () => { throw new Error('any?: Dvala implementation should be used instead') },\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: () => { throw new Error('not-any?: Dvala implementation should be used instead') },\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: () => { throw new Error('not-every?: Dvala implementation should be used instead') },\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 source: collectionModuleSource,\n docs: moduleDocsFromFunctions(collectionUtilsFunctions),\n}\n","{\n update: (coll, key, fn, ...extra-params) ->\n assoc(coll, key, apply(fn, [get(coll, key), ...extra-params])),\n\n update-in: (coll, ks, fn, ...extra-params) -> do\n let k = first(ks);\n if count(ks) == 1 then\n assoc(coll, k, apply(fn, [get(coll, k), ...extra-params]))\n else\n let inner = get(coll, k);\n let inner-coll = null?(inner) ? {} : inner;\n assoc(coll, k, apply(self, [inner-coll, slice(ks, 1), fn, ...extra-params]))\n end\n end,\n\n filteri: (coll, fn) -> do\n cond\n case array?(coll) then\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> if fn(first(pair), second(pair)) then [...acc, first(pair)] else acc end,\n []\n )\n\n case string?(coll) then\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> if fn(first(pair), second(pair)) then ++(acc, first(pair)) else acc end,\n \"\"\n )\n\n case object?(coll) then\n reduce(keys(coll), (acc, k) ->\n if fn(coll(k), k) then assoc(acc, k, coll(k)) else acc end,\n {}\n )\n\n case true then\n perform(effect(dvala.error), \"Expected collection\")\n end\n end,\n\n mapi: (coll, fn) -> do\n cond\n case array?(coll) then\n for (i in range(count(coll))) -> fn(nth(coll, i), i)\n\n case string?(coll) then\n reduce(\n for (i in range(count(coll))) -> fn(nth(coll, i), i),\n (acc, ch) -> ++(acc, ch),\n \"\"\n )\n\n case object?(coll) then\n reduce(keys(coll), (acc, k) ->\n assoc(acc, k, fn(coll(k), k)),\n {}\n )\n\n case true then\n perform(effect(dvala.error), \"Expected collection\")\n end\n end,\n\n reducei: (coll, fn, initial) -> do\n cond\n case string?(coll) then\n loop (acc = initial, i = 0) -> do\n if i >= count(coll) then\n acc\n else\n recur(fn(acc, nth(coll, i), i), i + 1)\n end\n end\n\n case array?(coll) then\n loop (acc = initial, i = 0) -> do\n if i >= count(coll) then\n acc\n else\n recur(fn(acc, nth(coll, i), i), i + 1)\n end\n end\n\n case object?(coll) then\n reduce(keys(coll), (acc, k) -> fn(acc, coll(k), k), initial)\n\n case true then\n perform(effect(dvala.error), \"Expected collection\")\n end\n end,\n\n reduce-right: (coll, fn, initial) -> do\n cond\n case string?(coll) then\n reduce(reverse(coll), fn, initial)\n\n case array?(coll) then\n reduce(reverse(coll), fn, initial)\n\n case object?(coll) then\n reduce(reverse(keys(coll)), (acc, k) -> fn(acc, coll(k)), initial)\n\n case true then\n perform(effect(dvala.error), \"Expected collection\")\n end\n end,\n\n reducei-right: (coll, fn, initial) -> do\n cond\n case string?(coll) then\n let len = count(coll);\n loop (acc = initial, i = len - 1) -> do\n if i < 0 then\n acc\n else\n recur(fn(acc, nth(coll, i), i), i - 1)\n end\n end\n\n case array?(coll) then\n let len = count(coll);\n loop (acc = initial, i = len - 1) -> do\n if i < 0 then\n acc\n else\n recur(fn(acc, nth(coll, i), i), i - 1)\n end\n end\n\n case object?(coll) then\n reduce(reverse(keys(coll)), (acc, k) -> fn(acc, coll(k), k), initial)\n\n case true then\n perform(effect(dvala.error), \"Expected collection\")\n end\n end,\n\n reductions: (coll, fn, initial) -> do\n let items = cond\n case string?(coll) then\n if count(coll) == 0 then [] else for (i in range(count(coll))) -> nth(coll, i) end\n\n case array?(coll) then coll\n\n case object?(coll) then\n for (k in keys(coll)) -> coll(k)\n\n case true then\n perform(effect(dvala.error), \"Expected collection\")\n end;\n if count(items) == 0 then\n [initial]\n else\n reduce(items, (acc, elem) -> do\n let prev = last(acc);\n [...acc, fn(prev, elem)]\n end, [initial])\n end\n end,\n\n reductionsi: (coll, fn, initial) -> do\n cond\n case string?(coll) then do\n if count(coll) == 0 then\n [initial]\n else\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> do\n let prev = last(acc);\n [...acc, fn(prev, first(pair), second(pair))]\n end,\n [initial]\n )\n end\n end\n\n case array?(coll) then do\n if count(coll) == 0 then\n [initial]\n else\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> do\n let prev = last(acc);\n [...acc, fn(prev, first(pair), second(pair))]\n end,\n [initial]\n )\n end\n end\n\n case object?(coll) then do\n let ks = keys(coll);\n if count(ks) == 0 then\n [initial]\n else\n reduce(ks, (acc, k) -> do\n let prev = last(acc);\n [...acc, fn(prev, coll(k), k)]\n end, [initial])\n end\n end\n\n case true then\n perform(effect(dvala.error), \"Expected collection\")\n end\n end,\n\n \"every?\": (coll, fn) -> do\n let items = cond\n case array?(coll) then coll\n case string?(coll) then for (i in range(count(coll))) -> nth(coll, i)\n case object?(coll) then for (k in keys(coll)) -> [k, coll(k)]\n case true then perform(effect(dvala.error), \"Expected collection\")\n end;\n loop (i = 0) ->\n cond\n case i >= count(items) then true\n case not(fn(nth(items, i))) then false\n case true then recur(i + 1)\n end\n end,\n\n \"any?\": (coll, fn) -> do\n let items = cond\n case array?(coll) then coll\n case string?(coll) then for (i in range(count(coll))) -> nth(coll, i)\n case object?(coll) then for (k in keys(coll)) -> [k, coll(k)]\n case true then perform(effect(dvala.error), \"Expected collection\")\n end;\n loop (i = 0) ->\n cond\n case i >= count(items) then false\n case fn(nth(items, i)) then true\n case true then recur(i + 1)\n end\n end,\n\n \"not-any?\": (coll, fn) -> do\n let items = cond\n case array?(coll) then coll\n case string?(coll) then for (i in range(count(coll))) -> nth(coll, i)\n case object?(coll) then for (k in keys(coll)) -> [k, coll(k)]\n case true then perform(effect(dvala.error), \"Expected collection\")\n end;\n loop (i = 0) ->\n cond\n case i >= count(items) then true\n case fn(nth(items, i)) then false\n case true then recur(i + 1)\n end\n end,\n\n \"not-every?\": (coll, fn) -> do\n let items = cond\n case array?(coll) then coll\n case string?(coll) then for (i in range(count(coll))) -> nth(coll, i)\n case object?(coll) then for (k in keys(coll)) -> [k, coll(k)]\n case true then perform(effect(dvala.error), \"Expected collection\")\n end;\n loop (i = 0) ->\n cond\n case i >= count(items) then false\n case not(fn(nth(items, i))) then true\n case true then recur(i + 1)\n end\n end\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, assertSeq } from '../../../typeGuards/dvala'\nimport { asNumber, assertNumber } from '../../../typeGuards/number'\nimport { assertString } from '../../../typeGuards/string'\nimport { collHasKey, deepEqual, toNonNegativeInteger } from '../../../utils'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../interface'\nimport { moduleDocsFromFunctions } from '../interface'\nimport type { DvalaModule } from '../interface'\nimport sequenceModuleSource from './sequence.dvala'\n\nconst sequenceUtilsFunctions: BuiltinNormalExpressions = {\n 'position': {\n evaluate: () => { throw new Error('position: Dvala implementation should be used instead') },\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: () => { throw new Error('sort-by: Dvala implementation should be used instead') },\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: () => { throw new Error('remove: Dvala implementation should be used instead') },\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: () => { throw new Error('split-with: Dvala implementation should be used instead') },\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: () => { throw new Error('group-by: Dvala implementation should be used instead') },\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: () => { throw new Error('partition-by: Dvala implementation should be used instead') },\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 source: sequenceModuleSource,\n docs: moduleDocsFromFunctions(sequenceUtilsFunctions),\n}\n","{\n position: (seq, fn) -> do\n let items = cond\n case null?(seq) then null\n case string?(seq) then for (i in range(count(seq))) -> nth(seq, i)\n case true then seq\n end;\n if null?(items) then null\n else\n loop (i = 0) ->\n cond\n case i >= count(items) then null\n case fn(nth(items, i)) then i\n case true then recur(i + 1)\n end\n end\n end,\n\n sort-by: (seq, keyfn, ...args) -> do\n let items = if string?(seq) then for (i in range(count(seq))) -> nth(seq, i) else [...seq] end;\n let keyed = map(items, (elem) -> [keyfn(elem), elem]);\n let sorted = if count(args) == 0 then\n sort(keyed, (a, b) -> compare(first(a), first(b)))\n else\n sort(keyed, (a, b) -> first(args)(first(a), first(b)))\n end;\n let result = map(sorted, second);\n if string?(seq) then join(result, \"\") else result end\n end,\n\n remove: (seq, fn) -> do\n let result = filter(\n if string?(seq) then for (i in range(count(seq))) -> nth(seq, i) else seq end,\n (elem) -> not(fn(elem))\n );\n if string?(seq) then join(result, \"\") else result end\n end,\n\n split-with: (seq, fn) -> do\n let items = if string?(seq) then for (i in range(count(seq))) -> nth(seq, i) else seq end;\n let idx = loop (i = 0) ->\n cond\n case i >= count(items) then -1\n case not(fn(nth(items, i))) then i\n case true then recur(i + 1)\n end;\n if idx == -1 then\n [seq, if array?(seq) then [] else \"\" end]\n else\n [slice(seq, 0, idx), slice(seq, idx)]\n end\n end,\n\n group-by: (seq, fn) -> do\n let items = if string?(seq) then for (i in range(count(seq))) -> nth(seq, i) else seq end;\n reduce(items, (result, val) -> do\n let key = fn(val);\n let existing = get(result, key);\n assoc(result, key, if null?(existing) then [val] else [...existing, val] end)\n end, {})\n end,\n\n partition-by: (seq, fn) -> do\n let items = if string?(seq) then for (i in range(count(seq))) -> nth(seq, i) else seq end;\n if count(items) == 0 then\n []\n else\n do\n let result = reduce(rest(items), (acc, elem) -> do\n let value = fn(elem);\n if value != first(acc) then\n [value, [...second(acc), [elem]]]\n else\n [value, [...slice(second(acc), 0, count(second(acc)) - 1), [...last(second(acc)), elem]]]\n end\n end, [fn(first(items)), [[first(items)]]]);\n let groups = second(result);\n if string?(seq) then\n map(groups, (group) -> join(group, \"\"))\n else\n groups\n end\n end\n end\n end\n}","import { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { Argument, BuiltinNormalExpressions } from '../../interface'\nimport { moduleDocsFromFunctions } from '../interface'\nimport type { DvalaModule } from '../interface'\nimport bitwiseModuleSource from './bitwise.dvala'\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 source: bitwiseModuleSource,\n docs: moduleDocsFromFunctions(bitwiseUtilsNormalExpression),\n}\n","{}","import { assertNumber } from '../../../typeGuards/number'\nimport { toFixedArity } from '../../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../../interface'\nimport { moduleDocsFromFunctions } from '../interface'\nimport type { DvalaModule } from '../interface'\nimport convertModuleSource from './convert.dvala'\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 source: convertModuleSource,\n docs: moduleDocsFromFunctions(convertFunctions),\n}\n","import type { DvalaModule } from './builtin/modules/interface'\nimport { assertModule } from './builtin/modules/assertion'\nimport { gridModule } from './builtin/modules/grid'\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 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 { createDvala } from '../createDvala'\nimport type { DvalaRunner } from '../createDvala'\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 = createDvala({ 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: DvalaRunner): 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","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","asNonUndefined","assertNonUndefined","undefined","isNonUndefined","isUnknownRecord","isUserDefinedFunction","isAny","asAny","assertAny","isSeq","asSeq","assertSeq","isObj","isRegularExpression","isEffect","assertObj","isColl","asColl","assertColl","regexp","assertStringOrRegularExpression","isStringOrRegularExpression","assertEffect","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","forEach","add","addToSet","target","source","EPSILON","epsilon","diff","abs","approxZero","smartTrim","str","minIndent","lines","split","match","shift","pop","indent","acc","lineIndent","Infinity","slice","trimEnd","assertArray","assertStringArray","every","v","isStringArray","assertCharArray","isCharArray","collectionNormalExpression","fun","colls","initial","get","defaultValue","includes","elem","assoc","copy","kvs","arr","concat","obj","assign","arrayNormalExpression","second","third","from","to","step","push","array","flatten","seq","depth","actualDepth","POSITIVE_INFINITY","flat","mapcat","windowSize","fn","sequenceNormalExpression","nth","n","last","at","substring","index","indexOf","findIndex","next","reverse","start","stop","some","sort","take","input","drop","annotatedArrays","WeakSet","annotatedVectors","annotadedNonVectors","annotadedMatrices","annotatedNonMatrices","annotatedGrids","annotatedNonGrids","annotate","isVector","isMatrix","isGrid","vector","assertVector","assert2dVector","is2dVector","assert3dVector","is3dVector","assertNonEmptyVector","grid","typePred","nbrOfCols","row","cell","assertGrid","matrix","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","boolean","parse","asEffect","e","pattern","matchType","flags","objectNormalExpression","vals","dissoc","newObj","merge","objs","zipmap","predicatesNormalExpression","NEGATIVE_INFINITY","table","regexpNormalExpression","sourceArg","flagsArg","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","isEffectRef","_isOperator","functionForms","variant","argsStr","argName","operatorForm","signature","arg","argStrings","example","ref","argType","typeString","vectorNormalExpression","sum","prod","mean","median","sorted","mid","calcMedian","expressions","normalExpressionReference","effectReference","doc","docString","argCounts","getMetaNormalExpression","expression","normalExpressions","normalExpressionTypes","allNormalExpressions","andSpecialExpression","evaluateAsNormalExpression","getUndefinedSymbols","node","contextStack","builtin","evaluateNode","condSpecialExpression","customVariants","details","bindingTargetTypes","chain","Promise","then","async","chainRemainingMap","currentPromise","startIndex","reduceSequential","chainRemainingReduce","forEachSequential","chainRemainingForEach","tryCatch","tryFn","catchFn","catch","error","walkDefaults","bindingTarget","onDefault","element","evaluateBindingNodeValues","record","createRecord","assertUnknownRecord","capturedKeys","restElement","existingVal","resolvedVal","restValues","restIndex","elements","getAllBindingTargetNames","names","getNamesFromBindingTarget","tryMatch","tryMatchRecord","matched","literalNode","literalValue","symbolNode","defaultNode","arrayTarget","el","matchSpecialExpression","body","guard","newContext","caseContextStack","create","definedSpecialExpression","doSpecialExpression","bodyResult","withHandlers","withResult","effectExpr","handlerFn","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","arraySpecialExpression","effectSpecialExpression","objectSpecialExpression","kvps","importSpecialExpression","parallelSpecialExpression","branch","performSpecialExpression","argExprs","raceSpecialExpression","specialExpressionTypes","cond","block","doseq","for","if","let","loop","object","recur","unless","import","effect","perform","parallel","race","specialExpressions","normalExpressionKeys","specialExpressionKeys","binaryOperators","symbolicOperators","nonFunctionOperatorSet","isFunctionOperator","operator","binaryOperatorSet","isBinaryOperator","symbolicOperatorSet","isSymbolicOperator","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","_","illegalSymbolCharacters","illegalFirstSymbolCharacters","illegalSymbolCharacterSet","illegalFirstSymbolCharacterSet","whitespaceRegExp","NO_MATCH","tokenizeString","escaping","tokenizeToken","decimalNumberRegExp","octalNumberRegExp","hexNumberRegExp","binaryNumberRegExp","postNumberRegExp","tokenizeSymbol","initialPosition","endsWith","tokenizers","symbolMeta","startsWith","stringLength","token","baseChar","nextChar","negate","plusPrefix","hasDecimalPoint","hasExponent","threeChars","twoChars","oneChar","tokenize","debug","tokenStream","tokens","hasDebugData","createSourceCodeInfo","tokenDescriptor","getCurrentToken","lastLine","lineNbr","getSourceCodeLine","nbrOfCharacters","tokenizeShebang","tokenizer","dvalaCommands","AutoCompleter","originalProgram","originalPosition","prefixProgram","suffixProgram","searchString","suggestions","suggestionIndex","lastToken","generateSuggestions","getNextSuggestion","getAutoCompleteSuggestionResult","getNextSuggestionSymbol","getPreviousSuggestion","getPreviousSuggestionSymbol","suggestion","program","getSuggestions","getSearchString","blacklist","startsWithCaseSensitive","generateWithPredicate","startsWithCaseInsensitive","includesCaseSensitive","includesCaseInsensitive","shouldInclude","bindings","localeCompare","isUserDefinedSymbolNode","asUserDefinedSymbolNode","assertUserDefinedSymbolNode","isNormalBuiltinSymbolNode","isSpecialBuiltinSymbolNode","isNormalExpressionNodeWithName","isNormalExpressionNode","nodeType","isSymbolNode","isSpreadNode","ContextStackImpl","_contexts","globalContext","modules","valueModules","pure","contexts","hostValues","Map","getContextsRaw","getHostValues","getModuleScopeBindings","scope","k","getGlobalContextIndex","fromDeserialized","cs","globalContextIndex","setContextsFromDeserialized","getModule","getValueModule","found","registerValueModule","set","currentContext","shadowedName","getShadowedBuiltinName","getValue","contextEntry","lookUp","hostValue","evaluateSymbol","specialExpression","specialBuiltinSymbolType","normalExpression","normalBuiltinSymbolType","lookUpResult","assertNotShadowingBuiltin","createContextStack","identifier","globalModuleScope","ast","nodes","unresolvedSymbols","subNode","findUnresolvedSymbolsInNode","normalExpressionNode","expressionNode","specialExpressionNode","specialExpressionType","castedGetUndefinedSymbols","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","withSourceCodeInfo","stringToSymbolNode","stringFromQuotedSymbol","backslash","singleQuote","normalChar","normalExpressionNames","specialExpressionNames","getSymbolName","createNamedNormalExpressionNode","isAtExpressionEnd","ctx","isAtEnd","tryPeek","fromBinaryOperatorToNode","left","right","ParserContext","storedPosition","parseExpression","advance","peek","peekSourceCodeInfo","currentToken","storePosition","restorePosition","peekAhead","getPosition","getTokenAt","pos","getPrecedence","operatorSign","parseImplicitBlock","ends","isImplicitBlockEnd","assertImplicitBlockEnd","parseDo","parseSymbol","parseString","doubleQuote","newline","tab","carriageReturn","backspace","formFeed","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","doNode","parseFunctionCall","nextToken","parseEffectArgs","moduleName","parseObject","stringNode","parseOperand","operand","lamdaFunction","startPos","endPos","dollar1","parseShorthandLambdaFunction","parseArray","tokenType","endStringPosition","lastIndexOf","regexpString","optionsString","optionsNode","parseRegexpShorthand","parseOperandPart","symbolToken","createAccessorNode","precedence","isUnless","condition","thenExpression","elseExpression","parseIfOrUnless","caseExpression","parseCond","valueExpression","parseMatch","isDoseq","forLoopBindings","loopBinding","newBoundNames","parseForOrDoseq","parseLoop","newPrecedece","newPrecedence","operatorSymbol","trueNode","falseNode","createParserContext","minifyTokenStream","removeWhiteSpace","isSingleLineCommentToken","isMultiLineCommentToken","isShebangToken","isWhitespaceToken","effectNameMatchesPattern","effectName","prefix","findMatchingHandlers","handlers","handler","SuspensionSignal","snapshots","nextSnapshotIndex","meta","_brand","isSuspensionSignal","ResumeFromSignal","continuation","trimToIndex","isResumeFromSignal","internMap","getEffectRef","fnvMixByte","hash","byte","imul","fnvMixInt","fnvMixString","charCodeAt","contentHash","is","aObj","bObj","estimateSize","size","walkAndCollect","hashGroups","parentInfo","_rootIdx","parent","group","existing","locations","deepClone","expandPoolRefs","pool","__poolRef","isPoolRef","id","serializeToObject","csMap","nextId","collectContextStacks","serializeValue","path","__csRef","serializedContextStacks","ctxIdx","serialized","serializedK","serializedMeta","version","contextStacks","serializeSuspensionBlob","base","roots","snapshot","dedupedRoots","threshold","clonedRoots","r","rootIdx","groups","info","alreadyPooled","loc","dedupSubTrees","deserializeFromObject","blobData","data","scs","placeholderContexts","resolveValue","isCSRef","resolvedContexts","serializedCtx","resolved","process","stdout","write","formatForOutput","replaceSpecialValues","standardEffects","console","log","globalThis","alert","stderr","prompt","_args","stdin","resolve","reject","chunks","setEncoding","on","chunk","resume","random","shuffled","tmp","now","Intl","DateTimeFormat","resolvedOptions","timeZone","setTimeout","evaluateNodeRecursive","evaluateReservedSymbol","paramNodes","placeholders","paramNode","spreadValue","evaluateParamsRecursive","nameSymbol","resolvedFn","dvalaImpl","executeUserDefinedRecursive","executeFunction","executeFunctionRecursive","evaluateNormalExpressionRecursive","env","runSyncTrampoline","runAsyncTrampoline","executeDvalaFunctionRecursive","evaluateArrayAsFunction","evaluateObjectAsFunction","evaluateStringAsFunction","evaluateNumberAsFunction","actualParams","paramsCopy","placeholderIndex","splice","executePartialRecursive","currentParams","finalArr","executeCompRecursive","mapSequential","executeJuxtRecursive","checks","check","executeEveryPredRecursive","executeSomePredRecursive","fnulledParams","executeFnullRecursive","effectRef","executeEffectMatcherRecursive","executeBuiltinRecursive","executeSpecialBuiltinRecursive","dvalaModule","functions","functionName","executeModuleRecursive","setupAndExecute","evaluatedFunction","evaluatedfunction","nbrOfNonRestArgs","paramSetup","defaultSetup","paramIndex","valueRecord","argIndex","restArgument","restSetup","newContextStack2","_acc","reservedName","stepNode","argNodes","nanFrame","evalArgsFrame","dispatchCall","firstArg","newK","stepNormalExpression","conditionNode","thenNode","elseNode","inverted","frame","firstNode","nextNode","advanceQq","skipUndefinedQq","cases","phase","matchValueNode","matchValue","withHandlerNodes","newEnv","bodyK","handlerNode","bindingContext","returnResult","bindingLevel","levelStates","handleRecur","singleFrame","isFirstSpread","isSpread","currentKey","evaluatedFunc","functionContext","new","evaluateFunction","valueModule","sourceEnv","mergeFrame","tsFunctions","module","sequenceFrame","allNodes","branches","stepSpecialExpression","builtinType","setupUserDefinedCall","wrapMaybePromiseAsStep","dispatchFunction","dispatchDvalaFunction","bodyNodes","bodyEnv","fnBodyFrame","bodyIndex","outerEnv","applyFrame","_value","newFrame","applySequence","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","applyRecur","applyPerformArgs","applyTryWith","resumeK","applyEffectResume","branchCount","completedBranches","suspendedBranches","applyParallelResume","currentArgNode","nextArg","applyEvalArgs","applyCallFn","applyFnBody","applyBindingDefault","applyNanCheck","stepInfo","extractBindings","awaitFrame","applyDebugStep","dvalaFunctions","dvalaOnlyFunctions","merged","currentLevel","currentState","nextElementIndex","letIndex","bindingIndex","bindingValue","nextLevel","tryDispatchDvalaError","signal","snapshotState","handlerMatchesEffect","invokeMatchedHandler","matchingHostHandlers","dispatchHostHandler","remainingK","rebindAll","innermostContext","newIterateFrame","frameIndex","handlerK","dispatchPerform","timestamp","runId","maxSnapshots","standardHandler","def","getStandardEffectHandler","matchingHandlers","effectSignal","AbortController","argsArray","resolveOutcome","o","kind","promise","tryHandler","outcome","settled","assertNotSettled","handlerResult","fail","msg","suspend","checkpoint","resumeFrom","throwSuspension","runBranch","runEffectLoop","tick","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","effectStep","effectHandlers","buildInitialStep","initialSnapshotState","deserializeOptions","debugMode","crypto","randomUUID","debugFrame","restoredK","cutIdx","coreDvalaSources","sequence","functional","initialized","Cache","cache","firstEntry","lastEntry","_size","maxSize","getContent","clear","newEntry","nextEntry","dropFirstEntry","isDvalaBundle","fileModules","assertSerializableBindings","assertSerializable","TypeError","getPrototypeOf","createDvala","initCoreDvalaSources","factoryBindings","factoryEffectHandlers","buildAst","cached","mergeBindings","runBindings","mergeEffectHandlers","runEffectHandlers","assertNotPureWithHandlers","run","runOptions","savedPure","fileSource","fileAst","moduleContextStack","evaluateWithSyncEffects","runAsync","evaluateWithEffects","definedBindings","modulesList","modulesMap","getUndefinedSymbolsInternal","standaloneGetUndefinedSymbols","getAutoCompleter","moduleDocs","assertNormalExpression","throwMessage","errorMessage","assertModule","col","shape","g","fill","cols","generate","generator","reshape","transpose","rotate","crop","begin","deleteCount","items","gridFunctions","flatTable","times","height","width","y","rowStart","colStart","rowEnd","colEnd","trMatrix","rowDeleteCount","colDeleteCount","flatArray","fromArray","gridModule","variance","stdev","iqr","span","skewness","kurtosis","rms","mad","medad","entropy","mode","linspace","cumsum","cumprod","quartiles","percentile","quantile","histogram","bins","ecdf","outliers","bincount","minSize","weights","winsorize","mse","rmse","mae","smape","q1Index","q1","q3Index","q3","lowerBound","upperBound","calcPercentile","sortedData","lowerIndex","upperIndex","weight","midIndex","q2","lowerHalf","upperHalf","midLower","midUpper","calcMean","geometricMeanReductionFunction","exp","medianReductionFunction","calcVariance","optionalMean","varianceReductionFunction","sampleVarianceReductionFunction","calcSampleVariance","minLength","calcStdDev","stdevReductionFunction","sampleStdevReductionFunction","calcSampleStdDev","iqrReductionFunction","spanReductionFunction","skewnessReductionFunction","stdDev","sampleSkewnessReductionFunction","sumSquaredDiffs","sumCubedDiffs","sampleVariance","sampleStdDev","sampleSkewness","kurtosisReductionFunction","eccessKurtosisReductionFunction","excessKurtosis","sampleKurtosisReductionFunction","sampleKurtosis","sampleExcessKurtosisReductionFunction","sampleExcessKurtosis","rmsReductionFunction","madReductionFunction","calcMad","calcMedad","medadReductionFunction","giniCoefficientReductionFunction","entropyReductionFunction","frequencies","total","frequency","probability","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","p","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","scale","scalar","linearAlgebraNormalExpression","cosTheta","cos","sinTheta","sin","u","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","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","keep","arithmeticNormalExpressions","d","arithmetic","roundedPosition","calculatedValue","isInArithmeticSequence","getBernoulliSeq","bernoulli","bernoulliNormalExpressions","predicate","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","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","moduleDocsFromFunctions","fromEntries","mathUtilsFunctions","asin","sinh","asinh","cosh","acosh","tan","atan","tanh","atanh","ln","log10","mathUtilsModule","functionalUtilsNormalExpression","juxt","aMin","aMax","bMin","bMax","getCommonArityFromFunctions","complement","fnull","functionalUtilsModule","stringUtilsFunctions","int","fromCodePoint","codePointAt","padString","padStart","padEnd","template","templateString","templateStrings","applyPlaceholders","stringPlaceholders","btoa","encodeURIComponent","_match","p1","fromCharCode","parseInt","decodeURIComponent","call","atob","base64string","capitalize","charAt","doubleDollarRegexp","re","placeHolder","stringUtilsModule","collectionUtilsFunctions","nextValue","originalColl","innerCollMeta","resultColl","newResultColl","cloneAndGetMeta","lastKey","parentKey","ks","update","filteri","mapi","reducei","reductions","reductionsi","collectionUtilsModule","sequenceUtilsFunctions","findLastIndex","keyfn","comparer","unshift","distinct","existingItem","remove","partition","pad","asArray","partitionHelper","search","suffix","interleave","seqs","isStringSeq","seqsArr","interpose","separator","outer","innerArr","padIndex","sequenceUtilsModule","bitwiseUtilsNormalExpression","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","fnName","fromDesc","toDesc","convertFunctions","celsius","generateTemperatureConversions","allBuiltinModules","runTest","testPath","testNamePattern","includedFilePaths","absoluteFilePath","getIncludesRecursively","includeFilePaths","fileContent","readDvalaFile","dirname","okToInclude","includeMatch","relativeFilePath","readIncludeDirectives","includeFilePath","getIncludedFilePaths","testResult","tap","success","testChunks","testProgram","currentTest","setupCode","currentLineNbr","testNameAnnotationMatch","directive","testName","getTestChunks","testChunkProgram","testNumber","dvala","getBindings","getErrorYaml","getErrorMessage","dvalaPath","fs","readFileSync","encoding","isAbstractDvalaError","formattedMessage","terms","getLocation"],"mappings":"gDAEM,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,O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AEZ,OAAOT,CACT,CAEO,MAAMk8C,GAAuD,CAClE/B,UAAW,CACT19C,SAAU,EAAEmJ,GAAIpQ,KACd8I,EAAasH,EAAGpQ,EAAgB,CAAEgI,SAAS,EAAMS,aAAa,EAAMI,IAAK,MAClE49C,GAAYr2C,IAErBlJ,MAAO2C,GAAa,KC5BX88C,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,CACnEhC,WAAc,CACZ39C,SAAU,EAAEmJ,GAAIpQ,KACd8I,EAAasH,EAAGpQ,EAAgB,CAAEgI,SAAS,EAAMS,aAAa,IA/BpE,SAAoB2H,GAElB,GAAIA,GAAK,EACP,MAAO,CAAC,IACV,GAAU,IAANA,EACF,MAAO,CAAC,CAAC,IAEX,MAAM5F,EAAqB,GAkB3B,OAfA,SAASq8C,EAAmBC,EAAmBrmD,EAAailD,GAC1D,GAAkB,IAAdoB,EAMJ,IAAK,IAAI77C,EAAIzK,KAAK2G,IAAI1G,EAAKqmD,GAAY77C,GAAK,EAAGA,IAC7Cy6C,EAAQn2C,KAAKtE,GACb47C,EAAmBC,EAAY77C,EAAGA,EAAGy6C,GACrCA,EAAQt4C,WARR5C,EAAO+E,KAAK,IAAIm2C,GAUnB,CAEDmB,CAAmBz2C,EAAGA,EAAG,IAClB5F,CACT,CAMao6C,CAAWx0C,IAEpBlJ,MAAO2C,GAAa,IAEtB,mBAAoB,CAClB5C,SAAU,EAAEmJ,GAAIpQ,KAEd,GADA8I,EAAasH,EAAGpQ,EAAgB,CAAEgI,SAAS,EAAMS,aAAa,IACpD,IAAN2H,EACF,OAA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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,YAAahH,KAC1D+G,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,YAAa7G,KAC1D4G,GAAqBC,GAAwB,OOvGlB,CACzB,EAC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