@mojir/dvala 0.0.7 → 0.0.10

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 (321) hide show
  1. package/dist/cli/cli.js +1622 -1620
  2. package/dist/cli/reference/examples.d.ts +1 -1
  3. package/dist/cli/src/AutoCompleter/AutoCompleter.d.ts +4 -2
  4. package/dist/cli/src/{Dvala/Cache.d.ts → Cache.d.ts} +1 -1
  5. package/dist/cli/src/builtin/specialExpressions/functions.d.ts +1 -1
  6. package/dist/cli/src/createDvala.d.ts +47 -0
  7. package/dist/cli/src/evaluator/ContextStack.d.ts +10 -2
  8. package/dist/cli/src/evaluator/effectTypes.d.ts +24 -6
  9. package/dist/cli/src/evaluator/suspension.d.ts +6 -0
  10. package/dist/cli/src/evaluator/trampoline.d.ts +15 -1
  11. package/dist/cli/src/parser/subParsers/parseDo.d.ts +1 -1
  12. package/dist/cli/src/tokenizer/token.d.ts +2 -4
  13. package/dist/cli/src/tokenizer/tokenize.d.ts +1 -2
  14. package/dist/cli/src/tokenizer/tokenizers.d.ts +2 -3
  15. package/dist/cli/src/tooling.d.ts +51 -0
  16. package/dist/debug.esm.js +1 -1
  17. package/dist/debug.esm.js.map +1 -1
  18. package/dist/debug.js +1 -1
  19. package/dist/debug.js.map +1 -1
  20. package/dist/dvala.iife.js +1 -1
  21. package/dist/dvala.iife.js.map +1 -1
  22. package/dist/full.esm.js +1 -1
  23. package/dist/full.esm.js.map +1 -1
  24. package/dist/full.js +1 -1
  25. package/dist/full.js.map +1 -1
  26. package/dist/index.esm.js +1 -1
  27. package/dist/index.esm.js.map +1 -1
  28. package/dist/index.js +1 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/mcp-server/common/utils.d.ts +2 -0
  31. package/dist/mcp-server/mcp-server/src/server.d.ts +1 -0
  32. package/dist/mcp-server/reference/api.d.ts +73 -0
  33. package/dist/mcp-server/reference/datatype.d.ts +3 -0
  34. package/dist/mcp-server/reference/examples.d.ts +11 -0
  35. package/dist/mcp-server/reference/index.d.ts +195 -0
  36. package/dist/mcp-server/reference/shorthand.d.ts +3 -0
  37. package/dist/mcp-server/server.js +36377 -0
  38. package/dist/mcp-server/src/AutoCompleter/AutoCompleter.d.ts +27 -0
  39. package/dist/{src/Dvala → mcp-server/src}/Cache.d.ts +1 -1
  40. package/dist/mcp-server/src/allModules.d.ts +2 -0
  41. package/dist/mcp-server/src/builtin/bindingNode.d.ts +11 -0
  42. package/dist/mcp-server/src/builtin/core/array.d.ts +2 -0
  43. package/dist/mcp-server/src/builtin/core/assertion.d.ts +2 -0
  44. package/dist/mcp-server/src/builtin/core/bitwise.d.ts +2 -0
  45. package/dist/mcp-server/src/builtin/core/collection.d.ts +2 -0
  46. package/dist/mcp-server/src/builtin/core/functional.d.ts +2 -0
  47. package/dist/mcp-server/src/builtin/core/math.d.ts +2 -0
  48. package/dist/mcp-server/src/builtin/core/meta.d.ts +3 -0
  49. package/dist/mcp-server/src/builtin/core/misc.d.ts +2 -0
  50. package/dist/mcp-server/src/builtin/core/object.d.ts +2 -0
  51. package/dist/mcp-server/src/builtin/core/predicates.d.ts +2 -0
  52. package/dist/mcp-server/src/builtin/core/regexp.d.ts +2 -0
  53. package/dist/mcp-server/src/builtin/core/sequence.d.ts +2 -0
  54. package/dist/mcp-server/src/builtin/core/string.d.ts +2 -0
  55. package/dist/mcp-server/src/builtin/core/vector.d.ts +2 -0
  56. package/dist/mcp-server/src/builtin/index.d.ts +13 -0
  57. package/dist/mcp-server/src/builtin/interface.d.ts +113 -0
  58. package/dist/mcp-server/src/builtin/modules/assertion/docs.d.ts +2 -0
  59. package/dist/mcp-server/src/builtin/modules/assertion/index.d.ts +2 -0
  60. package/dist/mcp-server/src/builtin/modules/bitwise/index.d.ts +2 -0
  61. package/dist/mcp-server/src/builtin/modules/collection/index.d.ts +2 -0
  62. package/dist/mcp-server/src/builtin/modules/convert/index.d.ts +2 -0
  63. package/dist/mcp-server/src/builtin/modules/functional/index.d.ts +2 -0
  64. package/dist/mcp-server/src/builtin/modules/grid/docs.d.ts +2 -0
  65. package/dist/mcp-server/src/builtin/modules/grid/fromArray.d.ts +8 -0
  66. package/dist/mcp-server/src/builtin/modules/grid/index.d.ts +2 -0
  67. package/dist/mcp-server/src/builtin/modules/grid/transpose.d.ts +2 -0
  68. package/dist/mcp-server/src/builtin/modules/interface.d.ts +28 -0
  69. package/dist/mcp-server/src/builtin/modules/linear-algebra/docs.d.ts +2 -0
  70. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +1 -0
  71. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +2 -0
  72. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +8 -0
  73. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +4 -0
  74. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/dot.d.ts +1 -0
  75. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +7 -0
  76. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +2 -0
  77. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +1 -0
  78. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +10 -0
  79. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/length.d.ts +1 -0
  80. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +1 -0
  81. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/scale.d.ts +1 -0
  82. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/solve.d.ts +8 -0
  83. package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +1 -0
  84. package/dist/mcp-server/src/builtin/modules/linear-algebra/index.d.ts +4 -0
  85. package/dist/mcp-server/src/builtin/modules/math/index.d.ts +2 -0
  86. package/dist/mcp-server/src/builtin/modules/matrix/docs.d.ts +2 -0
  87. package/dist/mcp-server/src/builtin/modules/matrix/helpers/adjugate.d.ts +1 -0
  88. package/dist/mcp-server/src/builtin/modules/matrix/helpers/band.d.ts +9 -0
  89. package/dist/mcp-server/src/builtin/modules/matrix/helpers/cofactor.d.ts +1 -0
  90. package/dist/mcp-server/src/builtin/modules/matrix/helpers/determinant.d.ts +6 -0
  91. package/dist/mcp-server/src/builtin/modules/matrix/helpers/inverse.d.ts +6 -0
  92. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isBanded.d.ts +11 -0
  93. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +10 -0
  94. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isIdentity.d.ts +1 -0
  95. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +1 -0
  96. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isSquare.d.ts +1 -0
  97. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isSymetric.d.ts +8 -0
  98. package/dist/mcp-server/src/builtin/modules/matrix/helpers/isTriangular.d.ts +13 -0
  99. package/dist/mcp-server/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +7 -0
  100. package/dist/mcp-server/src/builtin/modules/matrix/helpers/minor.d.ts +1 -0
  101. package/dist/mcp-server/src/builtin/modules/matrix/helpers/norm1.d.ts +1 -0
  102. package/dist/mcp-server/src/builtin/modules/matrix/helpers/trace.d.ts +8 -0
  103. package/dist/mcp-server/src/builtin/modules/matrix/index.d.ts +4 -0
  104. package/dist/mcp-server/src/builtin/modules/number-theory/binomialCefficient.d.ts +1 -0
  105. package/dist/mcp-server/src/builtin/modules/number-theory/combinations.d.ts +2 -0
  106. package/dist/mcp-server/src/builtin/modules/number-theory/derangements.d.ts +2 -0
  107. package/dist/mcp-server/src/builtin/modules/number-theory/divisors.d.ts +4 -0
  108. package/dist/mcp-server/src/builtin/modules/number-theory/docs.d.ts +2 -0
  109. package/dist/mcp-server/src/builtin/modules/number-theory/factorial.d.ts +3 -0
  110. package/dist/mcp-server/src/builtin/modules/number-theory/index.d.ts +4 -0
  111. package/dist/mcp-server/src/builtin/modules/number-theory/partitions.d.ts +2 -0
  112. package/dist/mcp-server/src/builtin/modules/number-theory/permutations.d.ts +2 -0
  113. package/dist/mcp-server/src/builtin/modules/number-theory/powerSet.d.ts +2 -0
  114. package/dist/mcp-server/src/builtin/modules/number-theory/primeFactors.d.ts +11 -0
  115. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/abundant.d.ts +2 -0
  116. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +2 -0
  117. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/bell.d.ts +1 -0
  118. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +2 -0
  119. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/catalan.d.ts +1 -0
  120. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/collatz.d.ts +2 -0
  121. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/composite.d.ts +3 -0
  122. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/deficient.d.ts +2 -0
  123. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/factorial.d.ts +1 -0
  124. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +1 -0
  125. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/geometric.d.ts +2 -0
  126. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/golomb.d.ts +2 -0
  127. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/happy.d.ts +2 -0
  128. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/index.d.ts +27 -0
  129. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/juggler.d.ts +2 -0
  130. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +2 -0
  131. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/lucas.d.ts +1 -0
  132. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/lucky.d.ts +2 -0
  133. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/mersenne.d.ts +1 -0
  134. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/padovan.d.ts +2 -0
  135. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/partition.d.ts +1 -0
  136. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/pell.d.ts +1 -0
  137. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/perfect.d.ts +1 -0
  138. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +2 -0
  139. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +10 -0
  140. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +2 -0
  141. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/poligonal.d.ts +2 -0
  142. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/prime.d.ts +3 -0
  143. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/recaman.d.ts +9 -0
  144. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/sylvester.d.ts +1 -0
  145. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +2 -0
  146. package/dist/mcp-server/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +1 -0
  147. package/dist/mcp-server/src/builtin/modules/sequence/index.d.ts +2 -0
  148. package/dist/mcp-server/src/builtin/modules/string/index.d.ts +2 -0
  149. package/dist/mcp-server/src/builtin/modules/vector/bincount.d.ts +9 -0
  150. package/dist/mcp-server/src/builtin/modules/vector/calcMad.d.ts +1 -0
  151. package/dist/mcp-server/src/builtin/modules/vector/calcMean.d.ts +1 -0
  152. package/dist/mcp-server/src/builtin/modules/vector/calcMedad.d.ts +1 -0
  153. package/dist/mcp-server/src/builtin/modules/vector/calcMedian.d.ts +1 -0
  154. package/dist/mcp-server/src/builtin/modules/vector/calcStdDev.d.ts +2 -0
  155. package/dist/mcp-server/src/builtin/modules/vector/calcVariance.d.ts +2 -0
  156. package/dist/mcp-server/src/builtin/modules/vector/docs.d.ts +2 -0
  157. package/dist/mcp-server/src/builtin/modules/vector/entropy.d.ts +8 -0
  158. package/dist/mcp-server/src/builtin/modules/vector/histogram.d.ts +9 -0
  159. package/dist/mcp-server/src/builtin/modules/vector/index.d.ts +2 -0
  160. package/dist/mcp-server/src/builtin/modules/vector/mode.d.ts +6 -0
  161. package/dist/mcp-server/src/builtin/modules/vector/outliers.d.ts +7 -0
  162. package/dist/mcp-server/src/builtin/modules/vector/percentile.d.ts +7 -0
  163. package/dist/mcp-server/src/builtin/modules/vector/quartiles.d.ts +1 -0
  164. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +2 -0
  165. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +2 -0
  166. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/index.d.ts +13 -0
  167. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +2 -0
  168. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +5 -0
  169. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/mad.d.ts +2 -0
  170. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/mean.d.ts +4 -0
  171. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/medad.d.ts +2 -0
  172. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/median.d.ts +2 -0
  173. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/prod.d.ts +2 -0
  174. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/rms.d.ts +2 -0
  175. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +3 -0
  176. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/span.d.ts +2 -0
  177. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +3 -0
  178. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/sum.d.ts +2 -0
  179. package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/variance.d.ts +3 -0
  180. package/dist/mcp-server/src/builtin/normalExpressions/index.d.ts +9 -0
  181. package/dist/mcp-server/src/builtin/normalExpressions/initCoreDvala.d.ts +1 -0
  182. package/dist/mcp-server/src/builtin/specialExpressionTypes.d.ts +24 -0
  183. package/dist/mcp-server/src/builtin/specialExpressions/and.d.ts +6 -0
  184. package/dist/mcp-server/src/builtin/specialExpressions/array.d.ts +6 -0
  185. package/dist/mcp-server/src/builtin/specialExpressions/block.d.ts +7 -0
  186. package/dist/mcp-server/src/builtin/specialExpressions/cond.d.ts +6 -0
  187. package/dist/mcp-server/src/builtin/specialExpressions/defined.d.ts +5 -0
  188. package/dist/mcp-server/src/builtin/specialExpressions/effect.d.ts +5 -0
  189. package/dist/mcp-server/src/builtin/specialExpressions/functions.d.ts +6 -0
  190. package/dist/mcp-server/src/builtin/specialExpressions/if.d.ts +6 -0
  191. package/dist/mcp-server/src/builtin/specialExpressions/import.d.ts +6 -0
  192. package/dist/mcp-server/src/builtin/specialExpressions/let.d.ts +6 -0
  193. package/dist/mcp-server/src/builtin/specialExpressions/loop.d.ts +6 -0
  194. package/dist/mcp-server/src/builtin/specialExpressions/loops.d.ts +9 -0
  195. package/dist/mcp-server/src/builtin/specialExpressions/match.d.ts +7 -0
  196. package/dist/mcp-server/src/builtin/specialExpressions/object.d.ts +6 -0
  197. package/dist/mcp-server/src/builtin/specialExpressions/or.d.ts +6 -0
  198. package/dist/mcp-server/src/builtin/specialExpressions/parallel.d.ts +6 -0
  199. package/dist/mcp-server/src/builtin/specialExpressions/perform.d.ts +6 -0
  200. package/dist/mcp-server/src/builtin/specialExpressions/qq.d.ts +6 -0
  201. package/dist/mcp-server/src/builtin/specialExpressions/race.d.ts +6 -0
  202. package/dist/mcp-server/src/builtin/specialExpressions/recur.d.ts +5 -0
  203. package/dist/mcp-server/src/builtin/specialExpressions/unless.d.ts +6 -0
  204. package/dist/mcp-server/src/builtin/utils.d.ts +6 -0
  205. package/dist/mcp-server/src/bundler/interface.d.ts +15 -0
  206. package/dist/mcp-server/src/constants/constants.d.ts +19 -0
  207. package/dist/mcp-server/src/createDvala.d.ts +47 -0
  208. package/dist/mcp-server/src/errors.d.ts +24 -0
  209. package/dist/mcp-server/src/evaluator/ContextStack.d.ts +70 -0
  210. package/dist/mcp-server/src/evaluator/contentHash.d.ts +21 -0
  211. package/dist/mcp-server/src/evaluator/dedupSubTrees.d.ts +37 -0
  212. package/dist/mcp-server/src/evaluator/effectRef.d.ts +27 -0
  213. package/dist/mcp-server/src/evaluator/effectTypes.d.ts +199 -0
  214. package/dist/mcp-server/src/evaluator/frames.d.ts +513 -0
  215. package/dist/mcp-server/src/evaluator/interface.d.ts +14 -0
  216. package/dist/mcp-server/src/evaluator/standardEffects.d.ts +50 -0
  217. package/dist/mcp-server/src/evaluator/step.d.ts +175 -0
  218. package/dist/mcp-server/src/evaluator/suspension.d.ts +92 -0
  219. package/dist/mcp-server/src/evaluator/trampoline.d.ts +138 -0
  220. package/dist/mcp-server/src/getUndefinedSymbols/index.d.ts +7 -0
  221. package/dist/mcp-server/src/initReferenceData.d.ts +1 -0
  222. package/dist/mcp-server/src/interface.d.ts +7 -0
  223. package/dist/mcp-server/src/parser/ParserContext.d.ts +20 -0
  224. package/dist/mcp-server/src/parser/getPrecedence.d.ts +3 -0
  225. package/dist/mcp-server/src/parser/helpers.d.ts +19 -0
  226. package/dist/mcp-server/src/parser/index.d.ts +5 -0
  227. package/dist/mcp-server/src/parser/subParsers/parseArray.d.ts +3 -0
  228. package/dist/mcp-server/src/parser/subParsers/parseBindingTarget.d.ts +8 -0
  229. package/dist/mcp-server/src/parser/subParsers/parseCond.d.ts +4 -0
  230. package/dist/mcp-server/src/parser/subParsers/parseDo.d.ts +3 -0
  231. package/dist/mcp-server/src/parser/subParsers/parseExpression.d.ts +5 -0
  232. package/dist/mcp-server/src/parser/subParsers/parseForOrDoseq.d.ts +4 -0
  233. package/dist/mcp-server/src/parser/subParsers/parseFunction.d.ts +4 -0
  234. package/dist/mcp-server/src/parser/subParsers/parseFunctionCall.d.ts +3 -0
  235. package/dist/mcp-server/src/parser/subParsers/parseIfOrUnless.d.ts +5 -0
  236. package/dist/mcp-server/src/parser/subParsers/parseImplicitBlock.d.ts +5 -0
  237. package/dist/mcp-server/src/parser/subParsers/parseLet.d.ts +4 -0
  238. package/dist/mcp-server/src/parser/subParsers/parseLoop.d.ts +4 -0
  239. package/dist/mcp-server/src/parser/subParsers/parseMatch.d.ts +4 -0
  240. package/dist/mcp-server/src/parser/subParsers/parseNumber.d.ts +3 -0
  241. package/dist/mcp-server/src/parser/subParsers/parseObject.d.ts +3 -0
  242. package/dist/mcp-server/src/parser/subParsers/parseOperand.d.ts +3 -0
  243. package/dist/mcp-server/src/parser/subParsers/parseRegexpShorthand.d.ts +3 -0
  244. package/dist/mcp-server/src/parser/subParsers/parseReservedSymbol.d.ts +3 -0
  245. package/dist/mcp-server/src/parser/subParsers/parseString.d.ts +4 -0
  246. package/dist/mcp-server/src/parser/subParsers/parseSymbol.d.ts +3 -0
  247. package/dist/mcp-server/src/parser/types.d.ts +128 -0
  248. package/dist/mcp-server/src/tokenizer/minifyTokenStream.d.ts +4 -0
  249. package/dist/mcp-server/src/tokenizer/operators.d.ts +12 -0
  250. package/dist/mcp-server/src/tokenizer/reservedNames.d.ts +65 -0
  251. package/dist/mcp-server/src/tokenizer/token.d.ts +82 -0
  252. package/dist/mcp-server/src/tokenizer/tokenize.d.ts +7 -0
  253. package/dist/mcp-server/src/tokenizer/tokenizers.d.ts +13 -0
  254. package/dist/mcp-server/src/tooling.d.ts +51 -0
  255. package/dist/mcp-server/src/transformer/index.d.ts +2 -0
  256. package/dist/mcp-server/src/typeGuards/annotatedCollections.d.ts +16 -0
  257. package/dist/mcp-server/src/typeGuards/array.d.ts +9 -0
  258. package/dist/mcp-server/src/typeGuards/astNode.d.ts +19 -0
  259. package/dist/mcp-server/src/typeGuards/dvala.d.ts +26 -0
  260. package/dist/mcp-server/src/typeGuards/dvalaFunction.d.ts +9 -0
  261. package/dist/mcp-server/src/typeGuards/index.d.ts +7 -0
  262. package/dist/mcp-server/src/typeGuards/number.d.ts +66 -0
  263. package/dist/mcp-server/src/typeGuards/string.d.ts +15 -0
  264. package/dist/mcp-server/src/untokenizer/index.d.ts +2 -0
  265. package/dist/mcp-server/src/utils/arity.d.ts +10 -0
  266. package/dist/mcp-server/src/utils/debug/debugTools.d.ts +1 -0
  267. package/dist/mcp-server/src/utils/debug/getCodeMarker.d.ts +2 -0
  268. package/dist/mcp-server/src/utils/debug/getSourceCodeInfo.d.ts +2 -0
  269. package/dist/mcp-server/src/utils/docString/generateDocString.d.ts +4 -0
  270. package/dist/mcp-server/src/utils/getAssertionError.d.ts +3 -0
  271. package/dist/mcp-server/src/utils/index.d.ts +14 -0
  272. package/dist/mcp-server/src/utils/maybePromise.d.ts +54 -0
  273. package/dist/mcp-server/src/utils/symbols.d.ts +3 -0
  274. package/dist/modules/grid.esm.js +1 -1
  275. package/dist/modules/grid.esm.js.map +1 -1
  276. package/dist/modules/grid.js +1 -1
  277. package/dist/modules/grid.js.map +1 -1
  278. package/dist/modules/reference/index.d.ts +136 -136
  279. package/dist/modules/src/AutoCompleter/AutoCompleter.d.ts +4 -2
  280. package/dist/modules/src/{Dvala/Cache.d.ts → Cache.d.ts} +1 -1
  281. package/dist/modules/src/builtin/specialExpressions/functions.d.ts +1 -1
  282. package/dist/modules/src/createDvala.d.ts +47 -0
  283. package/dist/modules/src/evaluator/ContextStack.d.ts +10 -2
  284. package/dist/modules/src/evaluator/effectTypes.d.ts +24 -6
  285. package/dist/modules/src/evaluator/suspension.d.ts +6 -0
  286. package/dist/modules/src/evaluator/trampoline.d.ts +15 -1
  287. package/dist/modules/src/index.d.ts +10 -5
  288. package/dist/modules/src/parser/subParsers/parseDo.d.ts +1 -1
  289. package/dist/modules/src/resume.d.ts +41 -0
  290. package/dist/modules/src/retrigger.d.ts +39 -0
  291. package/dist/modules/src/tokenizer/token.d.ts +2 -4
  292. package/dist/modules/src/tokenizer/tokenize.d.ts +1 -2
  293. package/dist/modules/src/tokenizer/tokenizers.d.ts +2 -3
  294. package/dist/modules/src/tooling.d.ts +51 -0
  295. package/dist/reference/index.d.ts +136 -136
  296. package/dist/src/AutoCompleter/AutoCompleter.d.ts +4 -2
  297. package/dist/src/Cache.d.ts +16 -0
  298. package/dist/src/builtin/specialExpressions/functions.d.ts +1 -1
  299. package/dist/src/createDvala.d.ts +47 -0
  300. package/dist/src/evaluator/ContextStack.d.ts +10 -2
  301. package/dist/src/evaluator/effectTypes.d.ts +24 -6
  302. package/dist/src/evaluator/suspension.d.ts +6 -0
  303. package/dist/src/evaluator/trampoline.d.ts +15 -1
  304. package/dist/src/index.d.ts +10 -5
  305. package/dist/src/parser/subParsers/parseDo.d.ts +1 -1
  306. package/dist/src/resume.d.ts +41 -0
  307. package/dist/src/retrigger.d.ts +39 -0
  308. package/dist/src/tokenizer/token.d.ts +2 -4
  309. package/dist/src/tokenizer/tokenize.d.ts +1 -2
  310. package/dist/src/tokenizer/tokenizers.d.ts +2 -3
  311. package/dist/src/tooling.d.ts +51 -0
  312. package/dist/testFramework.esm.js +1 -1
  313. package/dist/testFramework.esm.js.map +1 -1
  314. package/dist/testFramework.js +1 -1
  315. package/dist/testFramework.js.map +1 -1
  316. package/package.json +17 -6
  317. package/dist/cli/src/Dvala/Dvala.d.ts +0 -63
  318. package/dist/modules/src/Dvala/Dvala.d.ts +0 -63
  319. package/dist/modules/src/effects.d.ts +0 -110
  320. package/dist/src/Dvala/Dvala.d.ts +0 -63
  321. package/dist/src/effects.d.ts +0 -110
@@ -0,0 +1,54 @@
1
+ /**
2
+ * MaybePromise utilities for transparent async support.
3
+ *
4
+ * The sync path stays zero-overhead — when no async JS functions are involved,
5
+ * everything runs synchronously with only `instanceof Promise` checks as overhead.
6
+ * When an async value is detected, the evaluation chain switches to Promise-based
7
+ * execution for the remainder.
8
+ */
9
+ export type MaybePromise<T> = T | Promise<T>;
10
+ /**
11
+ * Chain a value that might be a Promise. If the value is sync, calls fn synchronously.
12
+ * If it's a Promise, chains with .then().
13
+ */
14
+ export declare function chain<T, U>(value: MaybePromise<T>, fn: (v: T) => MaybePromise<U>): MaybePromise<U>;
15
+ /**
16
+ * Like Array.map but handles MaybePromise callbacks sequentially.
17
+ * In the sync case, runs as a simple loop. Switches to async only when needed.
18
+ */
19
+ export declare function mapSequential<T, U>(arr: readonly T[], fn: (elem: T, index: number) => MaybePromise<U>): MaybePromise<U[]>;
20
+ /**
21
+ * Like Array.reduce but handles MaybePromise callbacks sequentially.
22
+ * In the sync case, runs as a simple loop. Switches to async only when needed.
23
+ */
24
+ export declare function reduceSequential<T, U>(arr: readonly T[], fn: (acc: U, elem: T, index: number) => MaybePromise<U>, initial: U): MaybePromise<U>;
25
+ /**
26
+ * Like Array.forEach but handles MaybePromise callbacks sequentially.
27
+ * In the sync case, runs as a simple loop. Switches to async only when needed.
28
+ */
29
+ export declare function forEachSequential<T>(arr: readonly T[], fn: (elem: T, index: number) => MaybePromise<void>): MaybePromise<void>;
30
+ /**
31
+ * Try/catch that handles MaybePromise values correctly.
32
+ * If tryFn returns a Promise, catches both sync throws and Promise rejections.
33
+ */
34
+ export declare function tryCatch<T>(tryFn: () => MaybePromise<T>, catchFn: (error: unknown) => MaybePromise<T>): MaybePromise<T>;
35
+ /**
36
+ * Like Array.some but handles MaybePromise callbacks sequentially.
37
+ * Returns the first truthy MaybePromise result, or false.
38
+ */
39
+ export declare function someSequential<T>(arr: readonly T[], fn: (elem: T, index: number) => MaybePromise<unknown>): MaybePromise<boolean>;
40
+ /**
41
+ * Like Array.every but handles MaybePromise callbacks sequentially.
42
+ * Returns false as soon as a falsy result is found.
43
+ */
44
+ export declare function everySequential<T>(arr: readonly T[], fn: (elem: T, index: number) => MaybePromise<unknown>): MaybePromise<boolean>;
45
+ /**
46
+ * Like Array.filter but handles MaybePromise callbacks sequentially.
47
+ * Returns the filtered array.
48
+ */
49
+ export declare function filterSequential<T>(arr: readonly T[], fn: (elem: T, index: number) => MaybePromise<unknown>): MaybePromise<T[]>;
50
+ /**
51
+ * Like Array.findIndex but handles MaybePromise callbacks sequentially.
52
+ * Returns -1 if no element matches.
53
+ */
54
+ export declare function findIndexSequential<T>(arr: readonly T[], fn: (elem: T, index: number) => MaybePromise<unknown>): MaybePromise<number>;
@@ -0,0 +1,3 @@
1
+ export declare const FUNCTION_SYMBOL = "^^fn^^";
2
+ export declare const REGEXP_SYMBOL = "^^re^^";
3
+ export declare const EFFECT_SYMBOL = "^^ef^^";
@@ -1,2 +1,2 @@
1
- function e(e){if(!e.position||!e.code)return"";const t=e.position.column-1,r=e.code.length-t-1;return`${" ".repeat(Math.max(t,0))}^${" ".repeat(Math.max(r,0))}`}class t extends Error{sourceCodeInfo;shortMessage;constructor(r,n){const i=r instanceof Error?r.message:`${r}`;super(function(t,r){if(!r)return t;const n=`${r.position.line}:${r.position.column}`;return`${t}${r.filePath?`\n${r.filePath}:${n}`:`\nLocation ${n}`}\n${r.code}\n${e(r)}`}(i,n)),this.shortMessage=i,this.sourceCodeInfo=n,Object.setPrototypeOf(this,t.prototype),this.name="DvalaError"}getCodeMarker(){return this.sourceCodeInfo&&e(this.sourceCodeInfo)}}const r={Number:1,String:2,NormalExpression:3,SpecialExpression:4,UserDefinedSymbol:5,NormalBuiltinSymbol:6,SpecialBuiltinSymbol:7,ReservedSymbol:8,Binding:9,Spread:10},n=new Set(Object.values(r));const i=new Set(["UserDefined","Partial","Comp","Constantly","Juxt","Complement","EveryPred","SomePred","Fnull","EffectMatcher","Builtin","SpecialBuiltin","Module"]);function o(e){return null!==e&&"object"==typeof e&&("^^fn^^"in e&&"functionType"in e&&("string"==typeof(t=e.functionType)&&i.has(t)));var t}function s(e){return!(!Array.isArray(e)||e.length<2)&&("number"==typeof(t=e[0])&&n.has(t));var t}function a(e){return o(e)?`<function ${e.name||"λ"}>`:s(e)?`${t=e[0],Object.keys(r).find(e=>r[e]===t)}-node`:null===e?"null":"object"==typeof e&&e instanceof RegExp?`${e}`:"object"==typeof e&&e instanceof Error?e.toString():JSON.stringify(e);var t}function l(e,t){return e?.sourceCodeInfo??t}function g(e,t={}){return"number"==typeof e&&(!Number.isNaN(e)&&(!(t.integer&&!Number.isInteger(e))&&(!(t.finite&&!Number.isFinite(e))&&((!t.zero||0===e)&&((!t.nonZero||0!==e)&&(!(t.positive&&e<=0)&&(!(t.negative&&e>=0)&&(!(t.nonPositive&&e>0)&&(!(t.nonNegative&&e<0)&&(!("number"==typeof t.gt&&e<=t.gt)&&(!("number"==typeof t.gte&&e<t.gte)&&(!("number"==typeof t.lt&&e>=t.lt)&&!("number"==typeof t.lte&&e>t.lte)))))))))))))}function d(e,r,n={}){if(!g(e,n))throw new t(`Expected ${function(e){if(e.zero)return"zero";const t=function(e){return e.positive?"positive":e.negative?"negative":e.nonNegative?"non negative":e.nonPositive?"non positive":e.nonZero?"non zero":""}(e),r=e.integer?"integer":"number",n=e.finite?"finite":"",i=function(e){return"number"!=typeof e.gt&&"number"!=typeof e.gte||"number"!=typeof e.lt&&"number"!=typeof e.lte?"number"==typeof e.gt||"number"==typeof e.gte?"number"==typeof e.gt?`n > ${e.gt}`:`n >= ${e.gte}`:"number"==typeof e.lt||"number"==typeof e.lte?"number"==typeof e.lt?`n < ${e.lt}`:`n <= ${e.lte}`:"":`${"number"==typeof e.gt?`${e.gt} < n `:`${e.gte} <= n `}${"number"==typeof e.lt?`< ${e.lt}`:`<= ${e.lte}`}`}(e);return[t,n,r,i].filter(e=>!!e).join(" ")}(n)}, got ${a(e)}.`,l(e,r))}const c=new WeakSet,p=new WeakSet,h=new WeakSet,u=new WeakSet,m=new WeakSet;function f(e,r){if(!function(e){return!(!Array.isArray(e)||!p.has(e)&&(h.has(e)||(e.every(e=>g(e))?(c.add(e),p.add(e),0):(h.add(e),1))))}(e))throw new t(`Expected a vector, but got ${e}`,r)}function y(e,r){if(!function(e){if(!Array.isArray(e))return!1;if(u.has(e))return!0;if(m.has(e))return!1;if(0===e.length)return m.add(e),!1;if(!Array.isArray(e[0]))return m.add(e),!1;const t=e[0].length;if(0===t)return m.add(e),!1;for(const r of e){if(!Array.isArray(r))return m.add(e),!1;if(r.length!==t)return m.add(e),!1}return c.add(e),u.add(e),!0}(e))throw new t(`Expected a grid, but got ${e}`,r)}function b(e,r,n){return new t(`Expected ${e}, got ${a(r)}.`,l(r,n))}function w(e,t){if(!Array.isArray(e))throw b("array",e,t)}function v(e){return{min:e,max:e}}const A={"cell-every?":{category:"grid",description:"Checks if all elements in a grid satisfy a predicate. Returns true only if the predicate returns true for every element in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { cell-every? } = import(grid);\ncell-every?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], string?)','let { cell-every? } = import(grid);\ncell-every?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], string?)',"let { cell-every? } = import(grid);\ncell-every?([\n [1, 2],\n [3, 4],\n], string?)"],seeAlso:["collection.every?","grid.some?","grid.every-row?","grid.every-col?"]},"some?":{category:"grid",description:"Checks if any element in a grid satisfies a predicate. Returns true if the predicate returns true for at least one element in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { some? } = import(grid);\nsome?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], string?)','let { some? } = import(grid);\nsome?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], string?)',"let { some? } = import(grid);\nsome?([\n [1, 2],\n [3, 4],\n], string?)"],seeAlso:["collection.any?","grid.cell-every?","grid.some-row?","grid.some-col?"]},"every-row?":{category:"grid",description:"Checks if all rows in a grid satisfy a predicate. Returns true only if the predicate returns true for every row in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { every-row? } = import(grid);\nevery-row?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> string?($[0]))','let { every-row? } = import(grid);\nevery-row?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> string?($[0]))',"let { every-row? } = import(grid);\nevery-row?([\n [1, 2],\n [3, 4],\n], -> string?($[0]))"],seeAlso:["grid.some-row?","grid.every-col?","grid.cell-every?"]},"some-row?":{category:"grid",description:"Checks if any row in a grid satisfies a predicate. Returns true if the predicate returns true for at least one row in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { some-row? } = import(grid);\nsome-row?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $ contains? "Albert")','let { some-row? } = import(grid);\nsome-row?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> $ contains? "Albert")','let { some-row? } = import(grid);\nsome-row?([\n [1, 2],\n [3, 4],\n], -> $ contains? "Albert")'],seeAlso:["grid.every-row?","grid.some-col?","grid.some?"]},"every-col?":{category:"grid",description:"Checks if all columns in a grid satisfy a predicate. Returns true only if the predicate returns true for every column in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { every-col? } = import(grid);\nevery-col?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> string?($[0]))','let { every-col? } = import(grid);\nevery-col?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> string?($[0]))',"let { every-col? } = import(grid);\nevery-col?([\n [1, 2],\n [3, 4],\n], -> string?($[0]))"],seeAlso:["grid.some-col?","grid.every-row?","grid.cell-every?"]},"some-col?":{category:"grid",description:"Checks if any column in a grid satisfies a predicate. Returns true if the predicate returns true for at least one column in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { some-col? } = import(grid);\nsome-col?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $ contains? "Albert")','let { some-col? } = import(grid);\nsome-col?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> $ contains? "Albert")','let { some-col? } = import(grid);\nsome-col?([\n [1, 2],\n [3, 4],\n], -> $ contains? "Albert")'],seeAlso:["grid.every-col?","grid.some-row?","grid.some?"]},row:{category:"grid",description:"Returns the row at index $a in the grid $b.",returns:{type:"any"},args:{a:{type:"grid"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:['let { row } = import(grid);\nrow([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 0)','let { row } = import(grid);\nrow([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)','let { row } = import(grid);\nrow([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 2)'],seeAlso:["grid.col","grid.shape"]},col:{category:"grid",description:"Returns the column at index $a in the grid $b.",returns:{type:"any"},args:{a:{type:"grid"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:['let { col } = import(grid);\ncol([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 0)','let { col } = import(grid);\ncol([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)','let { col } = import(grid);\ncol([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 2)'],seeAlso:["grid.row","grid.shape"]},shape:{category:"grid",description:"Returns the shape of the grid `g` as a `vector` of two numbers, where the first number is the number of rows and the second number is the number of columns.",returns:{type:"vector"},args:{g:{type:"grid",description:"The grid to get the shape of."}},variants:[{argumentNames:["g"]}],examples:['let { shape } = import(grid);\nshape([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { shape } = import(grid);\nshape([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { shape } = import(grid);\nshape([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.row","grid.col","grid.reshape"]},fill:{category:"grid",description:"Creates a grid of the specified size, filled with the specified value.",returns:{type:"grid"},args:{rows:{type:"integer",description:"The number of rows in the grid."},cols:{type:"integer",description:"The number of columns in the grid."},value:{type:"any",description:"The value to fill the grid with."}},variants:[{argumentNames:["rows","cols","value"]}],examples:["let { fill } = import(grid);\nfill(2, 3, 0)",'let { fill } = import(grid);\nfill(2, 3, "x")'],seeAlso:["grid.generate","grid.from-array"]},generate:{category:"grid",description:"Generates a grid of the specified size, where each element is generated by the provided function.",returns:{type:"grid"},args:{rows:{type:"number",description:"The number of rows in the grid."},cols:{type:"number",description:"The number of columns in the grid."},generator:{type:"function",description:"The function to generate the grid. It takes two arguments: the row index and the column index."}},variants:[{argumentNames:["rows","cols","generator"]}],examples:["let { generate } = import(grid);\ngenerate(3, 3, (i, j) -> i + j)"],seeAlso:["grid.fill","grid.from-array"]},reshape:{category:"grid",description:"Reshapes the grid `a` into a new grid with the specified number of rows `b`. The number of columns is automatically calculated based on the total number of elements in the grid.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:['let { reshape } = import(grid);\nreshape([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], 2)'],seeAlso:["grid.shape","grid.from-array"]},transpose:{category:"grid",description:"Transposes the grid `g`, swapping its rows and columns.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to transpose."}},variants:[{argumentNames:["g"]}],examples:['let { transpose } = import(grid);\ntranspose([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { transpose } = import(grid);\ntranspose([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { transpose } = import(grid);\ntranspose([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.flip-h","grid.flip-v","grid.rotate"]},"flip-h":{category:"grid",description:"Flips the grid `g` horizontally.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to flip horizontally."}},variants:[{argumentNames:["g"]}],examples:['let { flip-h } = import(grid);\nflip-h([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { flip-h } = import(grid);\nflip-h([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { flip-h } = import(grid);\nflip-h([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.flip-v","grid.transpose","grid.rotate"]},"flip-v":{category:"grid",description:"Flips the grid `g` vertically.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to flip vertically."}},variants:[{argumentNames:["g"]}],examples:['let { flip-v } = import(grid);\nflip-v([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { flip-v } = import(grid);\nflip-v([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { flip-v } = import(grid);\nflip-v([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.flip-h","grid.transpose","grid.rotate"]},rotate:{category:"grid",description:"Rotates the grid `g` by the specified angle. The angle is given in terms of 90-degree rotations. Positive values rotate the grid clockwise, while negative values rotate it counterclockwise.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 1)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 2)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 3)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 4)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], -1)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], -2)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], -3)"],seeAlso:["grid.transpose","grid.flip-h","grid.flip-v"]},crop:{category:"grid",description:"Crops the grid `g` from the starting index `begin` to the optional ending index `stop`. The crop is inclusive of the starting index and exclusive of the ending index.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to slice."},begin:{type:"vector",description:"The starting index of the slice as a vector of two numbers: `[row, col]`."},stop:{type:"vector",description:"Optional ending index of the slice as a vector of two numbers: `[row, col]`."}},variants:[{argumentNames:["g","begin"]},{argumentNames:["g","begin","stop"]}],examples:['let { crop } = import(grid);\ncrop([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [1, 1], [2, 2])','let { crop } = import(grid);\ncrop([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [1, 1])'],hideOperatorForm:!0,seeAlso:["grid.slice-rows","grid.slice-cols"]},"slice-rows":{category:"grid",description:"Slices rows of the grid `g` from the starting index `begin` to the optional ending index `stop`. The slice is inclusive of the starting index and exclusive of the ending index.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to slice."},begin:{type:"number",description:"The starting index of the slice."},stop:{type:"number",description:"Optional ending index of the slice."}},variants:[{argumentNames:["g","begin"]},{argumentNames:["g","begin","stop"]}],examples:['let { slice-rows } = import(grid);\nslice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { slice-rows } = import(grid);\nslice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)'],hideOperatorForm:!0,seeAlso:["grid.crop","grid.slice-cols","grid.splice-rows"]},"slice-cols":{category:"grid",description:"Slices columns of the grid `g` from the starting index `begin` to the optional ending index `stop`. The slice is inclusive of the starting index and exclusive of the ending index.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to slice."},begin:{type:"number",description:"The starting index of the slice."},stop:{type:"number",description:"Optional ending index of the slice."}},variants:[{argumentNames:["g","begin"]},{argumentNames:["g","begin","stop"]}],examples:['let { slice-cols } = import(grid);\nslice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { slice-cols } = import(grid);\nslice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)'],hideOperatorForm:!0,seeAlso:["grid.crop","grid.slice-rows","grid.splice-cols"]},"splice-rows":{category:"grid",description:"Splices rows of the grid `g` starting from the index `begin`. Deletes `deleteCount` rows and inserts the specified `items` at that position.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to splice."},begin:{type:"number",description:"The starting index of the splice."},deleteCount:{type:"number",description:"The number of rows to delete."},items:{type:"array",rest:!0,description:"The rows to insert."}},variants:[{argumentNames:["g","begin","deleteCount"]},{argumentNames:["g","begin","deleteCount","items"]}],examples:['let { splice-rows } = import(grid);\nsplice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { splice-rows } = import(grid);\nsplice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 1, ["Nazanin", "mother", 40])'],hideOperatorForm:!0,seeAlso:["grid.splice-cols","grid.slice-rows"]},"splice-cols":{category:"grid",description:"Splices columns of the grid `g` starting from the index `begin`. Deletes `deleteCount` columns and inserts the specified `items` at that position.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to splice."},begin:{type:"number",description:"The starting index of the splice."},deleteCount:{type:"number",description:"The number of columns to delete."},items:{type:"array",rest:!0,description:"The columns to insert."}},variants:[{argumentNames:["g","begin","deleteCount"]},{argumentNames:["g","begin","deleteCount","items"]}],examples:['let { splice-cols } = import(grid);\nsplice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { splice-cols } = import(grid);\nsplice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 1, ["f", "m", "s"])'],hideOperatorForm:!0,seeAlso:["grid.splice-rows","grid.slice-cols"]},"concat-rows":{category:"grid",description:"Concatenates two grids `a` and `b` by rows. The number of columns in both grids must be the same.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"grid"}},variants:[{argumentNames:["a","b"]}],examples:['let { concat-rows } = import(grid);\nconcat-rows([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], [\n [1, 2],\n [3, 4],\n])'],seeAlso:["grid.concat-cols","grid.push-rows"]},"concat-cols":{category:"grid",description:"Concatenates two grids `a` and `b` by columns. The number of rows in both grids must be the same.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"grid"}},variants:[{argumentNames:["a","b"]}],examples:['let { concat-cols } = import(grid);\nconcat-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])'],seeAlso:["grid.concat-rows","grid.push-cols"]},"cell-map":{category:"grid",description:"Maps a function `a` over each element of the grid `b`, returning a new grid with the results.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { cell-map } = import(grid);\ncell-map([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], str)'],seeAlso:["map","grid.cell-mapi","grid.cell-reduce"]},"cell-mapi":{category:"grid",description:"Maps a function `a` over each element of the grid `b`, passing the row and column index as additional arguments to the function.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { cell-mapi } = import(grid);\ncell-mapi([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $1 ++ "(" ++ $2 ++ ", " ++ $3 ++ ")")'],seeAlso:["grid.cell-map","grid.cell-reducei","map"]},"cell-reduce":{category:"grid",description:"Reduces the grid `a` using the function `b`, returning a single value.",returns:{type:"any"},args:{g:{type:"grid",description:"The grid to reduce."},f:{type:"function",description:"The function to reduce the grid. It takes two arguments: the accumulator and the current element."},"initial-value":{type:"any",description:"The initial value for the accumulator."}},variants:[{argumentNames:["g","f","initial-value"]}],examples:['// Using "as" alias because "reduce" shadows a builtin function\nlet { cell-reduce } = import(grid);\ncell-reduce([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ++, "")'],seeAlso:["reduce","grid.cell-reducei","grid.cell-map"]},"cell-reducei":{category:"grid",description:"Reduces the grid `a` using the function `b`, passing the row and column indices as additional arguments to the function.",returns:{type:"any"},args:{g:{type:"grid",description:"The grid to reduce."},f:{type:"function",description:"The function to reduce the grid. It takes four arguments: the accumulator, the current element, the row index, and the column index."},"initial-value":{type:"any",description:"The initial value for the accumulator."}},variants:[{argumentNames:["g","f","initial-value"]}],examples:['// Using "as" alias because "reducei" shadows a builtin function\nlet { cell-reducei } = import(grid);\ncell-reducei([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ++, "")'],seeAlso:["grid.cell-reduce","grid.cell-mapi","reduce"]},"push-rows":{category:"grid",description:"Pushes the specified rows into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to push rows into."},rows:{type:"array",rest:!0,description:"The rows to push into the grid."}},variants:[{argumentNames:["g","rows"]}],examples:['let { push-rows } = import(grid);\npush-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["Nazanin", "mother", 40])'],hideOperatorForm:!0,seeAlso:["grid.unshift-rows","grid.pop-row","grid.shift-row","grid.concat-rows"]},"unshift-rows":{category:"grid",description:"Unshifts the specified rows into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to unshift rows into."},rows:{type:"array",rest:!0,description:"The rows to unshift into the grid."}},variants:[{argumentNames:["g","rows"]}],examples:['let { unshift-rows } = import(grid);\nunshift-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["Nazanin", "mother", 40])'],hideOperatorForm:!0,seeAlso:["grid.push-rows","grid.shift-row","grid.pop-row"]},"pop-row":{category:"grid",description:"Pops the last row from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to pop a row from."}},variants:[{argumentNames:["g"]}],examples:['let { pop-row } = import(grid);\npop-row([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.shift-row","grid.push-rows","grid.unshift-rows"]},"shift-row":{category:"grid",description:"Shifts the first row from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to shift a row from."}},variants:[{argumentNames:["g"]}],examples:['let { shift-row } = import(grid);\nshift-row([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.pop-row","grid.push-rows","grid.unshift-rows"]},"push-cols":{category:"grid",description:"Pushes the specified columns into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to push columns into."},cols:{type:"array",rest:!0,description:"The columns to push into the grid."}},variants:[{argumentNames:["g","cols"]}],examples:['let { push-cols } = import(grid);\npush-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["f", "m", "s"])'],hideOperatorForm:!0,seeAlso:["grid.unshift-cols","grid.pop-col","grid.shift-col","grid.concat-cols"]},"unshift-cols":{category:"grid",description:"Unshifts the specified columns into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to unshift columns into."},cols:{type:"array",rest:!0,description:"The columns to unshift into the grid."}},variants:[{argumentNames:["g","cols"]}],examples:['let { unshift-cols } = import(grid);\nunshift-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["f", "m", "s"])'],hideOperatorForm:!0,seeAlso:["grid.push-cols","grid.shift-col","grid.pop-col"]},"pop-col":{category:"grid",description:"Pops the last column from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to pop a column from."}},variants:[{argumentNames:["g"]}],examples:['let { pop-col } = import(grid);\npop-col([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.shift-col","grid.push-cols","grid.unshift-cols"]},"shift-col":{category:"grid",description:"Shifts the first column from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to shift a column from."}},variants:[{argumentNames:["g"]}],examples:['let { shift-col } = import(grid);\nshift-col([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.pop-col","grid.push-cols","grid.unshift-cols"]},"from-array":{category:"grid",description:"Creates a grid from a flat array with specified dimensions. The array is reshaped into the specified number of rows, and the number of columns is automatically calculated based on the total number of elements in the array.",returns:{type:"grid"},args:{a:{type:"array"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:["let { from-array } = import(grid);\nfrom-array([1, 2, 3, 4], 2)","let { from-array } = import(grid);\nfrom-array([1, 2, 3, 4], 4)"],seeAlso:["grid.fill","grid.generate","grid.reshape"]}};function N(e){const t=[];for(let r=0;r<e[0].length;r+=1){const n=[];for(let t=0;t<e.length;t+=1)n.push(e[t][r]);t.push(n)}return t}const x={"cell-every?":{evaluate:()=>{throw new Error("cell-every?: Dvala implementation should be used instead")},arity:v(2)},"some?":{evaluate:()=>{throw new Error("some?: Dvala implementation should be used instead")},arity:v(2)},"every-row?":{evaluate:()=>{throw new Error("every-row?: Dvala implementation should be used instead")},arity:v(2)},"some-row?":{evaluate:()=>{throw new Error("some-row?: Dvala implementation should be used instead")},arity:v(2)},"every-col?":{evaluate:()=>{throw new Error("every-col?: Dvala implementation should be used instead")},arity:v(2)},"some-col?":{evaluate:()=>{throw new Error("some-col?: Dvala implementation should be used instead")},arity:v(2)},row:{evaluate:([e,t],r)=>(y(e,r),d(t,r,{integer:!0,nonNegative:!0,lt:e.length}),e[t]),arity:v(2)},col:{evaluate:([e,t],r)=>(y(e,r),d(t,r,{integer:!0,nonNegative:!0,lt:e[0].length}),e.map(e=>e[t])),arity:v(2)},shape:{evaluate:([e],t)=>(y(e,t),[e.length,e[0].length]),arity:v(1)},fill:{evaluate:([e,t,r],n)=>{d(e,n,{integer:!0,positive:!0}),d(t,n,{integer:!0,positive:!0}),function(e,t){if(!function(e){return void 0!==e}(e))throw b("not undefined",e,t)}(r,n);const i=[];for(let n=0;n<e;n+=1){const e=[];for(let n=0;n<t;n+=1)e.push(r);i.push(e)}return i},arity:v(3)},generate:{evaluate:()=>{throw new Error("generate: Dvala implementation should be used instead")},arity:v(3)},reshape:{evaluate:([e,r],n)=>{y(e,n),d(r,n,{integer:!0,positive:!0});const i=e.flat();if(i.length%r!==0)throw new t(`The number of elements in the grid must be divisible by rows, but got ${i.length} and ${r}`,n);const o=i.length/r,s=[];for(let e=0;e<r;e+=1){const t=[];for(let r=0;r<o;r+=1)t.push(i[e*o+r]);s.push(t)}return s},arity:v(2)},transpose:{evaluate:([e],t)=>(y(e,t),N(e)),arity:v(1)},"flip-h":{evaluate:([e],t)=>(y(e,t),e.map(e=>e.reverse())),arity:v(1)},"flip-v":{evaluate:([e],t)=>(y(e,t),e.reverse()),arity:v(1)},rotate:{evaluate:([e,t],r)=>{if(y(e,r),d(t,r,{integer:!0}),0===(t=(t%4+4)%4)||0===e.length)return e.map(e=>[...e]);const n=e.length,i=e[0].length;let o;switch(t){case 1:o=Array(i).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<i;r++)o[r][n-1-t]=e[t][r];break;case 2:o=Array(n).fill(null).map(()=>Array(i).fill(null));for(let t=0;t<n;t++)for(let r=0;r<i;r++)o[n-1-t][i-1-r]=e[t][r];break;case 3:o=Array(i).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<i;r++)o[i-1-r][t]=e[t][r]}return o},arity:v(2)},crop:{evaluate:([e,r,n],i)=>{if(y(e,i),f(r,i),2!==r.length)throw new t(`The start vector must have 2 elements, but got ${r.length}`,i);const[o,s]=r;if(d(o,i,{integer:!0,nonNegative:!0,lt:e.length}),d(s,i,{integer:!0,nonNegative:!0,lt:e[0].length}),n??=[e.length,e[0].length],f(n,i),2!==n.length)throw new t(`The end vector must have 2 elements, but got ${n.length}`,i);const[a,l]=n;d(a,i,{gt:o,lte:e.length}),d(l,i,{gt:s,lte:e[0].length});const g=[];for(let t=o;t<a;t+=1){const r=[];for(let n=s;n<l;n+=1)r.push(e[t][n]);g.push(r)}return g},arity:{min:2,max:3}},"slice-rows":{evaluate:([e,t,r],n)=>(y(e,n),void 0===r?(d(t,n,{integer:!0,lte:e.length,gte:-e.length}),t<0?e.slice(e.length+t):e.slice(t)):(d(t,n,{integer:!0,nonNegative:!0,lte:e.length}),d(r,n,{integer:!0}),d(r=r<0?e.length+r:r,n,{gt:t,lte:e.length}),e.slice(t,r))),arity:{min:2,max:3}},"slice-cols":{evaluate:([e,t,r],n)=>{y(e,n);const i=N(e);return void 0===r?(d(t,n,{integer:!0,lte:i.length,gte:-i.length}),N(t<0?i.slice(i.length+t):i.slice(t))):(d(t,n,{integer:!0,nonNegative:!0,lte:i.length}),d(r,n,{integer:!0}),d(r=r<0?i.length+r:r,n,{gt:t,lte:i.length}),N(i.slice(t,r)))},arity:{min:2,max:3}},"splice-rows":{evaluate:([e,r,n,...i],o)=>{y(e,o),d(r,o,{integer:!0,nonNegative:!0,lte:e.length}),d(n,o,{integer:!0,nonNegative:!0}),0!==i.length&&(y(i,o),i.every(r=>{if(w(r,o),e[0].length!==r.length)throw new t(`All rows must have the same length as the number of columns in grid, but got ${r.length}`,o);return!0}));const s=[];for(let t=0;t<r;t+=1)s.push(e[t]);i.length>0&&s.push(...i);for(let t=r+n;t<e.length;t+=1)s.push(e[t]);return s},arity:{min:3}},"splice-cols":{evaluate:([e,r,n,...i],o)=>{y(e,o);const s=N(e);d(r,o,{integer:!0,nonNegative:!0,lte:s.length}),d(n,o,{integer:!0,nonNegative:!0}),0!==i.length&&(y(i,o),i.every(e=>{if(w(e,o),s[0].length!==e.length)throw new t(`All rows must have the same length as the number of rows in grid, but got ${e.length}`,o);return!0}));const a=[];for(let e=0;e<r;e+=1)a.push(s[e]);a.push(...i);for(let e=r+n;e<s.length;e+=1)a.push(s[e]);return N(a)},arity:{min:3}},"concat-rows":{evaluate:(e,r)=>{w(e,r),e.every(e=>y(e,r));const n=e[0][0].length;e.slice(1).every(e=>{if(e[0].length!==n)throw new t(`All grids must have the same number of columns, but got ${n} and ${e[0].length}`,r);return!0});const i=[];return e.forEach(e=>{e.forEach(e=>{i.push(e)})}),i},arity:{min:1}},"concat-cols":{evaluate:(e,r)=>{w(e,r),e.every(e=>y(e,r));const n=e[0].length;e.slice(1).every(e=>{if(e.length!==n)throw new t(`All grids must have the same number of rows, but got ${n} and ${e.length}`,r);return!0});const i=[];for(let t=0;t<n;t+=1){const r=[];e.forEach(e=>{r.push(...e[t])}),i.push(r)}return i},arity:{min:1}},"cell-map":{evaluate:()=>{throw new Error("cell-map: Dvala implementation should be used instead")},arity:{min:2}},"cell-mapi":{evaluate:()=>{throw new Error("cell-mapi: Dvala implementation should be used instead")},arity:v(2)},"cell-reduce":{evaluate:()=>{throw new Error("cell-reduce: Dvala implementation should be used instead")},arity:v(3)},"cell-reducei":{evaluate:()=>{throw new Error("cell-reducei: Dvala implementation should be used instead")},arity:v(3)},"push-rows":{evaluate:([e,...r],n)=>{if(y(e,n),y(r,n),e[0].length!==r[0].length)throw new t(`All rows must have the same length as the number of columns in grid, but got ${e[0].length} and ${r[0].length}`,n);return[...e,...r]},arity:{min:2}},"unshift-rows":{evaluate:([e,...r],n)=>{if(y(e,n),y(r,n),e[0].length!==r[0].length)throw new t(`All rows must have the same length as the number of columns in grid, but got ${e[0].length} and ${r[0].length}`,n);return[...r,...e]},arity:{min:2}},"pop-row":{evaluate:([e],t)=>(y(e,t),1===e.length?null:e.slice(0,-1)),arity:v(1)},"shift-row":{evaluate:([e],t)=>(y(e,t),1===e.length?null:e.slice(1)),arity:v(1)},"push-cols":{evaluate:([e,...r],n)=>{if(y(e,n),y(r,n),e.length!==r[0].length)throw new t(`All columns must have the same length as the number of rows in grid, but got ${r.length}`,n);const i=[];for(let t=0;t<e.length;t+=1){const n=[];n.push(...e[t]),r.forEach(e=>{n.push(e[t])}),i.push(n)}return i},arity:{min:2}},"unshift-cols":{evaluate:([e,...r],n)=>{if(y(e,n),y(r,n),e.length!==r[0].length)throw new t(`All columns must have the same length as the number of rows in grid, but got ${r.length}`,n);const i=[];for(let t=0;t<e.length;t+=1){const n=[];r.forEach(e=>{n.push(e[t])}),n.push(...e[t]),i.push(n)}return i},arity:{min:2}},"pop-col":{evaluate:([e],t)=>(y(e,t),1===e[0].length?null:e.map(e=>e.slice(0,-1))),arity:v(1)},"shift-col":{evaluate:([e],t)=>(y(e,t),1===e[0].length?null:e.map(e=>e.slice(1))),arity:v(1)},"from-array":{evaluate:([e,r],n)=>{if(w(e,n),d(r,n,{integer:!0,positive:!0}),e.length%r!==0)throw new t(`The number of elements in the array must be divisible by rows, but got ${e.length} and ${r}`,n);return function(e,t){const r=[],n=e.length/t;for(let i=0;i<t;i++){const t=i*n,o=t+n;r.push(e.slice(t,o))}return r}(e,r)},arity:v(2)}};for(const[e,t]of Object.entries(A))x[e]&&(x[e].docs=t);const $={name:"grid",functions:x,source:'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\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\n',docs:A};export{$ as gridModule};
1
+ function e(e){if(!e.position||!e.code)return"";const t=e.position.column-1,r=e.code.length-t-1;return`${" ".repeat(Math.max(t,0))}^${" ".repeat(Math.max(r,0))}`}class t extends Error{sourceCodeInfo;shortMessage;constructor(r,n){const i=r instanceof Error?r.message:`${r}`;super(function(t,r){if(!r)return t;const n=`${r.position.line}:${r.position.column}`;return`${t}${r.filePath?`\n${r.filePath}:${n}`:`\nLocation ${n}`}\n${r.code}\n${e(r)}`}(i,n)),this.shortMessage=i,this.sourceCodeInfo=n,Object.setPrototypeOf(this,t.prototype),this.name="DvalaError"}getCodeMarker(){return this.sourceCodeInfo&&e(this.sourceCodeInfo)}}const r={Number:1,String:2,NormalExpression:3,SpecialExpression:4,UserDefinedSymbol:5,NormalBuiltinSymbol:6,SpecialBuiltinSymbol:7,ReservedSymbol:8,Binding:9,Spread:10},n=new Set(Object.values(r));const i=new Set(["UserDefined","Partial","Comp","Constantly","Juxt","Complement","EveryPred","SomePred","Fnull","EffectMatcher","Builtin","SpecialBuiltin","Module"]);function o(e){return null!==e&&"object"==typeof e&&("^^fn^^"in e&&"functionType"in e&&("string"==typeof(t=e.functionType)&&i.has(t)));var t}function s(e){return!(!Array.isArray(e)||e.length<2)&&("number"==typeof(t=e[0])&&n.has(t));var t}function a(e){return o(e)?`<function ${e.name||"λ"}>`:s(e)?`${t=e[0],Object.keys(r).find(e=>r[e]===t)}-node`:null===e?"null":"object"==typeof e&&e instanceof RegExp?`${e}`:"object"==typeof e&&e instanceof Error?e.toString():JSON.stringify(e);var t}function l(e,t){return e?.sourceCodeInfo??t}function g(e,t={}){return"number"==typeof e&&(!Number.isNaN(e)&&(!(t.integer&&!Number.isInteger(e))&&(!(t.finite&&!Number.isFinite(e))&&((!t.zero||0===e)&&((!t.nonZero||0!==e)&&(!(t.positive&&e<=0)&&(!(t.negative&&e>=0)&&(!(t.nonPositive&&e>0)&&(!(t.nonNegative&&e<0)&&(!("number"==typeof t.gt&&e<=t.gt)&&(!("number"==typeof t.gte&&e<t.gte)&&(!("number"==typeof t.lt&&e>=t.lt)&&!("number"==typeof t.lte&&e>t.lte)))))))))))))}function d(e,r,n={}){if(!g(e,n))throw new t(`Expected ${function(e){if(e.zero)return"zero";const t=function(e){return e.positive?"positive":e.negative?"negative":e.nonNegative?"non negative":e.nonPositive?"non positive":e.nonZero?"non zero":""}(e),r=e.integer?"integer":"number",n=e.finite?"finite":"",i=function(e){return"number"!=typeof e.gt&&"number"!=typeof e.gte||"number"!=typeof e.lt&&"number"!=typeof e.lte?"number"==typeof e.gt||"number"==typeof e.gte?"number"==typeof e.gt?`n > ${e.gt}`:`n >= ${e.gte}`:"number"==typeof e.lt||"number"==typeof e.lte?"number"==typeof e.lt?`n < ${e.lt}`:`n <= ${e.lte}`:"":`${"number"==typeof e.gt?`${e.gt} < n `:`${e.gte} <= n `}${"number"==typeof e.lt?`< ${e.lt}`:`<= ${e.lte}`}`}(e);return[t,n,r,i].filter(e=>!!e).join(" ")}(n)}, got ${a(e)}.`,l(e,r))}const c=new WeakSet,p=new WeakSet,h=new WeakSet,u=new WeakSet,m=new WeakSet;function f(e,r){if(!function(e){return!(!Array.isArray(e)||!p.has(e)&&(h.has(e)||(e.every(e=>g(e))?(c.add(e),p.add(e),0):(h.add(e),1))))}(e))throw new t(`Expected a vector, but got ${e}`,r)}function y(e,r){if(!function(e){if(!Array.isArray(e))return!1;if(u.has(e))return!0;if(m.has(e))return!1;if(0===e.length)return m.add(e),!1;if(!Array.isArray(e[0]))return m.add(e),!1;const t=e[0].length;if(0===t)return m.add(e),!1;for(const r of e){if(!Array.isArray(r))return m.add(e),!1;if(r.length!==t)return m.add(e),!1}return c.add(e),u.add(e),!0}(e))throw new t(`Expected a grid, but got ${e}`,r)}function b(e,r,n){return new t(`Expected ${e}, got ${a(r)}.`,l(r,n))}function w(e,t){if(!Array.isArray(e))throw b("array",e,t)}function v(e){return{min:e,max:e}}const A={"cell-every?":{category:"grid",description:"Checks if all elements in a grid satisfy a predicate. Returns true only if the predicate returns true for every element in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { cell-every? } = import(grid);\ncell-every?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], string?)','let { cell-every? } = import(grid);\ncell-every?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], string?)',"let { cell-every? } = import(grid);\ncell-every?([\n [1, 2],\n [3, 4],\n], string?)"],seeAlso:["collection.every?","grid.some?","grid.every-row?","grid.every-col?"]},"some?":{category:"grid",description:"Checks if any element in a grid satisfies a predicate. Returns true if the predicate returns true for at least one element in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { some? } = import(grid);\nsome?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], string?)','let { some? } = import(grid);\nsome?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], string?)',"let { some? } = import(grid);\nsome?([\n [1, 2],\n [3, 4],\n], string?)"],seeAlso:["collection.any?","grid.cell-every?","grid.some-row?","grid.some-col?"]},"every-row?":{category:"grid",description:"Checks if all rows in a grid satisfy a predicate. Returns true only if the predicate returns true for every row in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { every-row? } = import(grid);\nevery-row?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> string?($[0]))','let { every-row? } = import(grid);\nevery-row?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> string?($[0]))',"let { every-row? } = import(grid);\nevery-row?([\n [1, 2],\n [3, 4],\n], -> string?($[0]))"],seeAlso:["grid.some-row?","grid.every-col?","grid.cell-every?"]},"some-row?":{category:"grid",description:"Checks if any row in a grid satisfies a predicate. Returns true if the predicate returns true for at least one row in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { some-row? } = import(grid);\nsome-row?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $ contains? "Albert")','let { some-row? } = import(grid);\nsome-row?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> $ contains? "Albert")','let { some-row? } = import(grid);\nsome-row?([\n [1, 2],\n [3, 4],\n], -> $ contains? "Albert")'],seeAlso:["grid.every-row?","grid.some-col?","grid.some?"]},"every-col?":{category:"grid",description:"Checks if all columns in a grid satisfy a predicate. Returns true only if the predicate returns true for every column in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { every-col? } = import(grid);\nevery-col?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> string?($[0]))','let { every-col? } = import(grid);\nevery-col?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> string?($[0]))',"let { every-col? } = import(grid);\nevery-col?([\n [1, 2],\n [3, 4],\n], -> string?($[0]))"],seeAlso:["grid.some-col?","grid.every-row?","grid.cell-every?"]},"some-col?":{category:"grid",description:"Checks if any column in a grid satisfies a predicate. Returns true if the predicate returns true for at least one column in the grid.",returns:{type:"boolean"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { some-col? } = import(grid);\nsome-col?([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $ contains? "Albert")','let { some-col? } = import(grid);\nsome-col?([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], -> $ contains? "Albert")','let { some-col? } = import(grid);\nsome-col?([\n [1, 2],\n [3, 4],\n], -> $ contains? "Albert")'],seeAlso:["grid.every-col?","grid.some-row?","grid.some?"]},row:{category:"grid",description:"Returns the row at index $a in the grid $b.",returns:{type:"any"},args:{a:{type:"grid"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:['let { row } = import(grid);\nrow([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 0)','let { row } = import(grid);\nrow([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)','let { row } = import(grid);\nrow([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 2)'],seeAlso:["grid.col","grid.shape"]},col:{category:"grid",description:"Returns the column at index $a in the grid $b.",returns:{type:"any"},args:{a:{type:"grid"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:['let { col } = import(grid);\ncol([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 0)','let { col } = import(grid);\ncol([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)','let { col } = import(grid);\ncol([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 2)'],seeAlso:["grid.row","grid.shape"]},shape:{category:"grid",description:"Returns the shape of the grid `g` as a `vector` of two numbers, where the first number is the number of rows and the second number is the number of columns.",returns:{type:"vector"},args:{g:{type:"grid",description:"The grid to get the shape of."}},variants:[{argumentNames:["g"]}],examples:['let { shape } = import(grid);\nshape([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { shape } = import(grid);\nshape([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { shape } = import(grid);\nshape([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.row","grid.col","grid.reshape"]},fill:{category:"grid",description:"Creates a grid of the specified size, filled with the specified value.",returns:{type:"grid"},args:{rows:{type:"integer",description:"The number of rows in the grid."},cols:{type:"integer",description:"The number of columns in the grid."},value:{type:"any",description:"The value to fill the grid with."}},variants:[{argumentNames:["rows","cols","value"]}],examples:["let { fill } = import(grid);\nfill(2, 3, 0)",'let { fill } = import(grid);\nfill(2, 3, "x")'],seeAlso:["grid.generate","grid.from-array"]},generate:{category:"grid",description:"Generates a grid of the specified size, where each element is generated by the provided function.",returns:{type:"grid"},args:{rows:{type:"number",description:"The number of rows in the grid."},cols:{type:"number",description:"The number of columns in the grid."},generator:{type:"function",description:"The function to generate the grid. It takes two arguments: the row index and the column index."}},variants:[{argumentNames:["rows","cols","generator"]}],examples:["let { generate } = import(grid);\ngenerate(3, 3, (i, j) -> i + j)"],seeAlso:["grid.fill","grid.from-array"]},reshape:{category:"grid",description:"Reshapes the grid `a` into a new grid with the specified number of rows `b`. The number of columns is automatically calculated based on the total number of elements in the grid.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:['let { reshape } = import(grid);\nreshape([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], 2)'],seeAlso:["grid.shape","grid.from-array"]},transpose:{category:"grid",description:"Transposes the grid `g`, swapping its rows and columns.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to transpose."}},variants:[{argumentNames:["g"]}],examples:['let { transpose } = import(grid);\ntranspose([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { transpose } = import(grid);\ntranspose([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { transpose } = import(grid);\ntranspose([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.flip-h","grid.flip-v","grid.rotate"]},"flip-h":{category:"grid",description:"Flips the grid `g` horizontally.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to flip horizontally."}},variants:[{argumentNames:["g"]}],examples:['let { flip-h } = import(grid);\nflip-h([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { flip-h } = import(grid);\nflip-h([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { flip-h } = import(grid);\nflip-h([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.flip-v","grid.transpose","grid.rotate"]},"flip-v":{category:"grid",description:"Flips the grid `g` vertically.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to flip vertically."}},variants:[{argumentNames:["g"]}],examples:['let { flip-v } = import(grid);\nflip-v([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])','let { flip-v } = import(grid);\nflip-v([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])',"let { flip-v } = import(grid);\nflip-v([\n [1, 2],\n [3, 4],\n])"],seeAlso:["grid.flip-h","grid.transpose","grid.rotate"]},rotate:{category:"grid",description:"Rotates the grid `g` by the specified angle. The angle is given in terms of 90-degree rotations. Positive values rotate the grid clockwise, while negative values rotate it counterclockwise.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 1)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 2)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 3)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], 4)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], -1)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], -2)","let { rotate } = import(grid);\nrotate([\n [1, 2],\n [3, 4],\n], -3)"],seeAlso:["grid.transpose","grid.flip-h","grid.flip-v"]},crop:{category:"grid",description:"Crops the grid `g` from the starting index `begin` to the optional ending index `stop`. The crop is inclusive of the starting index and exclusive of the ending index.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to slice."},begin:{type:"vector",description:"The starting index of the slice as a vector of two numbers: `[row, col]`."},stop:{type:"vector",description:"Optional ending index of the slice as a vector of two numbers: `[row, col]`."}},variants:[{argumentNames:["g","begin"]},{argumentNames:["g","begin","stop"]}],examples:['let { crop } = import(grid);\ncrop([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [1, 1], [2, 2])','let { crop } = import(grid);\ncrop([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [1, 1])'],hideOperatorForm:!0,seeAlso:["grid.slice-rows","grid.slice-cols"]},"slice-rows":{category:"grid",description:"Slices rows of the grid `g` from the starting index `begin` to the optional ending index `stop`. The slice is inclusive of the starting index and exclusive of the ending index.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to slice."},begin:{type:"number",description:"The starting index of the slice."},stop:{type:"number",description:"Optional ending index of the slice."}},variants:[{argumentNames:["g","begin"]},{argumentNames:["g","begin","stop"]}],examples:['let { slice-rows } = import(grid);\nslice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { slice-rows } = import(grid);\nslice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)'],hideOperatorForm:!0,seeAlso:["grid.crop","grid.slice-cols","grid.splice-rows"]},"slice-cols":{category:"grid",description:"Slices columns of the grid `g` from the starting index `begin` to the optional ending index `stop`. The slice is inclusive of the starting index and exclusive of the ending index.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to slice."},begin:{type:"number",description:"The starting index of the slice."},stop:{type:"number",description:"Optional ending index of the slice."}},variants:[{argumentNames:["g","begin"]},{argumentNames:["g","begin","stop"]}],examples:['let { slice-cols } = import(grid);\nslice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { slice-cols } = import(grid);\nslice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1)'],hideOperatorForm:!0,seeAlso:["grid.crop","grid.slice-rows","grid.splice-cols"]},"splice-rows":{category:"grid",description:"Splices rows of the grid `g` starting from the index `begin`. Deletes `deleteCount` rows and inserts the specified `items` at that position.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to splice."},begin:{type:"number",description:"The starting index of the splice."},deleteCount:{type:"number",description:"The number of rows to delete."},items:{type:"array",rest:!0,description:"The rows to insert."}},variants:[{argumentNames:["g","begin","deleteCount"]},{argumentNames:["g","begin","deleteCount","items"]}],examples:['let { splice-rows } = import(grid);\nsplice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { splice-rows } = import(grid);\nsplice-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 1, ["Nazanin", "mother", 40])'],hideOperatorForm:!0,seeAlso:["grid.splice-cols","grid.slice-rows"]},"splice-cols":{category:"grid",description:"Splices columns of the grid `g` starting from the index `begin`. Deletes `deleteCount` columns and inserts the specified `items` at that position.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to splice."},begin:{type:"number",description:"The starting index of the splice."},deleteCount:{type:"number",description:"The number of columns to delete."},items:{type:"array",rest:!0,description:"The columns to insert."}},variants:[{argumentNames:["g","begin","deleteCount"]},{argumentNames:["g","begin","deleteCount","items"]}],examples:['let { splice-cols } = import(grid);\nsplice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 2)','let { splice-cols } = import(grid);\nsplice-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], 1, 1, ["f", "m", "s"])'],hideOperatorForm:!0,seeAlso:["grid.splice-rows","grid.slice-cols"]},"concat-rows":{category:"grid",description:"Concatenates two grids `a` and `b` by rows. The number of columns in both grids must be the same.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"grid"}},variants:[{argumentNames:["a","b"]}],examples:['let { concat-rows } = import(grid);\nconcat-rows([\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n], [\n [1, 2],\n [3, 4],\n])'],seeAlso:["grid.concat-cols","grid.push-rows"]},"concat-cols":{category:"grid",description:"Concatenates two grids `a` and `b` by columns. The number of rows in both grids must be the same.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"grid"}},variants:[{argumentNames:["a","b"]}],examples:['let { concat-cols } = import(grid);\nconcat-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], [\n ["Albert", "father"],\n ["Nina", "mother"],\n ["Kian", "son"],\n])'],seeAlso:["grid.concat-rows","grid.push-cols"]},"cell-map":{category:"grid",description:"Maps a function `a` over each element of the grid `b`, returning a new grid with the results.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { cell-map } = import(grid);\ncell-map([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], str)'],seeAlso:["map","grid.cell-mapi","grid.cell-reduce"]},"cell-mapi":{category:"grid",description:"Maps a function `a` over each element of the grid `b`, passing the row and column index as additional arguments to the function.",returns:{type:"grid"},args:{a:{type:"grid"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],examples:['let { cell-mapi } = import(grid);\ncell-mapi([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], -> $1 ++ "(" ++ $2 ++ ", " ++ $3 ++ ")")'],seeAlso:["grid.cell-map","grid.cell-reducei","map"]},"cell-reduce":{category:"grid",description:"Reduces the grid `a` using the function `b`, returning a single value.",returns:{type:"any"},args:{g:{type:"grid",description:"The grid to reduce."},f:{type:"function",description:"The function to reduce the grid. It takes two arguments: the accumulator and the current element."},"initial-value":{type:"any",description:"The initial value for the accumulator."}},variants:[{argumentNames:["g","f","initial-value"]}],examples:['// Using "as" alias because "reduce" shadows a builtin function\nlet { cell-reduce } = import(grid);\ncell-reduce([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ++, "")'],seeAlso:["reduce","grid.cell-reducei","grid.cell-map"]},"cell-reducei":{category:"grid",description:"Reduces the grid `a` using the function `b`, passing the row and column indices as additional arguments to the function.",returns:{type:"any"},args:{g:{type:"grid",description:"The grid to reduce."},f:{type:"function",description:"The function to reduce the grid. It takes four arguments: the accumulator, the current element, the row index, and the column index."},"initial-value":{type:"any",description:"The initial value for the accumulator."}},variants:[{argumentNames:["g","f","initial-value"]}],examples:['// Using "as" alias because "reducei" shadows a builtin function\nlet { cell-reducei } = import(grid);\ncell-reducei([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ++, "")'],seeAlso:["grid.cell-reduce","grid.cell-mapi","reduce"]},"push-rows":{category:"grid",description:"Pushes the specified rows into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to push rows into."},rows:{type:"array",rest:!0,description:"The rows to push into the grid."}},variants:[{argumentNames:["g","rows"]}],examples:['let { push-rows } = import(grid);\npush-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["Nazanin", "mother", 40])'],hideOperatorForm:!0,seeAlso:["grid.unshift-rows","grid.pop-row","grid.shift-row","grid.concat-rows"]},"unshift-rows":{category:"grid",description:"Unshifts the specified rows into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to unshift rows into."},rows:{type:"array",rest:!0,description:"The rows to unshift into the grid."}},variants:[{argumentNames:["g","rows"]}],examples:['let { unshift-rows } = import(grid);\nunshift-rows([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["Nazanin", "mother", 40])'],hideOperatorForm:!0,seeAlso:["grid.push-rows","grid.shift-row","grid.pop-row"]},"pop-row":{category:"grid",description:"Pops the last row from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to pop a row from."}},variants:[{argumentNames:["g"]}],examples:['let { pop-row } = import(grid);\npop-row([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.shift-row","grid.push-rows","grid.unshift-rows"]},"shift-row":{category:"grid",description:"Shifts the first row from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to shift a row from."}},variants:[{argumentNames:["g"]}],examples:['let { shift-row } = import(grid);\nshift-row([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.pop-row","grid.push-rows","grid.unshift-rows"]},"push-cols":{category:"grid",description:"Pushes the specified columns into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to push columns into."},cols:{type:"array",rest:!0,description:"The columns to push into the grid."}},variants:[{argumentNames:["g","cols"]}],examples:['let { push-cols } = import(grid);\npush-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["f", "m", "s"])'],hideOperatorForm:!0,seeAlso:["grid.unshift-cols","grid.pop-col","grid.shift-col","grid.concat-cols"]},"unshift-cols":{category:"grid",description:"Unshifts the specified columns into the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to unshift columns into."},cols:{type:"array",rest:!0,description:"The columns to unshift into the grid."}},variants:[{argumentNames:["g","cols"]}],examples:['let { unshift-cols } = import(grid);\nunshift-cols([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n], ["f", "m", "s"])'],hideOperatorForm:!0,seeAlso:["grid.push-cols","grid.shift-col","grid.pop-col"]},"pop-col":{category:"grid",description:"Pops the last column from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to pop a column from."}},variants:[{argumentNames:["g"]}],examples:['let { pop-col } = import(grid);\npop-col([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.shift-col","grid.push-cols","grid.unshift-cols"]},"shift-col":{category:"grid",description:"Shifts the first column from the grid `g` and returns the new grid.",returns:{type:"grid"},args:{g:{type:"grid",description:"The grid to shift a column from."}},variants:[{argumentNames:["g"]}],examples:['let { shift-col } = import(grid);\nshift-col([\n ["Albert", "father", 10],\n ["Nina", "mother", 20],\n ["Kian", "son", 30],\n])'],seeAlso:["grid.pop-col","grid.push-cols","grid.unshift-cols"]},"from-array":{category:"grid",description:"Creates a grid from a flat array with specified dimensions. The array is reshaped into the specified number of rows, and the number of columns is automatically calculated based on the total number of elements in the array.",returns:{type:"grid"},args:{a:{type:"array"},b:{type:"number"}},variants:[{argumentNames:["a","b"]}],examples:["let { from-array } = import(grid);\nfrom-array([1, 2, 3, 4], 2)","let { from-array } = import(grid);\nfrom-array([1, 2, 3, 4], 4)"],seeAlso:["grid.fill","grid.generate","grid.reshape"]}};function N(e){const t=[];for(let r=0;r<e[0].length;r+=1){const n=[];for(let t=0;t<e.length;t+=1)n.push(e[t][r]);t.push(n)}return t}const x={"cell-every?":{evaluate:()=>{throw new Error("cell-every?: Dvala implementation should be used instead")},arity:v(2)},"some?":{evaluate:()=>{throw new Error("some?: Dvala implementation should be used instead")},arity:v(2)},"every-row?":{evaluate:()=>{throw new Error("every-row?: Dvala implementation should be used instead")},arity:v(2)},"some-row?":{evaluate:()=>{throw new Error("some-row?: Dvala implementation should be used instead")},arity:v(2)},"every-col?":{evaluate:()=>{throw new Error("every-col?: Dvala implementation should be used instead")},arity:v(2)},"some-col?":{evaluate:()=>{throw new Error("some-col?: Dvala implementation should be used instead")},arity:v(2)},row:{evaluate:([e,t],r)=>(y(e,r),d(t,r,{integer:!0,nonNegative:!0,lt:e.length}),e[t]),arity:v(2)},col:{evaluate:([e,t],r)=>(y(e,r),d(t,r,{integer:!0,nonNegative:!0,lt:e[0].length}),e.map(e=>e[t])),arity:v(2)},shape:{evaluate:([e],t)=>(y(e,t),[e.length,e[0].length]),arity:v(1)},fill:{evaluate:([e,t,r],n)=>{d(e,n,{integer:!0,positive:!0}),d(t,n,{integer:!0,positive:!0}),function(e,t){if(!function(e){return void 0!==e}(e))throw b("not undefined",e,t)}(r,n);const i=[];for(let n=0;n<e;n+=1){const e=[];for(let n=0;n<t;n+=1)e.push(r);i.push(e)}return i},arity:v(3)},generate:{evaluate:()=>{throw new Error("generate: Dvala implementation should be used instead")},arity:v(3)},reshape:{evaluate:([e,r],n)=>{y(e,n),d(r,n,{integer:!0,positive:!0});const i=e.flat();if(i.length%r!==0)throw new t(`The number of elements in the grid must be divisible by rows, but got ${i.length} and ${r}`,n);const o=i.length/r,s=[];for(let e=0;e<r;e+=1){const t=[];for(let r=0;r<o;r+=1)t.push(i[e*o+r]);s.push(t)}return s},arity:v(2)},transpose:{evaluate:([e],t)=>(y(e,t),N(e)),arity:v(1)},"flip-h":{evaluate:([e],t)=>(y(e,t),e.map(e=>e.reverse())),arity:v(1)},"flip-v":{evaluate:([e],t)=>(y(e,t),e.reverse()),arity:v(1)},rotate:{evaluate:([e,t],r)=>{if(y(e,r),d(t,r,{integer:!0}),0===(t=(t%4+4)%4)||0===e.length)return e.map(e=>[...e]);const n=e.length,i=e[0].length;let o;switch(t){case 1:o=Array(i).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<i;r++)o[r][n-1-t]=e[t][r];break;case 2:o=Array(n).fill(null).map(()=>Array(i).fill(null));for(let t=0;t<n;t++)for(let r=0;r<i;r++)o[n-1-t][i-1-r]=e[t][r];break;case 3:o=Array(i).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<i;r++)o[i-1-r][t]=e[t][r]}return o},arity:v(2)},crop:{evaluate:([e,r,n],i)=>{if(y(e,i),f(r,i),2!==r.length)throw new t(`The start vector must have 2 elements, but got ${r.length}`,i);const[o,s]=r;if(d(o,i,{integer:!0,nonNegative:!0,lt:e.length}),d(s,i,{integer:!0,nonNegative:!0,lt:e[0].length}),n??=[e.length,e[0].length],f(n,i),2!==n.length)throw new t(`The end vector must have 2 elements, but got ${n.length}`,i);const[a,l]=n;d(a,i,{gt:o,lte:e.length}),d(l,i,{gt:s,lte:e[0].length});const g=[];for(let t=o;t<a;t+=1){const r=[];for(let n=s;n<l;n+=1)r.push(e[t][n]);g.push(r)}return g},arity:{min:2,max:3}},"slice-rows":{evaluate:([e,t,r],n)=>(y(e,n),void 0===r?(d(t,n,{integer:!0,lte:e.length,gte:-e.length}),t<0?e.slice(e.length+t):e.slice(t)):(d(t,n,{integer:!0,nonNegative:!0,lte:e.length}),d(r,n,{integer:!0}),d(r=r<0?e.length+r:r,n,{gt:t,lte:e.length}),e.slice(t,r))),arity:{min:2,max:3}},"slice-cols":{evaluate:([e,t,r],n)=>{y(e,n);const i=N(e);return void 0===r?(d(t,n,{integer:!0,lte:i.length,gte:-i.length}),N(t<0?i.slice(i.length+t):i.slice(t))):(d(t,n,{integer:!0,nonNegative:!0,lte:i.length}),d(r,n,{integer:!0}),d(r=r<0?i.length+r:r,n,{gt:t,lte:i.length}),N(i.slice(t,r)))},arity:{min:2,max:3}},"splice-rows":{evaluate:([e,r,n,...i],o)=>{y(e,o),d(r,o,{integer:!0,nonNegative:!0,lte:e.length}),d(n,o,{integer:!0,nonNegative:!0}),0!==i.length&&(y(i,o),i.every(r=>{if(w(r,o),e[0].length!==r.length)throw new t(`All rows must have the same length as the number of columns in grid, but got ${r.length}`,o);return!0}));const s=[];for(let t=0;t<r;t+=1)s.push(e[t]);i.length>0&&s.push(...i);for(let t=r+n;t<e.length;t+=1)s.push(e[t]);return s},arity:{min:3}},"splice-cols":{evaluate:([e,r,n,...i],o)=>{y(e,o);const s=N(e);d(r,o,{integer:!0,nonNegative:!0,lte:s.length}),d(n,o,{integer:!0,nonNegative:!0}),0!==i.length&&(y(i,o),i.every(e=>{if(w(e,o),s[0].length!==e.length)throw new t(`All rows must have the same length as the number of rows in grid, but got ${e.length}`,o);return!0}));const a=[];for(let e=0;e<r;e+=1)a.push(s[e]);a.push(...i);for(let e=r+n;e<s.length;e+=1)a.push(s[e]);return N(a)},arity:{min:3}},"concat-rows":{evaluate:(e,r)=>{w(e,r),e.every(e=>y(e,r));const n=e[0][0].length;e.slice(1).every(e=>{if(e[0].length!==n)throw new t(`All grids must have the same number of columns, but got ${n} and ${e[0].length}`,r);return!0});const i=[];return e.forEach(e=>{e.forEach(e=>{i.push(e)})}),i},arity:{min:1}},"concat-cols":{evaluate:(e,r)=>{w(e,r),e.every(e=>y(e,r));const n=e[0].length;e.slice(1).every(e=>{if(e.length!==n)throw new t(`All grids must have the same number of rows, but got ${n} and ${e.length}`,r);return!0});const i=[];for(let t=0;t<n;t+=1){const r=[];e.forEach(e=>{r.push(...e[t])}),i.push(r)}return i},arity:{min:1}},"cell-map":{evaluate:()=>{throw new Error("cell-map: Dvala implementation should be used instead")},arity:{min:2}},"cell-mapi":{evaluate:()=>{throw new Error("cell-mapi: Dvala implementation should be used instead")},arity:v(2)},"cell-reduce":{evaluate:()=>{throw new Error("cell-reduce: Dvala implementation should be used instead")},arity:v(3)},"cell-reducei":{evaluate:()=>{throw new Error("cell-reducei: Dvala implementation should be used instead")},arity:v(3)},"push-rows":{evaluate:([e,...r],n)=>{if(y(e,n),y(r,n),e[0].length!==r[0].length)throw new t(`All rows must have the same length as the number of columns in grid, but got ${e[0].length} and ${r[0].length}`,n);return[...e,...r]},arity:{min:2}},"unshift-rows":{evaluate:([e,...r],n)=>{if(y(e,n),y(r,n),e[0].length!==r[0].length)throw new t(`All rows must have the same length as the number of columns in grid, but got ${e[0].length} and ${r[0].length}`,n);return[...r,...e]},arity:{min:2}},"pop-row":{evaluate:([e],t)=>(y(e,t),1===e.length?null:e.slice(0,-1)),arity:v(1)},"shift-row":{evaluate:([e],t)=>(y(e,t),1===e.length?null:e.slice(1)),arity:v(1)},"push-cols":{evaluate:([e,...r],n)=>{if(y(e,n),y(r,n),e.length!==r[0].length)throw new t(`All columns must have the same length as the number of rows in grid, but got ${r.length}`,n);const i=[];for(let t=0;t<e.length;t+=1){const n=[];n.push(...e[t]),r.forEach(e=>{n.push(e[t])}),i.push(n)}return i},arity:{min:2}},"unshift-cols":{evaluate:([e,...r],n)=>{if(y(e,n),y(r,n),e.length!==r[0].length)throw new t(`All columns must have the same length as the number of rows in grid, but got ${r.length}`,n);const i=[];for(let t=0;t<e.length;t+=1){const n=[];r.forEach(e=>{n.push(e[t])}),n.push(...e[t]),i.push(n)}return i},arity:{min:2}},"pop-col":{evaluate:([e],t)=>(y(e,t),1===e[0].length?null:e.map(e=>e.slice(0,-1))),arity:v(1)},"shift-col":{evaluate:([e],t)=>(y(e,t),1===e[0].length?null:e.map(e=>e.slice(1))),arity:v(1)},"from-array":{evaluate:([e,r],n)=>{if(w(e,n),d(r,n,{integer:!0,positive:!0}),e.length%r!==0)throw new t(`The number of elements in the array must be divisible by rows, but got ${e.length} and ${r}`,n);return function(e,t){const r=[],n=e.length/t;for(let i=0;i<t;i++){const t=i*n,o=t+n;r.push(e.slice(t,o))}return r}(e,r)},arity:v(2)}};for(const[e,t]of Object.entries(A))x[e]&&(x[e].docs=t);const $={name:"grid",functions:x,source:'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;',docs:A};export{$ as gridModule};
2
2
  //# sourceMappingURL=grid.esm.js.map