@mojir/dvala 0.0.10 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/cli.js +33091 -36955
- package/package.json +191 -31
- package/dist/bundler.esm.js +0 -2
- package/dist/bundler.esm.js.map +0 -1
- package/dist/bundler.js +0 -2
- package/dist/bundler.js.map +0 -1
- package/dist/cli/cli/src/cli.d.ts +0 -2
- package/dist/cli/cli/src/cliDocumentation/formatCliDescription.d.ts +0 -3
- package/dist/cli/cli/src/cliDocumentation/getCliArgumentInfo.d.ts +0 -3
- package/dist/cli/cli/src/cliDocumentation/getCliDocumentation.d.ts +0 -2
- package/dist/cli/cli/src/cliDocumentation/getCliFunctionExamples.d.ts +0 -3
- package/dist/cli/cli/src/cliDocumentation/getCliFunctionSignature.d.ts +0 -3
- package/dist/cli/cli/src/cliDocumentation/getCliTitle.d.ts +0 -3
- package/dist/cli/cli/src/cliDocumentation/getCliType.d.ts +0 -3
- package/dist/cli/cli/src/cliFormatterRules.d.ts +0 -13
- package/dist/cli/cli/src/colorizer.d.ts +0 -939
- package/dist/cli/cli/src/createReadlineInterface.d.ts +0 -5
- package/dist/cli/cli/src/js-interop/Cli/Fs/index.d.ts +0 -2
- package/dist/cli/cli/src/js-interop/Cli/Proc/index.d.ts +0 -3
- package/dist/cli/cli/src/js-interop/Cli/index.d.ts +0 -2
- package/dist/cli/common/createFormatter.d.ts +0 -6
- package/dist/cli/common/utils.d.ts +0 -2
- package/dist/cli/reference/api.d.ts +0 -73
- package/dist/cli/reference/datatype.d.ts +0 -3
- package/dist/cli/reference/examples.d.ts +0 -11
- package/dist/cli/reference/index.d.ts +0 -195
- package/dist/cli/reference/shorthand.d.ts +0 -3
- package/dist/cli/src/AutoCompleter/AutoCompleter.d.ts +0 -27
- package/dist/cli/src/Cache.d.ts +0 -16
- package/dist/cli/src/allModules.d.ts +0 -2
- package/dist/cli/src/builtin/bindingNode.d.ts +0 -11
- package/dist/cli/src/builtin/core/array.d.ts +0 -2
- package/dist/cli/src/builtin/core/assertion.d.ts +0 -2
- package/dist/cli/src/builtin/core/bitwise.d.ts +0 -2
- package/dist/cli/src/builtin/core/collection.d.ts +0 -2
- package/dist/cli/src/builtin/core/functional.d.ts +0 -2
- package/dist/cli/src/builtin/core/math.d.ts +0 -2
- package/dist/cli/src/builtin/core/meta.d.ts +0 -3
- package/dist/cli/src/builtin/core/misc.d.ts +0 -2
- package/dist/cli/src/builtin/core/object.d.ts +0 -2
- package/dist/cli/src/builtin/core/predicates.d.ts +0 -2
- package/dist/cli/src/builtin/core/regexp.d.ts +0 -2
- package/dist/cli/src/builtin/core/sequence.d.ts +0 -2
- package/dist/cli/src/builtin/core/string.d.ts +0 -2
- package/dist/cli/src/builtin/core/vector.d.ts +0 -2
- package/dist/cli/src/builtin/index.d.ts +0 -13
- package/dist/cli/src/builtin/interface.d.ts +0 -113
- package/dist/cli/src/builtin/modules/assertion/docs.d.ts +0 -2
- package/dist/cli/src/builtin/modules/assertion/index.d.ts +0 -2
- package/dist/cli/src/builtin/modules/bitwise/index.d.ts +0 -2
- package/dist/cli/src/builtin/modules/collection/index.d.ts +0 -2
- package/dist/cli/src/builtin/modules/convert/index.d.ts +0 -2
- package/dist/cli/src/builtin/modules/functional/index.d.ts +0 -2
- package/dist/cli/src/builtin/modules/grid/docs.d.ts +0 -2
- package/dist/cli/src/builtin/modules/grid/fromArray.d.ts +0 -8
- package/dist/cli/src/builtin/modules/grid/index.d.ts +0 -2
- package/dist/cli/src/builtin/modules/grid/transpose.d.ts +0 -2
- package/dist/cli/src/builtin/modules/interface.d.ts +0 -28
- package/dist/cli/src/builtin/modules/linear-algebra/docs.d.ts +0 -2
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +0 -1
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +0 -2
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +0 -8
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +0 -4
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/dot.d.ts +0 -1
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +0 -7
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +0 -2
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +0 -1
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +0 -10
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/length.d.ts +0 -1
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +0 -1
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/scale.d.ts +0 -1
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/solve.d.ts +0 -8
- package/dist/cli/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +0 -1
- package/dist/cli/src/builtin/modules/linear-algebra/index.d.ts +0 -4
- package/dist/cli/src/builtin/modules/math/index.d.ts +0 -2
- package/dist/cli/src/builtin/modules/matrix/docs.d.ts +0 -2
- package/dist/cli/src/builtin/modules/matrix/helpers/adjugate.d.ts +0 -1
- package/dist/cli/src/builtin/modules/matrix/helpers/band.d.ts +0 -9
- package/dist/cli/src/builtin/modules/matrix/helpers/cofactor.d.ts +0 -1
- package/dist/cli/src/builtin/modules/matrix/helpers/determinant.d.ts +0 -6
- package/dist/cli/src/builtin/modules/matrix/helpers/inverse.d.ts +0 -6
- package/dist/cli/src/builtin/modules/matrix/helpers/isBanded.d.ts +0 -11
- package/dist/cli/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +0 -10
- package/dist/cli/src/builtin/modules/matrix/helpers/isIdentity.d.ts +0 -1
- package/dist/cli/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +0 -1
- package/dist/cli/src/builtin/modules/matrix/helpers/isSquare.d.ts +0 -1
- package/dist/cli/src/builtin/modules/matrix/helpers/isSymetric.d.ts +0 -8
- package/dist/cli/src/builtin/modules/matrix/helpers/isTriangular.d.ts +0 -13
- package/dist/cli/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +0 -7
- package/dist/cli/src/builtin/modules/matrix/helpers/minor.d.ts +0 -1
- package/dist/cli/src/builtin/modules/matrix/helpers/norm1.d.ts +0 -1
- package/dist/cli/src/builtin/modules/matrix/helpers/trace.d.ts +0 -8
- package/dist/cli/src/builtin/modules/matrix/index.d.ts +0 -4
- package/dist/cli/src/builtin/modules/number-theory/binomialCefficient.d.ts +0 -1
- package/dist/cli/src/builtin/modules/number-theory/combinations.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/derangements.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/divisors.d.ts +0 -4
- package/dist/cli/src/builtin/modules/number-theory/docs.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/factorial.d.ts +0 -3
- package/dist/cli/src/builtin/modules/number-theory/index.d.ts +0 -4
- package/dist/cli/src/builtin/modules/number-theory/partitions.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/permutations.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/powerSet.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/primeFactors.d.ts +0 -11
- package/dist/cli/src/builtin/modules/number-theory/sequences/abundant.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/bell.d.ts +0 -1
- package/dist/cli/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/catalan.d.ts +0 -1
- package/dist/cli/src/builtin/modules/number-theory/sequences/collatz.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/composite.d.ts +0 -3
- package/dist/cli/src/builtin/modules/number-theory/sequences/deficient.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/factorial.d.ts +0 -1
- package/dist/cli/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +0 -1
- package/dist/cli/src/builtin/modules/number-theory/sequences/geometric.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/golomb.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/happy.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/index.d.ts +0 -27
- package/dist/cli/src/builtin/modules/number-theory/sequences/juggler.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/lucas.d.ts +0 -1
- package/dist/cli/src/builtin/modules/number-theory/sequences/lucky.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/mersenne.d.ts +0 -1
- package/dist/cli/src/builtin/modules/number-theory/sequences/padovan.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/partition.d.ts +0 -1
- package/dist/cli/src/builtin/modules/number-theory/sequences/pell.d.ts +0 -1
- package/dist/cli/src/builtin/modules/number-theory/sequences/perfect.d.ts +0 -1
- package/dist/cli/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +0 -10
- package/dist/cli/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/poligonal.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/prime.d.ts +0 -3
- package/dist/cli/src/builtin/modules/number-theory/sequences/recaman.d.ts +0 -9
- package/dist/cli/src/builtin/modules/number-theory/sequences/sylvester.d.ts +0 -1
- package/dist/cli/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +0 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +0 -1
- package/dist/cli/src/builtin/modules/sequence/index.d.ts +0 -2
- package/dist/cli/src/builtin/modules/string/index.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/bincount.d.ts +0 -9
- package/dist/cli/src/builtin/modules/vector/calcMad.d.ts +0 -1
- package/dist/cli/src/builtin/modules/vector/calcMean.d.ts +0 -1
- package/dist/cli/src/builtin/modules/vector/calcMedad.d.ts +0 -1
- package/dist/cli/src/builtin/modules/vector/calcMedian.d.ts +0 -1
- package/dist/cli/src/builtin/modules/vector/calcStdDev.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/calcVariance.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/docs.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/entropy.d.ts +0 -8
- package/dist/cli/src/builtin/modules/vector/histogram.d.ts +0 -9
- package/dist/cli/src/builtin/modules/vector/index.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/mode.d.ts +0 -6
- package/dist/cli/src/builtin/modules/vector/outliers.d.ts +0 -7
- package/dist/cli/src/builtin/modules/vector/percentile.d.ts +0 -7
- package/dist/cli/src/builtin/modules/vector/quartiles.d.ts +0 -1
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/index.d.ts +0 -13
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +0 -5
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/mad.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/mean.d.ts +0 -4
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/medad.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/median.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/prod.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/rms.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +0 -3
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/span.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +0 -3
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/sum.d.ts +0 -2
- package/dist/cli/src/builtin/modules/vector/reductionFunctions/variance.d.ts +0 -3
- package/dist/cli/src/builtin/normalExpressions/index.d.ts +0 -9
- package/dist/cli/src/builtin/normalExpressions/initCoreDvala.d.ts +0 -1
- package/dist/cli/src/builtin/specialExpressionTypes.d.ts +0 -24
- package/dist/cli/src/builtin/specialExpressions/and.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/array.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/block.d.ts +0 -7
- package/dist/cli/src/builtin/specialExpressions/cond.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/defined.d.ts +0 -5
- package/dist/cli/src/builtin/specialExpressions/effect.d.ts +0 -5
- package/dist/cli/src/builtin/specialExpressions/functions.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/if.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/import.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/let.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/loop.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/loops.d.ts +0 -9
- package/dist/cli/src/builtin/specialExpressions/match.d.ts +0 -7
- package/dist/cli/src/builtin/specialExpressions/object.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/or.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/parallel.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/perform.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/qq.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/race.d.ts +0 -6
- package/dist/cli/src/builtin/specialExpressions/recur.d.ts +0 -5
- package/dist/cli/src/builtin/specialExpressions/unless.d.ts +0 -6
- package/dist/cli/src/builtin/utils.d.ts +0 -6
- package/dist/cli/src/bundler/index.d.ts +0 -9
- package/dist/cli/src/bundler/interface.d.ts +0 -15
- package/dist/cli/src/bundler.d.ts +0 -3
- package/dist/cli/src/cli.d.ts +0 -2
- package/dist/cli/src/cliDocumentation/formatCliDescription.d.ts +0 -3
- package/dist/cli/src/cliDocumentation/getCliArgumentInfo.d.ts +0 -3
- package/dist/cli/src/cliDocumentation/getCliDocumentation.d.ts +0 -2
- package/dist/cli/src/cliDocumentation/getCliFunctionExamples.d.ts +0 -3
- package/dist/cli/src/cliDocumentation/getCliFunctionSignature.d.ts +0 -3
- package/dist/cli/src/cliDocumentation/getCliTitle.d.ts +0 -3
- package/dist/cli/src/cliDocumentation/getCliType.d.ts +0 -3
- package/dist/cli/src/cliFormatterRules.d.ts +0 -13
- package/dist/cli/src/colorizer.d.ts +0 -939
- package/dist/cli/src/constants/constants.d.ts +0 -19
- package/dist/cli/src/createDvala.d.ts +0 -47
- package/dist/cli/src/createReadlineInterface.d.ts +0 -5
- package/dist/cli/src/errors.d.ts +0 -24
- package/dist/cli/src/evaluator/ContextStack.d.ts +0 -70
- package/dist/cli/src/evaluator/contentHash.d.ts +0 -21
- package/dist/cli/src/evaluator/dedupSubTrees.d.ts +0 -37
- package/dist/cli/src/evaluator/effectRef.d.ts +0 -27
- package/dist/cli/src/evaluator/effectTypes.d.ts +0 -199
- package/dist/cli/src/evaluator/frames.d.ts +0 -513
- package/dist/cli/src/evaluator/interface.d.ts +0 -14
- package/dist/cli/src/evaluator/standardEffects.d.ts +0 -50
- package/dist/cli/src/evaluator/step.d.ts +0 -175
- package/dist/cli/src/evaluator/suspension.d.ts +0 -92
- package/dist/cli/src/evaluator/trampoline.d.ts +0 -138
- package/dist/cli/src/getUndefinedSymbols/index.d.ts +0 -7
- package/dist/cli/src/initReferenceData.d.ts +0 -1
- package/dist/cli/src/interface.d.ts +0 -7
- package/dist/cli/src/js-interop/Cli/Fs/index.d.ts +0 -2
- package/dist/cli/src/js-interop/Cli/Proc/index.d.ts +0 -3
- package/dist/cli/src/js-interop/Cli/index.d.ts +0 -2
- package/dist/cli/src/parser/ParserContext.d.ts +0 -20
- package/dist/cli/src/parser/getPrecedence.d.ts +0 -3
- package/dist/cli/src/parser/helpers.d.ts +0 -19
- package/dist/cli/src/parser/index.d.ts +0 -5
- package/dist/cli/src/parser/subParsers/parseArray.d.ts +0 -3
- package/dist/cli/src/parser/subParsers/parseBindingTarget.d.ts +0 -8
- package/dist/cli/src/parser/subParsers/parseCond.d.ts +0 -4
- package/dist/cli/src/parser/subParsers/parseDo.d.ts +0 -3
- package/dist/cli/src/parser/subParsers/parseExpression.d.ts +0 -5
- package/dist/cli/src/parser/subParsers/parseForOrDoseq.d.ts +0 -4
- package/dist/cli/src/parser/subParsers/parseFunction.d.ts +0 -4
- package/dist/cli/src/parser/subParsers/parseFunctionCall.d.ts +0 -3
- package/dist/cli/src/parser/subParsers/parseIfOrUnless.d.ts +0 -5
- package/dist/cli/src/parser/subParsers/parseImplicitBlock.d.ts +0 -5
- package/dist/cli/src/parser/subParsers/parseLet.d.ts +0 -4
- package/dist/cli/src/parser/subParsers/parseLoop.d.ts +0 -4
- package/dist/cli/src/parser/subParsers/parseMatch.d.ts +0 -4
- package/dist/cli/src/parser/subParsers/parseNumber.d.ts +0 -3
- package/dist/cli/src/parser/subParsers/parseObject.d.ts +0 -3
- package/dist/cli/src/parser/subParsers/parseOperand.d.ts +0 -3
- package/dist/cli/src/parser/subParsers/parseRegexpShorthand.d.ts +0 -3
- package/dist/cli/src/parser/subParsers/parseReservedSymbol.d.ts +0 -3
- package/dist/cli/src/parser/subParsers/parseString.d.ts +0 -4
- package/dist/cli/src/parser/subParsers/parseSymbol.d.ts +0 -3
- package/dist/cli/src/parser/types.d.ts +0 -128
- package/dist/cli/src/symbolPatterns.d.ts +0 -2
- package/dist/cli/src/testFramework/index.d.ts +0 -15
- package/dist/cli/src/tokenizer/minifyTokenStream.d.ts +0 -4
- package/dist/cli/src/tokenizer/operators.d.ts +0 -12
- package/dist/cli/src/tokenizer/reservedNames.d.ts +0 -65
- package/dist/cli/src/tokenizer/token.d.ts +0 -82
- package/dist/cli/src/tokenizer/tokenize.d.ts +0 -7
- package/dist/cli/src/tokenizer/tokenizers.d.ts +0 -13
- package/dist/cli/src/tooling.d.ts +0 -51
- package/dist/cli/src/transformer/index.d.ts +0 -2
- package/dist/cli/src/typeGuards/annotatedCollections.d.ts +0 -16
- package/dist/cli/src/typeGuards/array.d.ts +0 -9
- package/dist/cli/src/typeGuards/astNode.d.ts +0 -19
- package/dist/cli/src/typeGuards/dvala.d.ts +0 -26
- package/dist/cli/src/typeGuards/dvalaFunction.d.ts +0 -9
- package/dist/cli/src/typeGuards/index.d.ts +0 -7
- package/dist/cli/src/typeGuards/number.d.ts +0 -66
- package/dist/cli/src/typeGuards/string.d.ts +0 -15
- package/dist/cli/src/untokenizer/index.d.ts +0 -2
- package/dist/cli/src/utils/arity.d.ts +0 -10
- package/dist/cli/src/utils/debug/debugTools.d.ts +0 -1
- package/dist/cli/src/utils/debug/getCodeMarker.d.ts +0 -2
- package/dist/cli/src/utils/debug/getSourceCodeInfo.d.ts +0 -2
- package/dist/cli/src/utils/docString/generateDocString.d.ts +0 -4
- package/dist/cli/src/utils/getAssertionError.d.ts +0 -3
- package/dist/cli/src/utils/index.d.ts +0 -14
- package/dist/cli/src/utils/maybePromise.d.ts +0 -54
- package/dist/cli/src/utils/symbols.d.ts +0 -3
- package/dist/common/createFormatter.d.ts +0 -6
- package/dist/common/utils.d.ts +0 -2
- package/dist/debug.esm.js +0 -2
- package/dist/debug.esm.js.map +0 -1
- package/dist/debug.js +0 -2
- package/dist/debug.js.map +0 -1
- package/dist/dvala.iife.js +0 -2
- package/dist/dvala.iife.js.map +0 -1
- package/dist/full.esm.js +0 -2
- package/dist/full.esm.js.map +0 -1
- package/dist/full.js +0 -2
- package/dist/full.js.map +0 -1
- package/dist/index.esm.js +0 -2
- package/dist/index.esm.js.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/mcp-server/common/utils.d.ts +0 -2
- package/dist/mcp-server/mcp-server/src/server.d.ts +0 -1
- package/dist/mcp-server/reference/api.d.ts +0 -73
- package/dist/mcp-server/reference/datatype.d.ts +0 -3
- package/dist/mcp-server/reference/examples.d.ts +0 -11
- package/dist/mcp-server/reference/index.d.ts +0 -195
- package/dist/mcp-server/reference/shorthand.d.ts +0 -3
- package/dist/mcp-server/server.js +0 -36377
- package/dist/mcp-server/src/AutoCompleter/AutoCompleter.d.ts +0 -27
- package/dist/mcp-server/src/Cache.d.ts +0 -16
- package/dist/mcp-server/src/allModules.d.ts +0 -2
- package/dist/mcp-server/src/builtin/bindingNode.d.ts +0 -11
- package/dist/mcp-server/src/builtin/core/array.d.ts +0 -2
- package/dist/mcp-server/src/builtin/core/assertion.d.ts +0 -2
- package/dist/mcp-server/src/builtin/core/bitwise.d.ts +0 -2
- package/dist/mcp-server/src/builtin/core/collection.d.ts +0 -2
- package/dist/mcp-server/src/builtin/core/functional.d.ts +0 -2
- package/dist/mcp-server/src/builtin/core/math.d.ts +0 -2
- package/dist/mcp-server/src/builtin/core/meta.d.ts +0 -3
- package/dist/mcp-server/src/builtin/core/misc.d.ts +0 -2
- package/dist/mcp-server/src/builtin/core/object.d.ts +0 -2
- package/dist/mcp-server/src/builtin/core/predicates.d.ts +0 -2
- package/dist/mcp-server/src/builtin/core/regexp.d.ts +0 -2
- package/dist/mcp-server/src/builtin/core/sequence.d.ts +0 -2
- package/dist/mcp-server/src/builtin/core/string.d.ts +0 -2
- package/dist/mcp-server/src/builtin/core/vector.d.ts +0 -2
- package/dist/mcp-server/src/builtin/index.d.ts +0 -13
- package/dist/mcp-server/src/builtin/interface.d.ts +0 -113
- package/dist/mcp-server/src/builtin/modules/assertion/docs.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/assertion/index.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/bitwise/index.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/collection/index.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/convert/index.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/functional/index.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/grid/docs.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/grid/fromArray.d.ts +0 -8
- package/dist/mcp-server/src/builtin/modules/grid/index.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/grid/transpose.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/interface.d.ts +0 -28
- package/dist/mcp-server/src/builtin/modules/linear-algebra/docs.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +0 -8
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +0 -4
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/dot.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +0 -7
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +0 -10
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/length.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/scale.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/solve.d.ts +0 -8
- package/dist/mcp-server/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/linear-algebra/index.d.ts +0 -4
- package/dist/mcp-server/src/builtin/modules/math/index.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/matrix/docs.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/adjugate.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/band.d.ts +0 -9
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/cofactor.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/determinant.d.ts +0 -6
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/inverse.d.ts +0 -6
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/isBanded.d.ts +0 -11
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +0 -10
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/isIdentity.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/isSquare.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/isSymetric.d.ts +0 -8
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/isTriangular.d.ts +0 -13
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +0 -7
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/minor.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/norm1.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/matrix/helpers/trace.d.ts +0 -8
- package/dist/mcp-server/src/builtin/modules/matrix/index.d.ts +0 -4
- package/dist/mcp-server/src/builtin/modules/number-theory/binomialCefficient.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/number-theory/combinations.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/derangements.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/divisors.d.ts +0 -4
- package/dist/mcp-server/src/builtin/modules/number-theory/docs.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/factorial.d.ts +0 -3
- package/dist/mcp-server/src/builtin/modules/number-theory/index.d.ts +0 -4
- package/dist/mcp-server/src/builtin/modules/number-theory/partitions.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/permutations.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/powerSet.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/primeFactors.d.ts +0 -11
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/abundant.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/bell.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/catalan.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/collatz.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/composite.d.ts +0 -3
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/deficient.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/factorial.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/geometric.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/golomb.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/happy.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/index.d.ts +0 -27
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/juggler.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/lucas.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/lucky.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/mersenne.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/padovan.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/partition.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/pell.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/perfect.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +0 -10
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/poligonal.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/prime.d.ts +0 -3
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/recaman.d.ts +0 -9
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/sylvester.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/sequence/index.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/string/index.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/bincount.d.ts +0 -9
- package/dist/mcp-server/src/builtin/modules/vector/calcMad.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/vector/calcMean.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/vector/calcMedad.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/vector/calcMedian.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/vector/calcStdDev.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/calcVariance.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/docs.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/entropy.d.ts +0 -8
- package/dist/mcp-server/src/builtin/modules/vector/histogram.d.ts +0 -9
- package/dist/mcp-server/src/builtin/modules/vector/index.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/mode.d.ts +0 -6
- package/dist/mcp-server/src/builtin/modules/vector/outliers.d.ts +0 -7
- package/dist/mcp-server/src/builtin/modules/vector/percentile.d.ts +0 -7
- package/dist/mcp-server/src/builtin/modules/vector/quartiles.d.ts +0 -1
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/index.d.ts +0 -13
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +0 -5
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/mad.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/mean.d.ts +0 -4
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/medad.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/median.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/prod.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/rms.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +0 -3
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/span.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +0 -3
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/sum.d.ts +0 -2
- package/dist/mcp-server/src/builtin/modules/vector/reductionFunctions/variance.d.ts +0 -3
- package/dist/mcp-server/src/builtin/normalExpressions/index.d.ts +0 -9
- package/dist/mcp-server/src/builtin/normalExpressions/initCoreDvala.d.ts +0 -1
- package/dist/mcp-server/src/builtin/specialExpressionTypes.d.ts +0 -24
- package/dist/mcp-server/src/builtin/specialExpressions/and.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/array.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/block.d.ts +0 -7
- package/dist/mcp-server/src/builtin/specialExpressions/cond.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/defined.d.ts +0 -5
- package/dist/mcp-server/src/builtin/specialExpressions/effect.d.ts +0 -5
- package/dist/mcp-server/src/builtin/specialExpressions/functions.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/if.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/import.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/let.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/loop.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/loops.d.ts +0 -9
- package/dist/mcp-server/src/builtin/specialExpressions/match.d.ts +0 -7
- package/dist/mcp-server/src/builtin/specialExpressions/object.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/or.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/parallel.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/perform.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/qq.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/race.d.ts +0 -6
- package/dist/mcp-server/src/builtin/specialExpressions/recur.d.ts +0 -5
- package/dist/mcp-server/src/builtin/specialExpressions/unless.d.ts +0 -6
- package/dist/mcp-server/src/builtin/utils.d.ts +0 -6
- package/dist/mcp-server/src/bundler/interface.d.ts +0 -15
- package/dist/mcp-server/src/constants/constants.d.ts +0 -19
- package/dist/mcp-server/src/createDvala.d.ts +0 -47
- package/dist/mcp-server/src/errors.d.ts +0 -24
- package/dist/mcp-server/src/evaluator/ContextStack.d.ts +0 -70
- package/dist/mcp-server/src/evaluator/contentHash.d.ts +0 -21
- package/dist/mcp-server/src/evaluator/dedupSubTrees.d.ts +0 -37
- package/dist/mcp-server/src/evaluator/effectRef.d.ts +0 -27
- package/dist/mcp-server/src/evaluator/effectTypes.d.ts +0 -199
- package/dist/mcp-server/src/evaluator/frames.d.ts +0 -513
- package/dist/mcp-server/src/evaluator/interface.d.ts +0 -14
- package/dist/mcp-server/src/evaluator/standardEffects.d.ts +0 -50
- package/dist/mcp-server/src/evaluator/step.d.ts +0 -175
- package/dist/mcp-server/src/evaluator/suspension.d.ts +0 -92
- package/dist/mcp-server/src/evaluator/trampoline.d.ts +0 -138
- package/dist/mcp-server/src/getUndefinedSymbols/index.d.ts +0 -7
- package/dist/mcp-server/src/initReferenceData.d.ts +0 -1
- package/dist/mcp-server/src/interface.d.ts +0 -7
- package/dist/mcp-server/src/parser/ParserContext.d.ts +0 -20
- package/dist/mcp-server/src/parser/getPrecedence.d.ts +0 -3
- package/dist/mcp-server/src/parser/helpers.d.ts +0 -19
- package/dist/mcp-server/src/parser/index.d.ts +0 -5
- package/dist/mcp-server/src/parser/subParsers/parseArray.d.ts +0 -3
- package/dist/mcp-server/src/parser/subParsers/parseBindingTarget.d.ts +0 -8
- package/dist/mcp-server/src/parser/subParsers/parseCond.d.ts +0 -4
- package/dist/mcp-server/src/parser/subParsers/parseDo.d.ts +0 -3
- package/dist/mcp-server/src/parser/subParsers/parseExpression.d.ts +0 -5
- package/dist/mcp-server/src/parser/subParsers/parseForOrDoseq.d.ts +0 -4
- package/dist/mcp-server/src/parser/subParsers/parseFunction.d.ts +0 -4
- package/dist/mcp-server/src/parser/subParsers/parseFunctionCall.d.ts +0 -3
- package/dist/mcp-server/src/parser/subParsers/parseIfOrUnless.d.ts +0 -5
- package/dist/mcp-server/src/parser/subParsers/parseImplicitBlock.d.ts +0 -5
- package/dist/mcp-server/src/parser/subParsers/parseLet.d.ts +0 -4
- package/dist/mcp-server/src/parser/subParsers/parseLoop.d.ts +0 -4
- package/dist/mcp-server/src/parser/subParsers/parseMatch.d.ts +0 -4
- package/dist/mcp-server/src/parser/subParsers/parseNumber.d.ts +0 -3
- package/dist/mcp-server/src/parser/subParsers/parseObject.d.ts +0 -3
- package/dist/mcp-server/src/parser/subParsers/parseOperand.d.ts +0 -3
- package/dist/mcp-server/src/parser/subParsers/parseRegexpShorthand.d.ts +0 -3
- package/dist/mcp-server/src/parser/subParsers/parseReservedSymbol.d.ts +0 -3
- package/dist/mcp-server/src/parser/subParsers/parseString.d.ts +0 -4
- package/dist/mcp-server/src/parser/subParsers/parseSymbol.d.ts +0 -3
- package/dist/mcp-server/src/parser/types.d.ts +0 -128
- package/dist/mcp-server/src/tokenizer/minifyTokenStream.d.ts +0 -4
- package/dist/mcp-server/src/tokenizer/operators.d.ts +0 -12
- package/dist/mcp-server/src/tokenizer/reservedNames.d.ts +0 -65
- package/dist/mcp-server/src/tokenizer/token.d.ts +0 -82
- package/dist/mcp-server/src/tokenizer/tokenize.d.ts +0 -7
- package/dist/mcp-server/src/tokenizer/tokenizers.d.ts +0 -13
- package/dist/mcp-server/src/tooling.d.ts +0 -51
- package/dist/mcp-server/src/transformer/index.d.ts +0 -2
- package/dist/mcp-server/src/typeGuards/annotatedCollections.d.ts +0 -16
- package/dist/mcp-server/src/typeGuards/array.d.ts +0 -9
- package/dist/mcp-server/src/typeGuards/astNode.d.ts +0 -19
- package/dist/mcp-server/src/typeGuards/dvala.d.ts +0 -26
- package/dist/mcp-server/src/typeGuards/dvalaFunction.d.ts +0 -9
- package/dist/mcp-server/src/typeGuards/index.d.ts +0 -7
- package/dist/mcp-server/src/typeGuards/number.d.ts +0 -66
- package/dist/mcp-server/src/typeGuards/string.d.ts +0 -15
- package/dist/mcp-server/src/untokenizer/index.d.ts +0 -2
- package/dist/mcp-server/src/utils/arity.d.ts +0 -10
- package/dist/mcp-server/src/utils/debug/debugTools.d.ts +0 -1
- package/dist/mcp-server/src/utils/debug/getCodeMarker.d.ts +0 -2
- package/dist/mcp-server/src/utils/debug/getSourceCodeInfo.d.ts +0 -2
- package/dist/mcp-server/src/utils/docString/generateDocString.d.ts +0 -4
- package/dist/mcp-server/src/utils/getAssertionError.d.ts +0 -3
- package/dist/mcp-server/src/utils/index.d.ts +0 -14
- package/dist/mcp-server/src/utils/maybePromise.d.ts +0 -54
- package/dist/mcp-server/src/utils/symbols.d.ts +0 -3
- package/dist/modules/assertion.esm.js +0 -2
- package/dist/modules/assertion.esm.js.map +0 -1
- package/dist/modules/assertion.js +0 -2
- package/dist/modules/assertion.js.map +0 -1
- package/dist/modules/bitwise.esm.js +0 -2
- package/dist/modules/bitwise.esm.js.map +0 -1
- package/dist/modules/bitwise.js +0 -2
- package/dist/modules/bitwise.js.map +0 -1
- package/dist/modules/cli/src/cli.d.ts +0 -2
- package/dist/modules/cli/src/cliDocumentation/formatCliDescription.d.ts +0 -3
- package/dist/modules/cli/src/cliDocumentation/getCliArgumentInfo.d.ts +0 -3
- package/dist/modules/cli/src/cliDocumentation/getCliDocumentation.d.ts +0 -2
- package/dist/modules/cli/src/cliDocumentation/getCliFunctionExamples.d.ts +0 -3
- package/dist/modules/cli/src/cliDocumentation/getCliFunctionSignature.d.ts +0 -3
- package/dist/modules/cli/src/cliDocumentation/getCliTitle.d.ts +0 -3
- package/dist/modules/cli/src/cliDocumentation/getCliType.d.ts +0 -3
- package/dist/modules/cli/src/cliFormatterRules.d.ts +0 -13
- package/dist/modules/cli/src/colorizer.d.ts +0 -939
- package/dist/modules/cli/src/createReadlineInterface.d.ts +0 -5
- package/dist/modules/cli/src/js-interop/Cli/Fs/index.d.ts +0 -2
- package/dist/modules/cli/src/js-interop/Cli/Proc/index.d.ts +0 -3
- package/dist/modules/cli/src/js-interop/Cli/index.d.ts +0 -2
- package/dist/modules/collection.esm.js +0 -2
- package/dist/modules/collection.esm.js.map +0 -1
- package/dist/modules/collection.js +0 -2
- package/dist/modules/collection.js.map +0 -1
- package/dist/modules/common/createFormatter.d.ts +0 -6
- package/dist/modules/common/utils.d.ts +0 -2
- package/dist/modules/convert.esm.js +0 -2
- package/dist/modules/convert.esm.js.map +0 -1
- package/dist/modules/convert.js +0 -2
- package/dist/modules/convert.js.map +0 -1
- package/dist/modules/functional.esm.js +0 -2
- package/dist/modules/functional.esm.js.map +0 -1
- package/dist/modules/functional.js +0 -2
- package/dist/modules/functional.js.map +0 -1
- package/dist/modules/grid.esm.js +0 -2
- package/dist/modules/grid.esm.js.map +0 -1
- package/dist/modules/grid.js +0 -2
- package/dist/modules/grid.js.map +0 -1
- package/dist/modules/linear-algebra.esm.js +0 -2
- package/dist/modules/linear-algebra.esm.js.map +0 -1
- package/dist/modules/linear-algebra.js +0 -2
- package/dist/modules/linear-algebra.js.map +0 -1
- package/dist/modules/math.esm.js +0 -2
- package/dist/modules/math.esm.js.map +0 -1
- package/dist/modules/math.js +0 -2
- package/dist/modules/math.js.map +0 -1
- package/dist/modules/matrix.esm.js +0 -2
- package/dist/modules/matrix.esm.js.map +0 -1
- package/dist/modules/matrix.js +0 -2
- package/dist/modules/matrix.js.map +0 -1
- package/dist/modules/number-theory.esm.js +0 -2
- package/dist/modules/number-theory.esm.js.map +0 -1
- package/dist/modules/number-theory.js +0 -2
- package/dist/modules/number-theory.js.map +0 -1
- package/dist/modules/reference/api.d.ts +0 -73
- package/dist/modules/reference/datatype.d.ts +0 -3
- package/dist/modules/reference/index.d.ts +0 -195
- package/dist/modules/reference/shorthand.d.ts +0 -3
- package/dist/modules/sequence.esm.js +0 -2
- package/dist/modules/sequence.esm.js.map +0 -1
- package/dist/modules/sequence.js +0 -2
- package/dist/modules/sequence.js.map +0 -1
- package/dist/modules/src/AutoCompleter/AutoCompleter.d.ts +0 -27
- package/dist/modules/src/Cache.d.ts +0 -16
- package/dist/modules/src/allModules.d.ts +0 -2
- package/dist/modules/src/builtin/bindingNode.d.ts +0 -11
- package/dist/modules/src/builtin/core/array.d.ts +0 -2
- package/dist/modules/src/builtin/core/assertion.d.ts +0 -2
- package/dist/modules/src/builtin/core/bitwise.d.ts +0 -2
- package/dist/modules/src/builtin/core/collection.d.ts +0 -2
- package/dist/modules/src/builtin/core/functional.d.ts +0 -2
- package/dist/modules/src/builtin/core/math.d.ts +0 -2
- package/dist/modules/src/builtin/core/meta.d.ts +0 -3
- package/dist/modules/src/builtin/core/misc.d.ts +0 -2
- package/dist/modules/src/builtin/core/object.d.ts +0 -2
- package/dist/modules/src/builtin/core/predicates.d.ts +0 -2
- package/dist/modules/src/builtin/core/regexp.d.ts +0 -2
- package/dist/modules/src/builtin/core/sequence.d.ts +0 -2
- package/dist/modules/src/builtin/core/string.d.ts +0 -2
- package/dist/modules/src/builtin/core/vector.d.ts +0 -2
- package/dist/modules/src/builtin/index.d.ts +0 -13
- package/dist/modules/src/builtin/interface.d.ts +0 -113
- package/dist/modules/src/builtin/modules/assertion/docs.d.ts +0 -2
- package/dist/modules/src/builtin/modules/assertion/index.d.ts +0 -2
- package/dist/modules/src/builtin/modules/bitwise/index.d.ts +0 -2
- package/dist/modules/src/builtin/modules/collection/index.d.ts +0 -2
- package/dist/modules/src/builtin/modules/convert/index.d.ts +0 -2
- package/dist/modules/src/builtin/modules/functional/index.d.ts +0 -2
- package/dist/modules/src/builtin/modules/grid/docs.d.ts +0 -2
- package/dist/modules/src/builtin/modules/grid/fromArray.d.ts +0 -8
- package/dist/modules/src/builtin/modules/grid/index.d.ts +0 -2
- package/dist/modules/src/builtin/modules/grid/transpose.d.ts +0 -2
- package/dist/modules/src/builtin/modules/interface.d.ts +0 -28
- package/dist/modules/src/builtin/modules/linear-algebra/docs.d.ts +0 -2
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +0 -1
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +0 -2
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +0 -8
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +0 -4
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/dot.d.ts +0 -1
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +0 -7
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +0 -2
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +0 -1
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +0 -10
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/length.d.ts +0 -1
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +0 -1
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/scale.d.ts +0 -1
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/solve.d.ts +0 -8
- package/dist/modules/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +0 -1
- package/dist/modules/src/builtin/modules/linear-algebra/index.d.ts +0 -4
- package/dist/modules/src/builtin/modules/math/index.d.ts +0 -2
- package/dist/modules/src/builtin/modules/matrix/docs.d.ts +0 -2
- package/dist/modules/src/builtin/modules/matrix/helpers/adjugate.d.ts +0 -1
- package/dist/modules/src/builtin/modules/matrix/helpers/band.d.ts +0 -9
- package/dist/modules/src/builtin/modules/matrix/helpers/cofactor.d.ts +0 -1
- package/dist/modules/src/builtin/modules/matrix/helpers/determinant.d.ts +0 -6
- package/dist/modules/src/builtin/modules/matrix/helpers/diagonal.d.ts +0 -1
- package/dist/modules/src/builtin/modules/matrix/helpers/inverse.d.ts +0 -6
- package/dist/modules/src/builtin/modules/matrix/helpers/isBanded.d.ts +0 -11
- package/dist/modules/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +0 -10
- package/dist/modules/src/builtin/modules/matrix/helpers/isIdentity.d.ts +0 -1
- package/dist/modules/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +0 -1
- package/dist/modules/src/builtin/modules/matrix/helpers/isSquare.d.ts +0 -1
- package/dist/modules/src/builtin/modules/matrix/helpers/isSymetric.d.ts +0 -8
- package/dist/modules/src/builtin/modules/matrix/helpers/isTriangular.d.ts +0 -13
- package/dist/modules/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +0 -7
- package/dist/modules/src/builtin/modules/matrix/helpers/minor.d.ts +0 -1
- package/dist/modules/src/builtin/modules/matrix/helpers/norm1.d.ts +0 -1
- package/dist/modules/src/builtin/modules/matrix/helpers/trace.d.ts +0 -8
- package/dist/modules/src/builtin/modules/matrix/index.d.ts +0 -4
- package/dist/modules/src/builtin/modules/number-theory/binomialCefficient.d.ts +0 -1
- package/dist/modules/src/builtin/modules/number-theory/combinations.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/derangements.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/divisors.d.ts +0 -4
- package/dist/modules/src/builtin/modules/number-theory/docs.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/factorial.d.ts +0 -3
- package/dist/modules/src/builtin/modules/number-theory/index.d.ts +0 -4
- package/dist/modules/src/builtin/modules/number-theory/partitions.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/permutations.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/powerSet.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/primeFactors.d.ts +0 -11
- package/dist/modules/src/builtin/modules/number-theory/sequences/abundant.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/bell.d.ts +0 -1
- package/dist/modules/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/catalan.d.ts +0 -1
- package/dist/modules/src/builtin/modules/number-theory/sequences/collatz.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/composite.d.ts +0 -3
- package/dist/modules/src/builtin/modules/number-theory/sequences/deficient.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/factorial.d.ts +0 -1
- package/dist/modules/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +0 -1
- package/dist/modules/src/builtin/modules/number-theory/sequences/geometric.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/golomb.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/happy.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/index.d.ts +0 -27
- package/dist/modules/src/builtin/modules/number-theory/sequences/juggler.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/lucas.d.ts +0 -1
- package/dist/modules/src/builtin/modules/number-theory/sequences/lucky.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/mersenne.d.ts +0 -1
- package/dist/modules/src/builtin/modules/number-theory/sequences/padovan.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/partition.d.ts +0 -1
- package/dist/modules/src/builtin/modules/number-theory/sequences/pell.d.ts +0 -1
- package/dist/modules/src/builtin/modules/number-theory/sequences/perfect.d.ts +0 -1
- package/dist/modules/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +0 -10
- package/dist/modules/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/poligonal.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/prime.d.ts +0 -3
- package/dist/modules/src/builtin/modules/number-theory/sequences/recaman.d.ts +0 -9
- package/dist/modules/src/builtin/modules/number-theory/sequences/sylvester.d.ts +0 -1
- package/dist/modules/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +0 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +0 -1
- package/dist/modules/src/builtin/modules/sequence/index.d.ts +0 -2
- package/dist/modules/src/builtin/modules/string/index.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/bincount.d.ts +0 -9
- package/dist/modules/src/builtin/modules/vector/calcMad.d.ts +0 -1
- package/dist/modules/src/builtin/modules/vector/calcMean.d.ts +0 -1
- package/dist/modules/src/builtin/modules/vector/calcMedad.d.ts +0 -1
- package/dist/modules/src/builtin/modules/vector/calcMedian.d.ts +0 -1
- package/dist/modules/src/builtin/modules/vector/calcStdDev.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/calcVariance.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/docs.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/entropy.d.ts +0 -8
- package/dist/modules/src/builtin/modules/vector/histogram.d.ts +0 -9
- package/dist/modules/src/builtin/modules/vector/index.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/mode.d.ts +0 -6
- package/dist/modules/src/builtin/modules/vector/outliers.d.ts +0 -7
- package/dist/modules/src/builtin/modules/vector/percentile.d.ts +0 -7
- package/dist/modules/src/builtin/modules/vector/quartiles.d.ts +0 -1
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/index.d.ts +0 -13
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +0 -5
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/mad.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/mean.d.ts +0 -4
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/medad.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/median.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/prod.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/rms.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +0 -3
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/span.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +0 -3
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/sum.d.ts +0 -2
- package/dist/modules/src/builtin/modules/vector/reductionFunctions/variance.d.ts +0 -3
- package/dist/modules/src/builtin/normalExpressions/index.d.ts +0 -9
- package/dist/modules/src/builtin/normalExpressions/initCoreDvala.d.ts +0 -1
- package/dist/modules/src/builtin/specialExpressionTypes.d.ts +0 -24
- package/dist/modules/src/builtin/specialExpressions/and.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/array.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/block.d.ts +0 -7
- package/dist/modules/src/builtin/specialExpressions/cond.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/defined.d.ts +0 -5
- package/dist/modules/src/builtin/specialExpressions/effect.d.ts +0 -5
- package/dist/modules/src/builtin/specialExpressions/functions.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/if.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/import.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/let.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/loop.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/loops.d.ts +0 -9
- package/dist/modules/src/builtin/specialExpressions/match.d.ts +0 -7
- package/dist/modules/src/builtin/specialExpressions/object.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/or.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/parallel.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/perform.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/qq.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/race.d.ts +0 -6
- package/dist/modules/src/builtin/specialExpressions/recur.d.ts +0 -5
- package/dist/modules/src/builtin/specialExpressions/unless.d.ts +0 -6
- package/dist/modules/src/builtin/utils.d.ts +0 -6
- package/dist/modules/src/bundler/index.d.ts +0 -9
- package/dist/modules/src/bundler/interface.d.ts +0 -15
- package/dist/modules/src/bundler.d.ts +0 -3
- package/dist/modules/src/constants/constants.d.ts +0 -19
- package/dist/modules/src/createDvala.d.ts +0 -47
- package/dist/modules/src/debug.d.ts +0 -115
- package/dist/modules/src/errors.d.ts +0 -24
- package/dist/modules/src/evaluator/ContextStack.d.ts +0 -70
- package/dist/modules/src/evaluator/contentHash.d.ts +0 -21
- package/dist/modules/src/evaluator/dedupSubTrees.d.ts +0 -37
- package/dist/modules/src/evaluator/effectRef.d.ts +0 -27
- package/dist/modules/src/evaluator/effectTypes.d.ts +0 -199
- package/dist/modules/src/evaluator/frames.d.ts +0 -513
- package/dist/modules/src/evaluator/interface.d.ts +0 -14
- package/dist/modules/src/evaluator/serialization.d.ts +0 -38
- package/dist/modules/src/evaluator/standardEffects.d.ts +0 -50
- package/dist/modules/src/evaluator/step.d.ts +0 -175
- package/dist/modules/src/evaluator/suspension.d.ts +0 -92
- package/dist/modules/src/evaluator/trampoline.d.ts +0 -138
- package/dist/modules/src/full.d.ts +0 -16
- package/dist/modules/src/getUndefinedSymbols/index.d.ts +0 -7
- package/dist/modules/src/index.d.ts +0 -23
- package/dist/modules/src/initReferenceData.d.ts +0 -1
- package/dist/modules/src/interface.d.ts +0 -7
- package/dist/modules/src/modules/assertion.d.ts +0 -2
- package/dist/modules/src/modules/bitwise.d.ts +0 -2
- package/dist/modules/src/modules/collection.d.ts +0 -2
- package/dist/modules/src/modules/convert.d.ts +0 -2
- package/dist/modules/src/modules/functional.d.ts +0 -2
- package/dist/modules/src/modules/grid.d.ts +0 -2
- package/dist/modules/src/modules/linear-algebra.d.ts +0 -2
- package/dist/modules/src/modules/math.d.ts +0 -2
- package/dist/modules/src/modules/matrix.d.ts +0 -2
- package/dist/modules/src/modules/number-theory.d.ts +0 -2
- package/dist/modules/src/modules/sequence.d.ts +0 -2
- package/dist/modules/src/modules/string.d.ts +0 -2
- package/dist/modules/src/modules/vector.d.ts +0 -2
- package/dist/modules/src/parser/ParserContext.d.ts +0 -20
- package/dist/modules/src/parser/getPrecedence.d.ts +0 -3
- package/dist/modules/src/parser/helpers.d.ts +0 -19
- package/dist/modules/src/parser/index.d.ts +0 -5
- package/dist/modules/src/parser/subParsers/parseArray.d.ts +0 -3
- package/dist/modules/src/parser/subParsers/parseBindingTarget.d.ts +0 -8
- package/dist/modules/src/parser/subParsers/parseCond.d.ts +0 -4
- package/dist/modules/src/parser/subParsers/parseDo.d.ts +0 -3
- package/dist/modules/src/parser/subParsers/parseExpression.d.ts +0 -5
- package/dist/modules/src/parser/subParsers/parseForOrDoseq.d.ts +0 -4
- package/dist/modules/src/parser/subParsers/parseFunction.d.ts +0 -4
- package/dist/modules/src/parser/subParsers/parseFunctionCall.d.ts +0 -3
- package/dist/modules/src/parser/subParsers/parseIfOrUnless.d.ts +0 -5
- package/dist/modules/src/parser/subParsers/parseImplicitBlock.d.ts +0 -5
- package/dist/modules/src/parser/subParsers/parseLet.d.ts +0 -4
- package/dist/modules/src/parser/subParsers/parseLoop.d.ts +0 -4
- package/dist/modules/src/parser/subParsers/parseMatch.d.ts +0 -4
- package/dist/modules/src/parser/subParsers/parseNumber.d.ts +0 -3
- package/dist/modules/src/parser/subParsers/parseObject.d.ts +0 -3
- package/dist/modules/src/parser/subParsers/parseOperand.d.ts +0 -3
- package/dist/modules/src/parser/subParsers/parseRegexpShorthand.d.ts +0 -3
- package/dist/modules/src/parser/subParsers/parseReservedSymbol.d.ts +0 -3
- package/dist/modules/src/parser/subParsers/parseString.d.ts +0 -4
- package/dist/modules/src/parser/subParsers/parseSymbol.d.ts +0 -3
- package/dist/modules/src/parser/types.d.ts +0 -128
- package/dist/modules/src/resume.d.ts +0 -41
- package/dist/modules/src/retrigger.d.ts +0 -39
- package/dist/modules/src/symbolPatterns.d.ts +0 -2
- package/dist/modules/src/testFramework/index.d.ts +0 -15
- package/dist/modules/src/tokenizer/minifyTokenStream.d.ts +0 -4
- package/dist/modules/src/tokenizer/operators.d.ts +0 -12
- package/dist/modules/src/tokenizer/reservedNames.d.ts +0 -65
- package/dist/modules/src/tokenizer/token.d.ts +0 -82
- package/dist/modules/src/tokenizer/tokenize.d.ts +0 -7
- package/dist/modules/src/tokenizer/tokenizers.d.ts +0 -13
- package/dist/modules/src/tooling.d.ts +0 -51
- package/dist/modules/src/transformer/index.d.ts +0 -2
- package/dist/modules/src/typeGuards/annotatedCollections.d.ts +0 -16
- package/dist/modules/src/typeGuards/array.d.ts +0 -9
- package/dist/modules/src/typeGuards/astNode.d.ts +0 -19
- package/dist/modules/src/typeGuards/dvala.d.ts +0 -26
- package/dist/modules/src/typeGuards/dvalaFunction.d.ts +0 -9
- package/dist/modules/src/typeGuards/index.d.ts +0 -7
- package/dist/modules/src/typeGuards/number.d.ts +0 -66
- package/dist/modules/src/typeGuards/string.d.ts +0 -15
- package/dist/modules/src/untokenizer/index.d.ts +0 -2
- package/dist/modules/src/utils/arity.d.ts +0 -10
- package/dist/modules/src/utils/debug/debugTools.d.ts +0 -1
- package/dist/modules/src/utils/debug/getCodeMarker.d.ts +0 -2
- package/dist/modules/src/utils/debug/getSourceCodeInfo.d.ts +0 -2
- package/dist/modules/src/utils/docString/generateDocString.d.ts +0 -4
- package/dist/modules/src/utils/getAssertionError.d.ts +0 -3
- package/dist/modules/src/utils/index.d.ts +0 -14
- package/dist/modules/src/utils/maybePromise.d.ts +0 -54
- package/dist/modules/src/utils/symbols.d.ts +0 -3
- package/dist/modules/string.esm.js +0 -2
- package/dist/modules/string.esm.js.map +0 -1
- package/dist/modules/string.js +0 -2
- package/dist/modules/string.js.map +0 -1
- package/dist/modules/vector.esm.js +0 -2
- package/dist/modules/vector.esm.js.map +0 -1
- package/dist/modules/vector.js +0 -2
- package/dist/modules/vector.js.map +0 -1
- package/dist/reference/api.d.ts +0 -73
- package/dist/reference/datatype.d.ts +0 -3
- package/dist/reference/index.d.ts +0 -195
- package/dist/reference/shorthand.d.ts +0 -3
- package/dist/src/AutoCompleter/AutoCompleter.d.ts +0 -27
- package/dist/src/Cache.d.ts +0 -16
- package/dist/src/allModules.d.ts +0 -2
- package/dist/src/builtin/bindingNode.d.ts +0 -11
- package/dist/src/builtin/core/array.d.ts +0 -2
- package/dist/src/builtin/core/assertion.d.ts +0 -2
- package/dist/src/builtin/core/bitwise.d.ts +0 -2
- package/dist/src/builtin/core/collection.d.ts +0 -2
- package/dist/src/builtin/core/functional.d.ts +0 -2
- package/dist/src/builtin/core/math.d.ts +0 -2
- package/dist/src/builtin/core/meta.d.ts +0 -3
- package/dist/src/builtin/core/misc.d.ts +0 -2
- package/dist/src/builtin/core/object.d.ts +0 -2
- package/dist/src/builtin/core/predicates.d.ts +0 -2
- package/dist/src/builtin/core/regexp.d.ts +0 -2
- package/dist/src/builtin/core/sequence.d.ts +0 -2
- package/dist/src/builtin/core/string.d.ts +0 -2
- package/dist/src/builtin/core/vector.d.ts +0 -2
- package/dist/src/builtin/index.d.ts +0 -13
- package/dist/src/builtin/interface.d.ts +0 -113
- package/dist/src/builtin/modules/assertion/docs.d.ts +0 -2
- package/dist/src/builtin/modules/assertion/index.d.ts +0 -2
- package/dist/src/builtin/modules/bitwise/index.d.ts +0 -2
- package/dist/src/builtin/modules/collection/index.d.ts +0 -2
- package/dist/src/builtin/modules/convert/index.d.ts +0 -2
- package/dist/src/builtin/modules/functional/index.d.ts +0 -2
- package/dist/src/builtin/modules/grid/docs.d.ts +0 -2
- package/dist/src/builtin/modules/grid/fromArray.d.ts +0 -8
- package/dist/src/builtin/modules/grid/index.d.ts +0 -2
- package/dist/src/builtin/modules/grid/transpose.d.ts +0 -2
- package/dist/src/builtin/modules/interface.d.ts +0 -28
- package/dist/src/builtin/modules/linear-algebra/docs.d.ts +0 -2
- package/dist/src/builtin/modules/linear-algebra/helpers/calcFractionalRanks.d.ts +0 -1
- package/dist/src/builtin/modules/linear-algebra/helpers/collinear.d.ts +0 -2
- package/dist/src/builtin/modules/linear-algebra/helpers/corrleation.d.ts +0 -8
- package/dist/src/builtin/modules/linear-algebra/helpers/covariance.d.ts +0 -4
- package/dist/src/builtin/modules/linear-algebra/helpers/dot.d.ts +0 -1
- package/dist/src/builtin/modules/linear-algebra/helpers/gaussJordanElimination.d.ts +0 -7
- package/dist/src/builtin/modules/linear-algebra/helpers/getUnit.d.ts +0 -2
- package/dist/src/builtin/modules/linear-algebra/helpers/isZeroVector.d.ts +0 -1
- package/dist/src/builtin/modules/linear-algebra/helpers/kendallTau.d.ts +0 -10
- package/dist/src/builtin/modules/linear-algebra/helpers/length.d.ts +0 -1
- package/dist/src/builtin/modules/linear-algebra/helpers/pearsonCorr.d.ts +0 -1
- package/dist/src/builtin/modules/linear-algebra/helpers/scale.d.ts +0 -1
- package/dist/src/builtin/modules/linear-algebra/helpers/solve.d.ts +0 -8
- package/dist/src/builtin/modules/linear-algebra/helpers/subtract.d.ts +0 -1
- package/dist/src/builtin/modules/linear-algebra/index.d.ts +0 -4
- package/dist/src/builtin/modules/math/index.d.ts +0 -2
- package/dist/src/builtin/modules/matrix/docs.d.ts +0 -2
- package/dist/src/builtin/modules/matrix/helpers/adjugate.d.ts +0 -1
- package/dist/src/builtin/modules/matrix/helpers/band.d.ts +0 -9
- package/dist/src/builtin/modules/matrix/helpers/cofactor.d.ts +0 -1
- package/dist/src/builtin/modules/matrix/helpers/determinant.d.ts +0 -6
- package/dist/src/builtin/modules/matrix/helpers/diagonal.d.ts +0 -1
- package/dist/src/builtin/modules/matrix/helpers/inverse.d.ts +0 -6
- package/dist/src/builtin/modules/matrix/helpers/isBanded.d.ts +0 -11
- package/dist/src/builtin/modules/matrix/helpers/isDiagonal.d.ts +0 -10
- package/dist/src/builtin/modules/matrix/helpers/isIdentity.d.ts +0 -1
- package/dist/src/builtin/modules/matrix/helpers/isOrthogonal.d.ts +0 -1
- package/dist/src/builtin/modules/matrix/helpers/isSquare.d.ts +0 -1
- package/dist/src/builtin/modules/matrix/helpers/isSymetric.d.ts +0 -8
- package/dist/src/builtin/modules/matrix/helpers/isTriangular.d.ts +0 -13
- package/dist/src/builtin/modules/matrix/helpers/matrixMultiply.d.ts +0 -7
- package/dist/src/builtin/modules/matrix/helpers/minor.d.ts +0 -1
- package/dist/src/builtin/modules/matrix/helpers/norm1.d.ts +0 -1
- package/dist/src/builtin/modules/matrix/helpers/trace.d.ts +0 -8
- package/dist/src/builtin/modules/matrix/index.d.ts +0 -4
- package/dist/src/builtin/modules/number-theory/binomialCefficient.d.ts +0 -1
- package/dist/src/builtin/modules/number-theory/combinations.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/derangements.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/divisors.d.ts +0 -4
- package/dist/src/builtin/modules/number-theory/docs.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/factorial.d.ts +0 -3
- package/dist/src/builtin/modules/number-theory/index.d.ts +0 -4
- package/dist/src/builtin/modules/number-theory/partitions.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/permutations.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/powerSet.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/primeFactors.d.ts +0 -11
- package/dist/src/builtin/modules/number-theory/sequences/abundant.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/arithmetic.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/bell.d.ts +0 -1
- package/dist/src/builtin/modules/number-theory/sequences/bernoulli.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/catalan.d.ts +0 -1
- package/dist/src/builtin/modules/number-theory/sequences/collatz.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/composite.d.ts +0 -3
- package/dist/src/builtin/modules/number-theory/sequences/deficient.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/factorial.d.ts +0 -1
- package/dist/src/builtin/modules/number-theory/sequences/fibonacci.d.ts +0 -1
- package/dist/src/builtin/modules/number-theory/sequences/geometric.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/golomb.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/happy.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/index.d.ts +0 -27
- package/dist/src/builtin/modules/number-theory/sequences/juggler.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/lookAndSay.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/lucas.d.ts +0 -1
- package/dist/src/builtin/modules/number-theory/sequences/lucky.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/mersenne.d.ts +0 -1
- package/dist/src/builtin/modules/number-theory/sequences/padovan.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/partition.d.ts +0 -1
- package/dist/src/builtin/modules/number-theory/sequences/pell.d.ts +0 -1
- package/dist/src/builtin/modules/number-theory/sequences/perfect.d.ts +0 -1
- package/dist/src/builtin/modules/number-theory/sequences/perfectCube.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/perfectPower.d.ts +0 -10
- package/dist/src/builtin/modules/number-theory/sequences/perfectSquare.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/poligonal.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/prime.d.ts +0 -3
- package/dist/src/builtin/modules/number-theory/sequences/recaman.d.ts +0 -9
- package/dist/src/builtin/modules/number-theory/sequences/sylvester.d.ts +0 -1
- package/dist/src/builtin/modules/number-theory/sequences/thueMorse.d.ts +0 -2
- package/dist/src/builtin/modules/number-theory/sequences/tribonacci.d.ts +0 -1
- package/dist/src/builtin/modules/sequence/index.d.ts +0 -2
- package/dist/src/builtin/modules/string/index.d.ts +0 -2
- package/dist/src/builtin/modules/vector/bincount.d.ts +0 -9
- package/dist/src/builtin/modules/vector/calcMad.d.ts +0 -1
- package/dist/src/builtin/modules/vector/calcMean.d.ts +0 -1
- package/dist/src/builtin/modules/vector/calcMedad.d.ts +0 -1
- package/dist/src/builtin/modules/vector/calcMedian.d.ts +0 -1
- package/dist/src/builtin/modules/vector/calcStdDev.d.ts +0 -2
- package/dist/src/builtin/modules/vector/calcVariance.d.ts +0 -2
- package/dist/src/builtin/modules/vector/docs.d.ts +0 -2
- package/dist/src/builtin/modules/vector/entropy.d.ts +0 -8
- package/dist/src/builtin/modules/vector/histogram.d.ts +0 -9
- package/dist/src/builtin/modules/vector/index.d.ts +0 -2
- package/dist/src/builtin/modules/vector/mode.d.ts +0 -6
- package/dist/src/builtin/modules/vector/outliers.d.ts +0 -7
- package/dist/src/builtin/modules/vector/percentile.d.ts +0 -7
- package/dist/src/builtin/modules/vector/quartiles.d.ts +0 -1
- package/dist/src/builtin/modules/vector/reductionFunctions/entropy.d.ts +0 -2
- package/dist/src/builtin/modules/vector/reductionFunctions/giniCoefficient.d.ts +0 -2
- package/dist/src/builtin/modules/vector/reductionFunctions/index.d.ts +0 -13
- package/dist/src/builtin/modules/vector/reductionFunctions/iqr.d.ts +0 -2
- package/dist/src/builtin/modules/vector/reductionFunctions/kurtosis.d.ts +0 -5
- package/dist/src/builtin/modules/vector/reductionFunctions/mad.d.ts +0 -2
- package/dist/src/builtin/modules/vector/reductionFunctions/mean.d.ts +0 -4
- package/dist/src/builtin/modules/vector/reductionFunctions/medad.d.ts +0 -2
- package/dist/src/builtin/modules/vector/reductionFunctions/median.d.ts +0 -2
- package/dist/src/builtin/modules/vector/reductionFunctions/prod.d.ts +0 -2
- package/dist/src/builtin/modules/vector/reductionFunctions/rms.d.ts +0 -2
- package/dist/src/builtin/modules/vector/reductionFunctions/skewness.d.ts +0 -3
- package/dist/src/builtin/modules/vector/reductionFunctions/span.d.ts +0 -2
- package/dist/src/builtin/modules/vector/reductionFunctions/standardDeviation.d.ts +0 -3
- package/dist/src/builtin/modules/vector/reductionFunctions/sum.d.ts +0 -2
- package/dist/src/builtin/modules/vector/reductionFunctions/variance.d.ts +0 -3
- package/dist/src/builtin/normalExpressions/index.d.ts +0 -9
- package/dist/src/builtin/normalExpressions/initCoreDvala.d.ts +0 -1
- package/dist/src/builtin/specialExpressionTypes.d.ts +0 -24
- package/dist/src/builtin/specialExpressions/and.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/array.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/block.d.ts +0 -7
- package/dist/src/builtin/specialExpressions/cond.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/defined.d.ts +0 -5
- package/dist/src/builtin/specialExpressions/effect.d.ts +0 -5
- package/dist/src/builtin/specialExpressions/functions.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/if.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/import.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/let.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/loop.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/loops.d.ts +0 -9
- package/dist/src/builtin/specialExpressions/match.d.ts +0 -7
- package/dist/src/builtin/specialExpressions/object.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/or.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/parallel.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/perform.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/qq.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/race.d.ts +0 -6
- package/dist/src/builtin/specialExpressions/recur.d.ts +0 -5
- package/dist/src/builtin/specialExpressions/unless.d.ts +0 -6
- package/dist/src/builtin/utils.d.ts +0 -6
- package/dist/src/bundler/index.d.ts +0 -9
- package/dist/src/bundler/interface.d.ts +0 -15
- package/dist/src/bundler.d.ts +0 -3
- package/dist/src/constants/constants.d.ts +0 -19
- package/dist/src/createDvala.d.ts +0 -47
- package/dist/src/debug.d.ts +0 -115
- package/dist/src/errors.d.ts +0 -24
- package/dist/src/evaluator/ContextStack.d.ts +0 -70
- package/dist/src/evaluator/contentHash.d.ts +0 -21
- package/dist/src/evaluator/dedupSubTrees.d.ts +0 -37
- package/dist/src/evaluator/effectRef.d.ts +0 -27
- package/dist/src/evaluator/effectTypes.d.ts +0 -199
- package/dist/src/evaluator/frames.d.ts +0 -513
- package/dist/src/evaluator/interface.d.ts +0 -14
- package/dist/src/evaluator/serialization.d.ts +0 -38
- package/dist/src/evaluator/standardEffects.d.ts +0 -50
- package/dist/src/evaluator/step.d.ts +0 -175
- package/dist/src/evaluator/suspension.d.ts +0 -92
- package/dist/src/evaluator/trampoline.d.ts +0 -138
- package/dist/src/full.d.ts +0 -16
- package/dist/src/getUndefinedSymbols/index.d.ts +0 -7
- package/dist/src/index.d.ts +0 -23
- package/dist/src/initReferenceData.d.ts +0 -1
- package/dist/src/interface.d.ts +0 -7
- package/dist/src/modules/assertion.d.ts +0 -2
- package/dist/src/modules/bitwise.d.ts +0 -2
- package/dist/src/modules/collection.d.ts +0 -2
- package/dist/src/modules/convert.d.ts +0 -2
- package/dist/src/modules/functional.d.ts +0 -2
- package/dist/src/modules/grid.d.ts +0 -2
- package/dist/src/modules/linear-algebra.d.ts +0 -2
- package/dist/src/modules/math.d.ts +0 -2
- package/dist/src/modules/matrix.d.ts +0 -2
- package/dist/src/modules/number-theory.d.ts +0 -2
- package/dist/src/modules/sequence.d.ts +0 -2
- package/dist/src/modules/string.d.ts +0 -2
- package/dist/src/modules/vector.d.ts +0 -2
- package/dist/src/parser/ParserContext.d.ts +0 -20
- package/dist/src/parser/getPrecedence.d.ts +0 -3
- package/dist/src/parser/helpers.d.ts +0 -19
- package/dist/src/parser/index.d.ts +0 -5
- package/dist/src/parser/subParsers/parseArray.d.ts +0 -3
- package/dist/src/parser/subParsers/parseBindingTarget.d.ts +0 -8
- package/dist/src/parser/subParsers/parseCond.d.ts +0 -4
- package/dist/src/parser/subParsers/parseDo.d.ts +0 -3
- package/dist/src/parser/subParsers/parseExpression.d.ts +0 -5
- package/dist/src/parser/subParsers/parseForOrDoseq.d.ts +0 -4
- package/dist/src/parser/subParsers/parseFunction.d.ts +0 -4
- package/dist/src/parser/subParsers/parseFunctionCall.d.ts +0 -3
- package/dist/src/parser/subParsers/parseIfOrUnless.d.ts +0 -5
- package/dist/src/parser/subParsers/parseImplicitBlock.d.ts +0 -5
- package/dist/src/parser/subParsers/parseLet.d.ts +0 -4
- package/dist/src/parser/subParsers/parseLoop.d.ts +0 -4
- package/dist/src/parser/subParsers/parseMatch.d.ts +0 -4
- package/dist/src/parser/subParsers/parseNumber.d.ts +0 -3
- package/dist/src/parser/subParsers/parseObject.d.ts +0 -3
- package/dist/src/parser/subParsers/parseOperand.d.ts +0 -3
- package/dist/src/parser/subParsers/parseRegexpShorthand.d.ts +0 -3
- package/dist/src/parser/subParsers/parseReservedSymbol.d.ts +0 -3
- package/dist/src/parser/subParsers/parseString.d.ts +0 -4
- package/dist/src/parser/subParsers/parseSymbol.d.ts +0 -3
- package/dist/src/parser/types.d.ts +0 -128
- package/dist/src/resume.d.ts +0 -41
- package/dist/src/retrigger.d.ts +0 -39
- package/dist/src/symbolPatterns.d.ts +0 -2
- package/dist/src/testFramework/index.d.ts +0 -15
- package/dist/src/tokenizer/minifyTokenStream.d.ts +0 -4
- package/dist/src/tokenizer/operators.d.ts +0 -12
- package/dist/src/tokenizer/reservedNames.d.ts +0 -65
- package/dist/src/tokenizer/token.d.ts +0 -82
- package/dist/src/tokenizer/tokenize.d.ts +0 -7
- package/dist/src/tokenizer/tokenizers.d.ts +0 -13
- package/dist/src/tooling.d.ts +0 -51
- package/dist/src/transformer/index.d.ts +0 -2
- package/dist/src/typeGuards/annotatedCollections.d.ts +0 -16
- package/dist/src/typeGuards/array.d.ts +0 -9
- package/dist/src/typeGuards/astNode.d.ts +0 -19
- package/dist/src/typeGuards/dvala.d.ts +0 -26
- package/dist/src/typeGuards/dvalaFunction.d.ts +0 -9
- package/dist/src/typeGuards/index.d.ts +0 -7
- package/dist/src/typeGuards/number.d.ts +0 -66
- package/dist/src/typeGuards/string.d.ts +0 -15
- package/dist/src/untokenizer/index.d.ts +0 -2
- package/dist/src/utils/arity.d.ts +0 -10
- package/dist/src/utils/debug/debugTools.d.ts +0 -1
- package/dist/src/utils/debug/getCodeMarker.d.ts +0 -2
- package/dist/src/utils/debug/getSourceCodeInfo.d.ts +0 -2
- package/dist/src/utils/docString/generateDocString.d.ts +0 -4
- package/dist/src/utils/getAssertionError.d.ts +0 -3
- package/dist/src/utils/index.d.ts +0 -14
- package/dist/src/utils/maybePromise.d.ts +0 -54
- package/dist/src/utils/symbols.d.ts +0 -3
- package/dist/testFramework.esm.js +0 -2
- package/dist/testFramework.esm.js.map +0 -1
- package/dist/testFramework.js +0 -2
- package/dist/testFramework.js.map +0 -1
package/dist/full.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";function e(e){if(!e.position||!e.code)return"";const t=e.position.column-1,r=e.code.length-t-1;return`${" ".repeat(Math.max(t,0))}^${" ".repeat(Math.max(r,0))}`}class t extends Error{params;constructor(e){super(`recur, params: ${e}`),Object.setPrototypeOf(this,t.prototype),this.name="RecurSignal",this.params=e}}class r extends Error{sourceCodeInfo;shortMessage;constructor(t,n){const o=t instanceof Error?t.message:`${t}`;super(function(t,r){if(!r)return t;const n=`${r.position.line}:${r.position.column}`;return`${t}${r.filePath?`\n${r.filePath}:${n}`:`\nLocation ${n}`}\n${r.code}\n${e(r)}`}(o,n)),this.shortMessage=o,this.sourceCodeInfo=n,Object.setPrototypeOf(this,r.prototype),this.name="DvalaError"}getCodeMarker(){return this.sourceCodeInfo&&e(this.sourceCodeInfo)}}class n extends r{userMessage;constructor(e,t){super(e,t),this.userMessage=e,Object.setPrototypeOf(this,n.prototype),this.name="UserDefinedError"}}class o extends r{constructor(e,t){super(e,t),Object.setPrototypeOf(this,o.prototype),this.name="AssertionError"}}class a extends r{symbol;constructor(e,t){super(`Undefined symbol '${e}'.`,t),this.symbol=e,Object.setPrototypeOf(this,a.prototype),this.name="UndefinedSymbolError"}}const i={Number:1,String:2,NormalExpression:3,SpecialExpression:4,UserDefinedSymbol:5,NormalBuiltinSymbol:6,SpecialBuiltinSymbol:7,ReservedSymbol:8,Binding:9,Spread:10},s=new Set(Object.values(i));function c(e){return Object.keys(i).find(t=>i[t]===e)}const l=new Set(["UserDefined","Partial","Comp","Constantly","Juxt","Complement","EveryPred","SomePred","Fnull","EffectMatcher","Builtin","SpecialBuiltin","Module"]);const u="^^fn^^",m="^^re^^",p="^^ef^^";function d(e){return null!==e&&"object"==typeof e&&(u in e&&"functionType"in e&&function(e){return"string"==typeof e&&l.has(e)}(e.functionType))}function h(e){return!(!Array.isArray(e)||e.length<2)&&function(e){return"number"==typeof e&&s.has(e)}(e[0])}function g(e){return d(e)?`<function ${e.name||"λ"}>`:h(e)?`${c(e[0])}-node`:null===e?"null":"object"==typeof e&&e instanceof RegExp?`${e}`:"object"==typeof e&&e instanceof Error?e.toString():JSON.stringify(e)}function f(e,t){return e?.sourceCodeInfo??t}function y(e,t,n){return new r(`Expected ${e}, got ${g(t)}.`,f(t,n))}function v(e,t){return b(e,t),e}function b(e,t){if(!function(e){return void 0!==e}(e))throw new r("Unexpected undefined",f(e,t))}function w(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function x(e){return null!==e&&"object"==typeof e&&!!e[u]}function k(e,t){if(!x(e))throw y("DvalaFunction",e,t)}function q(e){return x(e)&&"UserDefined"===e.functionType}function A(e,t){if(!q(e))throw y("UserDefinedFunction",e,t)}function N(e){return void 0!==e}function $(e,t){return E(e,t),e}function E(e,t){if(!N(e))throw y("not undefined",e,t)}function T(e){return Array.isArray(e)||"string"==typeof e}function S(e,t){return z(e,t),e}function z(e,t){if(!T(e))throw y("string or array",e,t)}function j(e){return!(null===e||"object"!=typeof e||Array.isArray(e)||e instanceof RegExp||x(e)||P(e)||D(e))}function I(e,t){if(!j(e))throw y("object",e,t)}function C(e){return T(e)||j(e)}function R(e,t){return M(e,t),e}function M(e,t){if(!C(e))throw y("string, array or object",e,t)}function P(e){return null!==e&&"object"==typeof e&&!!e[m]}function O(e,t){if(!function(e){return P(e)||"string"==typeof e}(e))throw y("string or RegularExpression",e,t)}function D(e){return null!==e&&"object"==typeof e&&!!e[p]}function V(e,t){if(!D(e))throw y("Effect",e,t)}function U(e,t){return F(e,t),e}function F(e,t){if(!function(e){return"number"==typeof e||!!C(e)||!!x(e)}(e))throw y("FunctionLike",e,t)}function W(e,t={}){return"string"==typeof e&&((!t.nonEmpty||0!==e.length)&&(!t.char||1===e.length))}function G(e,t,r={}){if(!W(e,r))throw y(""+(r.nonEmpty?"non empty string":r.char?"character":"string"),e,t)}function B(e,t,r={}){return G(e,t,r),e}function L(e){return"string"==typeof e||"number"==typeof e}function _(e,t){return K(e,t),e}function K(e,t){if(!L(e))throw y("string or number",e,t)}const J={assert:{evaluate:(e,t)=>{const r=e[0],n=2===e.length?e[1]:`${r}`;if(G(n,t),!r)throw new o(n,t);return $(r,t)},arity:{min:1,max:2},docs:{category:"assertion",description:"If $value is falsy it throws `AssertionError` with $message. If no $message is provided, message is set to $value.",returns:{type:"any"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['do assert(0, "Expected a positive value") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-truthy","assertion.assert-true"],hideOperatorForm:!0}}};function H(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 Y(e,t,n={}){if(!H(e,n))throw new r(`Expected ${function(e){if(e.zero)return"zero";const t=function(e){return e.positive?"positive":e.negative?"negative":e.nonNegative?"non negative":e.nonPositive?"non positive":e.nonZero?"non zero":""}(e),r=e.integer?"integer":"number",n=e.finite?"finite":"",o=function(e){return"number"!=typeof e.gt&&"number"!=typeof e.gte||"number"!=typeof e.lt&&"number"!=typeof e.lte?"number"==typeof e.gt||"number"==typeof e.gte?"number"==typeof e.gt?`n > ${e.gt}`:`n >= ${e.gte}`:"number"==typeof e.lt||"number"==typeof e.lte?"number"==typeof e.lt?`n < ${e.lt}`:`n <= ${e.lte}`:"":`${"number"==typeof e.gt?`${e.gt} < n `:`${e.gte} <= n `}${"number"==typeof e.lt?`< ${e.lt}`:`<= ${e.lte}`}`}(e);return[t,n,r,o].filter(e=>!!e).join(" ")}(n)}, got ${g(e)}.`,f(e,t))}function X(e,t,r={}){return Y(e,t,r),e}function Q(e,t){const{min:r}=e;return!("number"==typeof r&&t<r)}function Z(e){return"number"==typeof e||C(e)?re(1):e.arity}function ee(e,t,n){const{min:o,max:a}=e;if("number"==typeof o&&t<o)throw new r(`Wrong number of arguments, expected at least ${o}, got ${g(t)}.`,n);if("number"==typeof a&&t>a)throw new r(`Wrong number of arguments, expected at most ${a}, got ${g(t)}.`,n)}function te(e){return!("number"==typeof e.max&&e.max<2)&&!("number"==typeof e.min&&e.min>2)}function re(e){return{min:e,max:e}}function ne(e,t){return{a:{type:e},b:{type:t}}}const oe={"<<":{evaluate:([e,t],r)=>(Y(e,r,{integer:!0}),Y(t,r,{integer:!0,nonNegative:!0}),e<<t),arity:re(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ne("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Shifts $a arithmetically left by $b bit positions.",seeAlso:[">>",">>>"],examples:["1 << 10","<<(1, 10)","<<(-4, 2)"]}},">>":{evaluate:([e,t],r)=>(Y(e,r,{integer:!0}),Y(t,r,{integer:!0,nonNegative:!0}),e>>t),arity:re(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ne("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Shifts $a arithmetically right by $b bit positions.",seeAlso:["<<",">>>"],examples:["2048 >> 10",">>(2048, 10)",">>>(-16, 2)",">>(4, 10)"]}},">>>":{evaluate:([e,t],r)=>(Y(e,r,{integer:!0}),Y(t,r,{integer:!0,nonNegative:!0}),e>>>t),arity:re(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...ne("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Shifts $a arithmetically right by $b bit positions without sign extension.",seeAlso:["<<",">>"],examples:["-16 >>> 2",">>>(2048, 10)",">>>(-16, 2)",">>>(4, 10)",">>>(-1, 10)"]}},"&":{evaluate:([e,...t],r)=>(Y(e,r,{integer:!0}),t.reduce((e,t)=>(Y(t,r,{integer:!0}),e&t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...ne("integer","integer"),c:{type:"integer",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Returns bitwise `and` of all arguments.",seeAlso:["|","xor","bitwise.bit-not","bitwise.bit-and-not"],examples:["0b0011 & 0b0110","&(0b0011, 0b0110)","&(0b0011, 0b0110, 0b1001)"]}},"|":{evaluate:([e,...t],r)=>(Y(e,r,{integer:!0}),t.reduce((e,t)=>(Y(t,r,{integer:!0}),e|t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...ne("integer","integer"),c:{type:"integer",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Returns bitwise `or` of all arguments.",seeAlso:["&","xor","bitwise.bit-not","bitwise.bit-and-not"],examples:["0b0011 | 0b0110","|(0b0011, 0b0110)","|(0b1000, 0b0100, 0b0010)"]}},xor:{evaluate:([e,...t],r)=>(Y(e,r,{integer:!0}),t.reduce((e,t)=>(Y(t,r,{integer:!0}),e^t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...ne("integer","integer"),c:{type:"integer",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Returns bitwise `xor` of all arguments.",seeAlso:["&","|","bitwise.bit-not","bitwise.bit-and-not"],examples:["0b0011 xor 0b0110","xor(0b0011, 0b0110)","xor(0b11110000, 0b00111100, 0b10101010)"]}}};function ae(e,t){return!!C(e)&&("string"==typeof e||Array.isArray(e)?!!H(t,{integer:!0})&&(t>=0&&t<e.length):!!Object.getOwnPropertyDescriptor(e,t))}function ie(e,t,n){if(K(e,n),K(t,n),"string"==typeof e&&"string"==typeof t)return e<t?-1:e>t?1:0;if("number"==typeof e&&"number"==typeof t)return Math.sign(e-t);throw new r(`Cannot compare values of different types: ${typeof e} and ${typeof t}`,n)}function se(e,t,r){if(e===t)return!0;if("number"==typeof e&&"number"==typeof t)return ge(e,t);if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!se($(e[n],r),$(t[n],r),r))return!1;return!0}if(P(e)&&P(t))return e.s===t.s&&e.f===t.f;if(w(e)&&w(t)){const n=Object.keys(e),o=Object.keys(t);if(n.length!==o.length)return!1;for(let o=0;o<n.length;o+=1){const a=B(n[o],r);if(!se(e[a],t[a],r))return!1}return!0}return!1}function ce(e){return Math.max(0,Math.ceil(e))}function le(e){return e??null}function ue(e){return j(e)?Object.entries(e).reduce((e,t)=>{const[r,n]=t;return e[r]=ue(n),e},{}):Array.isArray(e)?e.map(e=>ue(e)):e}function me(e){return ue(e)}function pe(...e){const t=new Set;for(const r of e)r.forEach(e=>t.add(e));return t}function de(e,t){t.forEach(t=>e.add(t))}const he=1e-10;function ge(e,t,r=he){if(e===t)return!0;const n=Math.abs(e-t);if(0===e||0===t||n<r)return n<r;return n/(Math.abs(e)+Math.abs(t))<r}function fe(e){return Math.abs(e)<he}function ye(e,t=0){const r=e.split("\n");for(;r[0]?.match(/^\s*$/);)r.shift();for(;r[r.length-1]?.match(/^\s*$/);)r.pop();const n=r.reduce((e,t)=>{if(t.match(/^\s*$/))return e;const r=t.match(/^\s*/)[0].length;return Math.min(e,r)},1/0);return r.map(e=>" ".repeat(t)+e.slice(n)).join("\n").trimEnd()}function ve(e,t){if(!Array.isArray(e))throw y("array",e,t)}function be(e,t){if(!function(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e)}(e))throw y("array of strings",e,t)}function we(e,t){if(!function(e){return Array.isArray(e)&&e.every(e=>"string"==typeof e&&1===e.length)}(e))throw y("array of strings",e,t)}const xe={filter:{evaluate:()=>{throw new Error("filter is implemented in Dvala")},arity:re(2),docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function"},coll:{type:"collection"},fun:{type:"function"}},variants:[{argumentNames:["coll","fun"]}],description:"Creates a new collection with all elements that pass the test implemented by $fun.",seeAlso:["collection.filteri","map","sequence.remove"],examples:['\nfilter(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nfilter(\n [5, 10, 15, 20],\n -> $ > 10\n)","\nfilter(\n { a: 1, b: 2 },\n odd?\n)"]}},map:{evaluate:()=>{throw new Error("map is implemented in Dvala")},arity:{min:2},docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function"},colls:{type:"collection",rest:!0,description:"At least one."},fun:{type:"function"}},variants:[{argumentNames:["colls","fun"]}],description:"Creates a new collection populated with the results of calling $fun on every element in $colls.",seeAlso:["collection.mapi","filter","reduce","mapcat","grid.cell-map","grid.cell-mapi"],examples:["[1, 2, 3] map -","[1, 2, 3] map -> -($)",'map(["Albert", "Mojir", 42], str)',"map([1, 2, 3], inc)","map([1, 2, 3], [1, 10, 100], *)","map({ a: 1, b: 2 }, inc)","map({ a: 1, b: 2 }, { a: 10, b: 20 }, +)"]}},reduce:{evaluate:()=>{throw new Error("reduce is implemented in Dvala")},arity:re(3),docs:{category:"collection",returns:{type:"any"},args:{fun:{type:"function"},coll:{type:"collection"},initial:{type:"any"}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Runs $fun function on each element of the $coll, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value.",seeAlso:["collection.reduce-right","collection.reducei","collection.reductions","map","grid.cell-reduce","grid.cell-reducei"],examples:["reduce([1, 2, 3], +, 0)","reduce([], +, 0)","reduce({ a: 1, b: 2 }, +, 0)","\nreduce(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + (even?(value) ? value : 0),\n 0)"]}},get:{evaluate:(e,t)=>{const[r,n]=e,o=le(e[2]);if(K(n,t),null===r)return o;M(r,t);const a=function(e,t){if(j(e)){if("string"==typeof t&&ae(e,t))return le(e[t])}else if(H(t,{nonNegative:!0,integer:!0})&&t>=0&&t<e.length)return le(e[t])}(r,n);return void 0===a?o:a},arity:{min:2,max:3},docs:{category:"collection",returns:{type:"any"},args:{a:{type:"collection"},b:{type:["string","integer"]},"not-found":{type:"any",description:"Default value to return if $b is not found."}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","not-found"]}],description:"Returns value in $a mapped at $b.",seeAlso:["collection.get-in","contains?","find","nth"],examples:["[1, 2, 3] get 1",'{ a: 1 } get "a"','"Albert" get "3"',"\nget(\n [1, 2, 3],\n 1, // Optional comma after last argument\n)","\nget(\n [],\n 1\n)",'\nget(\n [],\n 1,\n "default"\n)','\nget(\n { a: 1 },\n "a"\n)','\nget(\n { a: 1 },\n "b"\n)','\nget(\n { a: 1 },\n "b",\n "default"\n)','\nget(\n null,\n "a"\n)','\nget(\n null,\n "b",\n "default"\n)']}},count:{evaluate:([e],t)=>null===e?0:"string"==typeof e?e.length:(M(e,t),Array.isArray(e)?e.length:Object.keys(e).length),arity:re(1),docs:{category:"collection",returns:{type:"number"},args:{coll:{type:["collection","null"]}},variants:[{argumentNames:["coll"]}],description:"Returns number of elements in $coll.",seeAlso:["empty?"],examples:["count([1, 2, 3])","count([])","count({ a: 1 })",'count("")','count("Albert")',"count(null)"]}},"contains?":{evaluate:([e,t],r)=>null!==e&&(M(e,r),W(e)?(G(t,r),e.includes(t)):T(e)?(E(t,r),!!e.find(e=>se($(e),t,r))):(G(t,r),t in e)),arity:re(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:["collection","null"]},b:{type:["string","integer"]}},variants:[{argumentNames:["a","b"]}],description:"Returns `true` if $a contains $b, otherwise returns `false`. For strings, it checks if substring is included.",seeAlso:["get","find","index-of"],examples:["[1, 2, 3] contains? 1","null contains? 1",'{ a: 1, b: 2 } contains? "a"',"\ncontains?(\n [],\n 1\n)","\ncontains?(\n [1],\n 1\n)","\ncontains?(\n [1, 2, 3],\n 1\n)",'\ncontains?(\n {},\n "a"\n)','\ncontains?(\n { a: 1, b: 2 },\n "a"\n)']}},assoc:{evaluate:([e,t,r],n)=>(M(e,n),K(t,n),E(r,n),function(e,t,r,n){if(M(e,n),K(t,n),Array.isArray(e)||"string"==typeof e){if(Y(t,n,{integer:!0}),Y(t,n,{gte:0}),Y(t,n,{lte:e.length}),"string"==typeof e)return G(r,n,{char:!0}),`${e.slice(0,t)}${r}${e.slice(t+1)}`;const o=[...e];return o[t]=r,o}G(t,n);const o={...e};return o[t]=r,o}(e,t,r,n)),arity:re(3),docs:{category:"collection",returns:{type:"collection"},args:{coll:{type:"collection"},key:{type:["string","number"]},value:{type:"any"},kvs:{type:"any",description:"Key-value pairs to associate.",rest:!0}},variants:[{argumentNames:["coll","key","value"]},{argumentNames:["coll","key","value","kvs"]}],description:"\nAdd or replace the value of element $key to $value in $coll. Repeated for all key-value pairs in $kvs.\nIf $coll is an 'array', $key must be `number` satisfying `0 <=` $key `<= length`.",seeAlso:["collection.assoc-in","dissoc","merge","collection.update"],examples:['\nassoc(\n [1, 2, 3],\n 1,\n "Two"\n)','\nassoc(\n [1, 2, 3],\n 3,\n "Four"\n)','\nassoc(\n { a: 1, b: 2 },\n "a",\n "One")','\nassoc(\n { a: 1, b: 2 },\n "c",\n "Three")','\nassoc(\n "Albert",\n 6,\n "a")']}},"++":{evaluate:(e,t)=>(H(e[0])||M(e[0],t),Array.isArray(e[0])?e.reduce((e,r)=>(ve(r,t),e.concat(r)),[]):L(e[0])?e.reduce((e,r)=>(K(r,t),`${e}${r}`),""):e.reduce((e,r)=>(I(r,t),Object.assign(e,r)),{})),arity:{min:1},docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"collection"},colls:{type:"collection",rest:!0}},variants:[{argumentNames:["a"]},{argumentNames:["a","colls"]}],description:"Concatenates collections into one collection.",seeAlso:["mapcat","str","join","push","sequence.unshift"],examples:['"Albert" ++ " " ++ "Mojir"','"Albert" ++ "Mojir"','++("Albert", "-", "Mojir")','++("Albert")','++("A", "l", "b", "e", "r", "t")',"++([1, 2], [3, 4])","++([], [3, 4])","++([1, 2], [])","++([1, 2], [3, 4], [5, 6])","++([])","++({ a: 1, b: 2 }, { b: 1, c: 2 })","++({}, { a: 1 })"]}}},ke={range:{evaluate:(e,t)=>{const[r,n,o]=e;let a,i,s;Y(r,t,{finite:!0}),1===e.length?(a=0,i=r,s=i>=0?1:-1):2===e.length?(Y(n,t,{finite:!0}),a=r,i=n,s=i>=a?1:-1):(Y(n,t,{finite:!0}),Y(o,t,{finite:!0}),a=r,i=n,s=o,Y(s,t,i>a?{positive:!0}:i<a?{negative:!0}:{nonZero:!0}));const c=[];for(let e=a;s<0?e>i:e<i;e+=s)c.push(e);return c},arity:{min:1,max:3},docs:{category:"array",returns:{type:"number",array:!0},args:{a:{type:"number"},b:{type:"number"},step:{type:"number"}},variants:[{argumentNames:["b"]},{argumentNames:["a","b"]},{argumentNames:["a","b","step"]}],description:"$range creates an array with a range of numbers from $a to $b (exclusive), by $step.\n\n$a defaults to 0.\n$step defaults to 1.",seeAlso:["repeat","vector.linspace"],examples:["range(4)","range(1, 4)","1 range 10","range(0.4, 4.9)","\nrange(\n 0.25, // start value\n 1, // end value (exclusive)\n 0.25, // step value\n)"]}},repeat:{evaluate:([e,t],r)=>{Y(t,r,{integer:!0,nonNegative:!0});const n=[];for(let r=0;r<t;r+=1)n.push(e);return n},arity:re(2),docs:{category:"array",returns:{type:"any",array:!0},args:{a:{type:"any"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],description:"Returns an array with $a repeated $b times.",seeAlso:["range","string.string-repeat"],examples:["repeat(10, 3)","repeat(10, 0)",'"Albert" repeat 5']}},flatten:{evaluate:([e,t],r)=>{ve(e,r);const n=void 0===t||t===Number.POSITIVE_INFINITY?Number.POSITIVE_INFINITY:X(t,r,{integer:!0,nonNegative:!0});return e.flat(n)},arity:{min:1,max:2},docs:{category:"array",returns:{type:"any",array:!0},args:{x:{type:["array","any"],description:"If $x is not an array, `[ ]` is returned."},depth:{type:"integer",description:"The depth level specifying how deep a nested array structure should be flattened. Defaults to `Infinity`."}},variants:[{argumentNames:["x"]},{argumentNames:["x","depth"]}],description:"Takes a nested array $x and flattens it.",seeAlso:["mapcat"],examples:["flatten([1, 2, [3, 4], 5])","flatten([1, [2, [3, [4]]]], 1)","flatten([1, [2, [3, [4]]]], 2)",'\nlet foo = "bar";\nflatten([\n 1,\n " 2 A ",\n [foo, [4, ["ABC"]]],\n 6,\n])'],hideOperatorForm:!0}},mapcat:{evaluate:()=>{throw new Error("mapcat is implemented in Dvala")},arity:re(2),docs:{category:"array",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function"},colls:{type:"collection",array:!0},fun:{type:"function"}},variants:[{argumentNames:["colls","fun"]}],description:"Returns the result of applying concat to the result of applying map to $fun and $colls.",seeAlso:["flatten","map","++"],examples:["[[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]] mapcat reverse","mapcat([[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]], reverse)","[[3, 2, 1, 0,], [6, 5, 4,], [9, 8, 7]] mapcat reverse","\nlet foo = (n) -> do\n [n - 1, n, n + 1]\nend;\n[1, 2, 3] mapcat foo","\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ filter odd?\n)"]}},"moving-fn":{evaluate:()=>{throw new Error("moving-fn is implemented in Dvala")},arity:re(3),docs:{category:"array",returns:{type:"array"},args:{arr:{type:"array"},windowSize:{type:"number",description:"The size of the moving window."},fn:{type:"function"}},variants:[{argumentNames:["arr","windowSize","fn"]}],description:"Returns the result of applying $fn to each moving window of size $windowSize in $arr.",seeAlso:["running-fn","vector.moving-mean"],examples:["moving-fn([1, 2, 3], 2, sum)","moving-fn([1, 2, 3], 1, sum)","moving-fn([1, 2, 3], 3, sum)"]}},"running-fn":{evaluate:()=>{throw new Error("running-fn is implemented in Dvala")},arity:re(2),docs:{category:"array",returns:{type:"array"},args:{a:{type:"array"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns the result of applying $b to each element of $a.",seeAlso:["moving-fn","vector.running-mean"],examples:["running-fn([1, 2, 3], sum)","running-fn([1, 2, 3], max)","running-fn([1, 2, 3], min)"]}}},qe={nth:{evaluate:(e,t)=>{const[r,n]=e,o=le(e[2]);if(Y(n,t,{integer:!0}),null===r)return o;if(z(r,t),n>=0&&n<r.length){return le(r[n])}return o},arity:{min:2,max:3},docs:{category:"sequence",returns:{type:"any"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:["sequence","null"]},n:{type:"integer"},"not-found":{type:"any"}},variants:[{argumentNames:["seq","n"]},{argumentNames:["seq","n","not-found"]}],description:"Accesses element $n of $seq. Accessing out-of-bounds indices returns $not-found, if present, else `null`.",seeAlso:["first","second","last","get","slice"],examples:["[1, 2, 3] nth 1",'"A string" nth 3',"nth([1, 2, 3], 1)","nth([1, 2, 3], 3)","nth([1, 2, 3], -1)","nth([1, 2, 3], 3, 99)",'nth("A string", 1)','nth("A string", 3)','nth("A string", -3)','nth("A string", 30, "X")',"nth(null, 1)",'nth(null, 1, "Default value")']}},first:{evaluate:([e],t)=>{if(null===e)return null;z(e,t);return le(e[0])},arity:re(1),docs:{category:"sequence",returns:{type:"any"},args:{seq:{type:["sequence","null"]}},variants:[{argumentNames:["seq"]}],description:"Returns the first element of $seq. If $seq is empty or `null`, `null` is returned.",seeAlso:["second","last","nth","rest","next"],examples:['first(["Albert", "Mojir", 160, [1, 2]])',"first([])","first(null)"]}},last:{evaluate:([e],t)=>{if(null===e)return null;z(e,t);return le(e.at(-1))},arity:re(1),docs:{category:"sequence",returns:{type:"any"},args:{seq:{type:["sequence","null"]}},variants:[{argumentNames:["seq"]}],description:"Returns the last element of $seq. If $seq is empty, `null` is returned.",seeAlso:["first","second","nth","pop"],examples:['last(["Albert", "Mojir", 160, [1, 2]])',"last([1, 2])","last([1])","last([])","last(null)"]}},pop:{evaluate:([e],t)=>(z(e,t),"string"==typeof e?e.substring(0,e.length-1):e.slice(0,e.length-1)),arity:re(1),docs:{category:"sequence",returns:{type:["sequence","null"],rest:!0},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"Returns a copy of $seq with last element removed. If $seq is empty `null` is returned.",seeAlso:["push","last"],examples:["pop([1, 2, 3])","pop([])"]}},"index-of":{evaluate:([e,t],r)=>{if(E(t,r),null===e)return null;if(z(e,r),"string"==typeof e){G(t,r);const n=e.indexOf(t);return-1!==n?n:null}{const n=e.findIndex(e=>se($(e,r),t),r);return-1!==n?n:null}},arity:re(2),docs:{category:"sequence",returns:{type:["number","null"]},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:["sequence","null"]},x:{type:"any"}},variants:[{argumentNames:["seq","x"]}],description:"Returns the index of $x in $seq. If element is not present in $seq `null` is returned.",seeAlso:["sequence.last-index-of","sequence.position","contains?"],examples:["[[1], [2], [1], [2]] index-of [1]",'index-of(["Albert", "Mojir", 160, [1, 2]], "Mojir")',"index-of([5, 10, 15, 20], 15)","index-of([5, 10, 15, 20], 1)","index-of(null, 1)"]}},push:{evaluate:([e,...t],r)=>(z(e,r),"string"==typeof e?(we(t,r),[e,...t].join("")):[...e,...t]),arity:{min:2},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:"sequence"},values:{type:"any",rest:!0,description:"At least one."}},variants:[{argumentNames:["seq","values"]}],description:"Returns copy of $seq with $values added to the end of it.",seeAlso:["sequence.unshift","pop","++"],examples:["[1, 2, 3] push 4",'"Albert" push "!"',"push([1, 2, 3], 4)","push([1, 2, 3], 4, 5, 6)","\nlet l = [1, 2, 3];\npush(l, 4);\nl"]}},rest:{evaluate:([e],t)=>(z(e,t),Array.isArray(e)?e.length<=1?[]:e.slice(1):e.substring(1)),arity:re(1),docs:{category:"sequence",returns:{type:["sequence","null"]},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"If $seq is an array, returns a new array with all but the first element from $seq.\nIf $seq has less than two elements, an empty array is returned.\nFor string $seq returns all but the first characters in $seq.",seeAlso:["next","first"],examples:['rest(["Albert", "Mojir", 160, [1, 2]])','rest(["Albert"])',"rest([])",'rest("Albert")','rest("A",)','rest("")']}},next:{evaluate:([e],t)=>(z(e,t),Array.isArray(e)?e.length<=1?null:e.slice(1):e.length<=1?null:e.substring(1)),arity:re(1),docs:{category:"sequence",returns:{type:["sequence","null"]},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"If $seq is an array, returns a new array with all but the first element from $seq. If $seq has less than two elements, `null` is returned. For string $seq returns all but the first characters in $seq. If length of string $seq is less than two, `null` is returned.",seeAlso:["rest","first"],examples:['next(["Albert", "Mojir", 160, [1, 2]])','next(["Albert"])',"next([])",'next("Albert")','next("A",)','next("")']}},reverse:{evaluate:([e],t)=>null===e?null:(z(e,t),Array.isArray(e)?[...e].reverse():e.split("").reverse().join("")),arity:re(1),docs:{category:"sequence",returns:{type:["sequence","null"]},args:{seq:{type:["sequence","null"]}},variants:[{argumentNames:["seq"]}],description:"If $seq is an array, creates a new array with the elements from $seq in reversed order. If $seq is a string, returns new reversed string.",seeAlso:["sort"],examples:['reverse(["Albert", "Mojir", 160, [1, 2]])',"reverse([])",'reverse("Albert")',"reverse(null)"]}},second:{evaluate:([e],t)=>null===e?null:(z(e,t),le(e[1])),arity:re(1),docs:{category:"sequence",returns:{type:"any"},args:{seq:{type:["sequence","null"]}},variants:[{argumentNames:["seq"]}],description:"Returns the second element of $seq. If $seq has less than two elements or is `null`, `null` is returned.",seeAlso:["first","last","nth"],examples:['second(["Albert", "Mojir", 160, [1, 2]])',"second([1])","second([])","second(null)"]}},slice:{evaluate:(e,t)=>{const[r,n,o]=e;return z(r,t),Y(n,t,{integer:!0}),2===e.length?(Array.isArray(r),r.slice(n)):(Y(o,t,{integer:!0}),Array.isArray(r),r.slice(n,o))},arity:{min:2,max:3},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence"},start:{type:"integer",description:"Defaults to `0`."},stop:{type:"integer",description:"Defaults to length of sequence + 1."}},variants:[{argumentNames:["seq","start"]},{argumentNames:["seq","start","stop"]}],description:"Returns a copy of a portion of $seq from index $start (inclusive) to $stop (exclusive).",seeAlso:["take","drop","sequence.splice","nth"],examples:["[1, 2, 3, 4, 5] slice 2","slice([1, 2, 3, 4, 5], 2, 4)","slice([1, 2, 3, 4, 5], 2)"]}},some:{evaluate:()=>{throw new Error("some is implemented in Dvala")},arity:re(2),docs:{category:"sequence",returns:{type:"any"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:["sequence","null"]},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns the first element that passes the test implemented by $fun. I no element was found, `null` is returned.",seeAlso:["sequence.position","collection.any?","find"],examples:['\nsome(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nsome(\n [5, 10, 15, 20],\n -> $ > 10\n)","\nsome(\n [1, 2, 3, 4],\n -> $ > 10\n)","\nsome(\n [],\n -> $ > 10\n)","\nsome(\n null,\n -> $ > 10\n)"]}},sort:{evaluate:()=>{throw new Error("sort is implemented in Dvala")},arity:{min:1,max:2},docs:{category:"sequence",returns:{type:"any",rest:!0},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq"]},{argumentNames:["seq","fun"]}],description:"Returns a new sequence with the elements from $seq sorted according to $fun. If no $fun is supplied, builtin `compare` will be used.",seeAlso:["sequence.sort-by","compare","reverse","vector.sort-indices"],examples:["[3, 1, 2] sort (a, b) -> b - a","sort([3, 1, 2])","\nsort(\n [3, 1, 2],\n (a, b) -> cond case a < b then -1 case a > b then 1 case true then -1 end\n)","\nsort(\n [3, 1, 2],\n (a, b) -> cond case a > b then -1 case a < b then 1 case true then -1 end\n)"]}},take:{evaluate:([e,t],r)=>{Y(t,r),z(e,r);const n=Math.max(Math.ceil(t),0);return e.slice(0,n)},arity:re(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},n:{type:"integer"},seq:{type:"sequence"}},variants:[{argumentNames:["seq","n"]}],description:"Constructs a new array/string with the $n first elements from $seq.",seeAlso:["take-last","take-while","drop","slice","sequence.split-at"],examples:["take([1, 2, 3, 4, 5], 3)","[1, 2, 3, 4, 5] take 3","take([1, 2, 3, 4, 5], 0)",'take("Albert", 2)','take("Albert", 50)']}},"take-last":{evaluate:([e,t],r)=>{z(e,r),Y(t,r);const n=Math.max(Math.ceil(t),0),o=e.length-n;return e.slice(o)},arity:re(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},n:{type:"integer"},seq:{type:"sequence"}},variants:[{argumentNames:["seq","n"]}],description:"Constructs a new array with the $n last elements from $seq.",seeAlso:["take","drop-last"],examples:["take-last([1, 2, 3, 4, 5], 3)","[1, 2, 3, 4, 5] take-last 3","take-last([1, 2, 3, 4, 5], 0)"]}},drop:{evaluate:([e,t],r)=>{Y(t,r);const n=Math.max(Math.ceil(t),0);return z(e,r),e.slice(n)},arity:re(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence"},n:{type:"integer"}},variants:[{argumentNames:["seq","n"]}],description:"Constructs a new array/string with the $n first elements dropped from $seq.",seeAlso:["drop-last","drop-while","take","slice","sequence.split-at"],examples:["drop([1, 2, 3, 4, 5], 3)","[1, 2, 3, 4, 5] drop 0",'drop("Albert", 2)','drop("Albert", 50)']}},"drop-last":{evaluate:([e,t],r)=>{z(e,r),Y(t,r);const n=Math.max(Math.ceil(t),0),o=e.length-n;return e.slice(0,o)},arity:re(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence"},n:{type:"integer"}},variants:[{argumentNames:["seq","n"]}],description:"Constructs a new array with the $n last elements dropped from $seq.",seeAlso:["drop","take-last"],examples:["drop-last([1, 2, 3, 4, 5], 3)","[1, 2, 3, 4, 5] drop-last 3","drop-last([1, 2, 3, 4, 5], 0)"]}},"take-while":{evaluate:()=>{throw new Error("take-while is implemented in Dvala")},arity:re(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns the members of $seq in order, stopping before the first one for which `predicate` returns a falsy value.",seeAlso:["take","drop-while","sequence.split-with"],examples:["take-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)","take-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)"]}},"drop-while":{evaluate:()=>{throw new Error("drop-while is implemented in Dvala")},arity:re(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns the members of $seq in order, skipping the fist elements for witch the `predicate` returns a truethy value.",seeAlso:["drop","take-while","sequence.split-with"],examples:["drop-while(\n [1, 2, 3, 2, 1],\n -> $ < 3\n)","drop-while(\n [1, 2, 3, 2, 1],\n -> $ > 3\n)"]}}},Ae=new WeakSet,Ne=new WeakSet,$e=new WeakSet,Ee=new WeakSet,Te=new WeakSet,Se=new WeakSet,ze=new WeakSet;function je(e){return Array.isArray(e)?(Ae.has(e)||(Ie(e),Ve(e)||Oe(e)),e):e}function Ie(e){return!!Array.isArray(e)&&(!!Ne.has(e)||!$e.has(e)&&(e.every(e=>H(e))?(Ae.add(e),Ne.add(e),!0):($e.add(e),!1)))}function Ce(e,t){if(!Ie(e))throw new r(`Expected a vector, but got ${e}`,t)}function Re(e,t){if(!function(e){return!!Ie(e)&&2===e.length}(e))throw new r(`Expected a 2d vector, but got ${e}`,t)}function Me(e,t){if(!function(e){return!!Ie(e)&&3===e.length}(e))throw new r(`Expected a 3d vector, but got ${e}`,t)}function Pe(e,t){if(Ce(e,t),0===e.length)throw new r(`Expected a non empty vector, but got ${e}`,t)}function Oe(e,t){if(!Array.isArray(e))return!1;if(Se.has(e))return!0;if(ze.has(e))return!1;if(0===e.length)return ze.add(e),!1;if(!Array.isArray(e[0]))return ze.add(e),!1;const r=e[0].length;if(0===r)return ze.add(e),!1;for(const n of e){if(!Array.isArray(n))return ze.add(e),!1;if(n.length!==r)return ze.add(e),!1;if(t&&n.some(e=>!t(e)))return!1}return Ae.add(e),Se.add(e),!0}function De(e,t){if(!Oe(e))throw new r(`Expected a grid, but got ${e}`,t)}function Ve(e){return Oe(e,H)?(Ee.add(e),!0):(Array.isArray(e)&&Te.add(e),!1)}function Ue(e,t){if(!Ve(e))throw new r(`Expected a matrix, but got ${e}`,t)}function Fe(e,t){if(!Ve(e))throw new r(`Expected a matrix, but got ${e}`,t);if(e.length!==e[0].length)throw new r(`Expected square matrix, but got ${e.length} and ${e[0].length}`,t)}function We(e,t){let n=!1,o=!1;for(const a of e)if(Ie(a))n=!0;else if(Ve(a))o=!0;else if(!H(a))throw new r("Invalid parameter type: "+typeof a,t);if(o){if(n)throw new r("Cannot mix vector and matrix types",t);let o=null,a=null;for(const n of e)if(Ve(n))if(null===o)o=n.length,a=n[0].length;else if(n.length!==o||n[0].length!==a)throw new r("Matrix dimensions do not match",t);return["matrix",e.map(e=>Ve(e)?e:Array.from({length:o},()=>Array.from({length:a},()=>e)))]}if(n){let n=null;for(const o of e)if(Ie(o))if(null===n)n=o.length;else if(o.length!==n)throw new r("Vector lengths do not match",t);return["vector",e.map(e=>Ie(e)?e:Array.from({length:n},()=>e))]}return["number",e]}function Ge(e){return(t,r)=>{const[n,o]=We(t,r);return"number"===n?e(o[0]):"vector"===n?o[0].map(t=>e(t)):o[0].map(t=>t.map(t=>e(t)))}}function Be(e){return(t,r)=>{const[n,o]=We(t,r);return"number"===n?e(o[0],o[1]):"vector"===n?o[0].map((t,r)=>e(t,o[1][r])):o[0].map((t,r)=>t.map((t,n)=>e(t,o[1][r][n])))}}function Le(e,t){return(r,n)=>{if(0===r.length)return e;const[o,a]=We(r,n);if("number"===o)return a.reduce((e,r)=>t(e,r),e);if("vector"===o){const[e,...r]=a;return r.reduce((e,r)=>e.map((e,n)=>t(e,r[n])),e)}{const[e,...r]=a;return r.reduce((e,r)=>e.map((e,n)=>e.map((e,o)=>t(e,r[n][o]))),e)}}}const _e={inc:{evaluate:Ge(e=>e+1),arity:re(1),docs:{category:"math",returns:{type:"number"},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `inc` function increments its argument by 1, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it increases each element by 1 while preserving the original structure.",seeAlso:["dec","+"],examples:["inc(0)","inc(1)","inc(100.1)","inc([1, 2, 3])","inc([[1, 2], [3, 4]])"]}},dec:{evaluate:Ge(e=>e-1),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `dec` function decrements its argument by 1, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it decreases each element by 1 while preserving the original structure.",seeAlso:["inc","-"],examples:["dec(0)","dec(1)","dec(100.1)","dec([1, 2, 3])","dec([[1, 2], [3, 4]])"]}},"+":{evaluate:Le(0,(e,t)=>e+t),arity:{},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]},xs:{type:["number","vector","matrix"],rest:!0}},variants:[{argumentNames:["xs"]}],description:"The `+` function performs addition of numbers and element-wise addition of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it adds the scalar to each element of the collection.",seeAlso:["-","*","/","inc"],examples:["1 + 2","1 + 20 + 30","+(1, 2, 3, 4)","+()","+(1)","[1, 2, 3] + 2","[1, 2, 3] + [4, 5, 6]","[[1, 2, 3], [4, 5, 6]] + [[7, 8, 9], [10, 11, 12]]","[[1, 2, 3], [4, 5, 6]] + 2"]}},"*":{evaluate:Le(1,(e,t)=>e*t),arity:{},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]},xs:{type:["number","vector","matrix"],rest:!0}},variants:[{argumentNames:["xs"]}],description:"The `*` function performs multiplication of `numbers` and element-wise multiplication of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it multiplies each element of the collection by the scalar.",seeAlso:["/","+","-","^"],examples:["6 * 7","-1 * 4","*(4, 7)","*(1, 2, 3, 4, 5)","*()","*(8)","[1, 2, 3] * 2","[1, 2, 3] * [4, 5, 6]","[[1, 2, 3], [4, 5, 6]] * [[7, 8, 9], [10, 11, 12]]","[[1, 2, 3], [4, 5, 6]] * 2"]}},"/":{evaluate:(e,t)=>{if(0===e.length)return 1;const[r,n]=We(e,t);if("number"===r){const[e,...t]=n;return 0===t.length?1/e:t.reduce((e,t)=>e/t,e)}if("vector"===r){const e=n[0];return n.slice(1).reduce((e,t)=>e.map((e,r)=>e/t[r]),e)}{const e=n[0];return n.slice(1).reduce((e,t)=>e.map((e,r)=>e.map((e,n)=>e/t[r][n])),e)}},arity:{},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]},xs:{type:["number","vector","matrix"],rest:!0}},variants:[{argumentNames:["xs"]}],description:"The `/` function performs division of `numbers` and element-wise division of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it divides each element of the collection by the scalar.",seeAlso:["*","+","-","quot","mod","%"],examples:["12 / 100","-1 / 4","/(7, 4)","/(1, 2, 4, 8)","/()","/(8)","[1, 2, 3] / 2","[1, 2, 3] / [4, 5, 6]","[[1, 2, 3], [4, 5, 6]] / [[7, 8, 9], [10, 11, 12]]","[[1, 2, 3], [4, 5, 6]] / 2"]}},"-":{evaluate:(e,t)=>{if(0===e.length)return 0;const[r,n]=We(e,t);if("number"===r){const[e,...t]=n;return 0===t.length?-e:t.reduce((e,t)=>e-t,e)}if("vector"===r){const e=n[0];return n.slice(1).reduce((e,t)=>e.map((e,r)=>e-t[r]),e)}{const e=n[0];return n.slice(1).reduce((e,t)=>e.map((e,r)=>e.map((e,n)=>e-t[r][n])),e)}},arity:{},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]},xs:{type:["number","vector","matrix"],rest:!0}},variants:[{argumentNames:["xs"]}],description:"Computes difference between first value and sum of the rest. When called with only one argument, it does negation.",seeAlso:["+","*","/","dec","abs"],examples:["50 - 8","1 - 1 - 1","-()","-(4, 2)","-(4, 3, 2, 1,)","[1, 2, 3] - 2","[1, 2, 3] - [4, 5, 6]","[[1, 2, 3], [4, 5, 6]] - [[7, 8, 9], [10, 11, 12]]","[[1, 2, 3], [4, 5, 6]] - 2"]}},quot:{evaluate:Be((e,t)=>Math.trunc(e/t)),arity:re(2),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]}},variants:[{argumentNames:["a","b"]}],description:"The `quot` function performs integer division truncated toward zero, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies integer division between each element of the collection and the scalar.",seeAlso:["mod","%","/","trunc"],examples:["quot(5, 3)","quot(5.2, 3.1)","quot(-5, 3)","5 quot -3","-5 quot -3","quot(5, 0)","quot(0, 5)","[1, 2, 3] quot 2","2 quot [1, 2, 3]","quot([1, 2, 3], [4, 5, 6])","[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]","quot([[1, 2, 3], [4, 5, 6]], 2)","[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]"]}},mod:{evaluate:Be((e,t)=>e-t*Math.floor(e/t)),arity:re(2),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]}},variants:[{argumentNames:["a","b"]}],description:"The `mod` function computes the modulo of division with the same sign as the divisor, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the modulo operation between each element of the collection and the scalar.",seeAlso:["%","quot","/"],examples:["mod(5, 3)","mod(5.2, 3.1)","mod(-5, 3)","5 mod -3","-5 mod -3","[1, 2, 3] mod 2","2 mod [1, 2, 3]","mod([1, 2, 3], [4, 5, 6])","[[1, 2, 3], [4, 5, 6]] mod [[7, 8, 9], [10, 11, 12]]","mod([[1, 2, 3], [4, 5, 6]], 2)"]}},"%":{evaluate:Be((e,t)=>e%t),arity:re(2),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]}},variants:[{argumentNames:["a","b"]}],description:"The `%` function computes the remainder of division with the same sign as the dividend, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the remainder operation between each element of the collection and the scalar.",seeAlso:["mod","quot","/"],examples:["5 % 3","5.2 % 3.1","-5 % 3","%(5, -3)","%(-5, -3)","[1, 2, 3] % 2","2 % [1, 2, 3]","%([1, 2, 3], [4, 5, 6])","[[1, 2, 3], [4, 5, 6]] % [[7, 8, 9], [10, 11, 12]]","%([[1, 2, 3], [4, 5, 6]], 2)"]}},sqrt:{evaluate:Ge(e=>Math.sqrt(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `sqrt` function calculates the square root of `numbers` and computes element-wise square roots of `vectors` and `matrices`. When applied to collections, it returns the square root of each element while preserving the original structure.",seeAlso:["cbrt","^"],examples:["sqrt(0)","sqrt(9)","sqrt(2)","sqrt(0)","sqrt(9)","sqrt(2)","sqrt([1, 4, 9])","sqrt([[1, 4], [9, 16]])"]}},cbrt:{evaluate:Ge(e=>Math.cbrt(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `cbrt` function calculates the cube root of `numbers` and computes element-wise cube roots of `vectors` and `matrices`. When applied to collections, it returns the cube root of each element while preserving the original structure.",seeAlso:["sqrt","^"],examples:["cbrt(0)","cbrt(27)","cbrt(2)","cbrt(1)","cbrt(0)","cbrt(27)","cbrt(2)","cbrt(1)","cbrt([1, 8, 27])","cbrt([[1, 8], [27, 64]])"]}},"^":{evaluate:Be((e,t)=>e**t),arity:re(2),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:["number","vector","matrix"]}},variants:[{argumentNames:["a","b"]}],description:"The ^ function computes exponentiation, raising the first argument to the power of the second, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the power operation between each element of the collection and the scalar.",seeAlso:["sqrt","cbrt","*","math.ln"],examples:["2 ^ 3","2 ^ 0","2 ^ -3","^(-2, 3)","^(-2, -3)","[1, 2, 3] ^ 2","2 ^ [1, 2, 3]","^([1, 2, 3], [4, 5, 6])","[[1, 2, 3], [4, 5, 6]] ^ [[7, 8, 9], [10, 11, 12]]","^([[1, 2, 3], [4, 5, 6]], 2)"]}},round:{evaluate:([e,t],r)=>{const[n,o]=We([e],r);if("number"===n){if(void 0===t||0===t)return Math.round(o[0]);{Y(t,r,{integer:!0,positive:!0});const e=10**t;return Math.round(o[0]*e)/e}}if("vector"===n){const e=o[0];if(void 0===t||0===t)return e.map(e=>Math.round(e));{Y(t,r,{integer:!0,positive:!0});const n=10**t;return e.map(e=>Math.round(e*n)/n)}}{const e=o[0];if(void 0===t||0===t)return e.map(e=>e.map(e=>Math.round(e)));{Y(t,r,{integer:!0,positive:!0});const n=10**t;return e.map(e=>e.map(e=>Math.round(e*n)/n))}}},arity:{min:1,max:2},docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{a:{type:["number","vector","matrix"]},b:{type:"integer"}},variants:[{argumentNames:["a"]},{argumentNames:["a","b"]}],description:"The `round` function rounds a `number` to the nearest `integer` or to a specified number of `decimal` places, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it rounds each element while preserving the original structure.",seeAlso:["floor","ceil","trunc"],examples:["round(2)","round(2.49)","round(2.5)","round(-2.49)","round(-2.5)","round(-2.501)","round(1.23456789, 4)","1.123456789 round 2","round([1.23456789, 2.3456789], 1)","[1.23456789, 2.3456789] round 4","[[1.23456789, 2.3456789], [3.456789, 4.56789]] round 4","round([[1.23456789, 2.3456789], [3.456789, 4.56789]], 2)"]}},trunc:{evaluate:Ge(e=>Math.trunc(e)),arity:re(1),docs:{category:"math",returns:{type:["integer","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `trunc` function truncates `numbers` toward zero (removing decimal portions without rounding), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it truncates each element while preserving the original structure.",seeAlso:["round","floor","ceil","quot"],examples:["trunc(2)","trunc(2.49)","trunc(2.5)","trunc(-2.49)","trunc(-2.5)","trunc(-2.501)","trunc([1.23456789, 2.3456789])","trunc([[1.23456789, 2.3456789], [3.456789, 4.56789]])"]}},floor:{evaluate:Ge(e=>Math.floor(e)),arity:re(1),docs:{category:"math",returns:{type:["integer","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `floor` function returns the largest `integer` less than or equal to a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the floor of each element while preserving the original structure.",seeAlso:["ceil","round","trunc"],examples:["floor(2)","floor(2.49)","floor(2.5)","floor(-2.49)","floor(-2.5)","floor(-2.501)","floor([1.23456789, 2.3456789])","floor([[1.23456789, 2.3456789], [3.456789, 4.56789]])"]}},ceil:{evaluate:Ge(e=>Math.ceil(e)),arity:re(1),docs:{category:"math",returns:{type:["integer","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `ceil` function returns the smallest `integer` greater than or equal to a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the ceiling of each element while preserving the original structure.",seeAlso:["floor","round","trunc"],examples:["ceil(2)","ceil(2.49)","ceil(2.5)","ceil(-2.49)","ceil(-2.5)","ceil(-2.501)","ceil([1.23456789, 2.3456789])","ceil([[1.23456789, 2.3456789], [3.456789, 4.56789]])"]}},min:{evaluate:(e,t)=>{if(1===e.length&&Ie(e[0])){const r=e[0];return Pe(r,t),r.reduce((e,t)=>Math.min(e,t),1/0)}const[r,...n]=e;return Y(r,t),n.reduce((e,r)=>(Y(r,t),Math.min(e,r)),r)},arity:{min:1},docs:{category:"math",returns:{type:"number"},args:{a:{type:"number"},b:{type:"number"},xs:{type:"number",rest:!0},vector:{type:"vector"}},variants:[{argumentNames:["xs"]},{argumentNames:["vector"]}],description:"Returns the smallest value. Accepts either multiple numbers or a single vector of numbers.",seeAlso:["max","vector.span","vector.min-index"],examples:["2 min 3","min(2, 0, 1)","min(2, -1, 1)","min([2, 0, -1])","12 min 14"]}},max:{evaluate:(e,t)=>{if(1===e.length&&Ie(e[0])){const r=e[0];return Pe(r,t),r.reduce((e,t)=>Math.max(e,t),-1/0)}const[r,...n]=e;return Y(r,t),n.reduce((e,r)=>(Y(r,t),Math.max(e,r)),r)},arity:{min:1},docs:{category:"math",returns:{type:"number"},args:{a:{type:"number"},b:{type:"number"},xs:{type:"number",rest:!0},vector:{type:"vector"}},variants:[{argumentNames:["xs"]},{argumentNames:["vector"]}],description:"Returns the largest value. Accepts either multiple numbers or a single vector of numbers.",seeAlso:["min","vector.span","vector.max-index"],examples:["2 max 3","max(2, 0, 1)","max(2, -1, 1)","max([2, 0, -1])","4 max 2"]}},abs:{evaluate:Ge(e=>Math.abs(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The abs function returns the absolute value (magnitude) of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the absolute value of each element while preserving the original structure.",seeAlso:["sign","-"],examples:["abs(-2.3)","abs(0)","abs(2.5)","abs([1, -2, 3])","abs([[1, -2], [3, -4]])"]}},sign:{evaluate:Ge(e=>Math.sign(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `sign` function returns the `sign` of a `number` (-1 for negative, 0 for zero, 1 for positive), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the sign of each element while preserving the original structure.",seeAlso:["abs"],examples:["sign(-2.3)","sign(-0)","sign(0)","sign(12312)","sign([1, -2, 3])","sign([[1, -2], [3, -4]])"]}}};function Ke([e,...t],r){const n=$(e,r);for(const e of t)if(!se(n,$(e,r),r))return!1;return!0}const Je={"==":{evaluate:(e,t)=>Ke(e,t),arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:"any"},b:{type:"any"},x:{type:"any"},ys:{type:"any",rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if all `values` are structaul equal to each other, otherwise result is `false`.",seeAlso:["!=","identical?"],examples:["1 == 1","[1, 2] == [1, 2]","\n{\n a: 1,\n b: 2,\n} == {\n b: 2,\n a: 1,\n}","==(1, 1)","==(1.01, 1)",'==("1", 1)','==("2", "2", "2", "2")',"==(2, 2, 1, 2)","==([1, 2], [1, 2])","==({ a: 1, b: 2 }, { b: 2, a: 1 })"]}},"!=":{evaluate:(e,t)=>!Ke(e,t),arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:"any"},b:{type:"any"},x:{type:"any"},ys:{type:"any",rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if all `values` are not equal to each other, otherwise result is `false`. `(!= a b c)` is same as `(not (== a b c))`.",seeAlso:["==","identical?"],examples:["1 != 2","3 != 3","!=(3)","!=(3, 3, 2)",'!=("3", "2", "1", "0",)',"!=(0, -0)"]}},"identical?":{evaluate:e=>function([e,...t]){for(const r of t)if(r!==e)return!1;return!0}(e),arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:"any"},b:{type:"any"}},variants:[{argumentNames:["a","b"]}],description:"Returns true if $a and $b are referential equal.",seeAlso:["==","!="],examples:["identical?({ a: 10, b: 20 }, { b: 20, a: 10 })","identical?([1, true, null], [1, true, null])","identical?(0.3, 0.1 + 0.2)"]}},">":{evaluate:([e,...t],r)=>{let n=_(e);for(const e of t){if(ie(n,_(e),r)<=0)return!1;n=_(e)}return!0},arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:["number","string"]},b:{type:["number","string"]},x:{type:["number","string"]},ys:{type:["number","string"],rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if $x and $ys are in decreasing order, `false` otherwise.",seeAlso:["<",">=","<=","compare"],examples:[">(1, 0)",">(1.01, 1)",">(1, 1)",">(4, 3, 2, 1)",">(3, 2, 2, 1)"]}},"<":{evaluate:([e,...t],r)=>{let n=_(e);for(const e of t){if(ie(n,_(e),r)>=0)return!1;n=_(e)}return!0},arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:["number","string"]},b:{type:["number","string"]},x:{type:["number","string"]},ys:{type:["number","string"],rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if $x and $ys are in increasing order, `false` otherwise.",seeAlso:[">",">=","<=","compare"],examples:["<(0, 1)","<(1, 1.01)","<(1, 1)","<(1, 2, 2, 3)",'<("a", "b")']}},">=":{evaluate:([e,...t],r)=>{let n=_(e);for(const e of t){if(ie(n,_(e),r)<0)return!1;n=_(e)}return!0},arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:["number","string"]},b:{type:["number","string"]},x:{type:["number","string"]},ys:{type:["number","string"],rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if $x and $ys are in non increasing order, `false` otherwise.",seeAlso:[">","<","<=","compare"],examples:["1 >= 1","0 >= 1",">=(1, 0)",">=(1.01, 1)",">=(1, 1)",">=(4, 3, 2, 1)",">=(3, 2, 2, 1)"]}},"<=":{evaluate:([e,...t],r)=>{let n=_(e);for(const e of t){if(ie(n,_(e),r)>0)return!1;n=_(e)}return!0},arity:{min:1},docs:{category:"misc",returns:{type:"boolean"},args:{a:{type:["number","string"]},b:{type:["number","string"]},x:{type:["number","string"]},ys:{type:["number","string"],rest:!0}},variants:[{argumentNames:["x"]},{argumentNames:["x","ys"]}],description:"Returns `true` if $x and $ys are in non decreasing order, `false` otherwise.",seeAlso:[">","<",">=","compare"],examples:["1 <= 1","<=(0, 1)","<=(1, 1.01)","<=(1, 1)","<=(1, 2, 3, 4)","<=(1, 2, 2, 3)"]}},not:{evaluate:([e])=>!e,arity:re(1),docs:{category:"misc",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Computes logical negation. Note that any other $x than `false`, `0`, `null` and `''` is truthy.",seeAlso:["boolean"],examples:["not(3)","not(true)",'not("A string")',"not(0)","not(false)","not(null)",'not("")']}},"epoch->iso-date":{evaluate:([e],t)=>(Y(e,t),new Date(e).toISOString()),arity:re(1),docs:{category:"misc",returns:{type:"string"},args:{ms:{type:"number"}},variants:[{argumentNames:["ms"]}],description:"Returns IOS date time string from `ms` (milliseconds elapsed since the UNIX epoch).",seeAlso:["iso-date->epoch"],examples:["epoch->iso-date(1649756230899)","epoch->iso-date(0)"]}},"iso-date->epoch":{evaluate:([e],t)=>{G(e,t);const r=new Date(e).valueOf();return Y(r,t,{finite:!0}),r},arity:re(1),docs:{category:"misc",returns:{type:"number"},args:{iso:{type:"string"}},variants:[{argumentNames:["iso"]}],description:"Returns milliseconds elapsed since the UNIX epoch to `iso`.",seeAlso:["epoch->iso-date"],examples:['iso-date->epoch("2022-04-12T09:37:10.899Z")','iso-date->epoch("1980-01-01")']}},boolean:{evaluate:([e])=>!!e,arity:re(1),docs:{category:"misc",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Coerces $x to boolean.",seeAlso:["not","boolean?","true?","false?"],examples:["boolean(0)","boolean(1)","boolean(null)",'boolean("Albert")']}},compare:{evaluate:([e,t],r)=>(K(e,r),K(t,r),ie(e,t,r)),arity:re(2),docs:{category:"misc",returns:{type:"number"},args:{a:{type:["number","string"]},b:{type:["number","string"]}},variants:[{argumentNames:["a","b"]}],description:"Compares two values. Returns `-1` if $a < $b, `1` if $a > $b and `0` if $a and $b have the same sort order.",seeAlso:["<",">","<=",">=","sort","sequence.sort-by"],examples:["compare(0, 1)","compare(0, 0)","compare(1, 0)",'compare("Albert", "Mojir")']}},"json-parse":{evaluate:([e],t)=>(G(e,t),JSON.parse(e)),arity:re(1),docs:{category:"misc",returns:{type:"any"},args:{x:{type:"string"}},variants:[{argumentNames:["x"]}],description:"Returns `JSON.parse(`$x`)`.",seeAlso:["json-stringify"],examples:['json-parse("[1, 2, 3]")']}},"json-stringify":{evaluate:([e,t],r)=>(E(e,r),void 0===t?JSON.stringify(e):(Y(t,r),JSON.stringify(e,null,t))),arity:{min:1,max:2},docs:{category:"misc",returns:{type:"string"},args:{x:{type:"any"},indent:{type:"integer",description:"Number of spaces to use for indentation."}},variants:[{argumentNames:["x"]},{argumentNames:["x","indent"]}],description:"Returns `JSON.stringify(`$x`)`. If second argument is provided, returns `JSON.stringify(`$x`, null, `$indent`)`.",seeAlso:["json-parse"],examples:["json-stringify([1, 2, 3])","json-stringify({ a: { b: 10 }}, 2)"],hideOperatorForm:!0}},"effect-name":{evaluate:([e],t)=>function(e,t){return V(e,t),e}(e,t).name,arity:re(1),docs:{category:"meta",returns:{type:"string"},args:{e:{type:"any",description:"An effect reference."}},variants:[{argumentNames:["e"]}],description:"Returns the name of an effect reference as a string.",seeAlso:["effect-matcher","effect?"],examples:["effect-name(effect(dvala.error))","effect-name(effect(llm.complete))"]}},"effect-matcher":{evaluate:([e],t)=>{if("string"==typeof e)return{[u]:!0,sourceCodeInfo:t,functionType:"EffectMatcher",matchType:"string",pattern:e,flags:"",arity:re(1)};if(P(e))return{[u]:!0,sourceCodeInfo:t,functionType:"EffectMatcher",matchType:"regexp",pattern:e.s,flags:e.f,arity:re(1)};throw new r("effect-matcher expects a string or regexp pattern",t)},arity:re(1),docs:{category:"meta",returns:{type:"function"},args:{pattern:{type:["string","regexp"],description:"A wildcard pattern or regexp to match against effect names."}},variants:[{argumentNames:["pattern"]}],description:"Returns a predicate function that matches effects by name. If $pattern is a string, uses wildcard matching: no wildcard means exact match, `.*` suffix matches the prefix and all descendants (dot boundary enforced), and `*` alone matches everything. If $pattern is a regexp, tests the effect name against the regexp.",seeAlso:["effect-name","effect?"],examples:['let pred = effect-matcher("dvala.*"); pred(effect(dvala.error))','let pred = effect-matcher("dvala.*"); pred(effect(custom.foo))','let pred = effect-matcher("*"); pred(effect(anything))']}},"type-of":{evaluate:([e])=>null==e?"null":"boolean"==typeof e?"boolean":"number"==typeof e?"number":"string"==typeof e?"string":D(e)?"effect":P(e)?"regexp":x(e)?"function":Array.isArray(e)?"array":"object",arity:re(1),docs:{category:"misc",returns:{type:"string"},args:{x:{type:"any",description:"The value to inspect."}},variants:[{argumentNames:["x"]}],description:'Returns a string representing the type of $x. Possible return values are `"number"`, `"string"`, `"boolean"`, `"null"`, `"array"`, `"object"`, `"function"`, `"regexp"`, and `"effect"`.',seeAlso:["number?","string?","boolean?","null?","array?","object?","function?","regexp?","effect?"],examples:["type-of(42)",'type-of("hello")',"type-of(true)","type-of(null)","type-of([1, 2, 3])","type-of({ a: 1 })","type-of((x) -> x + 1)",'type-of(regexp("^start"))',"type-of(effect(dvala.io.println))"]}}},He={keys:{evaluate:([e],t)=>(I(e,t),Object.keys(e)),arity:re(1),docs:{category:"object",returns:{type:"any",array:!0},args:{obj:{type:"object"}},variants:[{argumentNames:["obj"]}],description:"Returns array of all keys in $obj.",seeAlso:["vals","entries","zipmap","select-keys"],examples:["keys({})",'keys({ x: 10, y: true, z: "A string" })','keys(object("x", 10, "y", true, "z", "A string"))']}},vals:{evaluate:([e],t)=>(I(e,t),Object.values(e)),arity:re(1),docs:{category:"object",returns:{type:"any",array:!0},args:{obj:{type:"object"}},variants:[{argumentNames:["obj"]}],description:"Returns array of all values in $obj.",seeAlso:["keys","entries","zipmap"],examples:["vals({})",'vals({ x: 10, y: true, z: "A string" })','vals(object("x", 10, "y", true, "z", "A string"))']}},entries:{evaluate:([e],t)=>(I(e,t),Object.entries(e)),arity:re(1),docs:{category:"object",returns:{type:"array"},args:{obj:{type:"object"}},variants:[{argumentNames:["obj"]}],description:"Returns nested array of all key - value pairs in $obj.",seeAlso:["keys","vals","zipmap","find"],examples:["entries({})",'entries({ x: 10, y: true, z: "A string" })','entries(object("x", 10, "y", true, "z", "A string"))']}},find:{evaluate:([e,t],r)=>(I(e,r),G(t,r),ae(e,t)?[t,e[t]]:null),arity:re(2),docs:{category:"object",returns:{type:["array","null"]},args:{a:{type:"object"},b:{type:"string"},obj:{type:"object"},key:{type:"string"}},variants:[{argumentNames:["obj","key"]}],description:"Returns entry (key-value pair) for $key, or `null` if $key not present in $obj.",seeAlso:["get","contains?","entries","sequence.position","some"],examples:['{ a: 1, "b": 2 } find "a"','find(object("a", 1, "b", 2), "b")','find(object("a", 1, "b", 2), "c")']}},dissoc:{evaluate:([e,t],r)=>{I(e,r),G(t,r);const n={...e};return delete n[t],n},arity:re(2),docs:{category:"object",returns:{type:"object"},args:{a:{type:"object"},b:{type:"string"},obj:{type:"object"},key:{type:"string"}},variants:[{argumentNames:["obj","key"]}],description:"Return shallow copy of $obj with $key deleted.",seeAlso:["assoc","select-keys"],examples:['{ x: 10, y: 20 } dissoc "y"','dissoc({ x: 10, y: 20 }, "x")','dissoc({ x: 10 }, "y")','\nlet o = { a: 5 };\ndissoc(o, "a");\no']}},merge:{evaluate:(e,t)=>{if(0===e.length)return null;const[r,...n]=e;return I(r,t),n.reduce((e,r)=>(I(r,t),{...e,...r}),{...r})},arity:{min:0},docs:{category:"object",returns:{type:"object"},args:{a:{type:"object"},b:{type:"object"},objs:{type:"object",rest:!0}},variants:[{argumentNames:["objs"]}],description:"Returns a new object created by merging together all arguments.\n\nIf two keys appears in more than one object the value from the last object is used.\nIf no arguments are provided `null` is returned.",seeAlso:["merge-with","assoc"],examples:["{ x: 10 } merge { y: 20 }",'merge(object("x", 10), object("y", 20))','merge(object("x", 10), object("x", 15, "y", 20))']}},"merge-with":{evaluate:()=>{throw new Error("merge-with is implemented in Dvala")},arity:{min:2},docs:{category:"object",returns:{type:"object"},args:{objs:{type:"object",rest:!0},fun:{type:"function"}},variants:[{argumentNames:["objs","fun"]}],description:"\nReturns a new object created by merging together all arguments.\nIf two keys appears in more than one object $fun is used to calculate the new value.\n\nIf no arguments are provided `null` is returned.",seeAlso:["merge"],examples:['merge-with(object("x", 10), object("y", 20), +)','merge-with(object("x", 10), object("x", 15, "y", 20), +)',"merge-with({ x: 10 }, { x: 20 }, { x: 30 }, { x: 40 }, -)"],hideOperatorForm:!0}},zipmap:{evaluate:([e,t],r)=>{be(e,r),ve(t,r);const n=Math.min(e.length,t.length),o={};for(let a=0;a<n;a+=1){o[B(e[a],r)]=le(t[a])}return o},arity:re(2),docs:{category:"object",returns:{type:"object"},args:{a:{type:"array"},b:{type:"array"}},variants:[{argumentNames:["a","b"]}],description:"Returns a new object created by mapping $a to $b.",seeAlso:["entries","keys","vals","sequence.interleave"],examples:['["a", "b", "c"] zipmap [1, 2, 3]','zipmap(["a", "b", "c"], [10, null, [1, 2, 3]])','zipmap(["a", "b", "c"], [1])',"zipmap([], [10, null, [1, 2, 3]])"]}},"select-keys":{evaluate:([e,t],r)=>(be(t,r),I(e,r),t.reduce((t,r)=>(ae(e,r)&&(t[r]=le(e[r])),t),{})),arity:re(2),docs:{category:"object",returns:{type:"object"},args:{a:{type:"object"},b:{type:"array"}},variants:[{argumentNames:["a","b"]}],description:"Returns an object containing only those entries in $a whose key is in $b.",seeAlso:["dissoc","keys"],examples:['{ a: 1, b: 2, c: 3 } select-keys ["a", "b"]','select-keys({ a: 1, b: 2, c: 3 }, ["a", "b"])','select-keys({ a: 1 }, ["a", "b"])']}}},Ye={"function?":{evaluate:([e])=>x(e),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a function, otherwise `false`.",seeAlso:["string?","number?","boolean?","null?","array?","object?","regexp?","type-of"],examples:["function?(+)","function?(/)","function?((x, y) -> x + y)","function?(false)",'function?("false")',"function?([1, 2, 3])"]}},"string?":{evaluate:([e])=>"string"==typeof e,arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a string, otherwise `false`.",seeAlso:["blank?","number?","boolean?","null?","array?","object?","regexp?","function?","collection?","sequence?","type-of"],examples:['string?("")','string?("A string")','string?(true ? "A string" : false)',"string?(false)","string?([1, 2, 3])","string?(100)"]}},"number?":{evaluate:([e])=>"number"==typeof e,arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a number, otherwise `false`.",seeAlso:["integer?","zero?","pos?","neg?","finite?","number","string?","boolean?","null?","function?","type-of"],examples:["number?(0)","number?(2)","number?(-0.12)","number?(false)","number?([1, 2, 3])",'number?("A string")']}},"integer?":{evaluate:([e])=>"number"==typeof e&&H(e,{integer:!0}),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is an integer, otherwise `false`.",seeAlso:["number?","number","even?","odd?"],examples:["integer?(0)","integer?(-12)","integer?(42)","integer?(10.1)","integer?((x, y) -> x + y)","integer?(false)",'integer?("false")',"integer?([1, 2, 3])"]}},"boolean?":{evaluate:([e])=>"boolean"==typeof e,arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a `boolean`, otherwise `false`.",seeAlso:["true?","false?","boolean","string?","number?","null?","function?","type-of"],examples:["boolean?(true)","boolean?(false)","boolean?([1, 2, 3])","boolean?(0)",'boolean?("A string")']}},"null?":{evaluate:([e])=>null==e,arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is `null`, otherwise `false`.",seeAlso:["empty?","not-empty?","string?","number?","boolean?","function?","type-of"],examples:["null?(null)","null?(false)","null?([1, 2, 3])","null?(0)",'null?("A string")']}},"zero?":{evaluate:([e],t)=>(Y(e,t,{finite:!0}),Math.abs(e)<he),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is `0`, otherwise `false`.",seeAlso:["pos?","neg?","even?","number?"],examples:["zero?(0)","zero?(-0.0)","zero?(1)","zero?(0.1)"]}},"pos?":{evaluate:([e],t)=>(Y(e,t,{finite:!0}),e>0),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is greater than `0`, otherwise `false`.",seeAlso:["neg?","zero?","number?"],examples:["pos?(0)","pos?(-0.0)","pos?(1)","pos?(-0.1)"]}},"neg?":{evaluate:([e],t)=>(Y(e,t,{finite:!0}),e<0),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is less than `0`, otherwise `false`.",seeAlso:["pos?","zero?","number?"],examples:["neg?(0)","neg?(-0.0)","neg?(1)","neg?(-0.1)"]}},"even?":{evaluate:([e],t)=>(Y(e,t,{finite:!0}),e%2==0),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is even, otherwise `false`.",seeAlso:["odd?","integer?","zero?"],examples:["even?(0)","even?(-0.0)","even?(-1)","even?(2.1)"]}},"odd?":{evaluate:([e],t)=>(Y(e,t,{finite:!0}),H(e,{integer:!0})&&e%2!=0),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is odd, otherwise `false`.",seeAlso:["even?","integer?"],examples:["odd?(1.0)","odd?(1.001)","odd?(-1)","odd?(2.1)"]}},"array?":{evaluate:([e])=>Array.isArray(e),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is an array, otherwise `false`.",seeAlso:["sequence?","collection?","object?","string?","vector?","matrix?","grid?","function?","type-of"],examples:["array?([])","array?([1, 2, 3])",'array?(object("a", 10))',"array?(42)","array?(10.1)","array?((x, y) -> x + y)"]}},"collection?":{evaluate:([e])=>C(e),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a collection i.e. an array, an object or a string, otherwise `false`.",seeAlso:["sequence?","array?","object?","string?"],examples:["collection?([])","collection?([1, 2, 3])",'collection?(object("a", 10))','collection?("Albert")',"collection?(42)","collection?(10.1)","collection?((x, y) -> x + y)"]}},"sequence?":{evaluate:([e])=>T(e),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a sequence i.e. an array or a string, otherwise `false`.",seeAlso:["collection?","array?","string?"],examples:["sequence?([])","sequence?([1, 2, 3])",'sequence?(object("a", 10))','sequence?("Albert")',"sequence?(42)","sequence?(10.1)","sequence?((x, y) -> x + y)"]}},"object?":{evaluate:([e])=>j(e),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is an object, otherwise `false`.",seeAlso:["collection?","array?","string?","function?","type-of"],examples:['object?(object("a", 10))',"object?(42)","object?(10.1)","object?((x, y) -> x + y)",'object?(#"^start")','object?("false")',"object?([1, 2, 3])"]}},"regexp?":{evaluate:([e])=>P(e),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is a regexp, otherwise `false`.",seeAlso:["regexp","re-match","string?","function?","type-of"],examples:['regexp?(regexp("^start"))','regexp?(#"^start")',"regexp?(-12)","regexp?({})","regexp?(10.1)","regexp?((x, y) -> x + y)","regexp?(false)",'regexp?("false")',"regexp?([1, 2, 3])"]}},"effect?":{evaluate:([e])=>D(e),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is an effect, otherwise `false`.",seeAlso:["effect","effect-name","effect-matcher","perform","type-of"],examples:["effect?(effect(dvala.io.println))","effect?(42)",'effect?("hello")',"effect?(null)","effect?({})","effect?([1, 2, 3])"]}},"finite?":{evaluate:([e],t)=>(Y(e,t),Number.isFinite(e)),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is finite, otherwise `false`.",seeAlso:["positive-infinity?","negative-infinity?","number?"],examples:["finite?(1.0)","finite?(1 / 0)","finite?(-1 / 0)"]}},"positive-infinity?":{evaluate:([e],t)=>(Y(e,t),e===Number.POSITIVE_INFINITY),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x equals positive infinity, otherwise `false`.",seeAlso:["negative-infinity?","finite?"],examples:["positive-infinity?(1.0)","positive-infinity?(1 / 0)","positive-infinity?(-1 / 0)"]}},"negative-infinity?":{evaluate:([e],t)=>(Y(e,t),e===Number.NEGATIVE_INFINITY),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"number"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x equals negative infinity, otherwise `false`.",seeAlso:["positive-infinity?","finite?"],examples:["negative-infinity?(1.0)","negative-infinity?(1 / 0)","negative-infinity?(-1 / 0)"]}},"true?":{evaluate:([e])=>!0===e,arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is `true`, otherwise `false`.",seeAlso:["false?","boolean?","boolean"],examples:["true?(false)","true?(true)","true?(1)","true?(0)"]}},"false?":{evaluate:([e])=>!1===e,arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is `true`, otherwise `false`.",seeAlso:["true?","boolean?","boolean"],examples:["false?(false)","false?(true)","false?(1)","false?(0)"]}},"empty?":{evaluate:([e],t)=>null===e||(M(e,t),"string"==typeof e||Array.isArray(e)?0===e.length:0===Object.keys(e).length),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:["collection","string","null"]}},variants:[{argumentNames:["x"]}],description:"Returns `true` if $x is empty or `null`, otherwise `false`.",seeAlso:["not-empty?","collection.not-empty","null?","blank?","count"],examples:["empty?([])","empty?([1, 2, 3])","empty?({})","empty?({ a: 2 })",'empty?("")','empty?("Albert")',"empty?(null)"]}},"not-empty?":{evaluate:([e],t)=>null!==e&&(M(e,t),"string"==typeof e||Array.isArray(e)?e.length>0:Object.keys(e).length>0),arity:re(1),docs:{category:"predicate",returns:{type:"boolean"},args:{x:{type:["collection","string","null"]}},variants:[{argumentNames:["x"]}],description:"Returns `false` if $x is empty or `null`, otherwise `true`.",seeAlso:["empty?","collection.not-empty","null?"],examples:["not-empty?([])","not-empty?([1, 2, 3])","not-empty?({})","not-empty?({ a: 2 })",'not-empty?("")','not-empty?("Albert")',"not-empty?(null)"]}},"vector?":{evaluate:([e])=>Ie(e),arity:re(1),docs:{category:"predicate",description:"Checks if a value is a `vector`. A `vector` is an array of `numbers`.",seeAlso:["matrix?","grid?","array?"],returns:{type:"boolean"},args:{value:{type:"any",description:"The value to check."}},variants:[{argumentNames:["value"]}],examples:["vector?(1)","vector?([1, 2, 3])",'vector?([1, 2, "3"])']}},"matrix?":{evaluate:([e])=>Ve(e),arity:re(1),docs:{category:"predicate",description:"Checks if a value is a `matrix`. A `matrix` is an array of arrays of `numbers`.",seeAlso:["vector?","grid?","array?"],returns:{type:"boolean"},args:{value:{type:"any",description:"The value to check."}},variants:[{argumentNames:["value"]}],examples:["matrix?(1)","matrix?([1, 2, 3])","matrix?([[1, 2], [3, 4]])",'matrix?([[1, 2], [3, "4"]])',"matrix?([[1, 2], [3]])"]}},"grid?":{evaluate:([e])=>Oe(e),arity:re(1),docs:{category:"predicate",description:"Checks if a `value` is a `grid`. A `grid` is an `array` of `arrays` where all inner `arrays` have the same length.",seeAlso:["vector?","matrix?","array?"],returns:{type:"boolean"},args:{value:{type:"any",description:"The value to check."}},variants:[{argumentNames:["value"]}],examples:['grid?("1")','grid?(["1", 2, 3])','grid?([["1", 2], [3, 4]])','grid?([["1", 2], [3, "4"]])','grid?([["1", 2], [3]])']}}},Xe={regexp:{evaluate:([e,t],n)=>{G(e,n);const o=e||"(?:)",a="string"==typeof t?t:"";try{new RegExp(o,a)}catch(e){throw new r(`Invalid regular expression: ${o} ${a}`,n)}return{[m]:!0,sourceCodeInfo:n,s:o,f:a}},arity:{min:1,max:2},docs:{category:"regular-expression",returns:{type:"regexp"},args:{pattern:{type:"string"},flags:{type:"string",description:"Optional flags for the regular expression. Possible values are the same as Javascript RegExp takes."}},variants:[{argumentNames:["pattern"]},{argumentNames:["pattern","flags"]}],description:"Creates a RegExp from $pattern and $flags.",examples:['regexp("^\\s*(.*)$")','#"^\\s*(.*)$"','regexp("albert", "ig")','#"albert"ig'],seeAlso:["-short-regexp","re-match","replace","replace-all","regexp?"],hideOperatorForm:!0}},"re-match":{evaluate:([e,t],r)=>{if(function(e,t){if(!P(e))throw y("RegularExpression",e,t)}(t,r),!W(e))return null;const n=new RegExp(t.s,t.f).exec(e);return n?[...n]:null},arity:re(2),docs:{category:"regular-expression",returns:{type:"any"},args:{a:{type:"regexp"},b:{type:"string"}},variants:[{argumentNames:["a","b"]}],description:"Matches $b against regular expression $a.\nIf $b is a string and matches the regular expression, a `re-match`-array is returned, otherwise `null` is returned.",seeAlso:["regexp","replace","replace-all","-short-regexp","regexp?"],examples:['re-match(" A string", regexp("^\\\\s*(.*)$"))','re-match(" A string", #"^\\s*(.*)$")','re-match("My name is Albert", #"albert"i)','re-match("My name is Ben", #"albert"i)','re-match(null, #"albert"i)','re-match(1, #"albert"i)','re-match({}, #"albert"i)']}},replace:{evaluate:([e,t,r],n)=>{G(e,n),O(t,n),G(r,n);const o=P(t)?new RegExp(t.s,`${t.f}`):t;return e.replace(o,r)},arity:re(3),docs:{category:"regular-expression",returns:{type:"string"},args:{a:{type:"string"},b:{type:["regexp","string"]},x:{type:"string"}},variants:[{argumentNames:["a","b","x"]}],description:"Returns a new string with first match of regular expression $b replaced by $x.",seeAlso:["replace-all","regexp","re-match","-short-regexp"],examples:['replace("Duck duck", "u", "i")','replace("Duck duck", #"u", "i")','replace("abcABC", regexp("a", "i"), "-")','replace("abcABC", regexp("a", "gi"), "-")','replace("abcABC", #"a"i, "-")','replace("abcABC", #"a"gi, "-")']}},"replace-all":{evaluate:([e,t,r],n)=>{G(e,n),O(t,n),G(r,n);const o=P(t)?new RegExp(t.s,`${t.f.includes("g")?t.f:`${t.f}g`}`):t;return e.replaceAll(o,r)},arity:re(3),docs:{category:"regular-expression",returns:{type:"string"},args:{a:{type:"string"},b:{type:["regexp","string"]},x:{type:"string"}},variants:[{argumentNames:["a","b","x"]}],description:"Returns a new string with all matches of regular expression $b replaced by $x.",seeAlso:["replace","regexp","re-match","-short-regexp"],examples:['replace-all("Duck duck", "u", "i")','replace-all("Duck duck", regexp("u"), "i")','replace-all("abcABC", regexp("a", "i"), "-")','replace-all("abcABC", regexp("a", "gi"), "-")','replace-all("abcABC", #"a"i, "-")','replace-all("abcABC", #"a"gi, "-")']}}},Qe=/^\s*$/,Ze={str:{evaluate:e=>e.reduce((e,t)=>e+(null==t?"":j(t)||Array.isArray(t)?JSON.stringify(t):`${t}`),""),arity:{},docs:{category:"string",returns:{type:"string"},args:{values:{type:"any",rest:!0}},variants:[{argumentNames:["values"]}],description:"Concatenats $values into one string. If `value` equals `null` empty string is returned.",seeAlso:["++","join","string.template","string.string-repeat","number"],examples:['str("A string", ", and another string", " ...and more")','str("Just one string")',"str()",'str(0, false, true, null, #"^kalle", [1, 2, 3], {a: "a"})'],hideOperatorForm:!0}},number:{evaluate:([e],t)=>{G(e,t);const n=Number(e);if(Number.isNaN(n))throw new r(`Could not convert '${e}' to a number.`,t);return n},arity:re(1),docs:{category:"string",returns:{type:"number"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Parses $s to a number.",seeAlso:["str","number?","integer?"],examples:['number("10")','number("010")','number("-1.01")']}},"lower-case":{evaluate:([e],t)=>(G(e,t),e.toLowerCase()),arity:re(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns $s converted to lower case.",seeAlso:["upper-case","string.capitalize"],examples:['lower-case("Albert")','lower-case("")']}},"upper-case":{evaluate:([e],t)=>(G(e,t),e.toUpperCase()),arity:re(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns $s converted to upper case.",seeAlso:["lower-case","string.capitalize"],examples:['upper-case("Albert")','upper-case("")']}},trim:{evaluate:([e],t)=>(G(e,t),e.trim()),arity:re(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns a new string with leading and trailing whitespaces removed.",seeAlso:["string.trim-left","string.trim-right","blank?"],examples:['trim(" Albert ")','trim(" ")','trim("")']}},join:{evaluate:([e,t],r)=>(ve(e,r),e.forEach(e=>K(e,r)),G(t,r),e.join(t)),arity:re(2),docs:{category:"string",returns:{type:"string"},args:{a:{type:"array"},b:{type:"string"},arr:{type:"array"},delimiter:{type:"string"}},variants:[{argumentNames:["arr","delimiter"]}],description:"Returns a new string by concatenating all of the elements in $arr, separated by $delimiter.",seeAlso:["split","str","++","sequence.interpose"],examples:['map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str) join ", "','([0, 1, 2, 3, 4, 5, 6, 7, 8, 9] map str) join ", "','join(["Albert", 10], ", ")','join(["Albert", "Mojir"], " ")','join(map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str), ", ")']}},split:{evaluate:([e,t,r],n)=>{G(e,n),O(t,n),void 0!==r&&Y(r,n,{integer:!0,nonNegative:!0});const o="string"==typeof t?t:new RegExp(t.s,t.f);return e.split(o,r)},arity:{min:2,max:3},docs:{category:"string",returns:{type:"string",array:!0},args:{a:{type:"string"},b:{type:"string"},s:{type:"string"},delimiter:{type:"string"},limit:{type:"integer"}},variants:[{argumentNames:["s","delimiter"]},{argumentNames:["s","delimiter","limit"]}],description:"Divides $s into an array of substrings. The division is done by searching for `delimiter`. If `limit` as provided, at most `limit` number of substrings are returned.",seeAlso:["join","string.split-lines"],examples:['"Albert Mojir" split " "','split("Albert Mojir", " ")','split("abcdefghijklmnopqrstuvw", #"[aoueiy]")','split("0123456789", "")','split("0123456789", "", 5) map number']}},"blank?":{evaluate:([e],t)=>null===e||(G(e,t),Qe.test(e)),arity:re(1),docs:{category:"string",returns:{type:"boolean"},args:{s:{type:["string","null"]}},variants:[{argumentNames:["s"]}],description:"Returns true if $s is null or only contains whitespace characters.",seeAlso:["trim","empty?","string?"],examples:['blank?("")',"blank?(null)",'blank?("\n")','blank?(" ")','blank?(".")']}}},et={"|>":{evaluate:()=>{throw new Error("|> is implemented in Dvala")},arity:re(2),docs:{category:"functional",returns:{type:"any"},args:{a:{type:"any"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Takes a value $a and a function $b, and returns the result of applying $b to $a.",seeAlso:["apply","comp"],examples:["\n1 |> inc |> inc","range(10)\n |> map(_, -> $ ^ 2) // [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]\n |> filter(_, odd?) // [1, 9, 25, 49, 81]\n |> reduce(_, +, 0) // 165\n |> sqrt // 12.84523257866513\n |> round(_, 2)"]}},apply:{evaluate:()=>{throw new Error("apply is implemented in Dvala")},arity:{min:2},docs:{category:"functional",returns:{type:"any"},args:{a:{type:"function"},b:{type:"array"},fun:{type:"function"},args:{type:"array"}},variants:[{argumentNames:["fun","args"]}],description:"Call supplied function $fun with specified arguments $args.",seeAlso:["|>"],examples:["\napply(+, [1, 2, 3])","\napply(\n (x, y) -> sqrt(x ^ 2 + y ^ 2),\n [3, 4]\n)","\n(x, y) -> sqrt(x ^ 2 + y ^ 2) apply [3, 4]"]}},identity:{evaluate:([e])=>le(e),arity:re(1),docs:{category:"functional",returns:{type:"any"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns $x.",seeAlso:["constantly","functional.fnull"],examples:["identity(1)",'identity("Albert")',"identity({ a: 1 })","identity(null)"]}},comp:{evaluate:(e,t)=>(e.forEach(e=>F(e,t)),{[u]:!0,sourceCodeInfo:t,functionType:"Comp",params:e,arity:e.length>0?Z(e.at(-1)):{min:1,max:1}}),arity:{},docs:{category:"functional",returns:{type:"function"},args:{a:{type:"function"},b:{type:"function"},fns:{type:"function",rest:!0}},variants:[{argumentNames:["fns"]}],description:"Takes a variable number of functions and returns a function that is the composition of those.\n\n The returned function takes a variable number of arguments,\n applies the rightmost function to the args,\n the next function (right-to-left) to the result, etc.",seeAlso:["|>","functional.juxt","functional.complement"],examples:["\nlet negative-quotient = comp(-, /);\nnegative-quotient(9, 3)",'\nlet x = { bar: { foo: 42 } };\ncomp("foo", "bar")(x)']}},constantly:{evaluate:([e],t)=>({[u]:!0,sourceCodeInfo:t,functionType:"Constantly",value:le(e),arity:{}}),arity:re(1),docs:{category:"functional",returns:{type:"function"},args:{x:{type:"any"}},variants:[{argumentNames:["x"]}],description:"Returns a function that takes any number of arguments and always returns $x.",seeAlso:["identity","functional.fnull"],examples:["\nlet always-true = constantly(true);\nalways-true(9, 3)"]}}};function tt(e){return ye(`\n ${e.title}\n\n ${e.description.replace(/`(.+?)`/g,"$1").replace(/\$(\w+)/g,"$1").replace(/\*\*\*(.+)\*\*\*/g,"$1").replace(/\*\*(.+)\*\*/g,"$1")}\n\n Signature:\n ${function(e){const{title:t,variants:r,args:n,returns:o}=e,a=!rt(e)&&e._isOperator,i=r.map(r=>{if(rt(e)){const e=r.argumentNames.length>0?`, ${r.argumentNames.map(e=>{let t="";return n[e].rest&&(t+="..."),t+=e,t}).join(", ")}`:"";return` perform(effect(${t})${e}) -> ${nt(o)}`}return`${` ${t}(${r.argumentNames.map(e=>{let t="";return n[e].rest&&(t+="..."),t+=e,t}).join(", ")})`} -> ${nt(o)}`}),s=a?["","Operator:",` a ${t} b -> ${nt(o)}`]:[];return[...i,...s]}(e).join("\n ")}\n\n Arguments:\n ${function(e){return Object.entries(e.args).map(([e,t])=>`${e}: ${nt(t)}`)}(e).join("\n ")}\n\n Examples:\n${e.examples.map(e=>ye(e,4)).join("\n\n")}`)}function rt(e){return"effect"in e}function nt(e){const t=e.type,r=(Array.isArray(t)?t:[t]).join(" | ");return e.array||e.rest?`Array<${r}>`:r}function ot(e,t){return{doc:{evaluate:([r],n)=>{if(b(e),D(r)){const e=`-effect-${r.name}`,n=t[e];return n?tt(n):""}if(F(r,n),!x(r))return"";if("Builtin"===r.functionType){const t=e[r.name];return t?tt(t):""}return"UserDefined"===r.functionType?r.docString:""},arity:re(1),docs:{category:"meta",returns:{type:"string"},args:{value:{type:["function","effect"]}},variants:[{argumentNames:["value"]}],description:"Returns documentation string of the $value. Works on functions and effects.",seeAlso:["arity","with-doc"],examples:["doc(+)","doc(effect(dvala.io.println))",'let add = (x, y) -> x + y with-doc "Adds two numbers.";\ndoc(add)']}},"with-doc":{evaluate:([e,t],r)=>{if(F(e,r),G(t,r),!x(e)||"UserDefined"!==e.functionType)throw new Error("with-doc can only be used with user-defined functions");return{...e,[u]:!0,docString:t}},arity:re(2),docs:{category:"meta",returns:{type:"function"},args:{a:{type:"function"},b:{type:"string"}},variants:[{argumentNames:["a","b"]}],description:"Returns a new function with the documentation string $b attached. The original function is not modified.",seeAlso:["doc"],examples:['((x, y) -> x + y) with-doc "Adds two numbers."','let add = (x, y) -> x + y;\nadd with-doc "Adds x and y."']}},arity:{evaluate:([e],r)=>{if(D(e)){const r=`-effect-${e.name}`,n=t[r];if(!n)return{};const o=n.variants.map(e=>e.argumentNames.length);return{min:Math.min(...o),max:Math.max(...o)}}return F(e,r),x(e)?e.arity:re(1)},arity:re(1),docs:{category:"meta",returns:{type:"object"},args:{value:{type:["function","effect"]}},variants:[{argumentNames:["value"]}],description:"Returns arity of the $value. The arity is an object with the properties: `min` and `max`. If the function has fixed arity, `min` and `max` are equal to the number of required parameters. If no restrictions apply, empty object is returned. Also works on effects.",seeAlso:["doc"],examples:["arity(+)","arity(defined?)","arity(effect(dvala.random.int))","\nlet add = (x, y = 0) -> do\n x + y;\nend;\n\narity(add)","\nlet foo = (k, ...x) -> do\n k + x;\nend;\n arity(foo)"]}}}}const at={sum:{evaluate:([e],t)=>(Ce(e,t),e.reduce((e,t)=>e+t,0)),arity:re(1),docs:{category:"vector",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to sum."}},variants:[{argumentNames:["vector"]}],description:"Returns the **sum** of all elements in the `vector`. Returns `0` for an empty vector.",seeAlso:["prod","mean","median","vector.moving-sum","vector.centered-moving-sum","vector.running-sum","vector.cumsum"],examples:["sum([1, 2, 3, 4, 5])","sum([1, -2, 3])","sum([])"]}},prod:{evaluate:([e],t)=>(Ce(e,t),e.reduce((e,t)=>e*t,1)),arity:re(1),docs:{category:"vector",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to multiply."}},variants:[{argumentNames:["vector"]}],description:"Returns the **product** of all elements in the `vector`. Returns `1` for an empty vector.",seeAlso:["sum","mean","median","vector.moving-prod","vector.centered-moving-prod","vector.running-prod","vector.cumprod"],examples:["prod([1, 2, 3, 4, 5])","prod([1, -2, 3])","prod([])"]}},mean:{evaluate:([e],t)=>(Pe(e,t),e.reduce((e,t)=>e+t,0)/e.length),arity:re(1),docs:{category:"vector",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to calculate the mean of."}},variants:[{argumentNames:["vector"]}],description:"Returns the arithmetic **mean** of all elements in the `vector`. Throws for an empty vector.",seeAlso:["median","sum","prod","vector.moving-mean","vector.centered-moving-mean","vector.running-mean","vector.geometric-mean","vector.harmonic-mean","vector.rms","vector.mode"],examples:["mean([1, 2, 3, 4, 5])","mean([1, -2, 3])"]}},median:{evaluate:([e],t)=>(Pe(e,t),function(e){const t=[...e].sort((e,t)=>e-t),r=Math.floor(t.length/2);return t.length%2==0?(t[r-1]+t[r])/2:t[r]}(e)),arity:re(1),docs:{category:"vector",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to calculate the median of."}},variants:[{argumentNames:["vector"]}],description:"Returns the **median** of all elements in the `vector`. For even-length vectors, returns the average of the two middle values. Throws for an empty vector.",seeAlso:["mean","sum","prod","vector.moving-median","vector.centered-moving-median","vector.running-median","vector.mode","vector.quartiles","vector.percentile","vector.iqr","vector.medad"],examples:["median([1, 2, 3, 4, 5])","median([1, 2, 3, 4])","median([3, 1, 4, 1, 5])"]}}},it={},st={};const ct={...J,...oe,...xe,...ke,...qe,..._e,...ot(it,st),...Je,...He,...Ye,...Xe,...Ze,...et,...at};Object.entries(ct).forEach(([e,t])=>{t.name=e});const lt={...ct},ut={},mt=[];Object.entries(lt).forEach(([e,t],r)=>{ut[e]=r,mt.push(t)});const pt={arity:{},docs:{category:"special-expression",returns:{type:"any"},args:{a:{type:"any"},b:{type:"any"},c:{type:"any",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"\nComputes logical `and`. Evaluation of expressions starts from left.\nAs soon as an `expression` evaluates to a falsy value, the result is returned.\n\nIf all expressions evaluate to truthy values, the value of the last expression is returned.",examples:["true && 1","&&(1, 1)",'&&(3 > 2, "string")','&&(3 < 2, "string")',"&&(true, true, true, true)","&&(true, true, 0, true)"]},evaluateAsNormalExpression:(e,t)=>{let r=!0;for(const n of e)if(r=$(n,t),!r)break;return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},dt={arity:{},docs:{category:"special-expression",customVariants:["cond cond-branch cond-branch ... end"],details:[["cond-branch","case test then body","A branch of the cond expression."],["test","expression","The condition to test."],["body","expressions","The expressions to evaluate if the test is truthy."]],description:"Used for branching. `cond-branches` are tested sequentially from the top. If no branch is tested truthy, `null` is returned.",examples:['\ncond\n case false then "FALSE"\n case true then "TRUE"\nend','\ncond\n case false then "FALSE"\n case null then "null"\nend ?? "TRUE"','\ncond\n case false then "FALSE"\n case null then "null"\nend ?? "TRUE"']},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1].flat(),t,n,o)},ht=11,gt=12,ft=13,yt=14,vt=15,bt=16;function wt(e,t){return e instanceof Promise?e.then(t):t(e)}async function xt(e,t,r,n,o){t.push(await e);for(let e=o+1;e<r.length;e++)t.push(await n(r[e],e));return t}function kt(e,t,r){let n=r;for(let r=0;r<e.length;r++){const o=t(n,e[r],r);if(o instanceof Promise)return qt(o,e,t,r);n=o}return n}async function qt(e,t,r,n){let o=await e;for(let e=n+1;e<t.length;e++)o=await r(o,t[e],e);return o}function At(e,t){for(let r=0;r<e.length;r++){const n=t(e[r],r);if(n instanceof Promise)return Nt(n,e,t,r)}}async function Nt(e,t,r,n){await e;for(let e=n+1;e<t.length;e++)await r(t[e],e)}function $t(e,t){try{const r=e();return r instanceof Promise?r.catch(t):r}catch(e){return t(e)}}function Et(e,t){if(e[0]===ft)Object.values(e[1][0]).forEach(e=>{e[1][1]&&t(e[1][1]),Et(e,t)});else if(e[0]===yt)for(let r=0;r<e[1][0].length;r+=1){const n=e[1][0][r]??null;null!==n&&(n[1][1]&&t(n[1][1]),Et(n,t))}}function Tt(e,t,r){const n=e[2],o={};return wt(St(e,t,r,n,o),()=>o)}function St(e,t,n,o,a){if(e[0]===ft){!function(e,t){if(!w(e))throw new r(`Expected UnknownRecord, got ${g(e)}.`,f(e,t))}(t,o);const i=new Set;let s;return wt(At(Object.entries(e[1][0]),([e,r])=>{if(r[0]===gt)return void(s=r);i.add(e);const c=t[e];return wt(void 0!==c?c:r[1][1]?n(r[1][1]):null,e=>{const t=e??null;return E(t,o),St(r,t,n,o,a)})}),()=>{if(s){const e=Object.entries(t).filter(([e])=>!i.has(e)).reduce((e,[t,r])=>(e[t]=$(r),e),{});a[s[1][0]]=e}})}if(e[0]===yt){let r=null;ve(t,o);const i=[];for(let t=0;t<e[1][0].length;t+=1){const n=e[1][0][t]??null;if(null!==n){if(n[0]===gt){r=t;break}i.push({element:n,index:t})}}return wt(At(i,({element:e,index:r})=>{const i=t[r];return wt(void 0!==i?i:e[1][1]?n(e[1][1]):null,t=>{const r=t??null;return E(r,o),St(e,r,n,o,a)})}),()=>{if(null!==r){const n=t.slice(r),o=e[1][0][r];a[o[1][0]]=n}})}e[0]===gt?a[e[1][0]]=$(t):a[e[1][0][1]]=$(t)}function zt(e){const t={};return jt(e,t),t}function jt(e,t){if(null!==e)if(e[0]===yt)for(const r of e[1][0])jt(r,t);else if(e[0]===ft)for(const r of Object.values(e[1][0]))jt(r,t);else if(e[0]===gt){if(t[e[1][0]])throw new r(`Duplicate binding name: ${e[1][0]}`,e[2]);t[e[1][0]]=!0}else if(e[0]===ht){if(t[e[1][0][1]])throw new r(`Duplicate binding name: ${e[1][0]}`,e[2]);t[e[1][0][1]]=!0}}function It(e,t,r){const n={};return wt(Ct(e,t,r,n),e=>e?n:null)}function Ct(e,t,r,n){if(e[0]===bt)return!0;if(e[0]===vt){const n=e[1][0];return wt(r(n),e=>se(t,e))}if(e[0]===ht){const o=e[1][0],a=e[1][1];if(null==t){if(a)return wt(r(a),e=>(n[o[1]]=$(e),!0));n[o[1]]=t??null}else n[o[1]]=$(t);return!0}if(e[0]===ft){if(!w(t))return!1;const o=new Set;let a;const i=Object.entries(e[1][0]);let s=!0;for(const[e,c]of i)s=wt(s,i=>{if(!i)return!1;if(c[0]===gt)return a=c,!0;o.add(e);const s=t[e];if(void 0===s&&c[0]===vt)return wt(r(c[1][0]),e=>se(void 0,e));return wt(void 0!==s?s:c[1]&&c[1][1]?r(c[1][1]):null,e=>Ct(c,e??null,r,n))});return wt(s,e=>{if(!e)return!1;if(a){const e=Object.entries(t).filter(([e])=>!o.has(e)).reduce((e,[t,r])=>(e[t]=$(r),e),{});n[a[1][0]]=e}return!0})}{const o=e;if(!Array.isArray(t))return!1;const a=o[1][0];let i=null;for(let e=0;e<a.length;e+=1){const t=a[e];if(null!==t&&t[0]===gt){i=e;break}}if(null===i&&t.length!==a.length)return!1;if(null!==i&&t.length<i)return!1;let s=!0;for(let e=0;e<a.length;e+=1){const o=a[e];if(null===o)continue;if(o[0]===gt){n[o[1][0]]=t.slice(e);break}const i=o;s=wt(s,o=>!!o&&Ct(i,$(t[e]),r,n))}return s}}const Rt={arity:{},docs:{category:"special-expression",customVariants:["match value match-branch match-branch ... end"],details:[["value","any","The value to match against patterns."],["match-branch","case pattern [when guard] then body","A branch of the match expression."],["pattern","pattern","A pattern to match: literal, variable, array destructuring, object destructuring, or wildcard (_)."],["guard","expression","An optional guard expression that must be truthy for the match to succeed."],["body","expressions","The expressions to evaluate if the pattern matches."]],description:"Pattern matching expression. Matches `value` against each `pattern` sequentially. If a pattern matches (and the optional `when` guard is truthy), the corresponding `body` is evaluated and its result returned. Bound variables from the pattern are available in the guard and body. If no pattern matches, `null` is returned.",examples:['\nmatch 1\n case 1 then "One"\n case 2 then "Two"\nend','\nmatch [1, 2, 3]\n case [x] then "one element"\n case [x, y] then "two elements"\n case [x, ...xs] then "first: " ++ str(x) ++ " rest: " ++ str(xs)\nend','\nmatch { type: "click", x: 10, y: 20 }\n case { type: "click", x, y } then "Click at " ++ str(x) ++ ", " ++ str(y)\n case { type: "keydown", key } then "Key: " ++ key\n case _ then "unknown event"\nend','\nmatch { role: "admin", name: "Alice" }\n case { role: "admin", name } then "Admin: " ++ name\n case { role, name } when role == "user" then "User: " ++ name\n case _ then "Unknown role"\nend']},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>{const a=new Set;r([e[1][1]],t,n,o).forEach(e=>a.add(e));for(const[i,s,c]of e[1][2]){const e={};Object.assign(e,zt(i));const l=t.create(e);c&&r([c],l,n,o).forEach(e=>a.add(e)),r([s],l,n,o).forEach(e=>a.add(e))}return a}},Mt={category:"special-expression",returns:{type:"boolean"},args:{symbol:{type:"any"}},variants:[{argumentNames:["symbol"]}],description:"Returns `true` if `symbol` is defined, `false` otherwise.\n\nBuilt-in symbols are always considered defined. For user-defined symbols, checks if the symbol exists in the current scope.",examples:["let x = 42; defined?(x)","defined?(x)","defined?(+)"]},Pt={arity:re(1),docs:Mt,getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r([e[1][1]],t,n,o)},Ot={arity:{},docs:{category:"special-expression",customVariants:["do body end","do body with case effect(name) then handler end"],details:[["body","expressions","The expressions to evaluate."],["effect(name)","expression","An expression evaluating to an effect value."],["handler","expression","A function (args) -> result that handles the effect. Its return value resumes the perform call."]],description:"Evaluates `body`. Resulting value is the value of the last expression. Effect handlers can be installed via `with` to intercept `perform` calls.",examples:["\ndo\n let a = 1 + 2 + 3 + 4;\n let b = -> $ * ( $ + 1 );\n b(a)\nend",'\ndo\n perform(effect(dvala.io.println), "hello")\nwith\n case effect(dvala.io.println) then ([msg]) -> null\nend']},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>{const a=r(e[1][1],t.create({}),n,o),i=e[1][2];if(!i||0===i.length)return a;let s=new Set;for(const[e,a]of i){s=pe(s,r([e],t,n,o),r([a],t,n,o))}return pe(a,s)}},Dt={arity:{},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>function(e,t,r,n,o){const a=new Set,i={self:{value:null}};e[0].forEach(e=>{Object.assign(i,zt(e)),Et(e,e=>{de(a,r([e],t,n,o))})});const s=t.create(i),c=r(e[1],s,n,o);return de(a,c),a}(e[1][1],t,r,n,o)};const Vt={arity:{min:2,max:3},docs:{category:"special-expression",customVariants:["if test then true-expr else false-expr","if test then true-expr"],details:[["test","expression","The condition to test."],["true-expr","expression","The expression to evaluate if the test is truthy."],["false-expr","expression","The expression to evaluate if the test is falsy."]],description:"Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is truthy. If $test is falsy `false-expr` is executed, if no `false-expr` exists, `null` is returned.",examples:['\nif true then\n "TRUE"\nelse\n "FALSE"\nend','if false then "TRUE" else "FALSE" end','if true then "TRUE" end','if false then "TRUE" end']},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1].filter(e=>!!e),t,n,o)},Ut={arity:{},docs:{category:"special-expression",customVariants:["unless test then true-expr else false-expr end","unless test true-expr end"],details:[["test","expression","The condition to test."],["true-expr","expression","The expressions to evaluate if the test is falsy."],["false-expr","expression","The expressions to evaluate if the test is truthy."]],description:"Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is falsy. If $test is truthy `false-expr` is executed, if no `false-expr` exists, `null` is returned.",examples:['\nunless true then\n "TRUE"\nelse\n "FALSE"\nend','unless false then "TRUE" else "FALSE" end','unless true then "TRUE" end','unless false then "TRUE" end']},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1].filter(e=>!!e),t,n,o)},Ft={category:"special-expression",customVariants:["let s = value;"],details:[["s","symbol","The name of the variable to bind."],["value","any","The value to bind to the variable."]],description:"\n Binds local variables s to `value`. `value` can be any expression. The scope of the variables is the body of the let expression.",examples:["\nlet a = 1 + 2 + 3 + 4;\nlet b = -> $ * ( $ + 1 );\nb(a)"]},Wt={arity:re(0),docs:Ft,getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>{const a=e[1][1],i=a[1][0],s=a[1][1],c=r([s],t,n,o);return Et(i,e=>{de(c,r([e],t,n,o))}),t.addValues(zt(i),i[2]),c}},Gt={arity:{},docs:{category:"special-expression",customVariants:["loop (bindings) -> body"],details:[["bindings","binding pairs","Comma-separated bindings with initial values, e.g. `n = 10, acc = 0`."],["body","expression","The expression to evaluate repeatedly. Use `recur` to loop back with new values."]],description:"Creates a loop with initial bindings. Use `recur` inside the body to jump back to the loop head with new binding values.\n\nIf `recur` is not called, the loop terminates and returns the value of the body expression.",examples:["loop (n = 10, acc = 0) -> do\n if n == 0 then\n acc\n else\n recur(n - 1, acc + n)\n end\nend","loop (n = 5, acc = 1) -> do\n if n <= 1 then\n acc\n else\n recur(n - 1, acc * n)\n end\nend"]},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>{const a=e[1][1],i=a.reduce((e,t)=>{const r=zt(t[1][0]);return Object.keys(r).forEach(t=>{e[t]={value:!0}}),e},{});return pe(r(a.map(e=>e[1][1]),t,n,o),r([e[1][2]],t.create(i),n,o))}};function Bt(e,t,r,n,o){const a=new Set,i={},[,s,c]=e[1];return s.forEach(e=>{const[s,c,l,u]=e,[m,p]=s[1];r([p],t.create(i),n,o).forEach(e=>a.add(e)),Object.assign(i,zt(m)),c&&c.forEach(e=>{const[s,c]=e[1];r([c],t.create(i),n,o).forEach(e=>a.add(e)),Object.assign(i,zt(s))}),l&&r([l],t.create(i),n,o).forEach(e=>a.add(e)),u&&r([u],t.create(i),n,o).forEach(e=>a.add(e))}),r([c],t.create(i),n,o).forEach(e=>a.add(e)),a}const Lt={category:"special-expression",customVariants:["for (...binding) -> body"],details:[["binding","loop-var in collection [...let-binding] [where whereExpr] [while whileExp]","A for loop binding"],["loop-var","symbol","The name of the loop variable."],["collection","any","The collection to iterate over."],["let-binding","let binding","A let binding to create a local variable."],["whereExpr","expression","An expression that must evaluate to truthy for the loop body to be executed."],["whileExp","expression","An expression that must evaluate to truthy for the loop to continue."],["body","expressions","The expressions to evaluate for each iteration of the loop."]],returns:{type:"any",array:!0},description:"Iterates over `bindings`, evaluates `body` for each `binding` and returns an `array` of results.",examples:["\nfor (i in [1, 2, 3]) -> i * 2\n ","\nfor (\n i in range(10) let ii = i ^ 2 while ii < 40 when ii % 3 == 0,\n j in range(10) when j % 2 == 1\n) -> ii + j\n "]},_t={arity:re(1),docs:Lt,getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>Bt(e,t,r,n,o)},Kt={category:"special-expression",customVariants:["doseq (...binding) -> body"],details:[["binding","loop-var in collection [...let-binding] [where whereExpr] [while whileExp]","A doseq loop binding"],["loop-var","symbol","The name of the loop variable."],["collection","any","The collection to iterate over."],["let-binding","let binding","A let binding to create a local variable."],["whereExpr","expression","An expression that must evaluate to truthy for the loop body to be executed."],["whileExp","expression","An expression that must evaluate to truthy for the loop to continue."],["body","expressions","The expressions to evaluate for each iteration of the loop."]],returns:{type:"null"},description:"Iterates over `bindings`, evaluates `body` for each `binding` and returns `null`. This is useful for side effects.",examples:["\ndoseq (i in [1, 2, 3]) -> perform(effect(dvala.io.println), i * 2)\n "]},Jt={arity:re(1),docs:Kt,getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>Bt(e,t,r,n,o)},Ht={arity:{},docs:{category:"special-expression",returns:{type:"boolean"},args:{a:{type:"any"},b:{type:"any"},c:{type:"any",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"\n Computes logical `or`. Evaluation of expressions evaluation starts from left.\n As soon as a `expression` evaluates to a truthy value, the result is returned.\n\n If all expressions evaluate to falsy values, the value of the last expression is returned.",examples:["false || 1","||(1, 1)",'||(3 > 2, "string")','||(3 < 2, "string")',"||(false, false, false, true)","||(1, 2, 3, 4)"]},evaluateAsNormalExpression:(e,t)=>{let r=!1;for(const n of e)if(r=$(n,t),r)break;return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},Yt={arity:{min:1},docs:{category:"special-expression",returns:{type:"any"},args:{a:{type:"any"},b:{type:"any"},c:{type:"any",rest:!0}},variants:[{argumentNames:["a"]},{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Nullish coalescing operator. Returns the first non-`null` value.\n\nEvaluation is short-circuited — as soon as a non-`null` value is found, the remaining expressions are not evaluated.\n\nIf all values are `null`, returns `null`.\n\nAlso works with undefined symbols — if a symbol is undefined, it is treated as `null`.",examples:["1 ?? 2","null ?? 2","??(null)",'??(null, "default")','??(1, "default")','false ?? "default"',"??(null, null, 3)"]},evaluateAsNormalExpression:(e,t)=>{for(const r of e){const e=$(r,t);if(null!==e)return e}return null},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},Xt={arity:{},docs:{category:"special-expression",customVariants:["recur(...recur-args)"],description:"Recursevly calls enclosing function or loop with its evaluated `recur-args`.",examples:["\nlet foo = (n) -> do\n if zero?(n) then\n 0\n else\n n + recur(n - 1)\n end\nend;\nfoo(3)","\n((n) -> do\n if zero?(n) then\n 0\n else\n n + recur(n - 1)\n end\nend)(3)","\nloop (n = 3, acc = 0) -> do\n if zero?(n) then\n acc\n else\n recur(n - 1, acc + n)\n end\nend"]},evaluateAsNormalExpression:e=>{throw new t(e)},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},Qt={arity:{},docs:{category:"special-expression",returns:{type:"any",array:!0},args:{values:{type:"any",rest:!0}},variants:[{argumentNames:["values"]}],description:"Makes new array from $values.",examples:["array(1, 2, 3)","array(array(null, false, true))","[]","[1, 2, 3]","[1, 2, ...[3, 4, 5], 6]","[[null, false, true]]","[1, 2, 3][1]"],hideOperatorForm:!0},evaluateAsNormalExpression:(e,t)=>{const r=[];for(const n of e)r.push($(n,t));return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},Zt={arity:{},docs:{category:"special-expression",customVariants:["effect(name)"],details:[["name","dotted identifier","The effect name, e.g. `llm.complete` or `dvala.io.println`."]],description:"Returns the unique effect reference for the given name. Calling `effect` with the same name always returns the same reference. Effect references are first-class values that can be stored, passed, and compared with `==`.",examples:["effect(dvala.io.println)","==(effect(llm.complete), effect(llm.complete))"],seeAlso:["effect?"]},getUndefinedSymbols:()=>new Set},er={arity:{},docs:{category:"special-expression",returns:{type:"object"},args:{kvps:{type:"any",rest:!0,description:"key - value pairs, where key is a string"}},variants:[{argumentNames:["kvps"]}],description:"Constructs a new object. Object members are created from the $kvps key-value pairs. Requires an even number of arguments.",examples:["object()",'\nlet default = {\n type: "Person",\n name: "John Doe",\n age: 42\n};\n\n{\n ...default,\n name: "Lisa"\n}','object("x", 10, "y", true, "z", "A string")',"{}","{ a: 1, b: 2 }"],hideOperatorForm:!0},evaluateAsNormalExpression:(e,t)=>{const r={};for(let n=0;n<e.length;n+=2){const o=e[n],a=e[n+1];G(o,t),r[o]=a??null}return r},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>r(e[1][1],t,n,o)},tr={arity:re(1),docs:{category:"special-expression",description:"Imports all functions from a module as an object. Use destructuring to pick specific functions.",customVariants:["import(module-name)"],returns:{type:"object"},examples:["let v = import(vector); v.stdev([1, 2, 3, 4])","let { linspace } = import(vector); linspace(0, 10, 5)","let g = import(grid); g.row([[1, 2], [3, 4]], 0)"]},getUndefinedSymbols:()=>new Set},rr={arity:{min:1},docs:{category:"special-expression",customVariants:["parallel(expr1, expr2, ...)"],details:[["expr1, expr2, ...","expressions","Expressions to evaluate concurrently. Typically `perform(...)` calls."]],description:"Evaluates all branch expressions concurrently and returns an array of results in order. Each branch runs as an independent trampoline invocation. If any branch suspends, the entire `parallel` suspends with a composite blob. On resume, branches are resumed one at a time. Only available in async mode (`run()`). Requires at least one branch.",examples:[]},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>pe(...e[1][1].map(e=>r([e],t,n,o)))},nr={arity:{min:1},docs:{category:"special-expression",customVariants:["perform(eff)","perform(eff, arg1)","perform(eff, arg1, arg2, ...)"],details:[["eff","expression","An expression evaluating to an effect value (from `effect(name)`)."],["arg1, arg2, ...","expressions","Arguments passed to the effect handler."]],description:"Invokes an effect. The nearest enclosing `do/with` handler matching the effect intercepts the call. The handler receives the arguments as an array and its return value becomes the result of `perform`. If no local handler matches, the effect is dispatched to the host.",examples:['\ndo\n perform(effect(dvala.io.println), "hello")\nwith\n case effect(dvala.io.println) then ([msg]) -> msg\nend\n'],seeAlso:["effect?"]},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>{const[,a,i]=e[1];return pe(r([a],t,n,o),r(i,t,n,o))}},or={arity:{min:1},docs:{category:"special-expression",customVariants:["race(expr1, expr2, ...)"],details:[["expr1, expr2, ...","expressions","Expressions to race concurrently. Typically `perform(...)` calls."]],description:"Races all branch expressions concurrently. The first branch to complete wins — its value becomes the result. Losing branches are cancelled via AbortSignal. Errored branches are silently dropped. If all branches error, throws an aggregate error. If no branch completes but some suspend, the race suspends. On resume, the host provides the winner value directly. Only available in async mode (`run()`). Requires at least one branch.",examples:[]},getUndefinedSymbols:(e,t,{getUndefinedSymbols:r,builtin:n,evaluateNode:o})=>pe(...e[1][1].map(e=>r([e],t,n,o)))},ar={"??":0,"&&":1,"||":2,array:3,cond:4,"defined?":5,block:6,doseq:7,"0_lambda":8,for:9,if:10,let:11,loop:12,object:13,recur:14,match:15,unless:16,import:17,effect:18,perform:19,parallel:20,race:21},ir=[Yt,pt,Ht,Qt,dt,Pt,Ot,Jt,Dt,_t,Vt,Wt,Gt,er,Xt,Rt,Ut,tr,Zt,nr,rr,or],sr={normalExpressions:lt,specialExpressions:ir,allNormalExpressions:mt},cr=Object.keys(lt),lr=Object.keys(ar),ur=["^","*","/","%","+","-","<<",">>",">>>","++","<","<=","≤",">",">=","≥","==","!=","!=","&","xor","|","&&","||","??","|>"],mr=[...ur,"?",":","->","...",".",",","=",":",";"],pr=new Set(["comment","cond","defined?","block","doseq","if","let","loop","recur","unless","while"]);function dr(e){return!pr.has(e)}const hr=new Set(ur);function gr(e){return hr.has(e)}const fr=new Set(mr);function yr(e){return fr.has(e)}const vr=["number","string","object","array","vector","matrix","grid","boolean","function","integer","any","null","collection","sequence","regexp","effect","never"];function br(e){return"args"in e&&"variants"in e}const wr={"assert!=":{category:"assertion",description:"If $a is the same as $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert!= } = import(assertion);\ndo assert!=(0, 0, "Expected different values") with case effect(dvala.error) then ([msg]) -> msg end',"let { assert!= } = import(assertion);\ndo assert!=(0, 0) with case effect(dvala.error) then ([msg]) -> msg end","let { assert!= } = import(assertion);\ndo 0 assert!= 0 with case effect(dvala.error) then ([msg]) -> msg end","let { assert!= } = import(assertion);\ndo assert!=(0, 1) with case effect(dvala.error) then ([msg]) -> msg end"],seeAlso:["assertion.assert="],hideOperatorForm:!0},"assert=":{category:"assertion",description:"If $a is not structural equal to $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert= } = import(assertion);\ndo assert=({ "a": 1 }, { "a": 2 }, "Expected equal values") with case effect(dvala.error) then ([msg]) -> msg end','let { assert= } = import(assertion);\ndo assert=({ "a": 1 }, { "a": 2 }) with case effect(dvala.error) then ([msg]) -> msg end','let { assert= } = import(assertion);\ndo assert=({ "a": 1 }, { "a": 1 }) with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert!="],hideOperatorForm:!0},"assert-gt":{category:"assertion",description:"If $a is not greater than $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert-gt } = import(assertion);\ndo assert-gt(0, 1, "Expected greater value") with case effect(dvala.error) then ([msg]) -> msg end',"let { assert-gt } = import(assertion);\ndo assert-gt(0, 0) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-gt } = import(assertion);\ndo assert-gt(1, 0) with case effect(dvala.error) then ([msg]) -> msg end"],seeAlso:["assertion.assert-lt","assertion.assert-gte","assertion.assert-lte"],hideOperatorForm:!0},"assert-lt":{category:"assertion",description:"If $a is not less than $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert-lt } = import(assertion);\ndo assert-lt(1, 0, "Expected smaller value value") with case effect(dvala.error) then ([msg]) -> msg end',"let { assert-lt } = import(assertion);\ndo assert-lt(1, 1) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-lt } = import(assertion);\ndo assert-lt(0, 1) with case effect(dvala.error) then ([msg]) -> msg end"],seeAlso:["assertion.assert-gt","assertion.assert-lte","assertion.assert-gte"],hideOperatorForm:!0},"assert-gte":{category:"assertion",description:"If $a is less than $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert-gte } = import(assertion);\ndo assert-gte(0, 1, "Expected greater value") with case effect(dvala.error) then ([msg]) -> msg end',"let { assert-gte } = import(assertion);\ndo assert-gte(0, 1) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-gte } = import(assertion);\ndo assert-gte(1, 1) with case effect(dvala.error) then ([msg]) -> msg end"],seeAlso:["assertion.assert-lte","assertion.assert-gt","assertion.assert-lt"],hideOperatorForm:!0},"assert-lte":{category:"assertion",description:"If $a is grater than $b it throws `AssertionError`.",returns:{type:"null"},args:{a:{type:"any"},b:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","message"]}],examples:['let { assert-lte } = import(assertion);\ndo assert-lte(1, 0, "Expected smaller value value") with case effect(dvala.error) then ([msg]) -> msg end',"let { assert-lte } = import(assertion);\ndo assert-lte(1, 0) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-lte } = import(assertion);\ndo assert-lte(1, 1) with case effect(dvala.error) then ([msg]) -> msg end"],seeAlso:["assertion.assert-gte","assertion.assert-lt","assertion.assert-gt"],hideOperatorForm:!0},"assert-true":{category:"assertion",description:"If $value is not `true` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-true } = import(assertion);\ndo assert-true(false, "Expected true") with case effect(dvala.error) then ([msg]) -> msg end',"let { assert-true } = import(assertion);\ndo assert-true(false) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-true } = import(assertion);\ndo assert-true(true) with case effect(dvala.error) then ([msg]) -> msg end"],seeAlso:["assertion.assert-false","assertion.assert-truthy","assertion.assert-falsy","assert","assertion.assert-boolean"],hideOperatorForm:!0},"assert-false":{category:"assertion",description:"If $value is not `false` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-false } = import(assertion);\ndo assert-false(true, "Expected false") with case effect(dvala.error) then ([msg]) -> msg end',"let { assert-false } = import(assertion);\ndo assert-false(true) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-false } = import(assertion);\ndo assert-false(false) with case effect(dvala.error) then ([msg]) -> msg end"],seeAlso:["assertion.assert-true","assertion.assert-falsy","assertion.assert-truthy","assertion.assert-boolean"],hideOperatorForm:!0},"assert-truthy":{category:"assertion",description:"If $value is not `truthy` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-truthy } = import(assertion);\ndo assert-truthy(false, "Expected truthy") with case effect(dvala.error) then ([msg]) -> msg end',"let { assert-truthy } = import(assertion);\ndo assert-truthy(false) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-truthy } = import(assertion);\ndo assert-truthy(0) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-truthy } = import(assertion);\ndo assert-truthy(null) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-truthy } = import(assertion);\ndo assert-truthy("") with case effect(dvala.error) then ([msg]) -> msg end',"let { assert-truthy } = import(assertion);\ndo assert-truthy(true) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-truthy } = import(assertion);\ndo assert-truthy(1) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-truthy } = import(assertion);\ndo assert-truthy("x") with case effect(dvala.error) then ([msg]) -> msg end',"let { assert-truthy } = import(assertion);\ndo assert-truthy([]) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-truthy } = import(assertion);\ndo assert-truthy(nd) with case effect(dvala.error) then ([msg]) -> msg end"],seeAlso:["assertion.assert-falsy","assertion.assert-true","assertion.assert-false","assert","assertion.assert-null"],hideOperatorForm:!0},"assert-falsy":{category:"assertion",description:"If $value is not `falsy` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-falsy } = import(assertion);\ndo assert-falsy(true, "Expected falsy") with case effect(dvala.error) then ([msg]) -> msg end','let { assert-falsy } = import(assertion);\ndo assert-falsy("x") with case effect(dvala.error) then ([msg]) -> msg end',"let { assert-falsy } = import(assertion);\ndo assert-falsy([]) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-falsy } = import(assertion);\ndo assert-falsy(nd) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-falsy } = import(assertion);\ndo assert-falsy(1) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-falsy } = import(assertion);\ndo assert-falsy(false) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-falsy } = import(assertion);\ndo assert-falsy(0) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-falsy } = import(assertion);\ndo assert-falsy(null) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-falsy } = import(assertion);\ndo assert-falsy("") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-truthy","assertion.assert-false","assertion.assert-true","assertion.assert-null"],hideOperatorForm:!0},"assert-null":{category:"assertion",description:"If $value is not `null` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-null } = import(assertion);\ndo assert-null(null) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-null } = import(assertion);\ndo assert-null(true, "Expected null") with case effect(dvala.error) then ([msg]) -> msg end','let { assert-null } = import(assertion);\ndo assert-null("x") with case effect(dvala.error) then ([msg]) -> msg end',"let { assert-null } = import(assertion);\ndo assert-null([]) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-null } = import(assertion);\ndo assert-null(nd) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-null } = import(assertion);\ndo assert-null(1) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-null } = import(assertion);\ndo assert-null(false) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-null } = import(assertion);\ndo assert-null(0) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-null } = import(assertion);\ndo assert-null("") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-truthy","assertion.assert-falsy"],hideOperatorForm:!0},"assert-throws":{category:"assertion",description:"If $fun does not throw, it throws `AssertionError`.",returns:{type:"null"},args:{fun:{type:"function"},message:{type:"string"}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","message"]}],examples:['let { assert-throws } = import(assertion);\nassert-throws(-> perform(effect(dvala.error), "Error"))','let { assert-throws } = import(assertion);\ndo assert-throws(-> identity("Error")) with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-throws-error","assertion.assert-not-throws"],hideOperatorForm:!0},"assert-throws-error":{category:"assertion",description:"If $fun does not throw $error-message, it throws `AssertionError`.",returns:{type:"null"},args:{fun:{type:"function"},"error-message":{type:"string"},message:{type:"string"}},variants:[{argumentNames:["fun","error-message"]},{argumentNames:["fun","error-message","message"]}],examples:['let { assert-throws-error } = import(assertion);\ndo assert-throws-error(-> perform(effect(dvala.error), "Error"), "Error") with case effect(dvala.error) then ([msg]) -> msg end','let { assert-throws-error } = import(assertion);\ndo assert-throws-error(-> identity("Error"), "Error") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-throws","assertion.assert-not-throws"],hideOperatorForm:!0},"assert-not-throws":{category:"assertion",description:"If $fun throws, it throws `AssertionError`.",returns:{type:"null"},args:{fun:{type:"function"},message:{type:"string"}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","message"]}],examples:['let { assert-not-throws } = import(assertion);\ndo assert-not-throws(-> identity("Error")) with case effect(dvala.error) then ([msg]) -> msg end','let { assert-not-throws } = import(assertion);\ndo assert-not-throws(-> perform(effect(dvala.error), "Error")) with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-throws","assertion.assert-throws-error"],hideOperatorForm:!0},"assert-array":{category:"assertion",description:"If $value is not an `array` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-array } = import(assertion);\ndo assert-array([1, 2, 3]) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-array } = import(assertion);\ndo assert-array("string") with case effect(dvala.error) then ([msg]) -> msg end','let { assert-array } = import(assertion);\ndo assert-array(42, "Expected an array") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-object","assertion.assert-collection","assertion.assert-sequence"],hideOperatorForm:!0},"assert-boolean":{category:"assertion",description:"If $value is not a `boolean` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-boolean } = import(assertion);\ndo assert-boolean(true) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-boolean } = import(assertion);\ndo assert-boolean(false) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-boolean } = import(assertion);\ndo assert-boolean(1, "Expected a boolean") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-true","assertion.assert-false","assertion.assert-number","assertion.assert-string"],hideOperatorForm:!0},"assert-collection":{category:"assertion",description:"If $value is not a `collection` (array, object, or string) it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-collection } = import(assertion);\ndo assert-collection([1, 2]) with case effect(dvala.error) then ([msg]) -> msg end","let { assert-collection } = import(assertion);\ndo assert-collection({ a: 1 }) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-collection } = import(assertion);\ndo assert-collection("hello") with case effect(dvala.error) then ([msg]) -> msg end','let { assert-collection } = import(assertion);\ndo assert-collection(42, "Expected a collection") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-sequence","assertion.assert-array","assertion.assert-object"],hideOperatorForm:!0},"assert-function":{category:"assertion",description:"If $value is not a `function` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-function } = import(assertion);\ndo assert-function(-> $ + 1) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-function } = import(assertion);\ndo assert-function(42, "Expected a function") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-number","assertion.assert-string"],hideOperatorForm:!0},"assert-grid":{category:"assertion",description:"If $value is not a `grid` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-grid } = import(assertion);\ndo assert-grid([[1, 2], [3, 4]]) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-grid } = import(assertion);\ndo assert-grid([1, 2], "Expected a grid") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-matrix","assertion.assert-vector"],hideOperatorForm:!0},"assert-integer":{category:"assertion",description:"If $value is not an `integer` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-integer } = import(assertion);\ndo assert-integer(42) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-integer } = import(assertion);\ndo assert-integer(3.14, "Expected an integer") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-number"],hideOperatorForm:!0},"assert-matrix":{category:"assertion",description:"If $value is not a `matrix` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-matrix } = import(assertion);\ndo assert-matrix([[1, 2], [3, 4]]) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-matrix } = import(assertion);\ndo assert-matrix([1, 2], "Expected a matrix") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-vector","assertion.assert-grid"],hideOperatorForm:!0},"assert-number":{category:"assertion",description:"If $value is not a `number` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-number } = import(assertion);\ndo assert-number(42) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-number } = import(assertion);\ndo assert-number("hello", "Expected a number") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-integer","assertion.assert-boolean","assertion.assert-string","assertion.assert-function"],hideOperatorForm:!0},"assert-object":{category:"assertion",description:"If $value is not an `object` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-object } = import(assertion);\ndo assert-object({ a: 1 }) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-object } = import(assertion);\ndo assert-object([1, 2], "Expected an object") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-array","assertion.assert-collection"],hideOperatorForm:!0},"assert-regexp":{category:"assertion",description:"If $value is not a `regexp` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-regexp } = import(assertion);\ndo assert-regexp(#"^start") with case effect(dvala.error) then ([msg]) -> msg end','let { assert-regexp } = import(assertion);\ndo assert-regexp("hello", "Expected a regexp") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-string"],hideOperatorForm:!0},"assert-sequence":{category:"assertion",description:"If $value is not a `sequence` (array or string) it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-sequence } = import(assertion);\ndo assert-sequence([1, 2]) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-sequence } = import(assertion);\ndo assert-sequence("hello") with case effect(dvala.error) then ([msg]) -> msg end','let { assert-sequence } = import(assertion);\ndo assert-sequence({ a: 1 }, "Expected a sequence") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-collection","assertion.assert-array"],hideOperatorForm:!0},"assert-string":{category:"assertion",description:"If $value is not a `string` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:['let { assert-string } = import(assertion);\ndo assert-string("hello") with case effect(dvala.error) then ([msg]) -> msg end','let { assert-string } = import(assertion);\ndo assert-string(42, "Expected a string") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-number","assertion.assert-boolean","assertion.assert-regexp","assertion.assert-function"],hideOperatorForm:!0},"assert-vector":{category:"assertion",description:"If $value is not a `vector` it throws `AssertionError`.",returns:{type:"null"},args:{value:{type:"any"},message:{type:"string"}},variants:[{argumentNames:["value"]},{argumentNames:["value","message"]}],examples:["let { assert-vector } = import(assertion);\ndo assert-vector([1, 2, 3]) with case effect(dvala.error) then ([msg]) -> msg end",'let { assert-vector } = import(assertion);\ndo assert-vector(["a", "b"], "Expected a vector") with case effect(dvala.error) then ([msg]) -> msg end'],seeAlso:["assertion.assert-matrix","assertion.assert-grid"],hideOperatorForm:!0}},xr={"assert=":{evaluate:([e,t,r],n)=>{if(void 0!==r&&(G(r,n),r=` ${r}`),r??="",!se($(e,n),$(t,n),n))throw new o(`Expected ${JSON.stringify(e,null,2)} to deep equal ${JSON.stringify(t,null,2)}.${r}`,n);return null},arity:{min:2,max:3}},"assert!=":{evaluate:([e,t,r],n)=>{if(void 0!==r&&(G(r,n),r=` ${r}`),r??="",se($(e,n),$(t,n),n))throw new o(`Expected ${JSON.stringify(e)} not to deep equal ${JSON.stringify(t)}.${r}`,n);return null},arity:{min:2,max:3}},"assert-gt":{evaluate:([e,t,r],n)=>{if(K(e,n),K(t,n),void 0!==r&&(G(r,n),r=` ${r}`),r??="",ie(e,t,n)<=0)throw new o(`Expected ${e} to be grater than ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-gte":{evaluate:([e,t,r],n)=>{if(K(e,n),K(t,n),void 0!==r&&(G(r,n),r=` ${r}`),r??="",ie(e,t,n)<0)throw new o(`Expected ${e} to be grater than or equal to ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-lt":{evaluate:([e,t,r],n)=>{if(K(e,n),K(t,n),void 0!==r&&(G(r,n),r=` ${r}`),r??="",ie(e,t,n)>=0)throw new o(`Expected ${e} to be less than ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-lte":{evaluate:([e,t,r],n)=>{if(K(e,n),K(t,n),void 0!==r&&(G(r,n),r=` ${r}`),r??="",ie(e,t,n)>0)throw new o(`Expected ${e} to be less than or equal to ${t}.${r}`,n);return null},arity:{min:2,max:3}},"assert-true":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",!0!==e)throw new o(`Expected ${e} to be true.${t}`,r);return null},arity:{min:1,max:2}},"assert-false":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",!1!==e)throw new o(`Expected ${e} to be false.${t}`,r);return null},arity:{min:1,max:2}},"assert-truthy":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",!e)throw new o(`Expected ${e} to be truthy.${t}`,r);return null},arity:{min:1,max:2}},"assert-falsy":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",e)throw new o(`Expected ${e} to be falsy.${t}`,r);return null},arity:{min:1,max:2}},"assert-null":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",null!==e)throw new o(`Expected ${e} to be null.${t}`,r);return null},arity:{min:1,max:2}},"assert-throws":{evaluate:([e,t],r,n,{executeFunction:a})=>(void 0!==t&&(G(t,r),t=` ${t}`),t??="",F(e,r),$t(()=>wt(a(e,[],n,r),()=>{throw new o(`Expected function to throw.${t}`,r)}),()=>null)),arity:{min:1,max:2}},"assert-throws-error":{evaluate:([e,t,r],n,a,{executeFunction:i})=>(void 0!==r&&(G(r,n),r=` ${r}`),r??="",G(t,n),F(e,n),$t(()=>wt(i(e,[],a,n),()=>{throw new o(`Expected function to throw "${t}".${r}`,n)}),e=>{const a=e.shortMessage;if(a!==t)throw new o(`Expected function to throw "${t}", but thrown "${a}".${r}`,n);return null})),arity:{min:2,max:3}},"assert-not-throws":{evaluate:([e,t],r,n,{executeFunction:a})=>(void 0!==t&&(G(t,r),t=` ${t}`),t??="",F(e,r),$t(()=>wt(a(e,[],n,r),()=>null),()=>{throw new o(`Expected function not to throw.${t}`,r)})),arity:{min:1,max:2}},"assert-array":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",!Array.isArray(e))throw new o(`Expected ${JSON.stringify(e)} to be an array.${t}`,r);return null},arity:{min:1,max:2}},"assert-boolean":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="","boolean"!=typeof e)throw new o(`Expected ${JSON.stringify(e)} to be a boolean.${t}`,r);return null},arity:{min:1,max:2}},"assert-collection":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",!C(e))throw new o(`Expected ${JSON.stringify(e)} to be a collection.${t}`,r);return null},arity:{min:1,max:2}},"assert-function":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",!x(e))throw new o(`Expected ${JSON.stringify(e)} to be a function.${t}`,r);return null},arity:{min:1,max:2}},"assert-grid":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",!Oe(e))throw new o(`Expected ${JSON.stringify(e)} to be a grid.${t}`,r);return null},arity:{min:1,max:2}},"assert-integer":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="","number"!=typeof e||!H(e,{integer:!0}))throw new o(`Expected ${JSON.stringify(e)} to be an integer.${t}`,r);return null},arity:{min:1,max:2}},"assert-matrix":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",!Ve(e))throw new o(`Expected ${JSON.stringify(e)} to be a matrix.${t}`,r);return null},arity:{min:1,max:2}},"assert-number":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="","number"!=typeof e)throw new o(`Expected ${JSON.stringify(e)} to be a number.${t}`,r);return null},arity:{min:1,max:2}},"assert-object":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",!j(e))throw new o(`Expected ${JSON.stringify(e)} to be an object.${t}`,r);return null},arity:{min:1,max:2}},"assert-regexp":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",!P(e))throw new o(`Expected ${JSON.stringify(e)} to be a regexp.${t}`,r);return null},arity:{min:1,max:2}},"assert-sequence":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",!T(e))throw new o(`Expected ${JSON.stringify(e)} to be a sequence.${t}`,r);return null},arity:{min:1,max:2}},"assert-string":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="","string"!=typeof e)throw new o(`Expected ${JSON.stringify(e)} to be a string.${t}`,r);return null},arity:{min:1,max:2}},"assert-vector":{evaluate:([e,t],r)=>{if(void 0!==t&&(G(t,r),t=` ${t}`),t??="",!Ie(e))throw new o(`Expected ${JSON.stringify(e)} to be a vector.${t}`,r);return null},arity:{min:1,max:2}}};for(const[e,t]of Object.entries(wr))xr[e]&&(xr[e].docs=t);const kr={name:"assertion",functions:xr,source:"{}",docs:wr};const qr={"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 Ar(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 Nr={"cell-every?":{evaluate:()=>{throw new Error("cell-every?: Dvala implementation should be used instead")},arity:re(2)},"some?":{evaluate:()=>{throw new Error("some?: Dvala implementation should be used instead")},arity:re(2)},"every-row?":{evaluate:()=>{throw new Error("every-row?: Dvala implementation should be used instead")},arity:re(2)},"some-row?":{evaluate:()=>{throw new Error("some-row?: Dvala implementation should be used instead")},arity:re(2)},"every-col?":{evaluate:()=>{throw new Error("every-col?: Dvala implementation should be used instead")},arity:re(2)},"some-col?":{evaluate:()=>{throw new Error("some-col?: Dvala implementation should be used instead")},arity:re(2)},row:{evaluate:([e,t],r)=>(De(e,r),Y(t,r,{integer:!0,nonNegative:!0,lt:e.length}),e[t]),arity:re(2)},col:{evaluate:([e,t],r)=>(De(e,r),Y(t,r,{integer:!0,nonNegative:!0,lt:e[0].length}),e.map(e=>e[t])),arity:re(2)},shape:{evaluate:([e],t)=>(De(e,t),[e.length,e[0].length]),arity:re(1)},fill:{evaluate:([e,t,r],n)=>{Y(e,n,{integer:!0,positive:!0}),Y(t,n,{integer:!0,positive:!0}),E(r,n);const o=[];for(let n=0;n<e;n+=1){const e=[];for(let n=0;n<t;n+=1)e.push(r);o.push(e)}return o},arity:re(3)},generate:{evaluate:()=>{throw new Error("generate: Dvala implementation should be used instead")},arity:re(3)},reshape:{evaluate:([e,t],n)=>{De(e,n),Y(t,n,{integer:!0,positive:!0});const o=e.flat();if(o.length%t!==0)throw new r(`The number of elements in the grid must be divisible by rows, but got ${o.length} and ${t}`,n);const a=o.length/t,i=[];for(let e=0;e<t;e+=1){const t=[];for(let r=0;r<a;r+=1)t.push(o[e*a+r]);i.push(t)}return i},arity:re(2)},transpose:{evaluate:([e],t)=>(De(e,t),Ar(e)),arity:re(1)},"flip-h":{evaluate:([e],t)=>(De(e,t),e.map(e=>e.reverse())),arity:re(1)},"flip-v":{evaluate:([e],t)=>(De(e,t),e.reverse()),arity:re(1)},rotate:{evaluate:([e,t],r)=>{if(De(e,r),Y(t,r,{integer:!0}),0===(t=(t%4+4)%4)||0===e.length)return e.map(e=>[...e]);const n=e.length,o=e[0].length;let a;switch(t){case 1:a=Array(o).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<o;r++)a[r][n-1-t]=e[t][r];break;case 2:a=Array(n).fill(null).map(()=>Array(o).fill(null));for(let t=0;t<n;t++)for(let r=0;r<o;r++)a[n-1-t][o-1-r]=e[t][r];break;case 3:a=Array(o).fill(null).map(()=>Array(n).fill(null));for(let t=0;t<n;t++)for(let r=0;r<o;r++)a[o-1-r][t]=e[t][r]}return a},arity:re(2)},crop:{evaluate:([e,t,n],o)=>{if(De(e,o),Ce(t,o),2!==t.length)throw new r(`The start vector must have 2 elements, but got ${t.length}`,o);const[a,i]=t;if(Y(a,o,{integer:!0,nonNegative:!0,lt:e.length}),Y(i,o,{integer:!0,nonNegative:!0,lt:e[0].length}),n??=[e.length,e[0].length],Ce(n,o),2!==n.length)throw new r(`The end vector must have 2 elements, but got ${n.length}`,o);const[s,c]=n;Y(s,o,{gt:a,lte:e.length}),Y(c,o,{gt:i,lte:e[0].length});const l=[];for(let t=a;t<s;t+=1){const r=[];for(let n=i;n<c;n+=1)r.push(e[t][n]);l.push(r)}return l},arity:{min:2,max:3}},"slice-rows":{evaluate:([e,t,r],n)=>(De(e,n),void 0===r?(Y(t,n,{integer:!0,lte:e.length,gte:-e.length}),t<0?e.slice(e.length+t):e.slice(t)):(Y(t,n,{integer:!0,nonNegative:!0,lte:e.length}),Y(r,n,{integer:!0}),Y(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)=>{De(e,n);const o=Ar(e);return void 0===r?(Y(t,n,{integer:!0,lte:o.length,gte:-o.length}),Ar(t<0?o.slice(o.length+t):o.slice(t))):(Y(t,n,{integer:!0,nonNegative:!0,lte:o.length}),Y(r,n,{integer:!0}),Y(r=r<0?o.length+r:r,n,{gt:t,lte:o.length}),Ar(o.slice(t,r)))},arity:{min:2,max:3}},"splice-rows":{evaluate:([e,t,n,...o],a)=>{De(e,a),Y(t,a,{integer:!0,nonNegative:!0,lte:e.length}),Y(n,a,{integer:!0,nonNegative:!0}),0!==o.length&&(De(o,a),o.every(t=>{if(ve(t,a),e[0].length!==t.length)throw new r(`All rows must have the same length as the number of columns in grid, but got ${t.length}`,a);return!0}));const i=[];for(let r=0;r<t;r+=1)i.push(e[r]);o.length>0&&i.push(...o);for(let r=t+n;r<e.length;r+=1)i.push(e[r]);return i},arity:{min:3}},"splice-cols":{evaluate:([e,t,n,...o],a)=>{De(e,a);const i=Ar(e);Y(t,a,{integer:!0,nonNegative:!0,lte:i.length}),Y(n,a,{integer:!0,nonNegative:!0}),0!==o.length&&(De(o,a),o.every(e=>{if(ve(e,a),i[0].length!==e.length)throw new r(`All rows must have the same length as the number of rows in grid, but got ${e.length}`,a);return!0}));const s=[];for(let e=0;e<t;e+=1)s.push(i[e]);s.push(...o);for(let e=t+n;e<i.length;e+=1)s.push(i[e]);return Ar(s)},arity:{min:3}},"concat-rows":{evaluate:(e,t)=>{ve(e,t),e.every(e=>De(e,t));const n=e[0][0].length;e.slice(1).every(e=>{if(e[0].length!==n)throw new r(`All grids must have the same number of columns, but got ${n} and ${e[0].length}`,t);return!0});const o=[];return e.forEach(e=>{e.forEach(e=>{o.push(e)})}),o},arity:{min:1}},"concat-cols":{evaluate:(e,t)=>{ve(e,t),e.every(e=>De(e,t));const n=e[0].length;e.slice(1).every(e=>{if(e.length!==n)throw new r(`All grids must have the same number of rows, but got ${n} and ${e.length}`,t);return!0});const o=[];for(let t=0;t<n;t+=1){const r=[];e.forEach(e=>{r.push(...e[t])}),o.push(r)}return o},arity:{min:1}},"cell-map":{evaluate:()=>{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:re(2)},"cell-reduce":{evaluate:()=>{throw new Error("cell-reduce: Dvala implementation should be used instead")},arity:re(3)},"cell-reducei":{evaluate:()=>{throw new Error("cell-reducei: Dvala implementation should be used instead")},arity:re(3)},"push-rows":{evaluate:([e,...t],n)=>{if(De(e,n),De(t,n),e[0].length!==t[0].length)throw new r(`All rows must have the same length as the number of columns in grid, but got ${e[0].length} and ${t[0].length}`,n);return[...e,...t]},arity:{min:2}},"unshift-rows":{evaluate:([e,...t],n)=>{if(De(e,n),De(t,n),e[0].length!==t[0].length)throw new r(`All rows must have the same length as the number of columns in grid, but got ${e[0].length} and ${t[0].length}`,n);return[...t,...e]},arity:{min:2}},"pop-row":{evaluate:([e],t)=>(De(e,t),1===e.length?null:e.slice(0,-1)),arity:re(1)},"shift-row":{evaluate:([e],t)=>(De(e,t),1===e.length?null:e.slice(1)),arity:re(1)},"push-cols":{evaluate:([e,...t],n)=>{if(De(e,n),De(t,n),e.length!==t[0].length)throw new r(`All columns must have the same length as the number of rows in grid, but got ${t.length}`,n);const o=[];for(let r=0;r<e.length;r+=1){const n=[];n.push(...e[r]),t.forEach(e=>{n.push(e[r])}),o.push(n)}return o},arity:{min:2}},"unshift-cols":{evaluate:([e,...t],n)=>{if(De(e,n),De(t,n),e.length!==t[0].length)throw new r(`All columns must have the same length as the number of rows in grid, but got ${t.length}`,n);const o=[];for(let r=0;r<e.length;r+=1){const n=[];t.forEach(e=>{n.push(e[r])}),n.push(...e[r]),o.push(n)}return o},arity:{min:2}},"pop-col":{evaluate:([e],t)=>(De(e,t),1===e[0].length?null:e.map(e=>e.slice(0,-1))),arity:re(1)},"shift-col":{evaluate:([e],t)=>(De(e,t),1===e[0].length?null:e.map(e=>e.slice(1))),arity:re(1)},"from-array":{evaluate:([e,t],n)=>{if(ve(e,n),Y(t,n,{integer:!0,positive:!0}),e.length%t!==0)throw new r(`The number of elements in the array must be divisible by rows, but got ${e.length} and ${t}`,n);return function(e,t){const r=[],n=e.length/t;for(let o=0;o<t;o++){const t=o*n,a=t+n;r.push(e.slice(t,a))}return r}(e,t)},arity:re(2)}};for(const[e,t]of Object.entries(qr))Nr[e]&&(Nr[e].docs=t);const $r={name:"grid",functions:Nr,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:qr},Er={"moving-mean":{category:"vector",description:"Returns the **moving mean** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving mean** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-mean } = import(vector);\nmoving-mean([1, 2, 3, 4, 5], 3)","let { moving-mean } = import(vector);\nmoving-mean([1, 2, 3, 4, 5], 5)"],seeAlso:["moving-fn","mean","vector.centered-moving-mean","vector.running-mean"]},"centered-moving-mean":{category:"vector",description:"Returns the **centered moving mean** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving mean** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-mean } = import(vector);\ncentered-moving-mean([1, 2, 3, 4, 5], 3)","let { centered-moving-mean } = import(vector);\ncentered-moving-mean([1, 2, 3, 4, 5], 3, 0, 10)","let { centered-moving-mean } = import(vector);\ncentered-moving-mean([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["mean","vector.moving-mean","vector.running-mean"]},"running-mean":{category:"vector",description:"Returns the **running mean** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-mean } = import(vector);\nrunning-mean([1, 2, 3, 4, 5])"],seeAlso:["running-fn","mean","vector.moving-mean","vector.centered-moving-mean"]},"geometric-mean":{category:"vector",description:"Returns the **geometric mean** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **geometric mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { geometric-mean } = import(vector);\ngeometric-mean([1, 2, 3])","let { geometric-mean } = import(vector);\ngeometric-mean([1, 2, 9])"],seeAlso:["vector.moving-geometric-mean","vector.centered-moving-geometric-mean","vector.running-geometric-mean","mean","vector.harmonic-mean"]},"moving-geometric-mean":{category:"vector",description:"Returns the **moving geometric mean** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving geometric mean** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-geometric-mean } = import(vector);\nmoving-geometric-mean([1, 2, 3, 4, 5], 3)","let { moving-geometric-mean } = import(vector);\nmoving-geometric-mean([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.geometric-mean","vector.centered-moving-geometric-mean","vector.running-geometric-mean"]},"centered-moving-geometric-mean":{category:"vector",description:"Returns the **centered moving geometric mean** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving geometric mean** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-geometric-mean } = import(vector);\ncentered-moving-geometric-mean([1, 2, 3, 4, 5], 3)","let { centered-moving-geometric-mean } = import(vector);\ncentered-moving-geometric-mean([1, 2, 3, 4, 5], 3, 0, 10)","let { centered-moving-geometric-mean } = import(vector);\ncentered-moving-geometric-mean([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["vector.geometric-mean","vector.moving-geometric-mean","vector.running-geometric-mean"]},"running-geometric-mean":{category:"vector",description:"Returns the **running geometric mean** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running geometric mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-geometric-mean } = import(vector);\nrunning-geometric-mean([1, 2, 3, 4, 5])"],seeAlso:["vector.geometric-mean","vector.moving-geometric-mean","vector.centered-moving-geometric-mean"]},"harmonic-mean":{category:"vector",description:"Returns the **harmonic mean** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **harmonic mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { harmonic-mean } = import(vector);\nharmonic-mean([1, 2, 3])","let { harmonic-mean } = import(vector);\nharmonic-mean([1, 2, 9])"],seeAlso:["vector.moving-harmonic-mean","vector.centered-moving-harmonic-mean","vector.running-harmonic-mean","mean","vector.geometric-mean"]},"moving-harmonic-mean":{category:"vector",description:"Returns the **moving harmonic mean** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving harmonic mean** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-harmonic-mean } = import(vector);\nmoving-harmonic-mean([1, 2, 3, 4, 5], 3)","let { moving-harmonic-mean } = import(vector);\nmoving-harmonic-mean([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.harmonic-mean","vector.centered-moving-harmonic-mean","vector.running-harmonic-mean"]},"centered-moving-harmonic-mean":{category:"vector",description:"Returns the **centered moving harmonic mean** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving harmonic mean** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-harmonic-mean } = import(vector);\ncentered-moving-harmonic-mean([1, 2, 3, 4, 5], 3)","let { centered-moving-harmonic-mean } = import(vector);\ncentered-moving-harmonic-mean([1, 2, 3, 4, 5], 3, 0, 10)","let { centered-moving-harmonic-mean } = import(vector);\ncentered-moving-harmonic-mean([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["vector.harmonic-mean","vector.moving-harmonic-mean","vector.running-harmonic-mean"]},"running-harmonic-mean":{category:"vector",description:"Returns the **running harmonic mean** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running harmonic mean** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-harmonic-mean } = import(vector);\nrunning-harmonic-mean([1, 2, 3, 4, 5])"],seeAlso:["vector.harmonic-mean","vector.moving-harmonic-mean","vector.centered-moving-harmonic-mean"]},"moving-median":{category:"vector",description:"Returns the **moving median** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving median** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-median } = import(vector);\nmoving-median([1, 2, 3, 4, 5], 3)","let { moving-median } = import(vector);\nmoving-median([1, 2, 3, 4, 5], 5)"],seeAlso:["median","vector.centered-moving-median","vector.running-median"]},"centered-moving-median":{category:"vector",description:"Returns the **centered moving median** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving median** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-median } = import(vector);\ncentered-moving-median([1, 2, 3, 4, 5], 3)","let { centered-moving-median } = import(vector);\ncentered-moving-median([1, 2, 3, 4, 5], 3, 0, 10)","let { centered-moving-median } = import(vector);\ncentered-moving-median([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["median","vector.moving-median","vector.running-median"]},"running-median":{category:"vector",description:"Returns the **running median** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running median** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-median } = import(vector);\nrunning-median([1, 2, 3, 4, 5])"],seeAlso:["median","vector.moving-median","vector.centered-moving-median"]},variance:{category:"vector",description:"Returns the **variance** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **variance** of."}},variants:[{argumentNames:["vector"]}],examples:["let { variance } = import(vector);\nvariance([1, 2, 3])","let { variance } = import(vector);\nvariance([1, 2, -3])"],seeAlso:["linear-algebra.cov","vector.moving-variance","vector.centered-moving-variance","vector.running-variance","vector.stdev","vector.sample-variance","vector.mad"]},"moving-variance":{category:"vector",description:"Returns the **moving variance** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving variance** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-variance } = import(vector);\nmoving-variance([1, 2, 3, 4, 5], 3)","let { moving-variance } = import(vector);\nmoving-variance([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.variance","vector.centered-moving-variance","vector.running-variance"]},"centered-moving-variance":{category:"vector",description:"Returns the **centered moving variance** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving variance** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-variance } = import(vector);\ncentered-moving-variance([1, 2, 3, 4, 5], 3)","let { centered-moving-variance } = import(vector);\ncentered-moving-variance([1, 2, 3, 4, 5], 3, 1)","let { centered-moving-variance } = import(vector);\ncentered-moving-variance([1, 2, 3, 4, 5], 3, 1, 5)","let { centered-moving-variance } = import(vector);\ncentered-moving-variance([1, 2, 3, 4, 5], 3, 0, 6)"],seeAlso:["vector.variance","vector.moving-variance","vector.running-variance"]},"running-variance":{category:"vector",description:"Returns the **running variance** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running variance** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-variance } = import(vector);\nrunning-variance([1, 2, 3, 4, 5])"],seeAlso:["vector.variance","vector.moving-variance","vector.centered-moving-variance"]},"sample-variance":{category:"vector",description:"Returns the sample variance of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the sample variance of."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-variance } = import(vector);\nsample-variance([1, 2, 3])","let { sample-variance } = import(vector);\nsample-variance([1, 2, -3])","let { sample-variance } = import(vector);\nsample-variance([1, 2, 3, 4])","let { sample-variance } = import(vector);\nsample-variance([1, 2, -3, 4])","let { sample-variance } = import(vector);\nsample-variance([1, 2, 3, 40, 50])"],seeAlso:["vector.moving-sample-variance","vector.centered-moving-sample-variance","vector.running-sample-variance","vector.variance","vector.sample-stdev"]},"moving-sample-variance":{category:"vector",description:"Returns the **moving sample variance** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample variance** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-variance } = import(vector);\nmoving-sample-variance([1, 2, 3, 4, 5], 3)","let { moving-sample-variance } = import(vector);\nmoving-sample-variance([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.sample-variance","vector.centered-moving-sample-variance","vector.running-sample-variance"]},"centered-moving-sample-variance":{category:"vector",description:"Returns the **centered moving sample variance** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample variance** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-variance } = import(vector);\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3)","let { centered-moving-sample-variance } = import(vector);\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3, 1)","let { centered-moving-sample-variance } = import(vector);\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3, 1, 5)","let { centered-moving-sample-variance } = import(vector);\ncentered-moving-sample-variance([1, 2, 3, 4, 5], 3, 0, 6)"],seeAlso:["vector.sample-variance","vector.moving-sample-variance","vector.running-sample-variance"]},"running-sample-variance":{category:"vector",description:"Returns the **running sample variance** of the `vector`.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sample variance** of. First element in result is `null` since **sample variance** is not defined for a single element."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-variance } = import(vector);\nrunning-sample-variance([1, 2, 3, 4, 5])"],seeAlso:["vector.sample-variance","vector.moving-sample-variance","vector.centered-moving-sample-variance"]},stdev:{category:"vector",description:"Returns the standard deviation of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the standard deviation of."}},variants:[{argumentNames:["vector"]}],examples:["let { stdev } = import(vector);\nstdev([1, 2, 3])","let { stdev } = import(vector);\nstdev([1, 2, -3])","let { stdev } = import(vector);\nstdev([1, 2, 3, 4])","let { stdev } = import(vector);\nstdev([1, 2, -3, 4])","let { stdev } = import(vector);\nstdev([1, 2, 3, 40, 50])"],seeAlso:["vector.moving-stdev","vector.centered-moving-stdev","vector.running-stdev","vector.variance","vector.sample-stdev","vector.rms","vector.mad"]},"moving-stdev":{category:"vector",description:"Returns the **moving standard deviation** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving standard deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-stdev } = import(vector);\nmoving-stdev([1, 2, 3, 4, 5], 3)","let { moving-stdev } = import(vector);\nmoving-stdev([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.stdev","vector.centered-moving-stdev","vector.running-stdev"]},"centered-moving-stdev":{category:"vector",description:"Returns the **centered moving standard deviation** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving standard deviation** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-stdev } = import(vector);\ncentered-moving-stdev([1, 2, 3, 4, 5], 3)","let { centered-moving-stdev } = import(vector);\ncentered-moving-stdev([1, 2, 3, 4, 5], 3, 1)","let { centered-moving-stdev } = import(vector);\ncentered-moving-stdev([1, 2, 3, 4, 5], 3, 1, 5)","let { centered-moving-stdev } = import(vector);\ncentered-moving-stdev([1, 2, 3, 4, 5], 3, 0, 6)"],seeAlso:["vector.stdev","vector.moving-stdev","vector.running-stdev"]},"running-stdev":{category:"vector",description:"Returns the **running standard deviation** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running standard deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-stdev } = import(vector);\nrunning-stdev([1, 2, 3, 4, 5])"],seeAlso:["vector.stdev","vector.moving-stdev","vector.centered-moving-stdev"]},"sample-stdev":{category:"vector",description:"Returns the sample standard deviation of all elements in the vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the sample standard deviation of."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-stdev } = import(vector);\nsample-stdev([1, 2, 3])","let { sample-stdev } = import(vector);\nsample-stdev([1, 2, -3])","let { sample-stdev } = import(vector);\nsample-stdev([1, 2, 3, 4])","let { sample-stdev } = import(vector);\nsample-stdev([1, 2, -3, 4])","let { sample-stdev } = import(vector);\nsample-stdev([1, 2, 3, 40, 50])"],seeAlso:["vector.moving-sample-stdev","vector.centered-moving-sample-stdev","vector.running-sample-stdev","vector.stdev","vector.sample-variance"]},"moving-sample-stdev":{category:"vector",description:"Returns the **moving sample standard deviation** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample standard deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-stdev } = import(vector);\nmoving-sample-stdev([1, 2, 3, 4, 5], 3)","let { moving-sample-stdev } = import(vector);\nmoving-sample-stdev([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.sample-stdev","vector.centered-moving-sample-stdev","vector.running-sample-stdev"]},"centered-moving-sample-stdev":{category:"vector",description:"Returns the **centered moving sample standard deviation** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample standard deviation** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-stdev } = import(vector);\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3)","let { centered-moving-sample-stdev } = import(vector);\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3, 1)","let { centered-moving-sample-stdev } = import(vector);\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3, 1, 5)","let { centered-moving-sample-stdev } = import(vector);\ncentered-moving-sample-stdev([1, 2, 3, 4, 5], 3, 0, 6)"],seeAlso:["vector.sample-stdev","vector.moving-sample-stdev","vector.running-sample-stdev"]},"running-sample-stdev":{category:"vector",description:"Returns the **running sample standard deviation** of the `vector`.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sample standard deviation** of. First element in result is `null` since **sample standard deviation** is not defined for a single element."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-stdev } = import(vector);\nrunning-sample-stdev([1, 2, 3, 4, 5])"],seeAlso:["vector.sample-stdev","vector.moving-sample-stdev","vector.centered-moving-sample-stdev"]},iqr:{category:"vector",description:"Calculates the **interquartile range** of a `vector`. Returns the difference between the third and first quartiles.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **interquartile range** of. Minimum length is 4."}},variants:[{argumentNames:["vector"]}],examples:["let { iqr } = import(vector);\niqr([1, 2, 3, 4])","let { iqr } = import(vector);\niqr([5, 4, 3, 2, 1, 2, 3, 4, 5])","let { iqr } = import(vector);\niqr(range(1, 1000))","let { iqr } = import(vector);\niqr(map(range(1000), -> 1e6 / ($ + 1) ^ 2))","let { iqr } = import(vector);\nlet { ln } = import(math);\niqr(map(range(1000), -> ln($ + 1)))"],seeAlso:["vector.moving-iqr","vector.centered-moving-iqr","vector.running-iqr","vector.quartiles","median","vector.mad","vector.medad","vector.outliers?","vector.outliers"]},"moving-iqr":{category:"vector",description:"Calculates the **moving interquartile range** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving interquartile range** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-iqr } = import(vector);\nmoving-iqr([1, 2, 4, 7, 11, 16], 4)","let { moving-iqr } = import(vector);\nmoving-iqr([1, 2, 4, 7, 11, 16], 5)","let { moving-iqr } = import(vector);\nmoving-iqr([1, 2, 4, 7, 11, 16], 6)"],seeAlso:["vector.iqr","vector.centered-moving-iqr","vector.running-iqr"]},"centered-moving-iqr":{category:"vector",description:"Calculates the **centered moving interquartile range** of a `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving interquartile range** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-iqr } = import(vector);\ncentered-moving-iqr([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-iqr } = import(vector);\ncentered-moving-iqr([1, 2, 4, 7, 11, 16], 4, 0, 0)"],seeAlso:["vector.iqr","vector.moving-iqr","vector.running-iqr"]},"running-iqr":{category:"vector",description:"Calculates the **running interquartile range** of a `vector`. First three element in result is `null` since **running interquartile range** is not defined for less than four elements.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The `vector` to calculate the **running interquartile range** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-iqr } = import(vector);\nrunning-iqr([1, 2, 3, 4, 5, 6])","let { running-iqr } = import(vector);\nrunning-iqr([-1, -2, -3, 1, 2, 3])"],seeAlso:["vector.iqr","vector.moving-iqr","vector.centered-moving-iqr"]},"moving-sum":{category:"vector",description:"Returns the **moving sum** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sum** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sum } = import(vector);\nmoving-sum([1, 2, 3, 4, 5], 3)","let { moving-sum } = import(vector);\nmoving-sum([1, 2, 3, 4, 5], 5)"],seeAlso:["sum","vector.centered-moving-sum","vector.running-sum"]},"centered-moving-sum":{category:"vector",description:"Returns the **centered moving sum** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sum** of."},windowSize:{type:"integer",description:"The size of the centered moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sum } = import(vector);\ncentered-moving-sum([1, 2, 3, 4, 5], 3)","let { centered-moving-sum } = import(vector);\ncentered-moving-sum([1, 2, 3, 4, 5], 3, 0, 0)","let { centered-moving-sum } = import(vector);\ncentered-moving-sum([1, 2, 3, 4, 5], 3, 10)"],seeAlso:["sum","vector.moving-sum","vector.running-sum"]},"running-sum":{category:"vector",description:"Returns the **running sum** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sum** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sum } = import(vector);\nrunning-sum([1, 2, 3])","let { running-sum } = import(vector);\nrunning-sum([1, -2, -3])"],seeAlso:["sum","vector.moving-sum","vector.centered-moving-sum","vector.cumsum"]},"moving-prod":{category:"vector",description:"Returns the **moving product** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving product** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-prod } = import(vector);\nmoving-prod([1, 2, 3, 4, 5], 3)","let { moving-prod } = import(vector);\nmoving-prod([1, 2, 3, 4, 5], 5)"],seeAlso:["prod","vector.centered-moving-prod","vector.running-prod"]},"centered-moving-prod":{category:"vector",description:"Returns the **centered moving product** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving product** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-prod } = import(vector);\ncentered-moving-prod([1, 2, 3, 4, 5], 3)","let { centered-moving-prod } = import(vector);\ncentered-moving-prod([1, 2, 3, 4, 5], 3, 0, 0)"],seeAlso:["prod","vector.moving-prod","vector.running-prod"]},"running-prod":{category:"vector",description:"Returns the **running product** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running product** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-prod } = import(vector);\nrunning-prod([1, 2, 3, 4, 5])","let { running-prod } = import(vector);\nrunning-prod([1, -2, -3])"],seeAlso:["prod","vector.moving-prod","vector.centered-moving-prod","vector.cumprod"]},span:{category:"vector",description:"Returns the difference between the maximum and minimum values in a vector.",returns:{type:"number"},args:{vector:{type:"vector",description:"The vector to calculate the span of."}},variants:[{argumentNames:["vector"]}],examples:["let { span } = import(vector);\nspan([1, 2, 3])","let { span } = import(vector);\nspan([1, 1, 2, 3, 3])","let { span } = import(vector);\nspan([1, 2, -3])"],seeAlso:["vector.moving-span","vector.centered-moving-span","vector.running-span","min","max"]},"moving-span":{category:"vector",description:"Calculates the **moving span** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving span** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-span } = import(vector);\nmoving-span([1, 2, 4, 7, 11, 16], 4)","let { moving-span } = import(vector);\nmoving-span([1, 2, 4, 7, 11, 16], 5)","let { moving-span } = import(vector);\nmoving-span([1, 2, 4, 7, 11, 16], 6)"],seeAlso:["vector.span","vector.centered-moving-span","vector.running-span"]},"centered-moving-span":{category:"vector",description:"Calculates the **centered moving span** of a `vector` with a given window size. The result is padded with `leftPadding` on the left and right.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving span** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"The value to pad the result with on the left."},rightPadding:{type:"number",description:"The value to pad the result with on the right."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-span } = import(vector);\ncentered-moving-span([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-span } = import(vector);\ncentered-moving-span([1, 2, 4, 7, 11, 16], 3, 0, 100)"],seeAlso:["vector.span","vector.moving-span","vector.running-span"]},"running-span":{category:"vector",description:"Calculates the **running span** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running span** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-span } = import(vector);\nrunning-span([1, 2, 4])"],seeAlso:["vector.span","vector.moving-span","vector.centered-moving-span"]},skewness:{category:"vector",description:"Calculates the **skewness** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **skewness** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { skewness } = import(vector);\nskewness([1, 2, 3, 6, 20])","let { skewness } = import(vector);\nskewness([1, 2, 2, 3])"],seeAlso:["vector.moving-skewness","vector.centered-moving-skewness","vector.running-skewness","vector.kurtosis","vector.sample-skewness","vector.excess-kurtosis"]},"moving-skewness":{category:"vector",description:"Calculates the **moving skewness** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving skewness** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-skewness } = import(vector);\nmoving-skewness([1, 2, 4, 7, 11, 16], 4)","let { moving-skewness } = import(vector);\nmoving-skewness([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.skewness","vector.centered-moving-skewness","vector.running-skewness"]},"centered-moving-skewness":{category:"vector",description:"Calculates the **centered moving skewness** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving skewness** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-skewness } = import(vector);\ncentered-moving-skewness([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-skewness } = import(vector);\ncentered-moving-skewness([1, 2, 4, 7, 11, 16], 4, 0, 0)"],seeAlso:["vector.skewness","vector.moving-skewness","vector.running-skewness"]},"running-skewness":{category:"vector",description:"Calculates the **running skewness** of a `vector` with a given window size. First two element in result is `null` since **running skewness** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running skewness** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-skewness } = import(vector);\nrunning-skewness([1, 2, 4, 7, 11])"],seeAlso:["vector.skewness","vector.moving-skewness","vector.centered-moving-skewness"]},"sample-skewness":{category:"vector",description:"Calculates the **sample skewness** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **sample skewness** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-skewness } = import(vector);\nsample-skewness([1, 2, 3, 6, 20])","let { sample-skewness } = import(vector);\nsample-skewness([1, 2, 2, 3])"],seeAlso:["vector.moving-sample-skewness","vector.centered-moving-sample-skewness","vector.running-sample-skewness","vector.skewness","vector.sample-kurtosis"]},"moving-sample-skewness":{category:"vector",description:"Calculates the **moving sample skewness** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample skewness** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-skewness } = import(vector);\nmoving-sample-skewness([1, 2, 4, 7, 11, 16], 4)","let { moving-sample-skewness } = import(vector);\nmoving-sample-skewness([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.sample-skewness","vector.centered-moving-sample-skewness","vector.running-sample-skewness"]},"centered-moving-sample-skewness":{category:"vector",description:"Calculates the **centered moving sample skewness** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample skewness** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-skewness } = import(vector);\ncentered-moving-sample-skewness([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-sample-skewness } = import(vector);\ncentered-moving-sample-skewness([1, 2, 4, 7, 11, 16], 3, 0, 100)"],seeAlso:["vector.sample-skewness","vector.moving-sample-skewness","vector.running-sample-skewness"]},"running-sample-skewness":{category:"vector",description:"Calculates the **running sample skewness** of a `vector` with a given window size. First two element in result is `null` since **running sample skewness** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sample skewness** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-skewness } = import(vector);\nrunning-sample-skewness([1, 2, 4, 7, 11])"],seeAlso:["vector.sample-skewness","vector.moving-sample-skewness","vector.centered-moving-sample-skewness"]},"excess-kurtosis":{category:"vector",description:"Calculates the **excess kurtosis** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **excess kurtosis** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { excess-kurtosis } = import(vector);\nexcess-kurtosis([1, 2, 3, 6, 20])","let { excess-kurtosis } = import(vector);\nexcess-kurtosis([1, 2, 2, 3])"],seeAlso:["vector.moving-excess-kurtosis","vector.centered-moving-excess-kurtosis","vector.running-excess-kurtosis","vector.kurtosis","vector.sample-excess-kurtosis","vector.skewness"]},"moving-excess-kurtosis":{category:"vector",description:"Calculates the **moving excess kurtosis** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving excess kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-excess-kurtosis } = import(vector);\nmoving-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { moving-excess-kurtosis } = import(vector);\nmoving-excess-kurtosis([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.excess-kurtosis","vector.centered-moving-excess-kurtosis","vector.running-excess-kurtosis"]},"centered-moving-excess-kurtosis":{category:"vector",description:"Calculates the **centered moving excess kurtosis** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving excess kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-excess-kurtosis } = import(vector);\ncentered-moving-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-excess-kurtosis } = import(vector);\ncentered-moving-excess-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 0)"],seeAlso:["vector.excess-kurtosis","vector.moving-excess-kurtosis","vector.running-excess-kurtosis"]},"running-excess-kurtosis":{category:"vector",description:"Calculates the **running excess kurtosis** of a `vector` with a given window size. First two element in result is `null` since **running excess kurtosis** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running excess kurtosis** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-excess-kurtosis } = import(vector);\nrunning-excess-kurtosis([1, 2, 4, 7, 11])"],seeAlso:["vector.excess-kurtosis","vector.moving-excess-kurtosis","vector.centered-moving-excess-kurtosis"]},kurtosis:{category:"vector",description:"Calculates the **kurtosis** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **kurtosis** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { kurtosis } = import(vector);\nkurtosis([1, 2, 3, 6, 20])","let { kurtosis } = import(vector);\nkurtosis([1, 2, 2, 3])"],seeAlso:["vector.moving-kurtosis","vector.centered-moving-kurtosis","vector.running-kurtosis","vector.excess-kurtosis","vector.sample-kurtosis","vector.skewness"]},"moving-kurtosis":{category:"vector",description:"Calculates the **moving kurtosis** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-kurtosis } = import(vector);\nmoving-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { moving-kurtosis } = import(vector);\nmoving-kurtosis([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.kurtosis","vector.centered-moving-kurtosis","vector.running-kurtosis"]},"centered-moving-kurtosis":{category:"vector",description:"Calculates the **centered moving kurtosis** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-kurtosis } = import(vector);\ncentered-moving-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-kurtosis } = import(vector);\ncentered-moving-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 0)"],seeAlso:["vector.kurtosis","vector.moving-kurtosis","vector.running-kurtosis"]},"running-kurtosis":{category:"vector",description:"Calculates the **running kurtosis** of a `vector` with a given window size. First two element in result is `null` since **running kurtosis** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running kurtosis** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-kurtosis } = import(vector);\nrunning-kurtosis([1, 2, 4, 7, 11])"],seeAlso:["vector.kurtosis","vector.moving-kurtosis","vector.centered-moving-kurtosis"]},"sample-excess-kurtosis":{category:"vector",description:"Calculates the **sample excess kurtosis** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **sample excess kurtosis** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-excess-kurtosis } = import(vector);\nsample-excess-kurtosis([1, 2, 3, 6, 20])","let { sample-excess-kurtosis } = import(vector);\nsample-excess-kurtosis([1, 2, 2, 3])"],seeAlso:["vector.moving-sample-excess-kurtosis","vector.centered-moving-sample-excess-kurtosis","vector.running-sample-excess-kurtosis","vector.sample-kurtosis","vector.excess-kurtosis"]},"moving-sample-excess-kurtosis":{category:"vector",description:"Calculates the **moving sample excess kurtosis** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample excess kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-excess-kurtosis } = import(vector);\nmoving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { moving-sample-excess-kurtosis } = import(vector);\nmoving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.sample-excess-kurtosis","vector.centered-moving-sample-excess-kurtosis","vector.running-sample-excess-kurtosis"]},"centered-moving-sample-excess-kurtosis":{category:"vector",description:"Calculates the **centered moving sample excess kurtosis** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample excess kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-excess-kurtosis } = import(vector);\ncentered-moving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-sample-excess-kurtosis } = import(vector);\ncentered-moving-sample-excess-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 100)"],seeAlso:["vector.sample-excess-kurtosis","vector.moving-sample-excess-kurtosis","vector.running-sample-excess-kurtosis"]},"running-sample-excess-kurtosis":{category:"vector",description:"Calculates the **running sample excess kurtosis** of a `vector` with a given window size. First two element in result is `null` since **running sample excess kurtosis** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sample excess kurtosis** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-excess-kurtosis } = import(vector);\nrunning-sample-excess-kurtosis([1, 2, 4, 7, 11])"],seeAlso:["vector.sample-excess-kurtosis","vector.moving-sample-excess-kurtosis","vector.centered-moving-sample-excess-kurtosis"]},"sample-kurtosis":{category:"vector",description:"Calculates the **sample kurtosis** of a `vector`. Returns the third standardized moment.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **sample kurtosis** of. Minimum length is 3."}},variants:[{argumentNames:["vector"]}],examples:["let { sample-kurtosis } = import(vector);\nsample-kurtosis([1, 2, 3, 6, 20])","let { sample-kurtosis } = import(vector);\nsample-kurtosis([1, 2, 2, 3])"],seeAlso:["vector.moving-sample-kurtosis","vector.centered-moving-sample-kurtosis","vector.running-sample-kurtosis","vector.sample-excess-kurtosis","vector.kurtosis","vector.sample-skewness"]},"moving-sample-kurtosis":{category:"vector",description:"Calculates the **moving sample kurtosis** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving sample kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-sample-kurtosis } = import(vector);\nmoving-sample-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { moving-sample-kurtosis } = import(vector);\nmoving-sample-kurtosis([1, 2, 4, 7, 11, 16], 5)"],seeAlso:["vector.sample-kurtosis","vector.centered-moving-sample-kurtosis","vector.running-sample-kurtosis"]},"centered-moving-sample-kurtosis":{category:"vector",description:"Calculates the **centered moving sample kurtosis** of a `vector` with a given window size and padding.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving sample kurtosis** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-sample-kurtosis } = import(vector);\ncentered-moving-sample-kurtosis([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-sample-kurtosis } = import(vector);\ncentered-moving-sample-kurtosis([1, 2, 4, 7, 11, 16], 4, 0, 100)"],seeAlso:["vector.sample-kurtosis","vector.moving-sample-kurtosis","vector.running-sample-kurtosis"]},"running-sample-kurtosis":{category:"vector",description:"Calculates the **running sample kurtosis** of a `vector` with a given window size. First two element in result is `null` since **running sample kurtosis** is not defined for less than three elements.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running sample kurtosis** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-sample-kurtosis } = import(vector);\nrunning-sample-kurtosis([1, 2, 4, 7, 11])"],seeAlso:["vector.sample-kurtosis","vector.moving-sample-kurtosis","vector.centered-moving-sample-kurtosis"]},rms:{category:"vector",description:"Calculates the **root mean square** of a `vector`. Returns the square root of the average of the squares of the elements.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **root mean square** of. Minimum length is 1."}},variants:[{argumentNames:["vector"]}],examples:["let { rms } = import(vector);\nrms([1, 2, 3, 4])","let { rms } = import(vector);\nrms([5, 4, 3, 2, 1])","let { rms } = import(vector);\nrms(range(1, 1000))","let { rms } = import(vector);\nrms(map(range(1000), -> 1e6 / ($ + 1) ^ 2))","let { rms } = import(vector);\nlet { ln } = import(math);\nrms(map(range(1000), -> ln($ + 1)))"],seeAlso:["vector.moving-rms","vector.centered-moving-rms","vector.running-rms","mean","vector.stdev"]},"moving-rms":{category:"vector",description:"Calculates the **moving root mean square** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving root mean square** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-rms } = import(vector);\nmoving-rms([1, 2, 4, 7, 11, 16], 4)","let { moving-rms } = import(vector);\nmoving-rms([1, 2, 4, 7, 11, 16], 5)","let { moving-rms } = import(vector);\nmoving-rms([1, 2, 4, 7, 11, 16], 6)"],seeAlso:["vector.rms","vector.centered-moving-rms","vector.running-rms"]},"centered-moving-rms":{category:"vector",description:"Calculates the **centered moving root mean square** of a `vector` with a given window size and padding value.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving root mean square** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-rms } = import(vector);\ncentered-moving-rms([1, 2, 4, 7, 11, 16], 4)","let { centered-moving-rms } = import(vector);\ncentered-moving-rms([1, 2, 4, 7, 11, 16], 5, 0)","let { centered-moving-rms } = import(vector);\ncentered-moving-rms([1, 2, 4, 7, 11, 16], 6, 0, 0)"],seeAlso:["vector.rms","vector.moving-rms","vector.running-rms"]},"running-rms":{category:"vector",description:"Calculates the **running root mean square** of a `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running root mean square** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-rms } = import(vector);\nrunning-rms([1, 2, 3, 4, 5, 6])","let { running-rms } = import(vector);\nrunning-rms([1, -3, 2])","let { running-rms } = import(vector);\nrunning-rms([-1, -2, -3])","let { running-rms } = import(vector);\nrunning-rms([0])"],seeAlso:["vector.rms","vector.moving-rms","vector.centered-moving-rms"]},mad:{category:"vector",description:"Returns the **mean absolute deviation** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **mean absolute deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { mad } = import(vector);\nmad([1, 2, 3])","let { mad } = import(vector);\nmad([1, 2, -3])"],seeAlso:["vector.moving-mad","vector.centered-moving-mad","vector.running-mad","vector.medad","vector.stdev","vector.variance","vector.iqr"]},"moving-mad":{category:"vector",description:"Returns the **moving mean absolute deviation** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving mean absolute deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-mad } = import(vector);\nmoving-mad([1, 2, 3, 4, 5], 3)","let { moving-mad } = import(vector);\nmoving-mad([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.mad","vector.centered-moving-mad","vector.running-mad"]},"centered-moving-mad":{category:"vector",description:"Returns the **centered moving mean absolute deviation** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving mean absolute deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-mad } = import(vector);\ncentered-moving-mad([1, 2, 3, 4, 5], 3)","let { centered-moving-mad } = import(vector);\ncentered-moving-mad([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.mad","vector.moving-mad","vector.running-mad"]},"running-mad":{category:"vector",description:"Returns the **running mean absolute deviation** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running mean absolute deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-mad } = import(vector);\nrunning-mad([1, 2, 3])","let { running-mad } = import(vector);\nrunning-mad([1, 2, -3])"],seeAlso:["vector.mad","vector.moving-mad","vector.centered-moving-mad"]},medad:{category:"vector",description:"Returns the **median absolute deviation** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **median absolute deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { medad } = import(vector);\nmedad([1, 2, 3])","let { medad } = import(vector);\nmedad([1, 2, -3])"],seeAlso:["vector.moving-medad","vector.centered-moving-medad","vector.running-medad","vector.mad","median","vector.iqr"]},"moving-medad":{category:"vector",description:"Returns the **moving median absolute deviation** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving median absolute deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-medad } = import(vector);\nmoving-medad([1, 2, 3, 4, 5], 3)","let { moving-medad } = import(vector);\nmoving-medad([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.medad","vector.centered-moving-medad","vector.running-medad"]},"centered-moving-medad":{category:"vector",description:"Returns the **centered moving median absolute deviation** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving median absolute deviation** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-medad } = import(vector);\ncentered-moving-medad([1, 2, 3, 4, 5], 3)","let { centered-moving-medad } = import(vector);\ncentered-moving-medad([1, 2, 3, 4, 5], 5)"],seeAlso:["vector.medad","vector.moving-medad","vector.running-medad"]},"running-medad":{category:"vector",description:"Returns the **running median absolute deviation** of the `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running median absolute deviation** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-medad } = import(vector);\nrunning-medad([1, 2, 3])","let { running-medad } = import(vector);\nrunning-medad([1, 2, -3])"],seeAlso:["vector.medad","vector.moving-medad","vector.centered-moving-medad"]},"gini-coefficient":{category:"vector",description:"Returns the **gini coefficient** of all elements in the `vector`.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **gini coefficient** of."}},variants:[{argumentNames:["vector"]}],examples:["let { gini-coefficient } = import(vector);\ngini-coefficient([1, 2, 3])","let { gini-coefficient } = import(vector);\ngini-coefficient([1, 1, 3])"],seeAlso:["vector.moving-gini-coefficient","vector.centered-moving-gini-coefficient","vector.running-gini-coefficient","vector.entropy"]},"moving-gini-coefficient":{category:"vector",description:"Returns the **moving gini coefficient** of the `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving gini coefficient** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-gini-coefficient } = import(vector);\nmoving-gini-coefficient([1, 2, 3], 2)","let { moving-gini-coefficient } = import(vector);\nmoving-gini-coefficient([1, 1, 3], 2)"],seeAlso:["vector.gini-coefficient","vector.centered-moving-gini-coefficient","vector.running-gini-coefficient"]},"centered-moving-gini-coefficient":{category:"vector",description:"Returns the **centered moving gini coefficient** of the `vector` with a given window size.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving gini coefficient** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-gini-coefficient } = import(vector);\ncentered-moving-gini-coefficient([1, 2, 3], 2)","let { centered-moving-gini-coefficient } = import(vector);\ncentered-moving-gini-coefficient([1, 1, 3], 2)"],seeAlso:["vector.gini-coefficient","vector.moving-gini-coefficient","vector.running-gini-coefficient"]},"running-gini-coefficient":{category:"vector",description:"Returns the **running gini coefficient** of the `vector`.",returns:{type:"array"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running gini coefficient** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-gini-coefficient } = import(vector);\nrunning-gini-coefficient([1, 2, 3])","let { running-gini-coefficient } = import(vector);\nrunning-gini-coefficient([1, 1, 3])"],seeAlso:["vector.gini-coefficient","vector.moving-gini-coefficient","vector.centered-moving-gini-coefficient"]},entropy:{category:"vector",description:"Calculates the **entropy** of a `vector`. The entropy is a measure of the uncertainty associated with a random variable.",returns:{type:"number"},args:{vector:{type:"vector",description:"The `vector` to calculate the **entropy** of. Minimum length is 1."}},variants:[{argumentNames:["vector"]}],examples:["let { entropy } = import(vector);\nentropy([1, 1, 2, 3, 3, 3])","let { entropy } = import(vector);\nentropy([1, 2, 3])","let { entropy } = import(vector);\nentropy([1, 2, 2, 3])","let { entropy } = import(vector);\nentropy([0])","let { entropy } = import(vector);\nentropy([1])","let { entropy } = import(vector);\nentropy([1, 2])"],seeAlso:["vector.moving-entropy","vector.centered-moving-entropy","vector.running-entropy","vector.gini-coefficient"]},"moving-entropy":{category:"vector",description:"Calculates the **moving entropy** of a `vector` with a given window size.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **moving entropy** of."},windowSize:{type:"integer",description:"The size of the moving window."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]}],examples:["let { moving-entropy } = import(vector);\nmoving-entropy([1, 1, 2, 3, 3, 3], 4)","let { moving-entropy } = import(vector);\nmoving-entropy([1, 1, 2, 3, 3, 3], 3)","let { moving-entropy } = import(vector);\nmoving-entropy([1, 2], 2)"],seeAlso:["vector.entropy","vector.centered-moving-entropy","vector.running-entropy"]},"centered-moving-entropy":{category:"vector",description:"Calculates the **centered moving entropy** of a `vector` with a given window size.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The `vector` to calculate the **centered moving entropy** of."},windowSize:{type:"integer",description:"The size of the moving window."},leftPadding:{type:"number",description:"Optional value to use for padding. Default is `null`."},rightPadding:{type:"number",description:"Optional value to use for right padding. Default is `null`."},a:{type:"vector"},b:{type:"integer"}},variants:[{argumentNames:["vector","windowSize"]},{argumentNames:["vector","windowSize","leftPadding"]},{argumentNames:["vector","windowSize","leftPadding","rightPadding"]}],examples:["let { centered-moving-entropy } = import(vector);\ncentered-moving-entropy([1, 1, 2, 3, 3, 3], 4)","let { centered-moving-entropy } = import(vector);\ncentered-moving-entropy([1, 1, 2, 3, 3, 3], 3)","let { centered-moving-entropy } = import(vector);\ncentered-moving-entropy([1, 2], 2)"],seeAlso:["vector.entropy","vector.moving-entropy","vector.running-entropy"]},"running-entropy":{category:"vector",description:"Calculates the **running entropy** of a `vector`.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The `vector` to calculate the **running entropy** of."}},variants:[{argumentNames:["vector"]}],examples:["let { running-entropy } = import(vector);\nrunning-entropy([1, 1, 2, 3, 3, 3])","let { running-entropy } = import(vector);\nrunning-entropy([1, 2])"],seeAlso:["vector.entropy","vector.moving-entropy","vector.centered-moving-entropy"]},"monotonic?":{category:"vector",description:"Checks if a vector is monotonic.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { monotonic? } = import(vector);\nmonotonic?([1, 2, 3])","let { monotonic? } = import(vector);\nmonotonic?([1, 2, 2, 3])","let { monotonic? } = import(vector);\nmonotonic?([3, 2, 1])","let { monotonic? } = import(vector);\nmonotonic?([3, 2, 1, 1])","let { monotonic? } = import(vector);\nmonotonic?([3, 2, 1, 2])","let { monotonic? } = import(vector);\nmonotonic?([1])","let { monotonic? } = import(vector);\nmonotonic?([])"],seeAlso:["vector.strictly-monotonic?","vector.increasing?","vector.decreasing?"]},"strictly-monotonic?":{category:"vector",description:"Checks if a vector is strictly monotonic.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([1, 2, 3])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([1, 2, 2, 3])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([3, 2, 1])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([3, 2, 1, 1])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([3, 2, 1, 2])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([1])","let { strictly-monotonic? } = import(vector);\nstrictly-monotonic?([])"],seeAlso:["vector.monotonic?","vector.strictly-increasing?","vector.strictly-decreasing?"]},"increasing?":{category:"vector",description:"Checks if a vector is increasing.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { increasing? } = import(vector);\nincreasing?([1, 2, 3])","let { increasing? } = import(vector);\nincreasing?([1, 2, 2, 3])","let { increasing? } = import(vector);\nincreasing?([3, 2, 1])","let { increasing? } = import(vector);\nincreasing?([3, 2, 1, 1])","let { increasing? } = import(vector);\nincreasing?([3, 2, 1, 2])","let { increasing? } = import(vector);\nincreasing?([1])","let { increasing? } = import(vector);\nincreasing?([])"],seeAlso:["vector.strictly-increasing?","vector.decreasing?","vector.strictly-decreasing?","vector.monotonic?"]},"decreasing?":{category:"vector",description:"Checks if a vector is decreasing.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { decreasing? } = import(vector);\ndecreasing?([1, 2, 3])","let { decreasing? } = import(vector);\ndecreasing?([1, 2, 2, 3])","let { decreasing? } = import(vector);\ndecreasing?([3, 2, 1])","let { decreasing? } = import(vector);\ndecreasing?([3, 2, 1, 1])","let { decreasing? } = import(vector);\ndecreasing?([3, 2, 1, 2])","let { decreasing? } = import(vector);\ndecreasing?([1])","let { decreasing? } = import(vector);\ndecreasing?([])"],seeAlso:["vector.strictly-decreasing?","vector.increasing?","vector.strictly-increasing?","vector.monotonic?"]},"strictly-increasing?":{category:"vector",description:"Checks if a vector is strictly increasing.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { strictly-increasing? } = import(vector);\nstrictly-increasing?([1, 2, 3])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([1, 2, 2, 3])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([3, 2, 1])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([3, 2, 1, 1])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([3, 2, 1, 2])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([1])","let { strictly-increasing? } = import(vector);\nstrictly-increasing?([])"],seeAlso:["vector.increasing?","vector.decreasing?","vector.strictly-decreasing?","vector.strictly-monotonic?"]},"strictly-decreasing?":{category:"vector",description:"Checks if a vector is strictly decreasing.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The vector to check."}},variants:[{argumentNames:["vector"]}],examples:["let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([1, 2, 3])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([1, 2, 2, 3])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([3, 2, 1])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([3, 2, 1, 1])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([3, 2, 1, 2])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([1])","let { strictly-decreasing? } = import(vector);\nstrictly-decreasing?([])"],seeAlso:["vector.increasing?","vector.strictly-increasing?","vector.decreasing?","vector.strictly-monotonic?"]},mode:{category:"vector",description:"Returns the mode of all elements in the vector.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The vector to calculate the mode of."}},variants:[{argumentNames:["vector"]}],examples:["let { mode } = import(vector);\nmode([1, 2, 3])","let { mode } = import(vector);\nmode([1, 2, -3, 1])","let { mode } = import(vector);\nmode([2, 2, 3, 3, 4])","let { mode } = import(vector);\nmode([2, 2, 3, 3])","let { mode } = import(vector);\nmode([1, 2, 3, 2, 1, 2])"],seeAlso:["mean","median"]},"min-index":{category:"vector",description:"Returns the index of the minimum value of all elements in the vector.",returns:{type:"integer"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the minimum index of."}},variants:[{argumentNames:["vector"]}],examples:["let { min-index } = import(vector);\nmin-index([1, 2, 3])","let { min-index } = import(vector);\nmin-index([1, 1, 2, 3, 3])","let { min-index } = import(vector);\nmin-index([1, 2, -3])","let { min-index } = import(vector);\nmin-index([1, 2, 3, 4])","let { min-index } = import(vector);\nmin-index([1, 2, -3, 4])"],seeAlso:["vector.max-index","min"]},"max-index":{category:"vector",description:"Returns the index of the maximum value of all elements in the vector.",returns:{type:"integer"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the maximum index of."}},variants:[{argumentNames:["vector"]}],examples:["let { max-index } = import(vector);\nmax-index([1, 2, 3])","let { max-index } = import(vector);\nmax-index([1, 1, 2, 3, 3])","let { max-index } = import(vector);\nmax-index([1, 2, -3])","let { max-index } = import(vector);\nmax-index([1, 2, 3, 4])","let { max-index } = import(vector);\nmax-index([1, 2, -3, 4])"],seeAlso:["vector.min-index","max"]},"sort-indices":{category:"vector",description:"Returns the indices of the elements in the vector sorted in ascending order.",returns:{type:"vector"},args:{vector:{type:"vector",description:"Non emtpy vector to calculate the sorted indices of."}},variants:[{argumentNames:["vector"]}],examples:["let { sort-indices } = import(vector);\nsort-indices([1, 2, 3])","let { sort-indices } = import(vector);\nsort-indices([1, 1, 2, 3, 3])","let { sort-indices } = import(vector);\nsort-indices([1, 2, -3])","let { sort-indices } = import(vector);\nsort-indices([1, 2, 3, 4])","let { sort-indices } = import(vector);\nsort-indices([1, 2, -3, 4])"],seeAlso:["sort"]},"count-values":{category:"vector",description:"Counts the number of occurrences of each value in the vector.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"Vector to count the values of."}},variants:[{argumentNames:["vector"]}],examples:["let { count-values } = import(vector);\ncount-values([1, 2, 3])","let { count-values } = import(vector);\ncount-values([1, 1, 2, 3, 3])","let { count-values } = import(vector);\ncount-values([1, 2, -3])","let { count-values } = import(vector);\ncount-values([1, 2, 2, 1, 3, 2, 4, 2, 1, 2, 2, 1, 3, 2, 4])"],seeAlso:["sequence.frequencies","vector.bincount"]},linspace:{category:"vector",description:"Generates a vector of evenly spaced numbers between two values.",returns:{type:"number",array:!0},args:{start:{type:"number",description:"The starting value."},stop:{type:"number",description:"The ending value."},n:{type:"integer",description:"The number of values to generate."}},variants:[{argumentNames:["start","stop","n"]}],examples:["let { linspace } = import(vector);\nlinspace(0, 10, 6)","let { linspace } = import(vector);\nlinspace(10, 20, 25)"],seeAlso:["range"]},cumsum:{category:"vector",description:"Calculates the cumulative sum of a vector.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The vector to calculate the cumulative sum of."}},variants:[{argumentNames:["vector"]}],examples:["let { cumsum } = import(vector);\ncumsum([1, 2, 3])","let { cumsum } = import(vector);\ncumsum([1, 2, -3])","let { cumsum } = import(vector);\ncumsum([])"],seeAlso:["vector.cumprod","sum","vector.running-sum"]},cumprod:{category:"vector",description:"Calculates the cumulative product of a vector.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The vector to calculate the cumulative product of."}},variants:[{argumentNames:["vector"]}],examples:["let { cumprod } = import(vector);\ncumprod([1, 2, 3])","let { cumprod } = import(vector);\ncumprod([1, 2, -3, 0, 10])","let { cumprod } = import(vector);\ncumprod([])"],seeAlso:["vector.cumsum","prod","vector.running-prod"]},quartiles:{category:"vector",description:"Calculates the quartiles of a vector. Returns an array containing the first, second (median), and third quartiles.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The vector to calculate the quartiles of. Minimum length is 4."}},variants:[{argumentNames:["vector"]}],examples:["let { quartiles } = import(vector);\nquartiles([1, 2, 3, 4])","let { quartiles } = import(vector);\nquartiles([5, 4, 3, 2, 1, 2, 3, 4, 5])","let { quartiles } = import(vector);\nquartiles(range(1, 1000))","let { quartiles } = import(vector);\nquartiles(map(range(1000), -> 1e6 / ($ + 1) ^ 2))","let { quartiles } = import(vector);\nlet { ln } = import(math);\nquartiles(map(range(1000), -> ln($ + 1)))"],seeAlso:["vector.percentile","vector.quantile","median","vector.iqr"]},percentile:{category:"vector",description:"Calculates the percentile of a vector. Returns the value at the specified percentile.",returns:{type:"number"},args:{vector:{type:"vector",description:"The non empty vector to calculate the percentile of."},percentile:{type:"number",description:"The percentile to calculate. Must be between 0 and 1."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["vector","percentile"]}],examples:["let { percentile } = import(vector);\npercentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 35)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 0)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 10)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 20)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 30)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 40)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 50)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 60)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 70)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 80)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 90)","let { percentile } = import(vector);\npercentile(range(100) ^ 0.5, 100)"],seeAlso:["vector.quantile","vector.quartiles","median","vector.ecdf","vector.winsorize"]},quantile:{category:"vector",description:"Calculates the quantile of a vector. Returns the value at the specified quantile.",returns:{type:"number"},args:{vector:{type:"vector",description:"The non empty vector to calculate the quantile of."},quantile:{type:"number",description:"The quantile to calculate. Must be between 0 and 1."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["vector","quantile"]}],examples:["let { quantile } = import(vector);\nquantile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 0.35)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.1)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.2)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.3)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.4)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.5)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.6)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.7)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.8)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 0.9)","let { quantile } = import(vector);\nquantile(range(100) ^ 0.5, 1)"],seeAlso:["vector.percentile","vector.quartiles","vector.ecdf"]},histogram:{category:"vector",description:"Creates a histogram from a numeric `array` by dividing the data range into the specified number of bins. Returns an `array` of `[binStart, binEnd, count]` tuples representing each bin's range and the number of values within it. Handles empty arrays, identical values, and properly places maximum values in the last bin.",returns:{type:"array",array:!0},args:{vector:{type:"vector",description:"The numeric array to create a histogram from."},bins:{type:"integer",description:"The number of bins to divide the data range into."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["vector","bins"]}],examples:["let { histogram } = import(vector);\nhistogram([1, 2, 2, 3, 2, 6, 4, 3, 2, 4, 1, 3, 2, 9], 3)","let { histogram } = import(vector);\nhistogram([1, 2, 3, 4, 5], 5)","let { histogram } = import(vector);\nhistogram([1, 2, 3, 4, 5], 10)","let { histogram } = import(vector);\nhistogram([1, 2, 3, 4, 5], 1)"],seeAlso:["vector.bincount","vector.ecdf"]},ecdf:{category:"vector",description:"Calculates the empirical cumulative distribution function value for a given threshold in a non empty dataset. Returns the proportion of values in the `array` that are less than or equal to the specified threshold.",returns:{type:"number"},args:{vector:{type:"vector",description:"The numeric array to calculate the ECDF from."},threshold:{type:"number",description:"The threshold value to calculate the ECDF for."},a:{type:"number"},b:{type:"integer"}},variants:[{argumentNames:["vector","threshold"]}],examples:["let { ecdf } = import(vector);\necdf([1, 2, 2, 3, 2, 6, 4, 3, 2, 4, 1, 3, 2, 9, 10, 12], 5)","let { ecdf } = import(vector);\necdf([1, 2, 3, 4, 5], 3)","let { ecdf } = import(vector);\necdf([1, 2, 3, 4, 5], 0)","let { ecdf } = import(vector);\necdf([1, 2, 3, 4, 5], 10)","let { ecdf } = import(vector);\necdf([1, 2, 3, 4, 5], 2)"],seeAlso:["vector.histogram","vector.percentile","vector.quantile"]},"outliers?":{category:"vector",description:"Checks if the `vector` contains outliers based on the interquartile range (IQR) method. Returns `true` if outliers are present, `false` otherwise.",returns:{type:"boolean"},args:{vector:{type:"vector",description:"The `vector` to check for outliers."}},variants:[{argumentNames:["vector"]}],examples:["let { outliers? } = import(vector);\noutliers?([1, 2, 3])","let { outliers? } = import(vector);\noutliers?([1, 2, -3])","let { outliers? } = import(vector);\noutliers?([1, 2, 3, 2, 4, 120])"],seeAlso:["vector.outliers","vector.winsorize","vector.iqr"]},outliers:{category:"vector",description:"Identifies outliers in the `vector` based on the interquartile range (IQR) method. Returns an array of outlier values.",returns:{type:"number",array:!0},args:{vector:{type:"vector",description:"The `vector` to check for outliers."}},variants:[{argumentNames:["vector"]}],examples:["let { outliers } = import(vector);\noutliers([1, 2, 3])","let { outliers } = import(vector);\noutliers([1, 2, -3])","let { outliers } = import(vector);\noutliers([1, 2, 3, 2, 4, 120])"],seeAlso:["vector.outliers?","vector.winsorize","vector.iqr"]},bincount:{category:"vector",description:"counts occurrences of each `integer` in a vector, returning an array where index `i` contains the count of value `i`, with optional **minimum size** and **weights parameters**.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The vector to count occurrences in."},minSize:{type:"integer",description:"Optional minimum size of the output array."},weights:{type:"number",array:!0,description:"Optional weights for each element in the vector."}},variants:[{argumentNames:["vector"]},{argumentNames:["vector","minSize"]},{argumentNames:["vector","minSize","weights"]}],examples:["let { bincount } = import(vector);\nbincount([1, 2, 3])","let { bincount } = import(vector);\nbincount([1, 2, 2, 3, 3])"],seeAlso:["vector.count-values","vector.histogram"],hideOperatorForm:!0},winsorize:{category:"vector",description:"Limits extreme values in a `vector` by replacing values below the **lower quantile** and above the **upper quantile** with the values at those quantiles. The function takes a `vector` of values and **quantile thresholds** (between 0 and 1), with the upper quantile. Winsorization reduces the influence of outliers while preserving the overall distribution shape, making statistical analyses more robust.",returns:{type:"vector"},args:{vector:{type:"vector",description:"The vector to winsorize."},"lower-quantile":{type:"number",description:"The lower quantile threshold (between 0 and 1)."},"upper-quantile":{type:"number",description:"Optional Upper quantile threshold (between 0 and 1). Defaults to `(1 - lower-quantile)` if `lower-quantile <= 0.5` otherwise `1`."}},variants:[{argumentNames:["vector","lower-quantile"]},{argumentNames:["vector","lower-quantile","upper-quantile"]}],examples:["let { winsorize } = import(vector);\nwinsorize([2, 5, 8, 10, 15, 18, 20, 35, 60, 100], 0.25)","let { winsorize } = import(vector);\nwinsorize([2, 5, 8, 10, 15, 18, 20, 35, 60, 100], 0.25, 0.75)","let { winsorize } = import(vector);\nwinsorize([2, 5, 8, 10, 15, 18, 20, 35, 60, 100], 0.25, 0.5)"],seeAlso:["vector.outliers","vector.outliers?","vector.percentile"],hideOperatorForm:!0},mse:{category:"vector",description:"Calculates the **Mean Squared Error (MSE)** between two vectors. Returns the average of the squared differences between corresponding elements.",returns:{type:"number"},args:{a:{type:"vector",description:"The first vector."},b:{type:"vector",description:"The second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { mse } = import(vector);\nmse([1, 2, 3], [1, 2, 3])","let { mse } = import(vector);\nmse([1, 2, 3], [4, 5, 6])","let { mse } = import(vector);\nmse([1, 2, 3], [2, 2, 2])","let { mse } = import(vector);\nmse([1, 2], [3, 3])","let { mse } = import(vector);\nmse([1], [3])"],seeAlso:["vector.rmse","vector.mae","vector.smape"]},rmse:{category:"vector",description:"Calculates the **Root Mean Squared Error (RMSE)** between two vectors. Returns the square root of the average of the squared differences between corresponding elements.",returns:{type:"number"},args:{a:{type:"vector",description:"The first vector."},b:{type:"vector",description:"The second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { rmse } = import(vector);\nrmse([1, 2, 3], [1, 2, 3])","let { rmse } = import(vector);\nrmse([1, 2, 3], [4, 5, 6])","let { rmse } = import(vector);\nrmse([1, 2, 3], [2, 2, 2])","let { rmse } = import(vector);\nrmse([1, 2], [3, 3])","let { rmse } = import(vector);\nrmse([1], [3])"],seeAlso:["vector.mse","vector.mae","vector.smape"]},mae:{category:"vector",description:"Calculates the **Mean Absolute Error (MAE)** between two vectors. Returns the average of the absolute differences between corresponding elements.",returns:{type:"number"},args:{a:{type:"vector",description:"The first vector."},b:{type:"vector",description:"The second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { mae } = import(vector);\nmae([1, 2, 3], [1, 2, 3])","let { mae } = import(vector);\nmae([1, 2, 3], [4, 5, 6])","let { mae } = import(vector);\nmae([1, 2, 3], [2, 2, 2])","let { mae } = import(vector);\nmae([1, 2], [3, 3])","let { mae } = import(vector);\nmae([1], [3])"],seeAlso:["vector.mse","vector.rmse","vector.smape"]},smape:{category:"vector",description:"Calculates the **Symmetric Mean Absolute Percentage Error (SMAPE)** between two vectors. Returns the average of the absolute percentage differences between corresponding elements.",returns:{type:"number"},args:{a:{type:"vector",description:"The first vector."},b:{type:"vector",description:"The second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { smape } = import(vector);\nsmape([1, 2, 3], [1, 2, 3])","let { smape } = import(vector);\nsmape([1, 2, 3], [4, 5, 6])","let { smape } = import(vector);\nsmape([1, 2, 3], [2, 2, 2])","let { smape } = import(vector);\nsmape([1, 2], [3, 3])","let { smape } = import(vector);\nsmape([1], [3])"],seeAlso:["vector.mse","vector.rmse","vector.mae"]}};function Tr(e){if(e.length<=1)return[];const t=[...e].sort((e,t)=>e-t),r=Math.floor(.25*t.length),n=t.length%4==0?(t[r-1]+t[r])/2:t[r],o=Math.floor(.75*t.length),a=t.length%4==0?(t[o-1]+t[o])/2:t[o],i=a-n,s=n-1.5*i,c=a+1.5*i;return e.filter(e=>e<s||e>c)}function Sr(e,t){const r=[...e].sort((e,t)=>e-t);if(0===t)return r[0];if(100===t)return r[r.length-1];const n=t/100*(r.length-1);if(Number.isInteger(n))return r[n];const o=Math.floor(n),a=Math.ceil(n),i=n-o;return r[o]*(1-i)+r[a]*i}function zr(e){const t=[...e].sort((e,t)=>e-t),r=t.length/2;let n;n=t.length%2==0?(t[r-1]+t[r])/2:t[Math.floor(r)];const o=t.slice(0,Math.floor(t.length/2)),a=t.slice(Math.ceil(t.length/2));let i,s;if(o.length%2==0){const e=o.length/2;i=(o[e-1]+o[e])/2}else i=o[Math.floor(o.length/2)];if(a.length%2==0){const e=a.length/2;s=(a[e-1]+a[e])/2}else s=a[Math.floor(a.length/2)];return[i,n,s]}function jr(e){if(0===e.length)return 0;return e.reduce((e,t)=>e+t,0)/e.length}const Ir={"geometric-mean":e=>{if(e.some(e=>e<0))throw new Error("Geometric mean is not defined for non-positive numbers");return Math.exp(e.reduce((e,t)=>e+Math.log(t),0)/e.length)}};function Cr(e){const t=[...e].sort((e,t)=>e-t),r=Math.floor(t.length/2);return t.length%2==0?(t[r-1]+t[r])/2:t[r]}const Rr={median:e=>Cr(e)};function Mr(e,t){const r=t??jr(e);return e.reduce((e,t)=>e+(t-r)**2,0)/e.length}const Pr={variance:e=>Mr(e)},Or={"sample-variance":e=>function(e){const t=jr(e);return e.reduce((e,r)=>e+(r-t)**2,0)/(e.length-1)}(e),minLength:2};function Dr(e,t){const r=Mr(e,t);return Math.sqrt(r)}const Vr={stdev:e=>Dr(e)},Ur={"sample-stdev":e=>function(e,t){const r=Mr(e,t);return Math.sqrt(r*(e.length/(e.length-1)))}(e),minLength:2},Fr={iqr:e=>{const[t,,r]=zr(e);return r-t},minLength:4},Wr={span:e=>0===e.length?0:Math.max(...e)-Math.min(...e),minLength:0};const Gr={skewness:e=>function(e){const t=jr(e),r=Dr(e);if(0===r)throw new Error("Standard deviation is zero, skewness is undefined");return e.reduce((e,r)=>e+(r-t)**3,0)/(e.length*r**3)}(e),minLength:3},Br={"sample-skewness":e=>function(e){const t=e.length,r=e.reduce((e,t)=>e+t,0)/t;let n=0,o=0;for(const t of e){const e=t-r;n+=e*e,o+=e*e*e}const a=n/(t-1),i=Math.sqrt(a);if(0===i)throw new Error("Cannot calculate sample skewness when standard deviation is 0");return t/((t-1)*(t-2))*o/i**3}(e),minLength:3};function Lr(e){const t=jr(e),r=Dr(e);if(0===r)throw new Error("Standard deviation is zero, kurtosis is undefined");return e.reduce((e,r)=>e+(r-t)**4,0)/(e.length*r**4)}const _r={kurtosis:e=>Lr(e),minLength:4},Kr={"excess-kurtosis":e=>function(e){return Lr(e)-3}(e),minLength:4},Jr={"sample-kurtosis":e=>function(e){const t=e.length,r=e.reduce((e,t)=>e+t,0)/t,n=e.reduce((e,t)=>e+(t-r)**2,0)/(t-1);if(0===n)throw new Error("Variance is zero, kurtosis is undefined");return t*(t+1)*e.reduce((e,t)=>e+(t-r)**4,0)/((t-1)*(t-2)*(t-3)*n**2)}(e),minLength:4},Hr={"sample-excess-kurtosis":e=>function(e){const t=e.length,r=e.reduce((e,t)=>e+t,0)/t,n=e.reduce((e,t)=>e+(t-r)**2,0)/(t-1);if(0===n)throw new Error("Variance is zero, kurtosis is undefined");return t*(t+1)*e.reduce((e,t)=>e+(t-r)**4,0)/((t-1)*(t-2)*(t-3)*n**2)-3*(t-1)*(t-1)/((t-2)*(t-3))}(e),minLength:4},Yr={rms:e=>Math.sqrt(e.reduce((e,t)=>e+t**2,0)/e.length)};const Xr={mad:e=>function(e){const t=Cr(e);return e.reduce((e,r)=>e+Math.abs(r-t),0)/e.length}(e)};function Qr(e){const t=Cr(e);return 1.4826*Cr(e.map(e=>Math.abs(e-t)))}const Zr={medad:e=>Qr(e)},en={"gini-coefficient":e=>{if(e.some(e=>e<0))throw new Error("Gini coefficient is not defined for negative values");const t=[...e].sort((e,t)=>e-t),r=t.length,n=t.reduce((e,t)=>e+t,0);if(0===n)return 0;return 2*t.reduce((e,t,r)=>e+(r+1)*t,0)/(r*n)-(r+1)/r},minLength:1};const tn={entropy:e=>function(e){const t=new Map;for(const r of e)t.set(r,(t.get(r)||0)+1);const r=e.length;let n=0;for(const e of t.values()){const t=e/r;t>0&&(n-=t*Math.log2(t))}return n}(e),minLength:1},rn={};function nn(e){for(const[t,r]of Object.entries(e)){if(rn[t])throw new Error(`Duplicate normal expression key found: ${t}`);if("minLength"!==t&&"padding"!==t&&"function"==typeof r){const n=r,o=t.replace(/^/,""),a=`moving-${o}`,i=`centered-moving-${o}`,s=`running-${o}`,c=e.minLength??1;Y(c,void 0,{integer:!0,finite:!0,gte:0}),rn[t]=on(n,c),rn[a]=an(n,c),rn[i]=sn(n,c,e.padding??null),rn[s]=cn(n,c)}}}function on(e,t){return{evaluate:([n],o)=>{if(Ce(n,o),n.length<t)throw new r(`Vector length must be at least ${t}`,o);try{return e(n)}catch(e){throw new r(e,o)}},arity:re(1)}}function an(e,t){return{evaluate:([n,o],a)=>{if(Ce(n,a),Y(o,a,{integer:!0,finite:!0,gte:t,lte:n.length}),0===n.length)return[];try{if(o>=n.length)return[e(n)];const t=[];for(let r=0;r<n.length-o+1;r+=1)t.push(e(n.slice(r,r+o)));return t}catch(e){throw new r(e,a)}},arity:re(2)}}function sn(e,t,n){return{evaluate:([o,a,i,s],c)=>{if(Ce(o,c),o.length<t)throw new r(`Vector length must be at least ${t}`,c);if(Y(a,c,{integer:!0,finite:!0,gte:t,lte:o.length}),null!==(i=i??n)&&Y(i,c,{finite:!0}),null!==(s=s??n)&&Y(s,c,{finite:!0}),0===o.length)return[];const l=Math.floor(a/2),u=[...Array(l).fill(i),...o,...Array(l).fill(s)],m="number"==typeof i?0:l,p=o.length-("number"==typeof s?0:a-l-1),d=[...Array(m).fill(null)];try{for(let t=m;t<p;t+=1)d.push(e(u.slice(t,t+a)))}catch(e){throw new r(e,c)}return d.push(...Array(o.length-p).fill(null)),d},arity:{min:2,max:4}}}function cn(e,t){return{evaluate:([n],o)=>{if(Ce(n,o),n.length<t)throw new r(`Vector length must be at least ${t}`,o);if(0===n.length)return[];try{const r=Math.max(t-1,0),o=Array(r).fill(null);for(let t=r;t<n.length;t+=1)o.push(e(n.slice(0,t+1)));return o}catch(e){throw new r(e,o)}},arity:re(1)}}nn({mean:e=>jr(e)}),nn(Ir),nn({"harmonic-mean":e=>e.length/e.reduce((e,t)=>e+1/t,0)}),nn(Rr),nn({sum:e=>e.reduce((e,t)=>e+t,0),minLength:0}),nn({prod:e=>e.reduce((e,t)=>e*t,1),padding:1,minLength:0}),nn(Pr),nn(Or),nn(Vr),nn(Ur),nn(Fr),nn(Wr),nn(Gr),nn(Br),nn(Kr),nn(_r),nn(Hr),nn(Jr),nn(Yr),nn(Xr),nn(Zr),nn(en),nn(tn),delete rn.sum,delete rn.prod,delete rn.mean,delete rn.median;const ln={"monotonic?":{evaluate:([e],t)=>(Ce(e,t),e.every((t,r)=>0===r||t>=e[r-1])||e.every((t,r)=>0===r||t<=e[r-1])),arity:re(1)},"strictly-monotonic?":{evaluate:([e],t)=>(Ce(e,t),e.every((t,r)=>0===r||t>e[r-1])||e.every((t,r)=>0===r||t<e[r-1])),arity:re(1)},"increasing?":{evaluate:([e],t)=>(Ce(e,t),e.every((t,r)=>0===r||t>=e[r-1])),arity:re(1)},"decreasing?":{evaluate:([e],t)=>(Ce(e,t),e.every((t,r)=>0===r||t<=e[r-1])),arity:re(1)},"strictly-increasing?":{evaluate:([e],t)=>(Ce(e,t),e.every((t,r)=>0===r||t>e[r-1])),arity:re(1)},"strictly-decreasing?":{evaluate:([e],t)=>(Ce(e,t),e.every((t,r)=>0===r||t<e[r-1])),arity:re(1)},mode:{evaluate:([e],t)=>(Pe(e,t),function(e){const t=new Map;for(const r of e)t.set(r,(t.get(r)||0)+1);let r=0;for(const e of t.values())e>r&&(r=e);if(1===r)return e;const n=[];for(const[e,o]of t.entries())o===r&&n.push(e);return n}(e)),arity:re(1)},"min-index":{evaluate:([e],t)=>(Pe(e,t),e.reduce((t,r,n)=>r<e[t]?n:t,0)),arity:re(1)},"max-index":{evaluate:([e],t)=>(Pe(e,t),e.reduce((t,r,n)=>r>e[t]?n:t,0)),arity:re(1)},"sort-indices":{evaluate:([e],t)=>(Ce(e,t),[...e.keys()].sort((t,r)=>e[t]-e[r])),arity:re(1)},"count-values":{evaluate:([e],t)=>{Ce(e,t);const r=new Map;for(const t of e)r.set(t,(r.get(t)||0)+1);return[...r.entries()].sort((e,t)=>{const r=t[1]-e[1];return 0!==r?r:e[0]-t[0]})},arity:re(1)},linspace:{evaluate:([e,t,r],n)=>{if(Y(e,n,{finite:!0}),Y(t,n,{finite:!0}),Y(r,n,{integer:!0,nonNegative:!0}),0===r)return[];if(1===r)return[e];const o=(t-e)/(r-1);return Array.from({length:r},(t,r)=>e+r*o)},arity:re(3)},cumsum:{evaluate:([e],t)=>(Ce(e,t),e.reduce((e,t)=>{const r=e[e.length-1]??0;return e.push(r+t),e},[])),arity:re(1)},cumprod:{evaluate:([e],t)=>(Ce(e,t),e.reduce((e,t)=>{const r=e[e.length-1]??1;return e.push(r*t),e},[])),arity:re(1)},quartiles:{evaluate:([e],t)=>{if(Ce(e,t),e.length<4)throw new r("Quartiles require at least four values",t);return zr(e)},arity:re(1)},percentile:{evaluate:([e,t],r)=>(Pe(e,r),Y(t,r,{finite:!0,nonNegative:!0,lte:100}),Sr(e,t)),arity:re(2)},quantile:{evaluate:([e,t],r)=>(Ce(e,r),Y(t,r,{finite:!0,nonNegative:!0,lte:1}),Sr(e,100*t)),arity:re(2)},histogram:{evaluate:([e,t],r)=>(Ce(e,r),Y(t,r,{integer:!0,positive:!0}),function(e,t){if(0===e.length){const e=[];for(let r=0;r<t;r++)e.push([0,0,0]);return e}const r=Math.min(...e),n=Math.max(...e);if(r===n){const n=[];for(let e=0;e<t;e++)n.push([r,r,0]);return n[0][2]=e.length,n}const o=(n-r)/t,a=[];for(let e=0;e<t;e++){const i=r+e*o,s=e===t-1?n:r+(e+1)*o;a.push([i,s,0])}for(const i of e)i===n?a[t-1][2]+=1:a[Math.min(Math.floor((i-r)/o),t-1)][2]+=1;return a}(e,t)),arity:re(2)},ecdf:{evaluate:([e,t],r)=>{Pe(e,r),Y(t,r,{finite:!0});const n=[...e].sort((e,t)=>e-t),o=n.findIndex(e=>e>t);return-1===o?1:o/n.length},arity:re(2)},"outliers?":{evaluate:([e],t)=>(Ce(e,t),function(e){return Tr(e).length>0}(e)),arity:re(1)},outliers:{evaluate:([e],t)=>(Ce(e,t),Tr(e)),arity:re(1)},bincount:{evaluate:(e,t)=>{const n=e[0];Ce(n,t),n.forEach(e=>Y(e,t,{finite:!0,integer:!0,nonNegative:!0}));const o=e[1]??0;Y(o,t,{integer:!0,nonNegative:!0});const a=e[2]??void 0;if(void 0!==a){if(Ce(a,t),a.length!==n.length)throw new r("Weights vector must be the same length as the input vector",t);a.forEach(e=>Y(e,t,{finite:!0}))}return function(e,t=0,r){if(0===e.length)return Array.from({length:t},()=>0);const n=Math.max(...e),o=Math.max(n+1,t),a=Array.from({length:o},()=>0);for(let t=0;t<e.length;t++){const n=Math.floor(e[t]);n<o&&(a[n]+=r?r[t]:1)}return a}(n,o,a)},arity:{min:1,max:3}},winsorize:{evaluate:([e,t,r],n)=>{if(Ce(e,n),Y(t,n,{finite:!0,gte:0,lte:1}),r??=t>.5?1:1-t,Y(r,n,{finite:!0,gte:t,lte:1}),0===e.length)return[];const o=[...e].sort((e,t)=>e-t),a=Math.max(0,Math.floor(t*e.length)),i=Math.min(e.length-1,Math.max(0,Math.floor(r*e.length)-1)),s=o[a],c=o[i];return e.map(e=>Math.max(s,Math.min(e,c)))},arity:{min:2,max:3}},mse:{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+(r-t[n])**2,0)/e.length},arity:re(2)},rmse:{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return Math.sqrt(e.reduce((e,r,n)=>e+(r-t[n])**2,0)/e.length)},arity:re(2)},mae:{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+Math.abs(r-t[n]),0)/e.length},arity:re(2)},smape:{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>{const o=Math.abs(r-t[n]),a=(Math.abs(r)+Math.abs(t[n]))/2;return e+(0===a?0:o/a)},0)/e.length},arity:re(2)}};!function(e){for(const[t,r]of Object.entries(e)){if(ln[t])throw new Error(`Duplicate normal expression key found: ${t}`);ln[t]=r}}(rn);for(const[e,t]of Object.entries(Er))ln[e]&&(ln[e].docs=t);const un={name:"vector",functions:ln,source:"{}",docs:Er},mn={reflect:{category:"linear-algebra",description:"Reflects a vector across a given axis.",returns:{type:"vector"},args:{a:{type:"vector",description:"Vector to reflect."},b:{type:"vector",description:"Axis of reflection."}},variants:[{argumentNames:["a","b"]}],examples:["let { reflect } = import(linear-algebra);\nreflect([1, 2], [0, 1])","let { reflect } = import(linear-algebra);\nreflect([1, 2, 3], [0, 0, 1])"],seeAlso:["linear-algebra.refract","linear-algebra.projection"]},refract:{category:"linear-algebra",description:"Refracts a vector across a given axis.",returns:{type:"vector"},args:{vector:{type:"vector",description:"Vector to refract."},axis:{type:"vector",description:"Axis of refraction."},eta:{type:"number",description:"Refraction index."}},variants:[{argumentNames:["vector","axis","eta"]}],examples:["let { refract } = import(linear-algebra);\nrefract([1, 2], [0, 1], 1.5)","let { refract } = import(linear-algebra);\nrefract([1, 2, 3], [0, 0, 1], 1.5)"],seeAlso:["linear-algebra.reflect"]},lerp:{category:"linear-algebra",description:"Performs linear interpolation between two vectors.",returns:{type:"vector"},args:{a:{type:"vector",description:"Start vector."},b:{type:"vector",description:"End vector."},t:{type:"number",description:"Interpolation factor (0 to 1)."}},variants:[{argumentNames:["a","b","t"]}],examples:["let { lerp } = import(linear-algebra);\nlerp([1, 2], [3, 4], 0.5)","let { lerp } = import(linear-algebra);\nlerp([1, 2], [3, 4], 2)","let { lerp } = import(linear-algebra);\nlerp([1, 2], [3, 4], -1)","let { lerp } = import(linear-algebra);\nlerp([1, 2, 3], [4, 5, 6], 0.25)"],seeAlso:["linear-algebra.projection"]},rotate2d:{category:"linear-algebra",description:"Rotates a 2D vector by a given angle in radians.",returns:{type:"vector"},args:{a:{type:"vector",description:"Vector to rotate."},b:{type:"number",description:"Angle in b."}},variants:[{argumentNames:["a","b"]}],examples:["let { rotate2d } = import(linear-algebra);\nrotate2d([1, 0], PI / 2)","let { rotate2d } = import(linear-algebra);\nrotate2d([0, 1], PI)"],seeAlso:["linear-algebra.rotate3d","linear-algebra.angle"]},rotate3d:{category:"linear-algebra",description:"Rotates a 3D vector around a given axis by a given angle in radians.",returns:{type:"vector"},args:{v:{type:"vector",description:"Vector to rotate."},axis:{type:"vector",description:"Axis of rotation."},radians:{type:"number",description:"Angle in radians."}},variants:[{argumentNames:["v","axis","radians"]}],examples:["let { rotate3d } = import(linear-algebra);\nrotate3d([1, 0, 0], [0, 1, 0], PI / 2)","let { rotate3d } = import(linear-algebra);\nrotate3d([0, 1, 0], [1, 0, 0], PI)"],seeAlso:["linear-algebra.rotate2d","linear-algebra.angle"]},dot:{category:"linear-algebra",description:"Calculates the dot product of two vectors. The result is a scalar.",returns:{type:"number"},args:{a:{type:"vector",description:"First vector."},b:{type:"vector",description:"Second vector."}},variants:[{argumentNames:["a","b"]}],examples:["let { dot } = import(linear-algebra);\ndot([1, 2], [3, 4])","let { dot } = import(linear-algebra);\ndot([1, 2, 3], [4, 5, 6])"],seeAlso:["linear-algebra.cross","linear-algebra.cosine-similarity","linear-algebra.angle","linear-algebra.projection","linear-algebra.orthogonal?"]},cross:{category:"linear-algebra",description:"Calculates the cross product of two 3D vectors. The result is a vector perpendicular to both input vectors.",returns:{type:"vector"},args:{a:{type:"vector",description:"First vector (3D)."},b:{type:"vector",description:"Second vector (3D)."}},variants:[{argumentNames:["a","b"]}],examples:["let { cross } = import(linear-algebra);\ncross([1, 2, 3], [4, 5, 6])","let { cross } = import(linear-algebra);\ncross([1, 0, 0], [0, 1, 0])","let { cross } = import(linear-algebra);\ncross([0, 0, 1], [1, 0, 0])","let { cross } = import(linear-algebra);\ncross([1, 2, 3], [0, 0, 0])","let { cross } = import(linear-algebra);\ncross([0, 0, 0], [1, 2, 3])"],seeAlso:["linear-algebra.dot"]},"normalize-minmax":{category:"linear-algebra",description:"Normalizes the vector using min-max normalization. The result is a vector with values between 0 and 1.",returns:{type:"number",array:!0},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, 3])","let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, -3])","let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, 3, 4])","let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, -3, 4])","let { normalize-minmax } = import(linear-algebra);\nnormalize-minmax([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-zscore","linear-algebra.normalize-robust","linear-algebra.normalize-l1","linear-algebra.normalize-l2","linear-algebra.normalize-log"]},"normalize-zscore":{category:"linear-algebra",description:"Normalizes the vector using z-score normalization. The result is a vector with mean 0 and standard deviation 1.",returns:{type:"number",array:!0},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, 3])","let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, -3])","let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, 3, 4])","let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, -3, 4])","let { normalize-zscore } = import(linear-algebra);\nnormalize-zscore([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-minmax","linear-algebra.normalize-robust","linear-algebra.normalize-l1","linear-algebra.normalize-l2","linear-algebra.normalize-log"]},"normalize-robust":{category:"linear-algebra",description:"Normalizes the vector using robust normalization. The result is a vector with median 0 and median absolute deviation 1.",returns:{type:"number",array:!0},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, 3])","let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, -3])","let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, 3, 4])","let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, -3, 4])","let { normalize-robust } = import(linear-algebra);\nnormalize-robust([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-minmax","linear-algebra.normalize-zscore"]},"normalize-l1":{category:"linear-algebra",description:"Normalizes the vector using L1 normalization. The result is a vector with L1 norm equal to 1.",returns:{type:"number",array:!0},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, 3])","let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, -3])","let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, 3, 4])","let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, -3, 4])","let { normalize-l1 } = import(linear-algebra);\nnormalize-l1([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-l2","linear-algebra.normalize-minmax","linear-algebra.manhattan-norm","linear-algebra.normalize-zscore"]},"normalize-l2":{category:"linear-algebra",description:"Normalizes the vector using L2 normalization. The result is a vector with L2 norm equal to 1.",returns:{type:"number",array:!0},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, 3])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, 3])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, -3])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, 3, 4])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, -3, 4])","let { normalize-l2 } = import(linear-algebra);\nnormalize-l2([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-l1","linear-algebra.normalize-minmax","linear-algebra.euclidean-norm","linear-algebra.normalize-zscore"]},"normalize-log":{category:"linear-algebra",description:"Normalizes the vector using natural log normalization. The result is a vector with log-transformed values.",returns:{type:"number",array:!0},args:{v:{type:"vector",description:"Vector to normalize."}},variants:[{argumentNames:["v"]}],examples:["let { normalize-log } = import(linear-algebra);\nnormalize-log([1, 2, 3])","let { normalize-log } = import(linear-algebra);\nnormalize-log([1, 2, 3, 4])","let { normalize-log } = import(linear-algebra);\nnormalize-log([1, 2, 3, 40, 50])"],seeAlso:["linear-algebra.normalize-minmax","linear-algebra.normalize-zscore"]},angle:{category:"linear-algebra",description:"Calculates the **angle** between two vectors in radians.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { angle } = import(linear-algebra);\nangle([1, 0], [0, 1])","let { angle } = import(linear-algebra);\nangle([1, 0, 1], [0, 1, 0])"],seeAlso:["linear-algebra.dot","linear-algebra.collinear?","linear-algebra.orthogonal?","linear-algebra.rotate2d","linear-algebra.rotate3d","linear-algebra.parallel?","linear-algebra.cosine-similarity","linear-algebra.to-polar"]},projection:{category:"linear-algebra",description:"Calculates the **projection** of vector `a` onto vector `b`.",returns:{type:"vector"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { projection } = import(linear-algebra);\nprojection([1, 2], [3, 4])","let { projection } = import(linear-algebra);\nprojection([1, 2, 3], [4, 5, 6])"],seeAlso:["linear-algebra.dot","linear-algebra.reflect","linear-algebra.lerp"]},"collinear?":{category:"linear-algebra",description:"Checks if two vectors are **collinear**.",returns:{type:"boolean"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { collinear? } = import(linear-algebra);\ncollinear?([1, 2], [2, 4])","let { collinear? } = import(linear-algebra);\ncollinear?([1, 2], [-2, -4])","let { collinear? } = import(linear-algebra);\ncollinear?([1, 2, 3], [2, 4, 6])"],seeAlso:["linear-algebra.parallel?","linear-algebra.orthogonal?","linear-algebra.angle"]},"parallel?":{category:"linear-algebra",description:"Checks if two vectors are **parallel**.",returns:{type:"boolean"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { parallel? } = import(linear-algebra);\nparallel?([1, 2], [2, 4])","let { parallel? } = import(linear-algebra);\nparallel?([1, 2], [-2, -4])","let { parallel? } = import(linear-algebra);\nparallel?([1, 2, 3], [2, 4, 6])","let { parallel? } = import(linear-algebra);\nparallel?([1, 2], [3, 4])"],seeAlso:["linear-algebra.collinear?","linear-algebra.orthogonal?","linear-algebra.angle"]},"orthogonal?":{category:"linear-algebra",description:"Checks if two vectors are **orthogonal**.",returns:{type:"boolean"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { orthogonal? } = import(linear-algebra);\northogonal?([1, 0], [0, 1])","let { orthogonal? } = import(linear-algebra);\northogonal?([1, 0, 1], [0, 1, 0])","let { orthogonal? } = import(linear-algebra);\northogonal?([1, 2], [2, -1])"],seeAlso:["linear-algebra.collinear?","linear-algebra.parallel?","linear-algebra.dot","matrix.orthogonal-matrix?","linear-algebra.angle"]},"cosine-similarity":{category:"linear-algebra",description:"Calculates the **cosine similarity** between two vectors. The result is a value between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { cosine-similarity } = import(linear-algebra);\ncosine-similarity([1, 2], [3, 4])","let { cosine-similarity } = import(linear-algebra);\ncosine-similarity([1, 2, 3], [4, 5, 6])","let { cosine-similarity } = import(linear-algebra);\ncosine-similarity([1, 0], [0, 1])"],seeAlso:["linear-algebra.dot","linear-algebra.angle","linear-algebra.euclidean-distance"]},"euclidean-distance":{category:"linear-algebra",description:"Calculates the **Euclidean distance** between two vectors. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { euclidean-distance } = import(linear-algebra);\neuclidean-distance([1, 2], [3, 4])","let { euclidean-distance } = import(linear-algebra);\neuclidean-distance([1, 2, 3], [4, 5, 6])","let { euclidean-distance } = import(linear-algebra);\neuclidean-distance([1, 0], [0, 1])"],seeAlso:["linear-algebra.manhattan-distance","linear-algebra.chebyshev-distance","linear-algebra.minkowski-distance","linear-algebra.euclidean-norm","linear-algebra.cosine-similarity","linear-algebra.hamming-distance"]},"euclidean-norm":{category:"linear-algebra",description:"Calculates the **Euclidean norm** (L2 norm) of a vector. The result is a non-negative number.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to calculate the norm for."}},variants:[{argumentNames:["v"]}],examples:["let { euclidean-norm } = import(linear-algebra);\neuclidean-norm([1, 2])","let { euclidean-norm } = import(linear-algebra);\neuclidean-norm([3, 4])","let { euclidean-norm } = import(linear-algebra);\neuclidean-norm([1, 2, 3])"],seeAlso:["linear-algebra.manhattan-norm","linear-algebra.chebyshev-norm","linear-algebra.minkowski-norm","linear-algebra.euclidean-distance","linear-algebra.normalize-l2","linear-algebra.hamming-norm"]},"manhattan-distance":{category:"linear-algebra",description:"Calculates the **Manhattan distance** between two vectors. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { manhattan-distance } = import(linear-algebra);\nmanhattan-distance([1, 2], [3, 4])","let { manhattan-distance } = import(linear-algebra);\nmanhattan-distance([1, 2, 3], [4, 5, 6])","let { manhattan-distance } = import(linear-algebra);\nmanhattan-distance([1, 0], [0, 1])"],seeAlso:["linear-algebra.euclidean-distance","linear-algebra.chebyshev-distance","linear-algebra.minkowski-distance","linear-algebra.manhattan-norm","linear-algebra.hamming-distance"]},"manhattan-norm":{category:"linear-algebra",description:"Calculates the **Manhattan norm** (L1 norm) of a vector. The result is a non-negative number.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to calculate the norm for."}},variants:[{argumentNames:["v"]}],examples:["let { manhattan-norm } = import(linear-algebra);\nmanhattan-norm([1, 2])","let { manhattan-norm } = import(linear-algebra);\nmanhattan-norm([3, 4])","let { manhattan-norm } = import(linear-algebra);\nmanhattan-norm([1, 2, 3])"],seeAlso:["linear-algebra.euclidean-norm","linear-algebra.chebyshev-norm","linear-algebra.minkowski-norm","linear-algebra.manhattan-distance","linear-algebra.normalize-l1","linear-algebra.hamming-norm"]},"hamming-distance":{category:"linear-algebra",description:"Calculates the **Hamming distance** between two vectors. The result is a non-negative integer.",returns:{type:"integer"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { hamming-distance } = import(linear-algebra);\nhamming-distance([1, 2], [3, 4])","let { hamming-distance } = import(linear-algebra);\nhamming-distance([1, 2, 3], [4, 5, 6])","let { hamming-distance } = import(linear-algebra);\nhamming-distance([1, 0], [0, 1])"],seeAlso:["linear-algebra.euclidean-distance","linear-algebra.manhattan-distance","linear-algebra.hamming-norm"]},"hamming-norm":{category:"linear-algebra",description:"Calculates the **Hamming norm** of a vector. The result is a non-negative integer.",returns:{type:"integer"},args:{v:{type:"vector",description:"Vector to calculate the norm for."}},variants:[{argumentNames:["v"]}],examples:["let { hamming-norm } = import(linear-algebra);\nhamming-norm([1, 2])","let { hamming-norm } = import(linear-algebra);\nhamming-norm([3, 4])","let { hamming-norm } = import(linear-algebra);\nhamming-norm([1, 2, 3])"],seeAlso:["linear-algebra.euclidean-norm","linear-algebra.manhattan-norm","linear-algebra.hamming-distance"]},"chebyshev-distance":{category:"linear-algebra",description:"Calculates the **Chebyshev distance** between two vectors. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { chebyshev-distance } = import(linear-algebra);\nchebyshev-distance([1, 2], [3, 4])","let { chebyshev-distance } = import(linear-algebra);\nchebyshev-distance([1, 2, 3], [4, 5, 6])","let { chebyshev-distance } = import(linear-algebra);\nchebyshev-distance([1, 0], [0, 1])"],seeAlso:["linear-algebra.euclidean-distance","linear-algebra.manhattan-distance","linear-algebra.minkowski-distance","linear-algebra.chebyshev-norm"]},"chebyshev-norm":{category:"linear-algebra",description:"Calculates the **Chebyshev norm** of a vector. The result is a non-negative number.",returns:{type:"number"},args:{v:{type:"vector",description:"Vector to calculate the norm for."}},variants:[{argumentNames:["v"]}],examples:["let { chebyshev-norm } = import(linear-algebra);\nchebyshev-norm([1, 2])","let { chebyshev-norm } = import(linear-algebra);\nchebyshev-norm([3, 4])","let { chebyshev-norm } = import(linear-algebra);\nchebyshev-norm([1, 2, 3])"],seeAlso:["linear-algebra.euclidean-norm","linear-algebra.manhattan-norm","linear-algebra.minkowski-norm","linear-algebra.chebyshev-distance"]},"minkowski-distance":{category:"linear-algebra",description:"Calculates the **Minkowski distance** between two vectors. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"},p:{type:"number",description:"Order of the norm (p)."}},variants:[{argumentNames:["a","b","p"]}],examples:["let { minkowski-distance } = import(linear-algebra);\nminkowski-distance([1, 2], [3, 4], 2)","let { minkowski-distance } = import(linear-algebra);\nminkowski-distance([1, 2, 3], [4, 5, 6], 3)","let { minkowski-distance } = import(linear-algebra);\nminkowski-distance([1, 0], [0, 1], 1)"],seeAlso:["linear-algebra.euclidean-distance","linear-algebra.manhattan-distance","linear-algebra.chebyshev-distance","linear-algebra.minkowski-norm"]},"minkowski-norm":{category:"linear-algebra",description:"Calculates the **Minkowski norm** of a vector. The result is a non-negative number.",returns:{type:"number"},args:{a:{type:"vector",description:"Vector to calculate the norm for."},b:{type:"number",description:"Order of the norm (p)."}},variants:[{argumentNames:["a","b"]}],examples:["let { minkowski-norm } = import(linear-algebra);\nminkowski-norm([1, 2], 2)","let { minkowski-norm } = import(linear-algebra);\nminkowski-norm([3, 4], 3)","let { minkowski-norm } = import(linear-algebra);\nminkowski-norm([1, 2, 3], 4)"],seeAlso:["linear-algebra.euclidean-norm","linear-algebra.manhattan-norm","linear-algebra.chebyshev-norm","linear-algebra.minkowski-distance"]},cov:{category:"linear-algebra",description:"Calculates the **covariance** between two vectors. The result is a number.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { cov } = import(linear-algebra);\ncov([1, 2], [3, 4])","let { cov } = import(linear-algebra);\ncov([1, 2, 3], [4, 5, 6])","let { cov } = import(linear-algebra);\ncov([1, 0], [0, 1])"],seeAlso:["linear-algebra.corr","linear-algebra.pearson-corr","vector.variance"]},corr:{category:"linear-algebra",description:"Calculates the **correlation** between two vectors. The result is a number between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { corr } = import(linear-algebra);\ncorr([1, 2], [3, 4])","let { corr } = import(linear-algebra);\ncorr([1, 2, 3], [4, 5, 6])","let { corr } = import(linear-algebra);\ncorr([1, 0], [0, 1])"],seeAlso:["linear-algebra.cov","linear-algebra.pearson-corr","linear-algebra.spearman-corr","linear-algebra.kendall-tau","linear-algebra.autocorrelation","linear-algebra.cross-correlation"]},"spearman-corr":{category:"linear-algebra",description:"Calculates the **Spearman rank correlation** between two vectors. The result is a number between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { spearman-corr } = import(linear-algebra);\nspearman-corr([1, 2], [3, 4])","let { spearman-corr } = import(linear-algebra);\nspearman-corr([1, 2, 3], [4, 5, 6])","let { spearman-corr } = import(linear-algebra);\nspearman-corr([1, 0], [0, 1])"],seeAlso:["linear-algebra.pearson-corr","linear-algebra.kendall-tau","linear-algebra.corr"]},"pearson-corr":{category:"linear-algebra",description:"Calculates the **Pearson correlation** between two vectors. The result is a number between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { pearson-corr } = import(linear-algebra);\npearson-corr([1, 2], [3, 4])","let { pearson-corr } = import(linear-algebra);\npearson-corr([1, 2, 3], [4, 5, 6])","let { pearson-corr } = import(linear-algebra);\npearson-corr([1, 0], [0, 1])"],seeAlso:["linear-algebra.spearman-corr","linear-algebra.kendall-tau","linear-algebra.corr","linear-algebra.cov"]},"kendall-tau":{category:"linear-algebra",description:"Calculates the **Kendall Tau** rank correlation coefficient between two vectors. The result is a number between -1 and 1.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { kendall-tau } = import(linear-algebra);\nkendall-tau([1, 2], [3, 4])","let { kendall-tau } = import(linear-algebra);\nkendall-tau([1, 2, 3], [4, 5, 6])","let { kendall-tau } = import(linear-algebra);\nkendall-tau([1, 0], [0, 1])"],seeAlso:["linear-algebra.spearman-corr","linear-algebra.pearson-corr","linear-algebra.corr"]},autocorrelation:{category:"linear-algebra",description:"Calculates the **autocorrelation** of a vector. The result is a vector of autocorrelation coefficients.",returns:{type:"number"},args:{a:{type:"vector",description:"Vector to calculate the autocorrelation for."},b:{type:"integer",description:"Lag value for the autocorrelation."}},variants:[{argumentNames:["a","b"]}],examples:["let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], -2)","let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], -1)","let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], 0)","let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], 1)","let { autocorrelation } = import(linear-algebra);\nautocorrelation([1, 2, 3], 2)"],seeAlso:["linear-algebra.cross-correlation","linear-algebra.corr"]},"cross-correlation":{category:"linear-algebra",description:"Calculates the **cross-correlation** between two vectors. The result is a vector of cross-correlation coefficients.",returns:{type:"number"},args:{a:{type:"vector"},b:{type:"vector"},lag:{type:"integer",description:"Lag value for the cross-correlation."}},variants:[{argumentNames:["a","b","lag"]}],examples:["let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], -2)","let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], -1)","let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], 0)","let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], 1)","let { cross-correlation } = import(linear-algebra);\ncross-correlation([1, 2, 3], [4, 5, 6], 2)"],seeAlso:["linear-algebra.autocorrelation","linear-algebra.corr"]},rref:{category:"linear-algebra",description:"Calculates the **Reduced Row Echelon Form** (RREF) of a matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"Matrix to calculate the RREF for."}},variants:[{argumentNames:["m"]}],examples:["let { rref } = import(linear-algebra);\nrref([[1, 2], [3, 4]])","let { rref } = import(linear-algebra);\nrref([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { rref } = import(linear-algebra);\nrref([[1, 2, 3], [7, 8, 9], [4, 5, 7]])"],seeAlso:["linear-algebra.solve","matrix.rank"]},solve:{category:"linear-algebra",description:"Solves a system of linear equations represented by a matrix and a vector.",returns:{type:"vector"},args:{a:{type:"matrix"},b:{type:"vector"}},variants:[{argumentNames:["a","b"]}],examples:["let { solve } = import(linear-algebra);\nsolve([\n [2, 1, -1, 1], \n [4, 5, -3, 2], \n [6, -2, 5, -3], \n [8, 3, 2, 4]\n], [5, 10, 2, 17])","let { solve } = import(linear-algebra);\nsolve([[2, 0, 0], [3, 1, 0], [4, 5, 6]], [4, 5, 38])","let { solve } = import(linear-algebra);\nsolve([[2, 3], [1, -1]], [8, 2])"],seeAlso:["linear-algebra.rref","matrix.inv"]},"to-polar":{category:"linear-algebra",description:"Converts a 2D vector to polar coordinates.",returns:{type:"vector"},args:{vector:{type:"vector",description:"2D Vector to convert."}},variants:[{argumentNames:["vector"]}],examples:["let { to-polar } = import(linear-algebra);\nto-polar([1, 2])","let { to-polar } = import(linear-algebra);\nto-polar([3, 4])"],seeAlso:["linear-algebra.from-polar","linear-algebra.angle"]},"from-polar":{category:"linear-algebra",description:"Converts polar coordinates to a 2D vector.",returns:{type:"vector"},args:{polar:{type:"vector",description:"Polar coordinates to convert."}},variants:[{argumentNames:["polar"]}],examples:["let { from-polar } = import(linear-algebra);\nfrom-polar([1, PI / 4])","let { from-polar } = import(linear-algebra);\nfrom-polar([1, 0])","let { from-polar } = import(linear-algebra);\nfrom-polar([1, -PI / 2])"],seeAlso:["linear-algebra.to-polar"]}};function pn(e){const t=e.map(e=>[...e]),r=t.length,n=t[0].length;let o=0,a=0;for(let e=0;e<n;e++){let i=-1;for(let n=a;n<r;n++)if(!fe(t[n][e])){i=n;break}if(-1===i)continue;o+=1,i!==a&&([t[i],t[a]]=[t[a],t[i]]);const s=t[a][e];for(let r=e;r<n;r++)t[a][r]/=s;for(let o=0;o<r;o++)if(o!==a&&!fe(t[o][e])){const r=t[o][e];for(let i=e;i<n;i++)t[o][i]-=r*t[a][i]}if(a++,a===r)break}return[t,o]}function dn(e,t){const r=e=>e.every(e=>fe(e));if(r(e)||r(t))return!0;let n=0;for(;n<e.length&&fe(e[n]);)n++;const o=t[n]/e[n];for(let r=0;r<e.length;r++)if(!fe(e[r])||!fe(t[r])){if(fe(e[r]))return!1;if(!ge(t[r]/e[r],o))return!1}return!0}function hn(e){return e.every(e=>fe(e))}function gn(e,t){const r=jr(e),n=jr(t);let o=0,a=0,i=0;for(let s=0;s<e.length;s++){const c=e[s]-r,l=t[s]-n;o+=c*l,a+=c*c,i+=l*l}if(0===a||0===i)throw new Error("Cannot calculate Pearson correlation coefficient: one of the vectors has zero variance.");return o/(Math.sqrt(a)*Math.sqrt(i))}function fn(e){const t=[...e.keys()].sort((t,r)=>e[t]-e[r]),r=Array.from({length:e.length}).fill(0);let n=1,o=0;for(;o<t.length;){const a=e[t[o]];let i=o;for(;i<t.length&&e[t[i]]===a;)i++;const s=n+(i-o-1)/2;for(let e=o;e<i;e++)r[t[e]]=s;n+=i-o,o=i}return r}function yn(e,t){const r=jr(e),n=jr(t);let o=0;for(let a=0;a<e.length;a++)o+=(e[a]-r)*(t[a]-n);return o/e.length}function vn(e,t){if(0===e.length)return e;const n=Math.sqrt(e.reduce((e,t)=>e+t**2,0));if(fe(n))throw new r("The vector must not be zero",t);return e.map(e=>e/n)}function bn(e,t){return e.reduce((e,r,n)=>e+r*t[n],0)}function wn(e,t){return e.map((e,r)=>e-t[r])}function xn(e,t){return e.map(e=>e*t)}const kn={rotate2d:{evaluate:([e,t],r)=>{if(Re(e,r),hn(e))return e;Y(t,r,{finite:!0});const n=Math.cos(t),o=Math.sin(t);return[e[0]*n-e[1]*o,e[0]*o+e[1]*n]},arity:re(2)},rotate3d:{evaluate:([e,t,n],o)=>{if(Me(e,o),hn(e))return e;if(Y(n,o,{finite:!0}),Me(t,o),hn(t))throw new r("Rotation axis must not be zero",o);const a=Math.cos(n),i=Math.sin(n),[s,c,l]=vn(t,o),u=e[0]*s+e[1]*c+e[2]*l;return[u*s*(1-a)+e[0]*a+(-l*e[1]+c*e[2])*i,u*c*(1-a)+e[1]*a+(l*e[0]-s*e[2])*i,u*l*(1-a)+e[2]*a+(-c*e[0]+s*e[1])*i]},arity:re(3)},reflect:{evaluate:([e,t],n)=>{if(Ce(e,n),Ce(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);if(hn(t))throw new r("Reflection normal must not be zero",n);if(hn(e))return e;const o=vn(t,n);return wn(e,xn(o,2*bn(e,o)))},arity:re(2)},refract:{evaluate:([e,t,n],o)=>{if(Ce(e,o),Ce(t,o),Y(n,o,{finite:!0,positive:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",o);if(hn(t))throw new r("Refraction normal must not be zero",o);if(hn(e))return e;const a=vn(e,o),i=vn(t,o),s=bn(a,i),c=1-n*n*(1-s*s);if(c<0)return e;return wn(xn(a,n),xn(i,n*s+Math.sqrt(c)))},arity:re(3)},lerp:{evaluate:([e,t,n],o)=>{if(Ce(e,o),Ce(t,o),Y(n,o,{finite:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",o);return e.map((e,r)=>e+(t[r]-e)*n)},arity:re(3)},dot:{evaluate:([e,t],n)=>{if(Ce(e,n),Ce(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return bn(e,t)},arity:re(2)},cross:{evaluate:([e,t],n)=>{if(Ce(e,n),Ce(t,n),3!==e.length||3!==t.length)throw new r("Cross product is only defined for 3D vectors",n);return[e[1]*t[2]-e[2]*t[1],e[2]*t[0]-e[0]*t[2],e[0]*t[1]-e[1]*t[0]]},arity:re(2)},"normalize-minmax":{evaluate:([e],t)=>{if(Ce(e,t),0===e.length)return[];const r=e.reduce((e,t)=>t<e?t:e,e[0]),n=e.reduce((e,t)=>t>e?t:e,e[0]);return r===n?e.map(()=>0):e.map(e=>(e-r)/(n-r))},arity:re(1)},"normalize-robust":{evaluate:([e],t)=>{if(Ce(e,t),0===e.length)return[];const r=Cr(e),n=Qr(e);return 0===n?e.map(e=>e-r):e.map(e=>(e-r)/n)},arity:re(1)},"normalize-zscore":{evaluate:([e],t)=>{Ce(e,t);const r=jr(e),n=Dr(e);return 0===n?e.map(()=>0):e.map(e=>(e-r)/n)},arity:re(1)},"normalize-l1":{evaluate:([e],t)=>{if(Ce(e,t),0===e.length)return[];const r=e.reduce((e,t)=>e+Math.abs(t),0);return 0===r?e.map(()=>0):e.map(e=>e/r)},arity:re(1)},"normalize-l2":{evaluate:([e],t)=>(Ce(e,t),vn(e,t)),arity:re(1)},"normalize-log":{evaluate:([e],t)=>{if(Ce(e,t),0===e.length)return[];const n=Math.min(...e);if(n<=0)throw new r("Log normalization requires all values to be positive",t);return e.map(e=>Math.log(e/n))},arity:re(1)},angle:{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),hn(e)||hn(t))throw new r("Cannot calculate angle with zero-length vector",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);const o=e.reduce((e,r,n)=>e+r*t[n],0),a=Math.sqrt(e.reduce((e,t)=>e+t*t,0)),i=Math.sqrt(t.reduce((e,t)=>e+t*t,0));return Math.acos(o/(a*i))},arity:re(2)},projection:{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),hn(t))throw new r("Cannot project onto zero-length vector",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);const o=e.reduce((e,r,n)=>e+r*t[n],0),a=Math.sqrt(t.reduce((e,t)=>e+t*t,0));return t.map(e=>o/a**2*e)},arity:re(2)},"orthogonal?":{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return 0===e.reduce((e,r,n)=>e+r*t[n],0)},arity:re(2)},"parallel?":{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return function(e,t){if(!dn(e,t))return!1;for(let r=0;r<e.length;r++)if(!fe(e[r])&&!fe(t[r]))return Math.sign(e[r])===Math.sign(t[r]);return!0}(e,t)},arity:re(2)},"collinear?":{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return dn(e,t)},arity:re(2)},"cosine-similarity":{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),hn(e)||hn(t))throw new r("Cannot calculate cosine similarity with zero-length vector",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+r*t[n],0)/(Math.sqrt(e.reduce((e,t)=>e+t*t,0))*Math.sqrt(t.reduce((e,t)=>e+t*t,0)))},arity:re(2)},"euclidean-distance":{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return Math.sqrt(e.reduce((e,r,n)=>e+(r-t[n])**2,0))},arity:re(2)},"euclidean-norm":{evaluate:([e],t)=>(Pe(e,t),function(e){return Math.sqrt(e.reduce((e,t)=>e+t**2,0))}(e)),arity:re(1)},"manhattan-distance":{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+Math.abs(r-t[n]),0)},arity:re(2)},"manhattan-norm":{evaluate:([e],t)=>(Pe(e,t),e.reduce((e,t)=>e+Math.abs(t),0)),arity:re(1)},"hamming-distance":{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return e.reduce((e,r,n)=>e+(r!==t[n]?1:0),0)},arity:re(2)},"hamming-norm":{evaluate:([e],t)=>(Pe(e,t),e.reduce((e,t)=>e+(0!==t?1:0),0)),arity:re(1)},"chebyshev-distance":{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return Math.max(...e.map((e,r)=>Math.abs(e-t[r])))},arity:re(2)},"chebyshev-norm":{evaluate:([e],t)=>(Pe(e,t),Math.max(...e.map(e=>Math.abs(e)))),arity:re(1)},"minkowski-distance":{evaluate:([e,t,n],o)=>{if(Pe(e,o),Pe(t,o),Y(n,o,{finite:!0,positive:!0}),e.length!==t.length)throw new r("Vectors must be of the same length",o);return e.reduce((e,r,o)=>e+Math.abs(r-t[o])**n,0)**(1/n)},arity:re(3)},"minkowski-norm":{evaluate:([e,t],r)=>(Pe(e,r),Y(t,r,{finite:!0,positive:!0}),e.reduce((e,r)=>e+Math.abs(r)**t,0)**(1/t)),arity:re(2)},cov:{evaluate:([e,t],n)=>{if(Pe(e,n),Pe(t,n),e.length!==t.length)throw new r("Vectors must be of the same length",n);return 1===e.length?0:yn(e,t)},arity:re(2)},corr:{evaluate:([e,t],n)=>{if(Ce(e,n),Ce(t,n),e.length<=1)throw new r("Vectors must have at least 2 elements for corr",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);const o=jr(e),a=jr(t);return e.reduce((e,r,n)=>e+(r-o)*(t[n]-a),0)/Math.sqrt(e.reduce((e,t)=>e+(t-o)**2,0)*t.reduce((e,t)=>e+(t-a)**2,0))},arity:re(2)},"spearman-corr":{evaluate:([e,t],n)=>{if(Ce(e,n),Ce(t,n),e.length<=1)throw new r("Vectors must have at least 2 elements for corr",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);const o=fn(e),a=fn(t);try{return gn(o,a)}catch(e){throw new r(e,n)}},arity:re(2)},"pearson-corr":{evaluate:([e,t],n)=>{if(Ce(e,n),Ce(t,n),e.length<=1)throw new r("Vectors must have at least 2 elements for pearson-corr",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);try{return gn(e,t)}catch(e){throw new r(e,n)}},arity:re(2)},"kendall-tau":{evaluate:([e,t],n)=>{if(Ce(e,n),Ce(t,n),e.length<2)throw new r("Vectors must have at least 2 elements for kendall-tau",n);if(e.length!==t.length)throw new r("Vectors must be of the same length",n);try{return function(e,t,r=1e-10){let n=0,o=0,a=0,i=0;for(let s=0;s<e.length;s++)for(let c=s+1;c<e.length;c++){const l=e[s]-e[c],u=t[s]-t[c],m=Math.abs(l)<r,p=Math.abs(u)<r;m&&p||(m?a+=1:p?i+=1:l*u>0?n+=1:o+=1)}const s=n+o+a,c=n+o+i;if(0===s||0===c)throw new Error("Not enough data to calculate Kendall's Tau");return(n-o)/Math.sqrt(s*c)}(e,t)}catch(e){throw new r(e,n)}},arity:re(2)},autocorrelation:{evaluate:([e,t],n)=>{if(Ce(e,n),e.length<2)throw new r("Vector must have at least 2 elements for autocorrelation",n);if(Y(t,n,{integer:!0,lt:e.length,gt:-e.length}),0===t)return 1;const o=Math.abs(t),a=jr(e);let i=0;const s=e.length;for(let r=0;r<s-o;r++){const n=t<0?r:r+o;i+=(e[t<0?r+o:r]-a)*(e[n]-a)}let c=0;for(let t=0;t<s;t++)c+=(e[t]-a)**2;return 0===c?0:i/c},arity:re(2)},"cross-correlation":{evaluate:([e,t,n],o)=>{if(Ce(e,o),Ce(t,o),e.length<2)throw new r("Vectors must have at least 2 elements",o);if(e.length!==t.length)throw new r("Vectors must be of the same length",o);if(Y(n,o,{integer:!0,lt:e.length,gt:-e.length}),0===n&&e.length===t.length&&e.every((e,r)=>e===t[r]))return 1;const[a,i]=function(e,t,r){const n=Math.abs(r),o=e.length-n;let a=[],i=[];return r>=0?(a=e.slice(0,o),i=t.slice(r,r+o)):(a=e.slice(n),i=t.slice(0,o)),[a,i]}(e,t,n);return function(e,t){const r=jr(e),n=jr(t),o=Dr(e,r),a=Dr(t,n);return 0===o||0===a?0===o&&0===a&&r===n?1:0:yn(e,t)/(o*a)}(a,i)},arity:re(3)},rref:{evaluate:([e],t)=>{Ue(e,t);const[r]=pn(e);return r},arity:re(1)},solve:{evaluate:([e,t],n)=>{if(Fe(e,n),Ce(t,n),e.length!==t.length)throw new r(`The number of rows in the matrix must be equal to the length of the vector, but got ${e.length} and ${t.length}`,n);return function(e,t){const r=e.length,n=e.map((e,r)=>[...e,t[r]]),[o]=pn(n);for(let e=0;e<r;e+=1)if(fe(o[e][e]))return null;const a=Array.from({length:r},()=>0);for(let e=r-1;e>=0;e--){let t=0;for(let n=e+1;n<r;n++)t+=o[e][n]*a[n];a[e]=(o[e][r]-t)/o[e][e]}return a}(e,t)},arity:re(2)},"to-polar":{evaluate:([e],t)=>{if(Re(e,t),hn(e))return[0,0];return[Math.sqrt(e[0]**2+e[1]**2),Math.atan2(e[1],e[0])]},arity:re(1)},"from-polar":{evaluate:([e],t)=>{Re(e,t);const[r,n]=e;return 0===r?[0,0]:[r*Math.cos(n),r*Math.sin(n)]},arity:re(1)}};for(const[e,t]of Object.entries(mn))kn[e]&&(kn[e].docs=t);const qn={name:"linear-algebra",functions:kn,source:"{}",docs:mn},An={mul:{category:"matrix",description:"Multiplies two `matrices` using standard `matrix` multiplication based on **dot products** of rows and columns.",returns:{type:"matrix"},args:{a:{type:"matrix"},b:{type:"matrix"}},variants:[{argumentNames:["a","b"]}],examples:["let { mul } = import(matrix);\nmul([[1, 2], [3, 4]], [[5, 6], [7, 8]])","let { mul } = import(matrix);\nmul([[1, 2, 3], [4, 5, 6]], [[7, 8], [9, 10], [11, 12]])"],seeAlso:["matrix.det","matrix.inv"]},det:{category:"matrix",description:"Calculates the **determinant** of a square matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the determinant of."}},variants:[{argumentNames:["m"]}],examples:["let { det } = import(matrix);\ndet([[1, 2], [3, 4]])","let { det } = import(matrix);\ndet([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.inv","matrix.cofactor","matrix.adj","matrix.trace","matrix.rank","matrix.invertible?","matrix.mul","matrix.minor"]},inv:{category:"matrix",description:"Calculates the **inverse** of a square matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"The `matrix` to calculate the inverse of."}},variants:[{argumentNames:["m"]}],examples:["let { inv } = import(matrix);\ninv([[1, 2], [3, 4]])","let { inv } = import(matrix);\ninv([[1, 2, 3], [4, 5, 7], [7, 8, 10]])"],seeAlso:["matrix.det","matrix.adj","matrix.invertible?","linear-algebra.solve","matrix.mul","matrix.orthogonal-matrix?"]},adj:{category:"matrix",description:"Calculates the **adjugate** of a square matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"The `matrix` to calculate the adjugate of."}},variants:[{argumentNames:["m"]}],examples:["let { adj } = import(matrix);\nadj([[1, 2], [3, 4]])","let { adj } = import(matrix);\nadj([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { adj } = import(matrix);\nadj([[1, 2, 3], [7, 8, 9], [4, 5, 6]])"],seeAlso:["matrix.cofactor","matrix.det","matrix.inv"]},cofactor:{category:"matrix",description:"Calculates the **cofactor** of a square matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"The `matrix` to calculate the cofactor of."}},variants:[{argumentNames:["m"]}],examples:["let { cofactor } = import(matrix);\ncofactor([[1, 2], [3, 4]])","let { cofactor } = import(matrix);\ncofactor([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { cofactor } = import(matrix);\ncofactor([[1, 2, 3], [7, 8, 9], [4, 5, 6]])"],seeAlso:["matrix.adj","matrix.minor","matrix.det"]},minor:{category:"matrix",description:"Calculates the **minor** of a square matrix.",returns:{type:"matrix"},args:{m:{type:"matrix",description:"The `matrix` to calculate the minor of."},row:{type:"integer",description:"The row index of the element to calculate the minor for."},col:{type:"integer",description:"The column index of the element to calculate the minor for."}},variants:[{argumentNames:["m","row","col"]}],examples:["let { minor } = import(matrix);\nminor([[1, 2], [3, 4]], 0, 1)","let { minor } = import(matrix);\nminor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], 1, 1)"],seeAlso:["matrix.cofactor","matrix.det"]},trace:{category:"matrix",description:"Calculates the **trace** of a square matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the trace of."}},variants:[{argumentNames:["m"]}],examples:["let { trace } = import(matrix);\ntrace([[1, 2], [3, 4]])","let { trace } = import(matrix);\ntrace([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.det","matrix.diagonal?"]},"symmetric?":{category:"matrix",description:"Checks if a `matrix` is **symmetric**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for symmetry."}},variants:[{argumentNames:["m"]}],examples:["let { symmetric? } = import(matrix);\nsymmetric?([[1, 2], [2, 1]])","let { symmetric? } = import(matrix);\nsymmetric?([[1, 2, 3], [2, 1, 4], [3, 4, 1]])"],seeAlso:["matrix.orthogonal-matrix?","matrix.diagonal?","matrix.square?","matrix.hilbert"]},"triangular?":{category:"matrix",description:"Checks if a `matrix` is **triangular**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for triangularity."}},variants:[{argumentNames:["m"]}],examples:["let { triangular? } = import(matrix);\ntriangular?([[2, 0], [0, 1]])","let { triangular? } = import(matrix);\ntriangular?([[1, 2, 3], [0, 4, 5], [0, 0, 6]])"],seeAlso:["matrix.upper-triangular?","matrix.lower-triangular?","matrix.diagonal?","matrix.banded?"]},"upper-triangular?":{category:"matrix",description:"Checks if a `matrix` is **upper triangular**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for upper triangularity."}},variants:[{argumentNames:["m"]}],examples:["let { upper-triangular? } = import(matrix);\nupper-triangular?([[1, 2], [0, 3]])","let { upper-triangular? } = import(matrix);\nupper-triangular?([[1, 2, 3], [0, 4, 5], [0, 0, 6]])"],seeAlso:["matrix.lower-triangular?","matrix.triangular?","matrix.diagonal?"]},"lower-triangular?":{category:"matrix",description:"Checks if a `matrix` is **lower triangular**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for lower triangularity."}},variants:[{argumentNames:["m"]}],examples:["let { lower-triangular? } = import(matrix);\nlower-triangular?([[1, 0], [2, 3]])","let { lower-triangular? } = import(matrix);\nlower-triangular?([[1, 0, 0], [2, 3, 0], [4, 5, 6]])"],seeAlso:["matrix.upper-triangular?","matrix.triangular?","matrix.diagonal?"]},"diagonal?":{category:"matrix",description:"Checks if a `matrix` is **diagonal**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for diagonal property."}},variants:[{argumentNames:["m"]}],examples:["let { diagonal? } = import(matrix);\ndiagonal?([[1, 0], [0, 2]])","let { diagonal? } = import(matrix);\ndiagonal?([[1, 0, 0], [0, 2, 0], [0, 0, 3]])","let { diagonal? } = import(matrix);\ndiagonal?([[1, 0, 0], [2, 2, 2], [0, 0, 3]])"],seeAlso:["matrix.identity?","matrix.symmetric?","matrix.triangular?","matrix.trace","matrix.upper-triangular?","matrix.lower-triangular?","matrix.band","matrix.banded?"]},"square?":{category:"matrix",description:"Checks if a `matrix` is **square**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for square property."}},variants:[{argumentNames:["m"]}],examples:["let { square? } = import(matrix);\nsquare?([[1, 2], [3, 4]])","let { square? } = import(matrix);\nsquare?([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { square? } = import(matrix);\nsquare?([[1, 2, 3], [4, 5, 6]])"],seeAlso:["matrix.symmetric?","matrix.identity?","matrix.invertible?"]},"orthogonal-matrix?":{category:"matrix",description:"Checks if a `matrix` is **orthogonal**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for **orthogonality**."}},variants:[{argumentNames:["m"]}],examples:["let { orthogonal-matrix? } = import(matrix);\northogonal-matrix?([[1, 0], [0, 1]])","let { orthogonal-matrix? } = import(matrix);\northogonal-matrix?([[1, 0], [0, -1]])","let { orthogonal-matrix? } = import(matrix);\northogonal-matrix?([[1, 2], [3, 4]])"],seeAlso:["matrix.symmetric?","matrix.inv","matrix.identity?","linear-algebra.orthogonal?"]},"identity?":{category:"matrix",description:"Checks if a `matrix` is an **identity matrix**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for identity property."}},variants:[{argumentNames:["m"]}],examples:["let { identity? } = import(matrix);\nidentity?([[1, 0], [0, 1]])","let { identity? } = import(matrix);\nidentity?([[1, 0, 0], [0, 1, 0], [0, 0, 1]])","let { identity? } = import(matrix);\nidentity?([[1, 0, 0], [0, 1, 0], [0, 0, 0]])"],seeAlso:["matrix.diagonal?","matrix.square?","matrix.orthogonal-matrix?"]},"invertible?":{category:"matrix",description:"Checks if a `matrix` is **invertible**.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for invertibility."}},variants:[{argumentNames:["m"]}],examples:["let { invertible? } = import(matrix);\ninvertible?([[1, 2], [3, 4]])","let { invertible? } = import(matrix);\ninvertible?([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { invertible? } = import(matrix);\ninvertible?([[1, 2], [2, 4]])"],seeAlso:["matrix.det","matrix.inv","matrix.rank","matrix.square?"]},hilbert:{category:"matrix",description:"Generates a **Hilbert matrix** of size `n`.",returns:{type:"matrix"},args:{n:{type:"integer",description:"The size of the Hilbert matrix."}},variants:[{argumentNames:["n"]}],examples:["let { hilbert } = import(matrix);\nhilbert(3)","let { hilbert } = import(matrix);\nhilbert(4)"],seeAlso:["matrix.vandermonde","matrix.symmetric?"]},vandermonde:{category:"matrix",description:"Generates a **Vandermonde matrix** from a vector.",returns:{type:"matrix"},args:{v:{type:"vector",description:"The vector to generate the Vandermonde matrix from."}},variants:[{argumentNames:["v"]}],examples:["let { vandermonde } = import(matrix);\nvandermonde([1, 2, 3])","let { vandermonde } = import(matrix);\nvandermonde([1, 0, 1])"],seeAlso:["matrix.hilbert","matrix.band"]},band:{category:"matrix",description:"Generates a **banded matrix** of size `n` with lower band index `lband` and upper band index `uband`.",returns:{type:"matrix"},args:{n:{type:"integer",description:"The size of the banded matrix."},lband:{type:"integer",description:"The lower band index."},uband:{type:"integer",description:"The upper band index."}},variants:[{argumentNames:["n","lband","uband"]}],examples:["let { band } = import(matrix);\nband(3, 1, 1)","let { band } = import(matrix);\nband(4, 1, 2)"],seeAlso:["matrix.banded?","matrix.diagonal?","matrix.vandermonde"]},"banded?":{category:"matrix",description:"Checks if a `matrix` is **banded** with lower band index `lband` and upper band index `uband`.",returns:{type:"boolean"},args:{m:{type:"matrix",description:"The `matrix` to check for **banded** property."},lband:{type:"integer",description:"The lower band index."},uband:{type:"integer",description:"The upper band index."}},variants:[{argumentNames:["m","lband","uband"]}],examples:["let { banded? } = import(matrix);\nbanded?([\n [1, 1, 1, 0],\n [1, 1, 1, 1],\n [1, 1, 1, 1],\n [0, 1, 1, 1],\n], 2, 2)","let { banded? } = import(matrix);\nbanded?([\n [1, 1, 1, 0],\n [1, 1, 1, 1],\n [1, 1, 1, 1],\n [0, 1, 1, 1],\n], 1, 1)"],seeAlso:["matrix.band","matrix.triangular?","matrix.diagonal?"]},rank:{category:"matrix",description:"Calculates the **rank** of a matrix using **Gaussian elimination**.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the rank of."}},variants:[{argumentNames:["m"]}],examples:["let { rank } = import(matrix);\nrank([[1, 0, 0], [0, 1, 0], [0, 0, 1]])","let { rank } = import(matrix);\nrank([[1, 2, 3], [4, 5, 6], [7, 8, 9]])","let { rank } = import(matrix);\nrank([[2, 4, 6], [3, 6, 9], [4, 8, 12]])"],seeAlso:["matrix.det","matrix.invertible?","linear-algebra.rref"]},"frobenius-norm":{category:"matrix",description:"Calculates the **Frobenius norm** of a matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the Frobenius norm of."}},variants:[{argumentNames:["m"]}],examples:["let { frobenius-norm } = import(matrix);\nfrobenius-norm([[1, 2], [3, 4]])","let { frobenius-norm } = import(matrix);\nfrobenius-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.one-norm","matrix.inf-norm","matrix.max-norm"]},"one-norm":{category:"matrix",description:"Calculates the **one-norm** (column norm) of a matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the one-norm of."}},variants:[{argumentNames:["m"]}],examples:["let { one-norm } = import(matrix);\none-norm([[1, 2], [3, 4]])","let { one-norm } = import(matrix);\none-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.frobenius-norm","matrix.inf-norm","matrix.max-norm"]},"inf-norm":{category:"matrix",description:"Calculates the **infinity norm** of a matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the infinity norm of."}},variants:[{argumentNames:["m"]}],examples:["let { inf-norm } = import(matrix);\ninf-norm([[1, 2], [3, 4]])","let { inf-norm } = import(matrix);\ninf-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.frobenius-norm","matrix.one-norm","matrix.max-norm"]},"max-norm":{category:"matrix",description:"Calculates the **max norm** of a matrix.",returns:{type:"number"},args:{m:{type:"matrix",description:"The `matrix` to calculate the max norm of."}},variants:[{argumentNames:["m"]}],examples:["let { max-norm } = import(matrix);\nmax-norm([[1, 2], [3, 4]])","let { max-norm } = import(matrix);\nmax-norm([[1, 2, 3], [4, 5, 6], [7, 8, 9]])"],seeAlso:["matrix.frobenius-norm","matrix.one-norm","matrix.inf-norm"]}};function Nn(e){const t=e.length,r=[];for(let n=0;n<t;n++)r[n]=[...e[n]];if(1===t)return r[0][0];if(2===t)return r[0][0]*r[1][1]-r[0][1]*r[1][0];let n=1;for(let e=0;e<t-1;e+=1){let o=e;for(let n=e+1;n<t;n+=1)Math.abs(r[n][e])>Math.abs(r[o][e])&&(o=n);if(fe(r[o][e]))return 0;o!==e&&([r[e],r[o]]=[r[o],r[e]],n=-n);for(let n=e+1;n<t;n+=1){const o=r[n][e]/r[e][e];for(let a=e;a<t;a++)r[n][a]-=o*r[e][a]}}let o=n;for(let e=0;e<t;e++)o*=r[e][e];return o}function $n(e,t,r){const n=e.length,o=[];for(let a=0;a<n;a++)if(a!==t){const t=[];for(let o=0;o<n;o++)o!==r&&t.push(e[a][o]);o.push(t)}return o}function En(e){const t=e.length,r=[];for(let n=0;n<t;n++){r[n]=[];for(let o=0;o<t;o++){const t=(-1)**(n+o)*Nn($n(e,o,n));r[n][o]=t}}return r}function Tn(e){return e.length===e[0].length}function Sn(e){if(!Tn(e))return!1;const t=e.length;for(let r=0;r<t;r++)for(let n=0;n<t;n++)if(r===n){if(!ge(e[r][n],1))return!1}else if(!fe(e[r][n]))return!1;return!0}function zn(e,t){if(0===e.length||0===t.length||e[0].length!==t.length)throw new Error("Matrix dimensions do not match for multiplication");const r=e.length,n=e[0].length,o=t[0].length,a=Array(r).fill(0).map(()=>Array(o).fill(0));for(let i=0;i<r;i++)for(let r=0;r<n;r++){const n=e[i][r];for(let e=0;e<o;e++)a[i][e]+=n*t[r][e]}return a}const jn={mul:{evaluate:([e,t],n)=>{Ue(e,n),Ue(t,n);try{return zn(e,t)}catch(o){throw new r(`The number of columns in the first matrix must be equal to the number of rows in the second matrix, but got ${e[0].length} and ${t.length}`,n)}},arity:re(2)},det:{evaluate:([e],t)=>(Fe(e,t),Nn(e)),arity:re(1)},inv:{evaluate:([e],t)=>{Fe(e,t);const n=function(e){const t=e.length;if(1===t){const t=e[0][0];return fe(t)?null:[[1/t]]}const r=Nn(e);if(fe(r))return null;const n=En(e),o=[];for(let e=0;e<t;e++){o[e]=[];for(let a=0;a<t;a++)o[e][a]=n[e][a]/r}return o}(e);if(null===n)throw new r("The matrix must be invertible",t);return n},arity:re(1)},adj:{evaluate:([e],t)=>(Fe(e,t),En(e)),arity:re(1)},cofactor:{evaluate:([e],t)=>(Fe(e,t),function(e){const t=e.length,r=[];for(let n=0;n<t;n++){r[n]=[];for(let o=0;o<t;o++){const t=$n(e,n,o),a=(-1)**(n+o);r[n][o]=a*Nn(t)}}return r}(e)),arity:re(1)},minor:{evaluate:([e,t,r],n)=>(Ue(e,n),Y(t,n,{integer:!0,nonNegative:!0,lte:e.length}),Y(r,n,{integer:!0,nonNegative:!0,lte:e[0].length}),$n(e,t,r)),arity:re(3)},trace:{evaluate:([e],t)=>(Fe(e,t),function(e){return e.reduce((e,t,r)=>e+t[r],0)}(e)),arity:re(1)},"symmetric?":{evaluate:([e],t)=>(Ue(e,t),function(e){const t=e.length;if(!Tn(e))return!1;for(let r=0;r<t;r+=1)for(let t=0;t<r;t+=1)if(e[r][t]!==e[t][r])return!1;return!0}(e)),arity:re(1)},"triangular?":{evaluate:([e],t)=>(Ue(e,t),function(e){if(!Tn(e))return!1;const t=e.length;let r=!0,n=!0;for(let o=0;o<t;o++)for(let a=0;a<t;a++){if(o>a&&0!==e[o][a]&&(r=!1,!n))return!1;o<a&&0!==e[o][a]&&(n=!1)}return r||n}(e)),arity:re(1)},"upper-triangular?":{evaluate:([e],t)=>(Ue(e,t),function(e){if(!Tn(e))return!1;const t=e.length;for(let r=0;r<t;r++)for(let t=0;t<r;t++)if(0!==e[r][t])return!1;return!0}(e)),arity:re(1)},"lower-triangular?":{evaluate:([e],t)=>(Ue(e,t),function(e){if(!Tn(e))return!1;const t=e.length;if(!e.every(e=>e.length===t))return!1;for(let r=0;r<t;r++)for(let n=r+1;n<t;n++)if(0!==e[r][n])return!1;return!0}(e)),arity:re(1)},"diagonal?":{evaluate:([e],t)=>(Ue(e,t),function(e){if(!Tn(e))return!1;const t=e.length;for(let r=0;r<t;r+=1)for(let n=0;n<t;n+=1)if(r!==n&&0!==e[r][n])return!1;return!0}(e)),arity:re(1)},"square?":{evaluate:([e],t)=>(Ue(e,t),Tn(e)),arity:re(1)},"orthogonal-matrix?":{evaluate:([e],t)=>(Ue(e,t),function(e){return!!Tn(e)&&Sn(zn(e,Ar(e)))}(e)),arity:re(1)},"identity?":{evaluate:([e],t)=>(Ue(e,t),Sn(e)),arity:re(1)},"invertible?":{evaluate:([e],t)=>(Ue(e,t),!!function(e){return!!Ve(e)&&e.length===e[0].length}(e)&&!fe(Nn(e))),arity:re(1)},hilbert:{evaluate:([e],t)=>{Y(e,t,{integer:!0,positive:!0});const r=[];for(let t=0;t<e;t+=1){const n=[];for(let r=0;r<e;r+=1)n.push(1/(t+r+1));r.push(n)}return r},arity:re(1)},vandermonde:{evaluate:([e],t)=>{Ce(e,t);const r=[];for(let t=0;t<e.length;t+=1){const n=[];for(let r=0;r<e.length;r+=1)n.push(e[t]**r);r.push(n)}return r},arity:re(1)},band:{evaluate:([e,t,r],n)=>(Y(e,n,{integer:!0,positive:!0}),Y(t,n,{integer:!0,nonNegative:!0,lt:e}),Y(r,n,{integer:!0,nonNegative:!0,lte:e}),function(e,t,r){const n=Array.from({length:e},()=>Array.from({length:e},()=>0));for(let o=0;o<e;o++)for(let a=Math.max(0,o-t);a<=Math.min(e-1,o+r);a++)n[o][a]=1;return n}(e,t,r)),arity:re(3)},"banded?":{evaluate:([e,t,r],n)=>{Ue(e,n);const o=Math.max(e.length,e[0].length);return Y(t,n,{integer:!0,nonNegative:!0,lt:o}),Y(r,n,{integer:!0,nonNegative:!0,lt:o}),function(e,t,r){const n=e.length,o=e[0].length;for(let a=0;a<n;a++)for(let n=0;n<o;n++)if(0!==e[a][n]&&(a-n>t||n-a>r))return!1;return!0}(e,t,r)},arity:re(3)},rank:{evaluate:([e],t)=>{Ue(e,t);const[,r]=pn(e);return r},arity:re(1)},"frobenius-norm":{evaluate:([e],t)=>(Ue(e,t),Math.sqrt(e.reduce((e,t)=>e+t.reduce((e,t)=>e+t*t,0),0))),arity:re(1)},"one-norm":{evaluate:([e],t)=>(Ue(e,t),function(e){const t=e.length,r=e[0].length;let n=0;for(let o=0;o<r;o+=1){let r=0;for(let n=0;n<t;n+=1)r+=Math.abs(e[n][o]);n=Math.max(n,r)}return n}(e)),arity:re(1)},"inf-norm":{evaluate:([e],t)=>(Ue(e,t),e.reduce((e,t)=>Math.max(e,t.reduce((e,t)=>e+Math.abs(t),0)),0)),arity:re(1)},"max-norm":{evaluate:([e],t)=>(Ue(e,t),e.reduce((e,t)=>{const r=t.reduce((e,t)=>Math.max(e,Math.abs(t)),0);return Math.max(e,r)},0)),arity:re(1)}};for(const[e,t]of Object.entries(An))jn[e]&&(jn[e].docs=t);const In={name:"matrix",functions:jn,source:"{}",docs:An},Cn={"abundant-seq":{category:"number-theory",description:"Generates the abundant numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { abundant-seq } = import(number-theory);\nabundant-seq(1)","let { abundant-seq } = import(number-theory);\nabundant-seq(5)"],seeAlso:["number-theory.abundant-nth","number-theory.abundant-take-while","number-theory.abundant?","number-theory.deficient-seq","number-theory.perfect-seq"]},"abundant-take-while":{category:"number-theory",description:"Generates the abundant numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { abundant-take-while } = import(number-theory);\nabundant-take-while(-> $ < 100)"],seeAlso:["number-theory.abundant-seq","number-theory.abundant-nth","number-theory.abundant?"]},"abundant-nth":{category:"number-theory",description:"Generates the nth term of the abundant numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the number in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { abundant-nth } = import(number-theory);\nabundant-nth(1)","let { abundant-nth } = import(number-theory);\nabundant-nth(5)"],seeAlso:["number-theory.abundant-seq","number-theory.abundant-take-while","number-theory.abundant?"]},"abundant?":{category:"number-theory",description:"Checks if a number is abundant.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { abundant? } = import(number-theory);\nabundant?(12)","let { abundant? } = import(number-theory);\nabundant?(15)"],seeAlso:["number-theory.abundant-seq","number-theory.abundant-nth","number-theory.deficient?","number-theory.perfect?","number-theory.sigma","number-theory.divisors","number-theory.abundant-take-while"]},"arithmetic-seq":{category:"number-theory",description:"Generates the arithmetic sequence for a given $start, $step, and $length.",returns:{type:"integer",array:!0},args:{start:{type:"number",description:"The starting term of the sequence."},step:{type:"number",description:"The common difference of the sequence."},length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["start","step","length"]}],examples:["let { arithmetic-seq } = import(number-theory);\narithmetic-seq(3, 2, 2)","let { arithmetic-seq } = import(number-theory);\narithmetic-seq(2, 3, 2)","let { arithmetic-seq } = import(number-theory);\narithmetic-seq(1, 2, 2)","let { arithmetic-seq } = import(number-theory);\narithmetic-seq(1, 1.5, 12)"],seeAlso:["number-theory.arithmetic-nth","number-theory.arithmetic-take-while","number-theory.arithmetic?","number-theory.geometric-seq"]},"arithmetic-take-while":{category:"number-theory",description:"Generates the arithmetic sequence while a condition is met.",returns:{type:"integer",array:!0},args:{start:{type:"number",description:"The starting term of the sequence."},step:{type:"number",description:"The common difference of the sequence."},takeWhile:{type:"function",description:"A function that takes a number and an index and returns a boolean."}},variants:[{argumentNames:["start","step","takeWhile"]}],examples:["let { arithmetic-take-while } = import(number-theory);\narithmetic-take-while(1, 0.25, -> $ < 3)"],seeAlso:["number-theory.arithmetic-seq","number-theory.arithmetic-nth","number-theory.arithmetic?"]},"arithmetic-nth":{category:"number-theory",description:"Generates the nth term of the arithmetic sequence.",returns:{type:"number"},args:{start:{type:"number",description:"The starting term of the sequence."},step:{type:"number",description:"The common difference of the sequence."},n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["start","step","n"]}],examples:["let { arithmetic-nth } = import(number-theory);\narithmetic-nth(3, 2, 2)","let { arithmetic-nth } = import(number-theory);\narithmetic-nth(2, 3, 2)","let { arithmetic-nth } = import(number-theory);\narithmetic-nth(1, 2, 2)","let { arithmetic-nth } = import(number-theory);\narithmetic-nth(1, 1.5, 12)"],seeAlso:["number-theory.arithmetic-seq","number-theory.arithmetic-take-while","number-theory.arithmetic?"]},"arithmetic?":{category:"number-theory",description:"Checks if a number is part of the arithmetic sequence.",returns:{type:"boolean"},args:{start:{type:"number",description:"The starting term of the sequence."},step:{type:"number",description:"The common difference of the sequence."},n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["start","step","n"]}],examples:["let { arithmetic? } = import(number-theory);\narithmetic?(3, 2, 2)","let { arithmetic? } = import(number-theory);\narithmetic?(2, 3, 2)","let { arithmetic? } = import(number-theory);\narithmetic?(1, 2, 2)","let { arithmetic? } = import(number-theory);\narithmetic?(1, 1.5, 12)"],seeAlso:["number-theory.arithmetic-seq","number-theory.arithmetic-nth","number-theory.geometric?","number-theory.arithmetic-take-while"]},"bell-seq":{category:"number-theory",description:"Generates the Bell sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 22 (the maximum length of the pre-calculated bell numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { bell-seq } = import(number-theory);\nbell-seq(5)","let { bell-seq } = import(number-theory);\nbell-seq(10)","let { bell-seq } = import(number-theory);\nbell-seq()"],seeAlso:["number-theory.bell-nth","number-theory.bell-take-while","number-theory.bell?","number-theory.catalan-seq","number-theory.stirling-second","number-theory.stirling-first"]},"bell-take-while":{category:"number-theory",description:"Generates the Bell sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { bell-take-while } = import(number-theory);\nbell-take-while(-> $ < 1000)"],seeAlso:["number-theory.bell-seq","number-theory.bell-nth","number-theory.bell?"]},"bell-nth":{category:"number-theory",description:"Generates the nth term of the Bell sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { bell-nth } = import(number-theory);\nbell-nth(5)","let { bell-nth } = import(number-theory);\nbell-nth(10)"],seeAlso:["number-theory.bell-seq","number-theory.bell-take-while","number-theory.bell?"]},"bell?":{category:"number-theory",description:"Checks if a number is in the Bell sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { bell? } = import(number-theory);\nbell?(1)","let { bell? } = import(number-theory);\nbell?(27644437)","let { bell? } = import(number-theory);\nbell?(27644436)"],seeAlso:["number-theory.bell-seq","number-theory.bell-nth","number-theory.catalan?","number-theory.bell-take-while"]},"bernoulli-seq":{category:"number-theory",description:"Generates the Bernoulli sequence up to a specified length.",returns:{type:"number",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { bernoulli-seq } = import(number-theory);\nbernoulli-seq(5)","let { bernoulli-seq } = import(number-theory);\nbernoulli-seq(10)"],seeAlso:["number-theory.bernoulli-nth","number-theory.bernoulli-take-while"]},"bernoulli-take-while":{category:"number-theory",description:"Generates the Bernoulli sequence while a condition is met.",returns:{type:"number",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { bernoulli-take-while } = import(number-theory);\nbernoulli-take-while(-> abs($) < 100)"],seeAlso:["number-theory.bernoulli-seq","number-theory.bernoulli-nth"]},"bernoulli-nth":{category:"number-theory",description:"Generates the nth term of the Bernoulli sequence.",returns:{type:"number"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { bernoulli-nth } = import(number-theory);\nbernoulli-nth(5)","let { bernoulli-nth } = import(number-theory);\nbernoulli-nth(10)","let { bernoulli-nth } = import(number-theory);\nbernoulli-nth(23)"],seeAlso:["number-theory.bernoulli-seq","number-theory.bernoulli-take-while"]},"catalan-seq":{category:"number-theory",description:"Generates the Catalan sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 30 (the maximum length of the pre-calculated catalan numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { catalan-seq } = import(number-theory);\ncatalan-seq(5)","let { catalan-seq } = import(number-theory);\ncatalan-seq(10)","let { catalan-seq } = import(number-theory);\ncatalan-seq()"],seeAlso:["number-theory.catalan-nth","number-theory.catalan-take-while","number-theory.catalan?","number-theory.bell-seq"]},"catalan-take-while":{category:"number-theory",description:"Generates the Catalan sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { catalan-take-while } = import(number-theory);\ncatalan-take-while(-> $ < 1000)"],seeAlso:["number-theory.catalan-seq","number-theory.catalan-nth","number-theory.catalan?"]},"catalan-nth":{category:"number-theory",description:"Generates the nth term of the Catalan sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { catalan-nth } = import(number-theory);\ncatalan-nth(5)","let { catalan-nth } = import(number-theory);\ncatalan-nth(10)"],seeAlso:["number-theory.catalan-seq","number-theory.catalan-take-while","number-theory.catalan?"]},"catalan?":{category:"number-theory",description:"Determines if a number is in the Catalan sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { catalan? } = import(number-theory);\ncatalan?(5)","let { catalan? } = import(number-theory);\ncatalan?(10)"],seeAlso:["number-theory.catalan-seq","number-theory.catalan-nth","number-theory.bell?","number-theory.catalan-take-while"]},"collatz-seq":{category:"number-theory",description:"Generates the collatz sequence starting from a given integer.",returns:{type:"integer",array:!0},args:{start:{type:"integer",description:"The starting integer for the collatz sequence."}},variants:[{argumentNames:["start"]}],examples:["let { collatz-seq } = import(number-theory);\ncollatz-seq(3)","let { collatz-seq } = import(number-theory);\ncollatz-seq(11)"],seeAlso:["number-theory.juggler-seq"]},"composite-seq":{category:"number-theory",description:"Generates the composite sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { composite-seq } = import(number-theory);\ncomposite-seq(1)","let { composite-seq } = import(number-theory);\ncomposite-seq(2)","let { composite-seq } = import(number-theory);\ncomposite-seq(10)"],seeAlso:["number-theory.composite-nth","number-theory.composite-take-while","number-theory.composite?","number-theory.prime-seq"]},"composite-take-while":{category:"number-theory",description:"Generates the composite sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { composite-take-while } = import(number-theory);\ncomposite-take-while(-> $ < 50)"],seeAlso:["number-theory.composite-seq","number-theory.composite-nth","number-theory.composite?"]},"composite-nth":{category:"number-theory",description:"Generates the nth term of the composite sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the composite number to retrieve."}},variants:[{argumentNames:["n"]}],examples:["let { composite-nth } = import(number-theory);\ncomposite-nth(1)","let { composite-nth } = import(number-theory);\ncomposite-nth(2)","let { composite-nth } = import(number-theory);\ncomposite-nth(10)"],seeAlso:["number-theory.composite-seq","number-theory.composite-take-while","number-theory.composite?"]},"composite?":{category:"number-theory",description:"Determines if a number is composite.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { composite? } = import(number-theory);\ncomposite?(4)","let { composite? } = import(number-theory);\ncomposite?(5)","let { composite? } = import(number-theory);\ncomposite?(11)"],seeAlso:["number-theory.composite-seq","number-theory.composite-nth","number-theory.prime?","number-theory.prime-factors","number-theory.composite-take-while"]},"deficient-seq":{category:"number-theory",description:"Generates the deficient numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { deficient-seq } = import(number-theory);\ndeficient-seq(1)","let { deficient-seq } = import(number-theory);\ndeficient-seq(5)"],seeAlso:["number-theory.deficient-nth","number-theory.deficient-take-while","number-theory.deficient?","number-theory.abundant-seq","number-theory.perfect-seq"]},"deficient-take-while":{category:"number-theory",description:"Generates the deficient numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { deficient-take-while } = import(number-theory);\ndeficient-take-while(-> $ < 100)"],seeAlso:["number-theory.deficient-seq","number-theory.deficient-nth","number-theory.deficient?"]},"deficient-nth":{category:"number-theory",description:"Generates the nth term of the deficient numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the number in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { deficient-nth } = import(number-theory);\ndeficient-nth(5)","let { deficient-nth } = import(number-theory);\ndeficient-nth(12)"],seeAlso:["number-theory.deficient-seq","number-theory.deficient-take-while","number-theory.deficient?"]},"deficient?":{category:"number-theory",description:"Checks if a number is deficient.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { deficient? } = import(number-theory);\ndeficient?(12)","let { deficient? } = import(number-theory);\ndeficient?(15)"],seeAlso:["number-theory.deficient-seq","number-theory.deficient-nth","number-theory.abundant?","number-theory.perfect?","number-theory.sigma","number-theory.divisors","number-theory.deficient-take-while"]},"factorial-seq":{category:"number-theory",description:"Generates the factorial sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 19 (the maximum length of the pre-calculated factorial numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { factorial-seq } = import(number-theory);\nfactorial-seq(1)","let { factorial-seq } = import(number-theory);\nfactorial-seq(2)","let { factorial-seq } = import(number-theory);\nfactorial-seq(3)","let { factorial-seq } = import(number-theory);\nfactorial-seq(4)","let { factorial-seq } = import(number-theory);\nfactorial-seq(5)","let { factorial-seq } = import(number-theory);\nfactorial-seq(10)"],seeAlso:["number-theory.factorial-nth","number-theory.factorial-take-while","number-theory.factorial?","number-theory.factorial"]},"factorial-take-while":{category:"number-theory",description:"Generates the factorial sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { factorial-take-while } = import(number-theory);\nfactorial-take-while(-> $ < 1000)"],seeAlso:["number-theory.factorial-seq","number-theory.factorial-nth","number-theory.factorial?"]},"factorial-nth":{category:"number-theory",description:"Generates the nth term of the factorial sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { factorial-nth } = import(number-theory);\nfactorial-nth(1)","let { factorial-nth } = import(number-theory);\nfactorial-nth(2)","let { factorial-nth } = import(number-theory);\nfactorial-nth(3)","let { factorial-nth } = import(number-theory);\nfactorial-nth(4)","let { factorial-nth } = import(number-theory);\nfactorial-nth(5)","let { factorial-nth } = import(number-theory);\nfactorial-nth(10)"],seeAlso:["number-theory.factorial-seq","number-theory.factorial-take-while","number-theory.factorial?","number-theory.factorial"]},"factorial?":{category:"number-theory",description:"Checks if a number is in the factorial sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { factorial? } = import(number-theory);\nfactorial?(1)","let { factorial? } = import(number-theory);\nfactorial?(2)","let { factorial? } = import(number-theory);\nfactorial?(3)","let { factorial? } = import(number-theory);\nfactorial?(4)","let { factorial? } = import(number-theory);\nfactorial?(5)","let { factorial? } = import(number-theory);\nfactorial?(6)","let { factorial? } = import(number-theory);\nfactorial?(7)","let { factorial? } = import(number-theory);\nfactorial?(8)","let { factorial? } = import(number-theory);\nfactorial?(9)","let { factorial? } = import(number-theory);\nfactorial?(3628800)"],seeAlso:["number-theory.factorial-seq","number-theory.factorial-nth","number-theory.factorial","number-theory.factorial-take-while"]},"fibonacci-seq":{category:"number-theory",description:"Generates the fibonacci sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 79 (the maximum length of the pre-calculated Fibonacci numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { fibonacci-seq } = import(number-theory);\nfibonacci-seq(1)","let { fibonacci-seq } = import(number-theory);\nfibonacci-seq(2)","let { fibonacci-seq } = import(number-theory);\nfibonacci-seq()"],seeAlso:["number-theory.fibonacci-nth","number-theory.fibonacci-take-while","number-theory.fibonacci?","number-theory.lucas-seq","number-theory.tribonacci-seq","number-theory.pell-seq","number-theory.padovan-seq"]},"fibonacci-take-while":{category:"number-theory",description:"Generates the fibonacci sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { fibonacci-take-while } = import(number-theory);\nfibonacci-take-while(-> $ < 100)"],seeAlso:["number-theory.fibonacci-seq","number-theory.fibonacci-nth","number-theory.fibonacci?"]},"fibonacci-nth":{category:"number-theory",description:"Generates the nth term of the fibonacci sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { fibonacci-nth } = import(number-theory);\nfibonacci-nth(5)","let { fibonacci-nth } = import(number-theory);\nfibonacci-nth(50)"],seeAlso:["number-theory.fibonacci-seq","number-theory.fibonacci-take-while","number-theory.fibonacci?"]},"fibonacci?":{category:"number-theory",description:"Determines if a number is in the fibonacci sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { fibonacci? } = import(number-theory);\nfibonacci?(0)","let { fibonacci? } = import(number-theory);\nfibonacci?(1)","let { fibonacci? } = import(number-theory);\nfibonacci?(2)","let { fibonacci? } = import(number-theory);\nfibonacci?(3)","let { fibonacci? } = import(number-theory);\nfibonacci?(4)","let { fibonacci? } = import(number-theory);\nfibonacci?(5)","let { fibonacci? } = import(number-theory);\nfibonacci?(6)","let { fibonacci? } = import(number-theory);\nfibonacci?(7)","let { fibonacci? } = import(number-theory);\nfibonacci?(8)","let { fibonacci? } = import(number-theory);\nfibonacci?(9)"],seeAlso:["number-theory.fibonacci-seq","number-theory.fibonacci-nth","number-theory.lucas?","number-theory.fibonacci-take-while","number-theory.tribonacci?","number-theory.padovan?","number-theory.pell?"]},"geometric-seq":{category:"number-theory",description:"Generates the geometric sequence for a given $start, $ratio, and $length.",returns:{type:"integer",array:!0},args:{start:{type:"number",description:"The starting term of the sequence."},ratio:{type:"number",description:"The common ratio of the sequence."},length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["start","ratio","length"]}],examples:["let { geometric-seq } = import(number-theory);\ngeometric-seq(3, 2, 2)","let { geometric-seq } = import(number-theory);\ngeometric-seq(2, 3, 2)","let { geometric-seq } = import(number-theory);\ngeometric-seq(1, 2, 2)","let { geometric-seq } = import(number-theory);\ngeometric-seq(1, 1.5, 12)"],seeAlso:["number-theory.geometric-nth","number-theory.geometric-take-while","number-theory.geometric?","number-theory.arithmetic-seq"]},"geometric-take-while":{category:"number-theory",description:"Generates the geometric sequence while a condition is met.",returns:{type:"integer",array:!0},args:{start:{type:"number",description:"The starting term of the sequence."},ratio:{type:"number",description:"The common ratio of the sequence."},takeWhile:{type:"function",description:"A function that takes a number and an index and returns a boolean."}},variants:[{argumentNames:["start","ratio","takeWhile"]}],examples:["let { geometric-take-while } = import(number-theory);\ngeometric-take-while(1, 1.5, -> $ < 10)"],seeAlso:["number-theory.geometric-seq","number-theory.geometric-nth","number-theory.geometric?"]},"geometric-nth":{category:"number-theory",description:"Generates the nth term of the geometric sequence.",returns:{type:"number"},args:{start:{type:"number",description:"The starting term of the sequence."},ratio:{type:"number",description:"The common ratio of the sequence."},n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["start","ratio","n"]}],examples:["let { geometric-nth } = import(number-theory);\ngeometric-nth(3, 2, 2)","let { geometric-nth } = import(number-theory);\ngeometric-nth(2, 3, 2)","let { geometric-nth } = import(number-theory);\ngeometric-nth(1, 2, 2)","let { geometric-nth } = import(number-theory);\ngeometric-nth(1, 1.5, 4)"],seeAlso:["number-theory.geometric-seq","number-theory.geometric-take-while","number-theory.geometric?"]},"geometric?":{category:"number-theory",description:"Checks if a number is in the geometric sequence.",returns:{type:"boolean"},args:{start:{type:"number",description:"The starting term of the sequence."},ratio:{type:"number",description:"The common ratio of the sequence."},n:{type:"number",description:"The number to check."}},variants:[{argumentNames:["start","ratio","n"]}],examples:["let { geometric? } = import(number-theory);\ngeometric?(1, 2, 1)","let { geometric? } = import(number-theory);\ngeometric?(2, 3, 2)","let { geometric? } = import(number-theory);\ngeometric?(3, 2, 2)","let { geometric? } = import(number-theory);\ngeometric?(1, 1.5, 2.25)","let { geometric? } = import(number-theory);\ngeometric?(1, 1.5, -4)"],seeAlso:["number-theory.geometric-seq","number-theory.geometric-nth","number-theory.arithmetic?","number-theory.geometric-take-while"]},"golomb-seq":{category:"number-theory",description:"Generates the Golomb sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { golomb-seq } = import(number-theory);\ngolomb-seq(5)","let { golomb-seq } = import(number-theory);\ngolomb-seq(20)"],seeAlso:["number-theory.golomb-nth","number-theory.golomb-take-while","number-theory.golomb?","number-theory.recaman-seq"]},"golomb-take-while":{category:"number-theory",description:"Generates the Golomb sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { golomb-take-while } = import(number-theory);\ngolomb-take-while(-> $ <= 10)"],seeAlso:["number-theory.golomb-seq","number-theory.golomb-nth","number-theory.golomb?"]},"golomb-nth":{category:"number-theory",description:"Generates the nth term of the Golomb sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { golomb-nth } = import(number-theory);\ngolomb-nth(5)","let { golomb-nth } = import(number-theory);\ngolomb-nth(1000)"],seeAlso:["number-theory.golomb-seq","number-theory.golomb-take-while","number-theory.golomb?"]},"golomb?":{category:"number-theory",description:"Checks if a number is in the Golomb sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { golomb? } = import(number-theory);\ngolomb?(1)","let { golomb? } = import(number-theory);\ngolomb?(2)","let { golomb? } = import(number-theory);\ngolomb?(3345)","let { golomb? } = import(number-theory);\ngolomb?(67867864)"],seeAlso:["number-theory.golomb-seq","number-theory.golomb-nth","number-theory.golomb-take-while"]},"happy-seq":{category:"number-theory",description:"Generates the happy sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { happy-seq } = import(number-theory);\nhappy-seq(1)","let { happy-seq } = import(number-theory);\nhappy-seq(2)","let { happy-seq } = import(number-theory);\nhappy-seq(20)"],seeAlso:["number-theory.happy-nth","number-theory.happy-take-while","number-theory.happy?","number-theory.lucky-seq"]},"happy-take-while":{category:"number-theory",description:"Generates the happy sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { happy-take-while } = import(number-theory);\nhappy-take-while(-> $ < 100)"],seeAlso:["number-theory.happy-seq","number-theory.happy-nth","number-theory.happy?"]},"happy-nth":{category:"number-theory",description:"Generates the nth term of the happy sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the happy number to return."}},variants:[{argumentNames:["n"]}],examples:["let { happy-nth } = import(number-theory);\nhappy-nth(1)","let { happy-nth } = import(number-theory);\nhappy-nth(2)","let { happy-nth } = import(number-theory);\nhappy-nth(20)"],seeAlso:["number-theory.happy-seq","number-theory.happy-take-while","number-theory.happy?"]},"happy?":{category:"number-theory",description:"Determines if a number is a happy number.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { happy? } = import(number-theory);\nhappy?(1)","let { happy? } = import(number-theory);\nhappy?(2)","let { happy? } = import(number-theory);\nhappy?(100)"],seeAlso:["number-theory.happy-seq","number-theory.happy-nth","number-theory.happy-take-while"]},"juggler-seq":{category:"number-theory",description:"Generates the Juggler sequence starting from a given integer.",returns:{type:"integer",array:!0},args:{start:{type:"integer",description:"The starting integer for the Juggler sequence."}},variants:[{argumentNames:["start"]}],examples:["let { juggler-seq } = import(number-theory);\njuggler-seq(3)","let { juggler-seq } = import(number-theory);\njuggler-seq(5)"],seeAlso:["number-theory.collatz-seq"]},"look-and-say-seq":{category:"number-theory",description:"Generates the Look-and-Say sequence up to a specified length.",returns:{type:"string",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { look-and-say-seq } = import(number-theory);\nlook-and-say-seq(5)"],seeAlso:["number-theory.look-and-say-nth","number-theory.look-and-say-take-while","number-theory.look-and-say?"]},"look-and-say-take-while":{category:"number-theory",description:"Generates the Look-and-Say sequence while a condition is met.",returns:{type:"string",array:!0},args:{takeWhile:{type:"function",description:"A function that takes a string and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { look-and-say-take-while } = import(number-theory);\nlook-and-say-take-while((term, index) -> count(term) < 10)","let { look-and-say-take-while } = import(number-theory);\nlook-and-say-take-while(-> $2 <= 10)"],seeAlso:["number-theory.look-and-say-seq","number-theory.look-and-say-nth","number-theory.look-and-say?"]},"look-and-say-nth":{category:"number-theory",description:"Generates the nth term of the Look-and-Say sequence.",returns:{type:"string"},args:{n:{type:"integer",description:"The index of the term in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { look-and-say-nth } = import(number-theory);\nlook-and-say-nth(5)"],seeAlso:["number-theory.look-and-say-seq","number-theory.look-and-say-take-while","number-theory.look-and-say?"]},"look-and-say?":{category:"number-theory",description:"Checks if a string is a valid Look-and-Say term.",returns:{type:"boolean"},args:{term:{type:"string",description:"The term to check."}},variants:[{argumentNames:["term"]}],examples:['let { look-and-say? } = import(number-theory);\nlook-and-say?("111221")','let { look-and-say? } = import(number-theory);\nlook-and-say?("123")'],seeAlso:["number-theory.look-and-say-seq","number-theory.look-and-say-nth","number-theory.look-and-say-take-while"]},"lucas-seq":{category:"number-theory",description:"Generates the lucas sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 77 (the maximum length of the pre-calculated Lucas numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { lucas-seq } = import(number-theory);\nlucas-seq(1)","let { lucas-seq } = import(number-theory);\nlucas-seq(2)","let { lucas-seq } = import(number-theory);\nlucas-seq()"],seeAlso:["number-theory.lucas-nth","number-theory.lucas-take-while","number-theory.lucas?","number-theory.fibonacci-seq"]},"lucas-take-while":{category:"number-theory",description:"Generates the lucas sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { lucas-take-while } = import(number-theory);\nlucas-take-while(-> $ < 100)"],seeAlso:["number-theory.lucas-seq","number-theory.lucas-nth","number-theory.lucas?"]},"lucas-nth":{category:"number-theory",description:"Generates the nth term of the lucas sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { lucas-nth } = import(number-theory);\nlucas-nth(1)","let { lucas-nth } = import(number-theory);\nlucas-nth(2)","let { lucas-nth } = import(number-theory);\nlucas-nth(10)"],seeAlso:["number-theory.lucas-seq","number-theory.lucas-take-while","number-theory.lucas?"]},"lucas?":{category:"number-theory",description:"Determines if a number is in the lucas sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { lucas? } = import(number-theory);\nlucas?(1)","let { lucas? } = import(number-theory);\nlucas?(2)","let { lucas? } = import(number-theory);\nlucas?(10)"],seeAlso:["number-theory.lucas-seq","number-theory.lucas-nth","number-theory.fibonacci?","number-theory.lucas-take-while"]},"lucky-seq":{category:"number-theory",description:"Generates the lucky sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { lucky-seq } = import(number-theory);\nlucky-seq(1)","let { lucky-seq } = import(number-theory);\nlucky-seq(2)","let { lucky-seq } = import(number-theory);\nlucky-seq(20)"],seeAlso:["number-theory.lucky-nth","number-theory.lucky-take-while","number-theory.lucky?","number-theory.happy-seq","number-theory.prime-seq"]},"lucky-take-while":{category:"number-theory",description:"Generates the lucky sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { lucky-take-while } = import(number-theory);\nlucky-take-while(-> $ < 100)"],seeAlso:["number-theory.lucky-seq","number-theory.lucky-nth","number-theory.lucky?"]},"lucky-nth":{category:"number-theory",description:"Generates the nth term of the lucky sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The position in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { lucky-nth } = import(number-theory);\nlucky-nth(1)","let { lucky-nth } = import(number-theory);\nlucky-nth(2)","let { lucky-nth } = import(number-theory);\nlucky-nth(20)"],seeAlso:["number-theory.lucky-seq","number-theory.lucky-take-while","number-theory.lucky?"]},"lucky?":{category:"number-theory",description:"Checks if a number is a lucky number.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { lucky? } = import(number-theory);\nlucky?(4)","let { lucky? } = import(number-theory);\nlucky?(7)","let { lucky? } = import(number-theory);\nlucky?(33)"],seeAlso:["number-theory.lucky-seq","number-theory.lucky-nth","number-theory.prime?","number-theory.lucky-take-while"]},"mersenne-seq":{category:"number-theory",description:"Generates the Mersenne sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 9 (the maximum length of the pre-calculated mersenne numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { mersenne-seq } = import(number-theory);\nmersenne-seq(1)","let { mersenne-seq } = import(number-theory);\nmersenne-seq(5)","let { mersenne-seq } = import(number-theory);\nmersenne-seq()"],seeAlso:["number-theory.mersenne-nth","number-theory.mersenne-take-while","number-theory.mersenne?","number-theory.prime-seq"]},"mersenne-take-while":{category:"number-theory",description:"Generates the Mersenne sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { mersenne-take-while } = import(number-theory);\nmersenne-take-while(-> $ < 1000)"],seeAlso:["number-theory.mersenne-seq","number-theory.mersenne-nth","number-theory.mersenne?"]},"mersenne-nth":{category:"number-theory",description:"Generates the nth term of the Mersenne sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { mersenne-nth } = import(number-theory);\nmersenne-nth(1)","let { mersenne-nth } = import(number-theory);\nmersenne-nth(5)"],seeAlso:["number-theory.mersenne-seq","number-theory.mersenne-take-while","number-theory.mersenne?"]},"mersenne?":{category:"number-theory",description:"Checks if a number is in the Mersenne sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { mersenne? } = import(number-theory);\nmersenne?(3)","let { mersenne? } = import(number-theory);\nmersenne?(4)","let { mersenne? } = import(number-theory);\nmersenne?(7)"],seeAlso:["number-theory.mersenne-seq","number-theory.mersenne-nth","number-theory.prime?","number-theory.mersenne-take-while"]},"padovan-seq":{category:"number-theory",description:"Generates the Padovan sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { padovan-seq } = import(number-theory);\npadovan-seq(5)","let { padovan-seq } = import(number-theory);\npadovan-seq(10)","let { padovan-seq } = import(number-theory);\npadovan-seq(20)"],seeAlso:["number-theory.padovan-nth","number-theory.padovan-take-while","number-theory.padovan?","number-theory.fibonacci-seq"]},"padovan-take-while":{category:"number-theory",description:"Generates the Padovan sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { padovan-take-while } = import(number-theory);\npadovan-take-while(-> $ < 1000)"],seeAlso:["number-theory.padovan-seq","number-theory.padovan-nth","number-theory.padovan?"]},"padovan-nth":{category:"number-theory",description:"Generates the nth term of the Padovan sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { padovan-nth } = import(number-theory);\npadovan-nth(5)","let { padovan-nth } = import(number-theory);\npadovan-nth(10)","let { padovan-nth } = import(number-theory);\npadovan-nth(20)"],seeAlso:["number-theory.padovan-seq","number-theory.padovan-take-while","number-theory.padovan?"]},"padovan?":{category:"number-theory",description:"Checks if a number is in the Padovan sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { padovan? } = import(number-theory);\npadovan?(1)","let { padovan? } = import(number-theory);\npadovan?(265)","let { padovan? } = import(number-theory);\npadovan?(6)"],seeAlso:["number-theory.padovan-seq","number-theory.padovan-nth","number-theory.fibonacci?","number-theory.padovan-take-while"]},"partition-seq":{category:"number-theory",description:"Generates the partition numbers up to a specified length. If no length is provided, it defaults to 299 (the maximum length of the pre-calculated partition numbers).",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { partition-seq } = import(number-theory);\npartition-seq(1)","let { partition-seq } = import(number-theory);\npartition-seq(10)","let { partition-seq } = import(number-theory);\npartition-seq()"],seeAlso:["number-theory.partition-nth","number-theory.partition-take-while","number-theory.partition?","number-theory.partitions","number-theory.count-partitions"]},"partition-take-while":{category:"number-theory",description:"Generates the partition numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { partition-take-while } = import(number-theory);\npartition-take-while(-> $ < 1000)"],seeAlso:["number-theory.partition-seq","number-theory.partition-nth","number-theory.partition?"]},"partition-nth":{category:"number-theory",description:"Generates the nth term of the partition numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the partition number to generate."}},variants:[{argumentNames:["n"]}],examples:["let { partition-nth } = import(number-theory);\npartition-nth(1)","let { partition-nth } = import(number-theory);\npartition-nth(5)"],seeAlso:["number-theory.partition-seq","number-theory.partition-take-while","number-theory.partition?"]},"partition?":{category:"number-theory",description:"Checks if a number is in the partition numbers.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { partition? } = import(number-theory);\npartition?(0)","let { partition? } = import(number-theory);\npartition?(1)","let { partition? } = import(number-theory);\npartition?(2)","let { partition? } = import(number-theory);\npartition?(3)","let { partition? } = import(number-theory);\npartition?(4)","let { partition? } = import(number-theory);\npartition?(5)"],seeAlso:["number-theory.partition-seq","number-theory.partition-nth","number-theory.partitions","number-theory.partition-take-while"]},"pell-seq":{category:"number-theory",description:"Generates the Pell sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 42 (the maximum length of the pre-calculated Pell numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { pell-seq } = import(number-theory);\npell-seq(5)","let { pell-seq } = import(number-theory);\npell-seq(10)","let { pell-seq } = import(number-theory);\npell-seq()"],seeAlso:["number-theory.pell-nth","number-theory.pell-take-while","number-theory.pell?","number-theory.fibonacci-seq"]},"pell-take-while":{category:"number-theory",description:"Generates the Pell sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { pell-take-while } = import(number-theory);\npell-take-while(-> $ < 1000)"],seeAlso:["number-theory.pell-seq","number-theory.pell-nth","number-theory.pell?"]},"pell-nth":{category:"number-theory",description:"Generates the nth term of the Pell sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { pell-nth } = import(number-theory);\npell-nth(5)","let { pell-nth } = import(number-theory);\npell-nth(10)","let { pell-nth } = import(number-theory);\npell-nth(20)"],seeAlso:["number-theory.pell-seq","number-theory.pell-take-while","number-theory.pell?"]},"pell?":{category:"number-theory",description:"Checks if a number is a Pell number.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { pell? } = import(number-theory);\npell?(1)","let { pell? } = import(number-theory);\npell?(470832)","let { pell? } = import(number-theory);\npell?(10)"],seeAlso:["number-theory.pell-seq","number-theory.pell-nth","number-theory.fibonacci?","number-theory.pell-take-while"]},"perfect-seq":{category:"number-theory",description:"Generates the perfect numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If no length is provided, it defaults to 7 (the maximum length of the pre-calculated perfect numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { perfect-seq } = import(number-theory);\nperfect-seq(1)","let { perfect-seq } = import(number-theory);\nperfect-seq(5)","let { perfect-seq } = import(number-theory);\nperfect-seq()"],seeAlso:["number-theory.perfect-nth","number-theory.perfect-take-while","number-theory.perfect?","number-theory.abundant-seq","number-theory.deficient-seq","number-theory.amicable?"]},"perfect-take-while":{category:"number-theory",description:"Generates the perfect numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { perfect-take-while } = import(number-theory);\nperfect-take-while(-> $ < 1000)"],seeAlso:["number-theory.perfect-seq","number-theory.perfect-nth","number-theory.perfect?"]},"perfect-nth":{category:"number-theory",description:"Generates the nth term of the perfect numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the perfect number to generate."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-nth } = import(number-theory);\nperfect-nth(1)","let { perfect-nth } = import(number-theory);\nperfect-nth(5)"],seeAlso:["number-theory.perfect-seq","number-theory.perfect-take-while","number-theory.perfect?"]},"perfect?":{category:"number-theory",description:"Checks if a number is in the perfect numbers.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect? } = import(number-theory);\nperfect?(0)","let { perfect? } = import(number-theory);\nperfect?(1)","let { perfect? } = import(number-theory);\nperfect?(2)","let { perfect? } = import(number-theory);\nperfect?(3)","let { perfect? } = import(number-theory);\nperfect?(4)","let { perfect? } = import(number-theory);\nperfect?(5)","let { perfect? } = import(number-theory);\nperfect?(6)","let { perfect? } = import(number-theory);\nperfect?(7)","let { perfect? } = import(number-theory);\nperfect?(8)","let { perfect? } = import(number-theory);\nperfect?(9)"],seeAlso:["number-theory.perfect-seq","number-theory.perfect-nth","number-theory.abundant?","number-theory.deficient?","number-theory.sigma","number-theory.perfect-take-while","number-theory.amicable?","number-theory.proper-divisors"]},"perfect-square-seq":{category:"number-theory",description:"Generates the perfect square numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { perfect-square-seq } = import(number-theory);\nperfect-square-seq(5)","let { perfect-square-seq } = import(number-theory);\nperfect-square-seq(20)"],seeAlso:["number-theory.perfect-square-nth","number-theory.perfect-square-take-while","number-theory.perfect-square?","number-theory.perfect-cube-seq","number-theory.perfect-power-seq","number-theory.polygonal-seq"]},"perfect-square-take-while":{category:"number-theory",description:"Generates the perfect square numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { perfect-square-take-while } = import(number-theory);\nperfect-square-take-while(-> $ <= 100)"],seeAlso:["number-theory.perfect-square-seq","number-theory.perfect-square-nth","number-theory.perfect-square?"]},"perfect-square-nth":{category:"number-theory",description:"Generates the nth term of the perfect square numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-square-nth } = import(number-theory);\nperfect-square-nth(1)","let { perfect-square-nth } = import(number-theory);\nperfect-square-nth(5)"],seeAlso:["number-theory.perfect-square-seq","number-theory.perfect-square-take-while","number-theory.perfect-square?"]},"perfect-square?":{category:"number-theory",description:"Checks if a number is a perfect square.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-square? } = import(number-theory);\nperfect-square?(16)","let { perfect-square? } = import(number-theory);\nperfect-square?(20)"],seeAlso:["number-theory.perfect-square-seq","number-theory.perfect-square-nth","number-theory.perfect-cube?","number-theory.perfect-power?","number-theory.perfect-square-take-while","number-theory.perfect-power","number-theory.polygonal?"]},"perfect-cube-seq":{category:"number-theory",description:"Generates the perfect cube numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { perfect-cube-seq } = import(number-theory);\nperfect-cube-seq(5)","let { perfect-cube-seq } = import(number-theory);\nperfect-cube-seq(20)"],seeAlso:["number-theory.perfect-cube-nth","number-theory.perfect-cube-take-while","number-theory.perfect-cube?","number-theory.perfect-square-seq","number-theory.perfect-power-seq"]},"perfect-cube-take-while":{category:"number-theory",description:"Generates the perfect cube numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { perfect-cube-take-while } = import(number-theory);\nperfect-cube-take-while(-> $ <= 100)"],seeAlso:["number-theory.perfect-cube-seq","number-theory.perfect-cube-nth","number-theory.perfect-cube?"]},"perfect-cube-nth":{category:"number-theory",description:"Generates the nth term of the perfect cube numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-cube-nth } = import(number-theory);\nperfect-cube-nth(1)","let { perfect-cube-nth } = import(number-theory);\nperfect-cube-nth(5)"],seeAlso:["number-theory.perfect-cube-seq","number-theory.perfect-cube-take-while","number-theory.perfect-cube?"]},"perfect-cube?":{category:"number-theory",description:"Checks if a number is in the perfect cube numbers.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-cube? } = import(number-theory);\nperfect-cube?(7)","let { perfect-cube? } = import(number-theory);\nperfect-cube?(8)","let { perfect-cube? } = import(number-theory);\nperfect-cube?(9)"],seeAlso:["number-theory.perfect-cube-seq","number-theory.perfect-cube-nth","number-theory.perfect-square?","number-theory.perfect-power?","number-theory.perfect-cube-take-while","number-theory.perfect-power"]},"perfect-power-seq":{category:"number-theory",description:"Generates the perfect power numbers up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { perfect-power-seq } = import(number-theory);\nperfect-power-seq(5)","let { perfect-power-seq } = import(number-theory);\nperfect-power-seq(20)"],seeAlso:["number-theory.perfect-power-nth","number-theory.perfect-power-take-while","number-theory.perfect-power?","number-theory.perfect-power","number-theory.perfect-square-seq","number-theory.perfect-cube-seq"]},"perfect-power-take-while":{category:"number-theory",description:"Generates the perfect power numbers while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { perfect-power-take-while } = import(number-theory);\nperfect-power-take-while(-> $ <= 100)"],seeAlso:["number-theory.perfect-power-seq","number-theory.perfect-power-nth","number-theory.perfect-power?"]},"perfect-power-nth":{category:"number-theory",description:"Generates the nth term of the perfect power numbers.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-power-nth } = import(number-theory);\nperfect-power-nth(3)","let { perfect-power-nth } = import(number-theory);\nperfect-power-nth(15)"],seeAlso:["number-theory.perfect-power-seq","number-theory.perfect-power-take-while","number-theory.perfect-power?"]},"perfect-power?":{category:"number-theory",description:"Checks if a number is in the perfect power numbers.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-power? } = import(number-theory);\nperfect-power?(7)","let { perfect-power? } = import(number-theory);\nperfect-power?(8)","let { perfect-power? } = import(number-theory);\nperfect-power?(9)","let { perfect-power? } = import(number-theory);\nperfect-power?(10)"],seeAlso:["number-theory.perfect-power-seq","number-theory.perfect-power-nth","number-theory.perfect-power","number-theory.perfect-square?","number-theory.perfect-cube?","number-theory.perfect-power-take-while"]},"polygonal-seq":{category:"number-theory",description:"Generates the polygonal sequence for a given number of sides and length.",returns:{type:"integer",array:!0},args:{sides:{type:"integer",description:"The number of sides of the polygon."},length:{type:"integer",description:"The length of the sequence to generate."},a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["sides","length"]}],examples:["let { polygonal-seq } = import(number-theory);\npolygonal-seq(3, 2)","let { polygonal-seq } = import(number-theory);\npolygonal-seq(4, 2)","let { polygonal-seq } = import(number-theory);\npolygonal-seq(5, 3)","let { polygonal-seq } = import(number-theory);\npolygonal-seq(6, 5)","let { polygonal-seq } = import(number-theory);\npolygonal-seq(100, 10)"],seeAlso:["number-theory.polygonal-nth","number-theory.polygonal-take-while","number-theory.polygonal?","number-theory.perfect-square-seq"]},"polygonal-take-while":{category:"number-theory",description:"Generates the polygonal sequence while a condition is met.",returns:{type:"integer",array:!0},args:{sides:{type:"integer",description:"The number of sides of the polygon."},takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."},a:{type:"integer"},b:{type:"function"}},variants:[{argumentNames:["sides","takeWhile"]}],examples:["let { polygonal-take-while } = import(number-theory);\npolygonal-take-while(15, -> $ < 1000)"],seeAlso:["number-theory.polygonal-seq","number-theory.polygonal-nth","number-theory.polygonal?"]},"polygonal-nth":{category:"number-theory",description:"Generates the nth term of the polygonal sequence.",returns:{type:"integer"},args:{sides:{type:"integer",description:"The number of sides of the polygon."},n:{type:"integer",description:"The index of the term to generate."},a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["sides","n"]}],examples:["let { polygonal-nth } = import(number-theory);\npolygonal-nth(3, 9)","let { polygonal-nth } = import(number-theory);\npolygonal-nth(4, 5)","let { polygonal-nth } = import(number-theory);\npolygonal-nth(5, 5)"],seeAlso:["number-theory.polygonal-seq","number-theory.polygonal-take-while","number-theory.polygonal?"]},"polygonal?":{category:"number-theory",description:"Checks if a number is in the polygonal sequence.",returns:{type:"boolean"},args:{sides:{type:"integer",description:"The number of sides of the polygon."},n:{type:"integer",description:"The number to check."},a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["sides","n"]}],examples:["let { polygonal? } = import(number-theory);\npolygonal?(3, 10)","let { polygonal? } = import(number-theory);\npolygonal?(3, 9)","let { polygonal? } = import(number-theory);\npolygonal?(4, 10000)","let { polygonal? } = import(number-theory);\npolygonal?(4, 1000)","let { polygonal? } = import(number-theory);\npolygonal?(6, 45)"],seeAlso:["number-theory.polygonal-seq","number-theory.polygonal-nth","number-theory.perfect-square?","number-theory.polygonal-take-while"]},"prime-seq":{category:"number-theory",description:"Generates the prime sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { prime-seq } = import(number-theory);\nprime-seq(1)","let { prime-seq } = import(number-theory);\nprime-seq(2)","let { prime-seq } = import(number-theory);\nprime-seq(10)"],seeAlso:["number-theory.prime-nth","number-theory.prime-take-while","number-theory.prime?","number-theory.composite-seq","number-theory.mersenne-seq","number-theory.lucky-seq"]},"prime-take-while":{category:"number-theory",description:"Generates the prime sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { prime-take-while } = import(number-theory);\nprime-take-while(-> $ < 50)"],seeAlso:["number-theory.prime-seq","number-theory.prime-nth","number-theory.prime?"]},"prime-nth":{category:"number-theory",description:"Generates the nth term of the prime sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { prime-nth } = import(number-theory);\nprime-nth(1)","let { prime-nth } = import(number-theory);\nprime-nth(2)","let { prime-nth } = import(number-theory);\nprime-nth(10)"],seeAlso:["number-theory.prime-seq","number-theory.prime-take-while","number-theory.prime?"]},"prime?":{category:"number-theory",description:"Determines if a number is prime.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { prime? } = import(number-theory);\nprime?(1)","let { prime? } = import(number-theory);\nprime?(2)","let { prime? } = import(number-theory);\nprime?(3)","let { prime? } = import(number-theory);\nprime?(4)","let { prime? } = import(number-theory);\nprime?(997)","let { prime? } = import(number-theory);\nprime?(1001)"],seeAlso:["number-theory.prime-seq","number-theory.prime-nth","number-theory.composite?","number-theory.prime-factors","number-theory.mersenne?","number-theory.prime-take-while","number-theory.lucky?"]},"recaman-seq":{category:"number-theory",description:"Generates the Recaman sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { recaman-seq } = import(number-theory);\nrecaman-seq(5)","let { recaman-seq } = import(number-theory);\nrecaman-seq(10)","let { recaman-seq } = import(number-theory);\nrecaman-seq(20)"],seeAlso:["number-theory.recaman-nth","number-theory.recaman-take-while","number-theory.recaman?","number-theory.golomb-seq"]},"recaman-take-while":{category:"number-theory",description:"Generates the Recaman sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { recaman-take-while } = import(number-theory);\nrecaman-take-while(-> $ < 10)"],seeAlso:["number-theory.recaman-seq","number-theory.recaman-nth","number-theory.recaman?"]},"recaman-nth":{category:"number-theory",description:"Generates the nth term of the Recaman sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { recaman-nth } = import(number-theory);\nrecaman-nth(5)","let { recaman-nth } = import(number-theory);\nrecaman-nth(10)","let { recaman-nth } = import(number-theory);\nrecaman-nth(20)"],seeAlso:["number-theory.recaman-seq","number-theory.recaman-take-while","number-theory.recaman?"]},"recaman?":{category:"number-theory",description:"Checks if a number is in the Recaman sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { recaman? } = import(number-theory);\nrecaman?(5)","let { recaman? } = import(number-theory);\nrecaman?(10)","let { recaman? } = import(number-theory);\nrecaman?(20)"],seeAlso:["number-theory.recaman-seq","number-theory.recaman-nth","number-theory.recaman-take-while"]},"sylvester-seq":{category:"number-theory",description:"Generates the Sylvester sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate. If not provided, the default is 6 (the maximum length of the pre-calculated Sylvester numbers)."}},variants:[{argumentNames:["length"]},{argumentNames:[]}],examples:["let { sylvester-seq } = import(number-theory);\nsylvester-seq(5)","let { sylvester-seq } = import(number-theory);\nsylvester-seq()","let { sylvester-seq } = import(number-theory);\nsylvester-seq()"],seeAlso:["number-theory.sylvester-nth","number-theory.sylvester-take-while","number-theory.sylvester?"]},"sylvester-take-while":{category:"number-theory",description:"Generates the Sylvester sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { sylvester-take-while } = import(number-theory);\nsylvester-take-while(-> $ < 100000)"],seeAlso:["number-theory.sylvester-seq","number-theory.sylvester-nth","number-theory.sylvester?"]},"sylvester-nth":{category:"number-theory",description:"Generates the nth term of the Sylvester sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { sylvester-nth } = import(number-theory);\nsylvester-nth(1)","let { sylvester-nth } = import(number-theory);\nsylvester-nth(5)"],seeAlso:["number-theory.sylvester-seq","number-theory.sylvester-take-while","number-theory.sylvester?"]},"sylvester?":{category:"number-theory",description:"Checks if a number is in the Sylvester sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { sylvester? } = import(number-theory);\nsylvester?(2)","let { sylvester? } = import(number-theory);\nsylvester?(3)","let { sylvester? } = import(number-theory);\nsylvester?(6)"],seeAlso:["number-theory.sylvester-seq","number-theory.sylvester-nth","number-theory.sylvester-take-while"]},"thue-morse-seq":{category:"number-theory",description:"Generates the Thue-Morse sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { thue-morse-seq } = import(number-theory);\nthue-morse-seq(5)","let { thue-morse-seq } = import(number-theory);\nthue-morse-seq(10)","let { thue-morse-seq } = import(number-theory);\nthue-morse-seq(20)"],seeAlso:["number-theory.thue-morse-nth","number-theory.thue-morse-take-while","number-theory.thue-morse?"]},"thue-morse-take-while":{category:"number-theory",description:"Generates the Thue-Morse sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { thue-morse-take-while } = import(number-theory);\nthue-morse-take-while(-> $2 < 10)"],seeAlso:["number-theory.thue-morse-seq","number-theory.thue-morse-nth","number-theory.thue-morse?"]},"thue-morse-nth":{category:"number-theory",description:"Generates the nth term of the Thue-Morse sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term in the sequence."}},variants:[{argumentNames:["n"]}],examples:["let { thue-morse-nth } = import(number-theory);\nthue-morse-nth(5)","let { thue-morse-nth } = import(number-theory);\nthue-morse-nth(10)","let { thue-morse-nth } = import(number-theory);\nthue-morse-nth(20)"],seeAlso:["number-theory.thue-morse-seq","number-theory.thue-morse-take-while","number-theory.thue-morse?"]},"thue-morse?":{category:"number-theory",description:"Checks if a number is part of the Thue-Morse sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { thue-morse? } = import(number-theory);\nthue-morse?(1)","let { thue-morse? } = import(number-theory);\nthue-morse?(2)"],seeAlso:["number-theory.thue-morse-seq","number-theory.thue-morse-nth","number-theory.thue-morse-take-while"]},"tribonacci-seq":{category:"number-theory",description:"Generates the tribonacci sequence up to a specified length.",returns:{type:"integer",array:!0},args:{length:{type:"integer",description:"The length of the sequence to generate."}},variants:[{argumentNames:["length"]}],examples:["let { tribonacci-seq } = import(number-theory);\ntribonacci-seq(1)","let { tribonacci-seq } = import(number-theory);\ntribonacci-seq(2)","let { tribonacci-seq } = import(number-theory);\ntribonacci-seq(10)"],seeAlso:["number-theory.tribonacci-nth","number-theory.tribonacci-take-while","number-theory.tribonacci?","number-theory.fibonacci-seq"]},"tribonacci-take-while":{category:"number-theory",description:"Generates the tribonacci sequence while a condition is met.",returns:{type:"integer",array:!0},args:{takeWhile:{type:"function",description:"A function that takes an integer and an index and returns a boolean."}},variants:[{argumentNames:["takeWhile"]}],examples:["let { tribonacci-take-while } = import(number-theory);\ntribonacci-take-while(-> $ < 100)"],seeAlso:["number-theory.tribonacci-seq","number-theory.tribonacci-nth","number-theory.tribonacci?"]},"tribonacci-nth":{category:"number-theory",description:"Generates the nth term of the tribonacci sequence.",returns:{type:"integer"},args:{n:{type:"integer",description:"The index of the term to generate."}},variants:[{argumentNames:["n"]}],examples:["let { tribonacci-nth } = import(number-theory);\ntribonacci-nth(1)","let { tribonacci-nth } = import(number-theory);\ntribonacci-nth(2)","let { tribonacci-nth } = import(number-theory);\ntribonacci-nth(10)"],seeAlso:["number-theory.tribonacci-seq","number-theory.tribonacci-take-while","number-theory.tribonacci?"]},"tribonacci?":{category:"number-theory",description:"Determines if a number is in the tribonacci sequence.",returns:{type:"boolean"},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { tribonacci? } = import(number-theory);\ntribonacci?(0)","let { tribonacci? } = import(number-theory);\ntribonacci?(1)","let { tribonacci? } = import(number-theory);\ntribonacci?(2)","let { tribonacci? } = import(number-theory);\ntribonacci?(3)","let { tribonacci? } = import(number-theory);\ntribonacci?(4)","let { tribonacci? } = import(number-theory);\ntribonacci?(5)","let { tribonacci? } = import(number-theory);\ntribonacci?(6)","let { tribonacci? } = import(number-theory);\ntribonacci?(7)","let { tribonacci? } = import(number-theory);\ntribonacci?(8)","let { tribonacci? } = import(number-theory);\ntribonacci?(9)","let { tribonacci? } = import(number-theory);\ntribonacci?(10)"],seeAlso:["number-theory.tribonacci-seq","number-theory.tribonacci-nth","number-theory.fibonacci?","number-theory.tribonacci-take-while"]},"count-combinations":{category:"number-theory",description:"Calculates the number of combinations of n items taken k at a time.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { count-combinations } = import(number-theory);\ncount-combinations(5, 3)","let { count-combinations } = import(number-theory);\ncount-combinations(10, 2)"],seeAlso:["number-theory.combinations","number-theory.count-permutations","number-theory.factorial","number-theory.multinomial","number-theory.stirling-second","number-theory.count-partitions","number-theory.count-power-set"]},combinations:{category:"number-theory",description:"Generates all possible combinations of a specified size from a collection.",returns:{type:"array",array:!0},args:{set:{type:"array",array:!0,description:"The input collection to generate combinations from."},n:{type:"integer",description:"The size of each combination."},a:{type:"array"},b:{type:"integer"}},variants:[{argumentNames:["set","n"]}],examples:["let { combinations } = import(number-theory);\ncombinations([1, 2, 3], 2)",'let { combinations } = import(number-theory);\ncombinations(["a", "b", "c"], 2)',"let { combinations } = import(number-theory);\ncombinations([1, 2, 3], 0)","let { combinations } = import(number-theory);\ncombinations([1, 2, 3], 1)","let { combinations } = import(number-theory);\ncombinations([1, 2, 3], 3)"],seeAlso:["number-theory.count-combinations","number-theory.permutations","number-theory.power-set","number-theory.cartesian-product","number-theory.partitions"]},"count-derangements":{category:"number-theory",description:"Calculates the number of derangements (permutations where no element appears in its original position) of n items.",returns:{type:"integer"},args:{n:{type:"integer",description:"The total number of items."}},variants:[{argumentNames:["n"]}],examples:["let { count-derangements } = import(number-theory);\ncount-derangements(4)","let { count-derangements } = import(number-theory);\ncount-derangements(5)"],seeAlso:["number-theory.derangements","number-theory.count-permutations","number-theory.factorial"]},derangements:{category:"number-theory",description:"Generates all derangements (permutations where no element appears in its original position) of a set.",returns:{type:"array",array:!0},args:{set:{type:"array",array:!0,description:"The input collection to generate derangements from."}},variants:[{argumentNames:["set"]}],examples:["let { derangements } = import(number-theory);\nderangements([1, 2, 3, 4])",'let { derangements } = import(number-theory);\nderangements(["a", "b", "c"])'],seeAlso:["number-theory.count-derangements","number-theory.permutations"]},divisors:{category:"number-theory",description:"Returns the divisors of a number.",returns:{type:"integer",array:!0},args:{n:{type:"integer",description:"The number to find divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { divisors } = import(number-theory);\ndivisors(12)","let { divisors } = import(number-theory);\ndivisors(100)","let { divisors } = import(number-theory);\ndivisors(37)"],seeAlso:["number-theory.count-divisors","number-theory.proper-divisors","number-theory.sigma","number-theory.prime-factors","number-theory.divisible-by?","number-theory.lcm","number-theory.abundant?","number-theory.deficient?","number-theory.count-proper-divisors"]},"count-divisors":{category:"number-theory",description:"Returns the number of divisors of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { count-divisors } = import(number-theory);\ncount-divisors(12)","let { count-divisors } = import(number-theory);\ncount-divisors(100)","let { count-divisors } = import(number-theory);\ncount-divisors(37)"],seeAlso:["number-theory.divisors","number-theory.count-proper-divisors","number-theory.sigma"]},"proper-divisors":{category:"number-theory",description:"Returns the proper divisors of a number.",returns:{type:"integer",array:!0},args:{n:{type:"integer",description:"The number to find proper divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { proper-divisors } = import(number-theory);\nproper-divisors(12)","let { proper-divisors } = import(number-theory);\nproper-divisors(100)","let { proper-divisors } = import(number-theory);\nproper-divisors(37)"],seeAlso:["number-theory.count-proper-divisors","number-theory.divisors","number-theory.amicable?","number-theory.perfect?"]},"count-proper-divisors":{category:"number-theory",description:"Returns the number of proper divisors of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count proper divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { count-proper-divisors } = import(number-theory);\ncount-proper-divisors(12)","let { count-proper-divisors } = import(number-theory);\ncount-proper-divisors(100)","let { count-proper-divisors } = import(number-theory);\ncount-proper-divisors(37)"],seeAlso:["number-theory.proper-divisors","number-theory.count-divisors","number-theory.divisors"]},factorial:{category:"number-theory",description:"Calculates the factorial of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the factorial for."}},variants:[{argumentNames:["n"]}],examples:["let { factorial } = import(number-theory);\nfactorial(5)","let { factorial } = import(number-theory);\nfactorial(0)","let { factorial } = import(number-theory);\nfactorial(10)","let { factorial } = import(number-theory);\nfactorial(20)"],seeAlso:["number-theory.factorial-seq","number-theory.factorial-nth","number-theory.factorial?","number-theory.count-combinations","number-theory.count-permutations","number-theory.multinomial","number-theory.count-derangements"]},partitions:{category:"number-theory",description:"Generates all partitions of a number.",returns:{type:"array",array:!0},args:{n:{type:"integer",description:"The number to partition."}},variants:[{argumentNames:["n"]}],examples:["let { partitions } = import(number-theory);\npartitions(4)","let { partitions } = import(number-theory);\npartitions(8)"],seeAlso:["number-theory.count-partitions","number-theory.partition-seq","number-theory.combinations","number-theory.partition?"]},"count-partitions":{category:"number-theory",description:"Returns the number of partitions of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count partitions for."}},variants:[{argumentNames:["n"]}],examples:["let { count-partitions } = import(number-theory);\ncount-partitions(4)","let { count-partitions } = import(number-theory);\ncount-partitions(8)","let { count-partitions } = import(number-theory);\ncount-partitions(15)"],seeAlso:["number-theory.partitions","number-theory.partition-seq","number-theory.count-combinations"]},permutations:{category:"number-theory",description:"Generates all permutations of a collection.",returns:{type:"array",array:!0},args:{set:{type:"array",array:!0,description:"The input collection to generate permutations from."}},variants:[{argumentNames:["set"]}],examples:["let { permutations } = import(number-theory);\npermutations([1, 2, 3])",'let { permutations } = import(number-theory);\npermutations(["a", "b", "c"])',"let { permutations } = import(number-theory);\npermutations([1, 2, 3, 4])","let { permutations } = import(number-theory);\npermutations([1, 2])","let { permutations } = import(number-theory);\npermutations([1])","let { permutations } = import(number-theory);\npermutations([])"],seeAlso:["number-theory.count-permutations","number-theory.combinations","number-theory.derangements","number-theory.cartesian-product"]},"count-permutations":{category:"number-theory",description:"Returns the number of permutations of n items taken k at a time.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { count-permutations } = import(number-theory);\ncount-permutations(5, 3)","let { count-permutations } = import(number-theory);\ncount-permutations(10, 2)","let { count-permutations } = import(number-theory);\ncount-permutations(10, 10)","let { count-permutations } = import(number-theory);\ncount-permutations(10, 0)","let { count-permutations } = import(number-theory);\ncount-permutations(10, 1)"],seeAlso:["number-theory.permutations","number-theory.count-combinations","number-theory.factorial","number-theory.multinomial","number-theory.stirling-first","number-theory.count-derangements"]},"power-set":{category:"number-theory",description:"Generates the power set of a collection.",returns:{type:"array",array:!0},args:{set:{type:"any",array:!0,description:"The input collection to generate the power set from."}},variants:[{argumentNames:["set"]}],examples:['let { power-set } = import(number-theory);\npower-set(["a", "b", "c"])',"let { power-set } = import(number-theory);\npower-set([1, 2])","let { power-set } = import(number-theory);\npower-set([1])","let { power-set } = import(number-theory);\npower-set([])"],seeAlso:["number-theory.count-power-set","number-theory.combinations","number-theory.cartesian-product"]},"count-power-set":{category:"number-theory",description:"Returns the number of subsets of a set.",returns:{type:"integer"},args:{n:{type:"integer",description:"The size of the set."}},variants:[{argumentNames:["n"]}],examples:["let { count-power-set } = import(number-theory);\ncount-power-set(3)","let { count-power-set } = import(number-theory);\ncount-power-set(5)","let { count-power-set } = import(number-theory);\ncount-power-set(10)"],seeAlso:["number-theory.power-set","number-theory.count-combinations"]},"prime-factors":{category:"number-theory",description:"Returns the prime factors of a number.",returns:{type:"integer",array:!0},args:{n:{type:"integer",description:"The number to factor."}},variants:[{argumentNames:["n"]}],examples:["let { prime-factors } = import(number-theory);\nprime-factors(12)","let { prime-factors } = import(number-theory);\nprime-factors(100)","let { prime-factors } = import(number-theory);\nprime-factors(37)"],seeAlso:["number-theory.count-prime-factors","number-theory.distinct-prime-factors","number-theory.prime?","number-theory.divisors","number-theory.euler-totient","number-theory.mobius","number-theory.composite?","number-theory.count-distinct-prime-factors"]},"count-prime-factors":{category:"number-theory",description:"Returns the number of prime factors of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count prime factors for."}},variants:[{argumentNames:["n"]}],examples:["let { count-prime-factors } = import(number-theory);\ncount-prime-factors(12)","let { count-prime-factors } = import(number-theory);\ncount-prime-factors(100)","let { count-prime-factors } = import(number-theory);\ncount-prime-factors(37)"],seeAlso:["number-theory.prime-factors","number-theory.distinct-prime-factors","number-theory.count-distinct-prime-factors"]},"distinct-prime-factors":{category:"number-theory",description:"Returns the distinct prime factors of a number.",returns:{type:"integer",array:!0},args:{n:{type:"integer",description:"The number to find distinct prime factors for."}},variants:[{argumentNames:["n"]}],examples:["let { distinct-prime-factors } = import(number-theory);\ndistinct-prime-factors(12)","let { distinct-prime-factors } = import(number-theory);\ndistinct-prime-factors(100)","let { distinct-prime-factors } = import(number-theory);\ndistinct-prime-factors(37)"],seeAlso:["number-theory.prime-factors","number-theory.count-distinct-prime-factors","number-theory.count-prime-factors"]},"count-distinct-prime-factors":{category:"number-theory",description:"Returns the number of distinct prime factors of a number.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to count distinct prime factors for."}},variants:[{argumentNames:["n"]}],examples:["let { count-distinct-prime-factors } = import(number-theory);\ncount-distinct-prime-factors(12)","let { count-distinct-prime-factors } = import(number-theory);\ncount-distinct-prime-factors(100)","let { count-distinct-prime-factors } = import(number-theory);\ncount-distinct-prime-factors(37)"],seeAlso:["number-theory.distinct-prime-factors","number-theory.prime-factors","number-theory.count-prime-factors"]},"coprime?":{category:"number-theory",description:"Checks if two numbers are coprime (i.e., their GCD is 1).",returns:{type:"boolean"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { coprime? } = import(number-theory);\ncoprime?(12, 8)","let { coprime? } = import(number-theory);\ncoprime?(12, 5)","let { coprime? } = import(number-theory);\ncoprime?(37, 1)","let { coprime? } = import(number-theory);\ncoprime?(0, 0)","let { coprime? } = import(number-theory);\ncoprime?(0, 5)","let { coprime? } = import(number-theory);\ncoprime?(5, 0)","let { coprime? } = import(number-theory);\ncoprime?(1, 0)","let { coprime? } = import(number-theory);\ncoprime?(0, 1)","let { coprime? } = import(number-theory);\ncoprime?(1, 1)","let { coprime? } = import(number-theory);\ncoprime?(2, 3)"],seeAlso:["number-theory.gcd","number-theory.euler-totient","number-theory.divisible-by?","number-theory.lcm","number-theory.carmichael-lambda"]},"divisible-by?":{category:"number-theory",description:"Checks if a number is divisible by another number.",returns:{type:"boolean"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { divisible-by? } = import(number-theory);\ndivisible-by?(12, 4)","let { divisible-by? } = import(number-theory);\ndivisible-by?(12, 5)","let { divisible-by? } = import(number-theory);\ndivisible-by?(37, 1)","let { divisible-by? } = import(number-theory);\ndivisible-by?(0, 0)","let { divisible-by? } = import(number-theory);\ndivisible-by?(0, 5)","let { divisible-by? } = import(number-theory);\ndivisible-by?(5, 0)"],seeAlso:["number-theory.divisors","number-theory.gcd","number-theory.coprime?"]},gcd:{category:"number-theory",description:"Calculates the greatest common divisor (GCD) of two numbers.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { gcd } = import(number-theory);\ngcd(100, 25)","let { gcd } = import(number-theory);\ngcd(37, 1)","let { gcd } = import(number-theory);\ngcd(0, 0)","let { gcd } = import(number-theory);\ngcd(0, 5)","let { gcd } = import(number-theory);\ngcd(5, 0)"],seeAlso:["number-theory.lcm","number-theory.extended-gcd","number-theory.coprime?","number-theory.divisible-by?"]},lcm:{category:"number-theory",description:"Calculates the least common multiple (LCM) of two numbers.",returns:{type:"integer"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { lcm } = import(number-theory);\nlcm(100, 25)","let { lcm } = import(number-theory);\nlcm(37, 1)","let { lcm } = import(number-theory);\nlcm(0, 5)","let { lcm } = import(number-theory);\nlcm(5, 0)"],seeAlso:["number-theory.gcd","number-theory.divisors","number-theory.coprime?"]},multinomial:{category:"number-theory",description:"Calculates the multinomial coefficient from of a list of numbers representing the sizes of each group.",returns:{type:"integer"},args:{args:{type:"integer",rest:!0,description:"The numbers representing the sizes of each group."}},variants:[{argumentNames:["args"]}],examples:["let { multinomial } = import(number-theory);\nmultinomial(5, 2, 3)","let { multinomial } = import(number-theory);\nmultinomial(10, 2, 3, 5)"],seeAlso:["number-theory.count-combinations","number-theory.factorial","number-theory.count-permutations"],hideOperatorForm:!0},"amicable?":{category:"number-theory",description:"Checks if two numbers are amicable (i.e., the sum of the proper divisors of each number equals the other number).",returns:{type:"boolean"},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { amicable? } = import(number-theory);\namicable?(220, 284)","let { amicable? } = import(number-theory);\namicable?(1184, 1210)","let { amicable? } = import(number-theory);\namicable?(2620, 2924)","let { amicable? } = import(number-theory);\namicable?(5020, 5564)","let { amicable? } = import(number-theory);\namicable?(6232, 6368)"],seeAlso:["number-theory.proper-divisors","number-theory.perfect?","number-theory.sigma","number-theory.perfect-seq"]},"euler-totient":{category:"number-theory",description:"Calculates the Euler's totient function (φ(n)) of a number, which counts the integers up to n that are coprime to n.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the totient for."}},variants:[{argumentNames:["n"]}],examples:["let { euler-totient } = import(number-theory);\neuler-totient(1)","let { euler-totient } = import(number-theory);\neuler-totient(2)","let { euler-totient } = import(number-theory);\neuler-totient(10)","let { euler-totient } = import(number-theory);\neuler-totient(20)"],seeAlso:["number-theory.coprime?","number-theory.carmichael-lambda","number-theory.mobius","number-theory.prime-factors","number-theory.mertens"]},mobius:{category:"number-theory",description:"Calculates the Möbius function (μ(n)) of a number, which is used in number theory.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the Möbius function for."}},variants:[{argumentNames:["n"]}],examples:["let { mobius } = import(number-theory);\nmobius(1)","let { mobius } = import(number-theory);\nmobius(2)","let { mobius } = import(number-theory);\nmobius(3)","let { mobius } = import(number-theory);\nmobius(4)","let { mobius } = import(number-theory);\nmobius(6)","let { mobius } = import(number-theory);\nmobius(12)","let { mobius } = import(number-theory);\nmobius(30)"],seeAlso:["number-theory.mertens","number-theory.euler-totient","number-theory.prime-factors"]},mertens:{category:"number-theory",description:"Calculates the Mertens function (M(n)) of a number, which is the sum of the Möbius function up to n.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the Mertens function for."}},variants:[{argumentNames:["n"]}],examples:["let { mobius } = import(number-theory);\nmobius(1)","let { mobius } = import(number-theory);\nmobius(2)","let { mobius } = import(number-theory);\nmobius(3)","let { mobius } = import(number-theory);\nmobius(4)","let { mobius } = import(number-theory);\nmobius(6)","let { mobius } = import(number-theory);\nmobius(12)","let { mobius } = import(number-theory);\nmobius(30)"],seeAlso:["number-theory.mobius","number-theory.euler-totient"]},sigma:{category:"number-theory",description:"Calculates the sum of divisors function (σ(n)) of a number, which is the sum of all positive divisors of n.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the sum of divisors for."}},variants:[{argumentNames:["n"]}],examples:["let { sigma } = import(number-theory);\nsigma(1)","let { sigma } = import(number-theory);\nsigma(2)","let { sigma } = import(number-theory);\nsigma(3)","let { sigma } = import(number-theory);\nsigma(4)","let { sigma } = import(number-theory);\nsigma(6)","let { sigma } = import(number-theory);\nsigma(12)","let { sigma } = import(number-theory);\nsigma(30)"],seeAlso:["number-theory.divisors","number-theory.perfect?","number-theory.abundant?","number-theory.deficient?","number-theory.amicable?","number-theory.count-divisors"]},"carmichael-lambda":{category:"number-theory",description:"Calculates the Carmichael function (λ(n)) of a number, which is the smallest positive integer m such that a^m ≡ 1 (mod n) for all integers a coprime to n.",returns:{type:"integer"},args:{n:{type:"integer",description:"The number to calculate the Carmichael function for."}},variants:[{argumentNames:["n"]}],examples:["let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(1)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(2)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(3)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(4)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(6)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(12)","let { carmichael-lambda } = import(number-theory);\ncarmichael-lambda(30)"],seeAlso:["number-theory.euler-totient","number-theory.mod-exp","number-theory.coprime?"]},"cartesian-product":{category:"number-theory",description:"Calculates the Cartesian product of two or more sets.",returns:{type:"array",array:!0},args:{sets:{type:"array",array:!0,description:"The input collections to calculate the Cartesian product from."},a:{type:"array"},b:{type:"array"}},variants:[{argumentNames:["sets"]}],examples:['let { cartesian-product } = import(number-theory);\ncartesian-product([1, 2], ["a", "b"])','let { cartesian-product } = import(number-theory);\ncartesian-product([1, 2], ["a", "b"], [true, false])','let { cartesian-product } = import(number-theory);\ncartesian-product([1, 2, 3], ["x", "y", "z"])'],seeAlso:["number-theory.combinations","number-theory.power-set","number-theory.permutations"]},"perfect-power":{category:"number-theory",description:"Returns a tuple of the base and exponent if the number is a perfect power, otherwise returns null.",returns:{type:["array","null"]},args:{n:{type:"integer",description:"The number to check."}},variants:[{argumentNames:["n"]}],examples:["let { perfect-power } = import(number-theory);\nperfect-power(1)","let { perfect-power } = import(number-theory);\nperfect-power(2)","let { perfect-power } = import(number-theory);\nperfect-power(4)","let { perfect-power } = import(number-theory);\nperfect-power(8)","let { perfect-power } = import(number-theory);\nperfect-power(9)","let { perfect-power } = import(number-theory);\nperfect-power(16)","let { perfect-power } = import(number-theory);\nperfect-power(19)"],seeAlso:["number-theory.perfect-power?","number-theory.perfect-power-seq","number-theory.perfect-square?","number-theory.perfect-cube?"]},"mod-exp":{category:"number-theory",description:"Calculates the modular exponentiation of a base raised to an exponent modulo a modulus.",returns:{type:"integer"},args:{base:{type:"integer"},exponent:{type:"integer"},modulus:{type:"integer"}},variants:[{argumentNames:["base","exponent","modulus"]}],examples:["let { mod-exp } = import(number-theory);\nmod-exp(2, 3, 5)","let { mod-exp } = import(number-theory);\nmod-exp(3, 4, 7)","let { mod-exp } = import(number-theory);\nmod-exp(5, 6, 11)","let { mod-exp } = import(number-theory);\nmod-exp(7, 8, 13)"],seeAlso:["number-theory.mod-inv","number-theory.carmichael-lambda","number-theory.chinese-remainder"]},"mod-inv":{category:"number-theory",description:"Calculates the modular multiplicative inverse of a number modulo another number.",returns:{type:"integer"},args:{a:{type:"integer"},m:{type:"integer"}},variants:[{argumentNames:["a","m"]}],examples:["let { mod-inv } = import(number-theory);\nmod-inv(3, 11)","let { mod-inv } = import(number-theory);\nmod-inv(10, 17)","let { mod-inv } = import(number-theory);\nmod-inv(5, 13)","let { mod-inv } = import(number-theory);\nmod-inv(7, 19)"],seeAlso:["number-theory.mod-exp","number-theory.extended-gcd","number-theory.chinese-remainder"]},"extended-gcd":{category:"number-theory",description:"Calculates the extended greatest common divisor (GCD) of two numbers, returning the GCD and the coefficients of Bézout's identity.",returns:{type:"integer",array:!0},args:{a:{type:"integer"},b:{type:"integer"}},variants:[{argumentNames:["a","b"]}],examples:["let { extended-gcd } = import(number-theory);\nextended-gcd(30, 12)","let { extended-gcd } = import(number-theory);\nextended-gcd(56, 98)","let { extended-gcd } = import(number-theory);\nextended-gcd(101, 10)","let { extended-gcd } = import(number-theory);\nextended-gcd(17, 13)"],seeAlso:["number-theory.gcd","number-theory.mod-inv","number-theory.chinese-remainder"]},"chinese-remainder":{category:"number-theory",description:"Solves a system of simultaneous congruences using the Chinese Remainder Theorem.",returns:{type:"integer"},args:{remainders:{type:"integer",array:!0,description:"The remainders of the congruences."},moduli:{type:"integer",array:!0,description:"The moduli of the congruences."},a:{type:"array"},b:{type:"array"}},variants:[{argumentNames:["remainders","moduli"]}],examples:["let { chinese-remainder } = import(number-theory);\nchinese-remainder([2, 3], [3, 5])","let { chinese-remainder } = import(number-theory);\nchinese-remainder([1, 2], [3, 4])","let { chinese-remainder } = import(number-theory);\nchinese-remainder([0, 1], [2, 3])","let { chinese-remainder } = import(number-theory);\nchinese-remainder([1, 2, 3], [4, 5, 7])"],seeAlso:["number-theory.mod-exp","number-theory.mod-inv","number-theory.extended-gcd"]},"stirling-first":{category:"number-theory",description:"Calculates the Stirling numbers of the first kind, which count the number of permutations of n elements with k cycles.",returns:{type:"integer"},args:{a:{type:"integer",description:"The number of elements."},b:{type:"integer",description:"The number of cycles."}},variants:[{argumentNames:["a","b"]}],examples:["let { stirling-first } = import(number-theory);\nstirling-first(5, 2)","let { stirling-first } = import(number-theory);\nstirling-first(4, 3)","let { stirling-first } = import(number-theory);\nstirling-first(6, 1)","let { stirling-first } = import(number-theory);\nstirling-first(7, 4)","let { stirling-first } = import(number-theory);\nstirling-first(8, 5)"],seeAlso:["number-theory.stirling-second","number-theory.bell-seq","number-theory.count-permutations"]},"stirling-second":{category:"number-theory",description:"Calculates the Stirling numbers of the second kind, which count the number of ways to partition n elements into k non-empty subsets.",returns:{type:"integer"},args:{a:{type:"integer",description:"The number of elements."},b:{type:"integer",description:"The number of subsets."}},variants:[{argumentNames:["a","b"]}],examples:["let { stirling-second } = import(number-theory);\nstirling-second(5, 2)","let { stirling-second } = import(number-theory);\nstirling-second(4, 3)","let { stirling-second } = import(number-theory);\nstirling-second(6, 1)","let { stirling-second } = import(number-theory);\nstirling-second(7, 4)","let { stirling-second } = import(number-theory);\nstirling-second(8, 5)"],seeAlso:["number-theory.stirling-first","number-theory.bell-seq","number-theory.count-combinations"]}};function Rn(e,t){if(0===t||t===e)return 1;let r=1;for(let n=0;n<t;n++)r*=(e-n)/(n+1);return r}function Mn(e,t){if(1===t)return e.map(e=>[e]);const r=[];for(let n=0;n<=e.length-t;n++){const o=e[n],a=Mn(e.slice(n+1),t-1);for(const e of a)r.push([o,...e])}return r}const Pn={combinations:{evaluate:([e,t],r)=>(ve(e,r),Y(t,r,{integer:!0,nonNegative:!0,lte:e.length}),0===t?[[]]:Mn(e,t)),arity:re(2)},"count-combinations":{evaluate:([e,t],r)=>(Y(e,r,{integer:!0,nonNegative:!0}),Y(t,r,{integer:!0,nonNegative:!0,lte:e}),Rn(e,t)),arity:re(2)}};const On={derangements:{evaluate:([e],t)=>(ve(e,t),function(e){const t=e.length,r=[],n=Array.from({length:t},()=>!1),o=Array.from({length:t});return function a(i){if(i!==t)for(let r=0;r<t;r++)n[r]||r===i||(n[r]=!0,o[i]=e[r],a(i+1),n[r]=!1);else r.push([...o])}(0),r}(e)),arity:re(1)},"count-derangements":{evaluate:([e],t)=>(Y(e,t,{finite:!0,integer:!0,positive:!0}),function(e){if(1===e)return 0;let t=1,r=0,n=0;for(let o=2;o<=e;o++)n=(o-1)*(t+r),t=r,r=n;return n}(e)),arity:re(1)}};function Dn(e){const t=[];for(let r=1;r<=Math.sqrt(e);r++)e%r===0&&(t.push(r),r!==e/r&&t.push(e/r));return t}function Vn(e){return Dn(e).sort((e,t)=>e-t)}function Un(e){return Vn(e).slice(0,-1)}const Fn={divisors:{evaluate:([e],t)=>(Y(e,t,{finite:!0,integer:!0,positive:!0}),Vn(e)),arity:re(1)},"count-divisors":{evaluate:([e],t)=>(Y(e,t,{finite:!0,integer:!0,positive:!0}),Dn(e).length),arity:re(1)},"proper-divisors":{evaluate:([e],t)=>(Y(e,t,{finite:!0,integer:!0,positive:!0}),Un(e)),arity:re(1)},"count-proper-divisors":{evaluate:([e],t)=>(Y(e,t,{finite:!0,integer:!0,positive:!0}),Dn(e).length-1),arity:re(1)}},Wn=[1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368e3,20922789888e3,355687428096e3,6402373705728e3];function Gn(e){if(e<0)throw new Error("Factorial is not defined for negative numbers");if(0===e||1===e)return 1;if(e<=18)return Wn[e];let t=Wn[18];for(let r=19;r<=e;r++)t*=r;return t}const Bn={factorial:{evaluate:([e],t)=>(Y(e,t,{integer:!0,nonNegative:!0,lte:170}),Gn(e)),arity:re(1)}},Ln=[1,2,3,5,7,11,15,22,30,42,56,77,101,135,176,231,297,385,490,627,792,1002,1255,1575,1958,2436,3010,3718,4565,5604,6842,8349,10143,12310,14883,17977,21637,26015,31185,37338,44583,53174,63261,75175,89134,105558,124754,147273,173525,204226,239943,281589,329931,386155,451276,526823,614154,715220,831820,966467,1121505,1300156,1505499,1741630,2012558,2323520,2679689,3087735,3554345,4087968,4697205,5392783,6185689,7089500,8118264,9289091,10619863,12132164,13848650,15796476,18004327,20506255,23338469,26543660,30167357,34262962,38887673,44108109,49995925,56634173,64112359,72533807,82010177,92669720,104651419,118114304,133230930,150198136,169229875,190569292,214481126,241265379,271248950,304801365,342325709,384276336,431149389,483502844,541946240,607163746,679903203,761002156,851376628,952050665,1064144451,1188908248,1327710076,1482074143,1653668665,1844349560,2056148051,2291320912,2552338241,2841940500,3163127352,3519222692,3913864295,4351078600,4835271870,5371315400,5964539504,6620830889,7346629512,8149040695,9035836076,10015581680,11097645016,12292341831,13610949895,15065878135,16670689208,18440293320,20390982757,22540654445,24908858009,27517052599,30388671978,33549419497,37027355200,40853235313,45060624582,49686288421,54770336324,60356673280,66493182097,73232243759,80630964769,88751778802,97662728555,107438159466,118159068427,129913904637,142798995930,156919475295,172389800255,189334822579,207890420102,228204732751,250438925115,274768617130,301384802048,330495499613,362326859895,397125074750,435157697830,476715857290,522115831195,571701605655,625846753120,684957390936,749474411781,819876908323,896684817527,980462880430,0xf98dace281,1171432692373,1280011042268,1398341745571,1527273599625,1667727404093,1820701100652,1987276856363,2168627105469,2366022741845,2580840212973,2814570987591,3068829878530,3345365983698,3646072432125,3972999029388,4328363658647,4714566886083,5134205287973,5590088317495,6085253859260,6622987708040,7206841706490,7840656226137,8528581302375,9275102575355,0x92c1cc50847,0x9f8afdf968b,0xad6918d4f36,0xbc72dde1287,0xccc0de0d1d7,0xde6da02b061,0xf195c5ba10a,18028182516671,19573856161145,21248279009367,23061871173849,25025873760111,27152408925615,29454549941750,31946390696157,34643126322519,37561133582570,40718063627362,44132934884255,47826239745920,51820051838712,56138148670947,60806135438329,65851585970275,71304185514919,77195892663512,83561103925871,90436839668817,97862933703585,0x604ca1b434ad,0x682ca0bc6d4e,0x70ad06a4328b,0x79da3e8e4df8,0x83c1a359c63d,0x8e7190d8114a,0x99f976fff202,0xa669edb53a4a,0xb3d4caca1bc8,0xc24d38b78151,0xd1e7cfd30909,0xe2bab064772f,0xf4dd9f8523e3,290726957916112,313891991306665,338854264248680,365749566870782,394723676655357,425933084409356,459545750448675,495741934760846,534715062908609,576672674947168,621837416509615,670448123060170,722760953690372,779050629562167,839611730366814,904760108316360,974834369944625,0x3bb262854d36d,0x404dafd2efa2e,0x4541ae2536f6d,0x4a94ddd83ba57,0x504e363fd1eca,0x56752ddfc97e7,0x5d11c356f6b53,0x642c86bff69f5,0x6bcea3db036a0,0x7401ecbfdbd63,0x7cd0e571c49d4,0x8646d010a1b6f,0x906fba0855202,0x9b5889f52508f,0xa70f0ea631153,0xb3a20ef033ec5,0xc1215ac210755,0xcf9ddd28cfa8d,0xdf29afbd9f60e,0xefd82f26a7157,4534253126900886,4872038056472084,5234371069753672,5622992691950605,6039763882095515,6486674127079088,6965850144195831,7479565078510584,8030248384943040,8620496275465025];const _n={partitions:{evaluate:([e],t)=>(Y(e,t,{integer:!0,nonNegative:!0}),function(e){if(e<=0)return[[]];if(1===e)return[[1]];const t=[];return function e(r,n,o){if(0!==r)for(let t=Math.min(n,r);t>=1;t--)o.push(t),e(r-t,t,o),o.pop();else t.push([...o])}(e,e,[]),t}(e)),arity:re(1)},"count-partitions":{evaluate:([e],t)=>{if(Y(e,t,{integer:!0,nonNegative:!0}),0===e)return 1;if(e>Ln.length)throw new r(`n is too large. The maximum value is ${Ln.length-1}.`,t);return Ln[e-1]},arity:re(1)}};function Kn(e){if(0===e.length)return[[]];const t=[];for(let r=0;r<e.length;r++){const n=e[r],o=Kn([...e.slice(0,r),...e.slice(r+1)]);for(const e of o)t.push([n,...e])}return t}const Jn={permutations:{evaluate:([e],t)=>(ve(e,t),Kn(e)),arity:re(1)},"count-permutations":{evaluate:([e,t],r)=>(Y(e,r,{integer:!0,nonNegative:!0}),Y(t,r,{integer:!0,nonNegative:!0,lte:e}),Gn(e)/Gn(e-t)),arity:re(2)}};const Hn={"power-set":{evaluate:([e],t)=>(ve(e,t),function(e){const t=[[]];for(const r of e){const e=t.map(e=>[...e,r]);t.push(...e)}return t}(e)),arity:re(1)},"count-power-set":{evaluate:([e],t)=>(Y(e,t,{integer:!0,nonNegative:!0}),e>=53?1/0:2**e),arity:re(1)}};function Yn(e){if(1===e)return[];const t=[];let r=2;for(;e>1;)e%r===0?(t.push(r),e/=r):r++;return t}const Xn={"prime-factors":{evaluate:([e],t)=>(Y(e,t,{finite:!0,integer:!0,positive:!0}),Yn(e)),arity:re(1)},"distinct-prime-factors":{evaluate:([e],t)=>{Y(e,t,{finite:!0,integer:!0,positive:!0});const r=Yn(e),n=new Set(r);return Array.from(n)},arity:re(1)},"count-prime-factors":{evaluate:([e],t)=>(Y(e,t,{finite:!0,integer:!0,positive:!0}),Yn(e).length),arity:re(1)},"count-distinct-prime-factors":{evaluate:([e],t)=>{Y(e,t,{finite:!0,integer:!0,positive:!0});const r=Yn(e);return new Set(r).size},arity:re(1)}};function Qn(e){return Un(e).reduce((e,t)=>e+t,0)>e}const Zn={"abundant-seq":e=>{const t=[];let r=2;for(;t.length<e;)Qn(r)&&t.push(r),r+=1;return t},"abundant?":e=>Qn(e),"abundant-take-while":e=>{const t=[];return function r(n){return Qn(n)?wt(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(2)}};const eo={"arithmetic-seq":{evaluate:([e,t,r],n)=>(Y(e,n,{finite:!0}),Y(t,n,{finite:!0}),Y(r,n,{integer:!0,positive:!0}),Array.from({length:r},(r,n)=>e+n*t)),arity:re(3)},"arithmetic-take-while":{evaluate:([e,t,r],n,o,{executeFunction:a})=>{Y(e,n,{finite:!0}),Y(t,n,{finite:!0}),F(r,n);const i=e,s=t,c=r,l=[];return function e(t){const r=i+t*s;return wt(a(c,[r,t],o,n),n=>n?(l.push(r),e(t+1)):l)}(0)},arity:re(3)},"arithmetic-nth":{evaluate:([e,t,r],n)=>(Y(e,n,{finite:!0}),Y(t,n,{finite:!0}),Y(r,n,{integer:!0,positive:!0}),e+(r-1)*t),arity:re(3)},"arithmetic?":{evaluate:([e,t,r],n)=>(Y(r,n),Y(e,n,{finite:!0}),Y(t,n,{finite:!0}),function(e,t,r){if(0===t)return ge(r,e);const n=(r-e)/t;if(n<0)return!1;const o=Math.round(n),a=e+t*o;return ge(n,o)&&ge(a,r)}(e,t,r)),arity:re(3)}};function to(e){const t=[1];for(let r=1;r<e;r+=1){let e=0;for(let n=0;n<r;n+=1)e+=Rn(r+1,n)*t[n];t[r]=r>1&&r%2==1?0:-e/(r+1)}return t}const ro={"bernoulli-seq":{evaluate:([e],t)=>(Y(e,t,{integer:!0,positive:!0}),to(e)),arity:re(1)},"bernoulli-nth":{evaluate:([e],t)=>{Y(e,t,{integer:!0,positive:!0});return to(e)[e-1]},arity:re(1)},"bernoulli-take-while":{evaluate:([e],t,r,{executeFunction:n})=>{F(e,t);const o=e;return function(e){const t=[1];return function r(n){let o=0;for(let e=0;e<n;e++)o+=Rn(n+1,e)*t[e];const a=n>1&&n%2==1?0:-o/(n+1);return wt(e(a,n),e=>e?(t.push(a),r(n+1)):t)}(1)}((e,t)=>wt(n(o,[e,t],r),e=>!!e))},arity:re(1)}};function no(e){if(e<=1)return!1;if(e<=3)return!0;if(e%2==0||e%3==0)return!1;for(let t=5;t*t<=e;t+=6)if(e%t===0||e%(t+2)===0)return!1;return!0}const oo={"prime-seq":e=>{const t=[];let r=2;for(;t.length<e;)no(r)&&t.push(r),r+=1;return t},"prime?":e=>no(e),"prime-take-while":e=>{const t=[];return function r(n){return no(n)?wt(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(2)}};function ao(e){return!(e<=1)&&!no(e)}const io={"composite-seq":e=>{const t=[];let r=2;for(;t.length<e;)ao(r)&&t.push(r),r+=1;return t},"composite?":e=>ao(e),"composite-take-while":e=>{const t=[];return function r(n){return ao(n)?wt(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(4)}};function so(e){return Un(e).reduce((e,t)=>e+t,0)<e}const co={"deficient-seq":e=>{const t=[];let r=1;for(;t.length<e;)so(r)&&t.push(r),r+=1;return t},"deficient?":e=>so(e),"deficient-take-while":e=>{const t=[];return function r(n){return so(n)?wt(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(1)}};const lo={"geometric-seq":{evaluate:([e,t,r],n)=>(Y(e,n,{finite:!0}),Y(t,n,{finite:!0}),Y(r,n,{integer:!0,positive:!0}),Array.from({length:r},(r,n)=>e*t**n)),arity:re(3)},"geometric-take-while":{evaluate:([e,t,r],n,o,{executeFunction:a})=>{Y(e,n,{finite:!0}),Y(t,n,{finite:!0}),F(r,n);const i=e,s=t,c=r,l=[];return function e(t){const r=i*s**t;return wt(a(c,[r,t],o,n),n=>n?(l.push(r),e(t+1)):l)}(0)},arity:re(3)},"geometric-nth":{evaluate:([e,t,r],n)=>(Y(e,n,{finite:!0}),Y(t,n,{finite:!0}),Y(r,n,{integer:!0,positive:!0}),e*t**(r-1)),arity:re(3)},"geometric?":{evaluate:([e,t,r],n)=>(Y(r,n),Y(e,n,{finite:!0}),Y(t,n,{finite:!0}),function(e,t,r){if(ge(e,0))return ge(r,0);if(ge(t,1))return ge(r,e);if(ge(t,0))return ge(r,0)||ge(r,e);if(ge(r,e))return!0;if(ge(t,-1))return ge(r,e)||ge(r,-e);if(t<0){const n=Math.log(Math.abs(r/e))/Math.log(Math.abs(t)),o=Math.round(n);if(!ge(o,n)||o<0)return!1;const a=o%2==0?Math.sign(e):Math.sign(e)*Math.sign(t);return Math.sign(r)===a}if(t>1&&r<e||t<1&&r>e)return!1;const n=Math.log(r/e)/Math.log(t),o=Math.round(n);return!(!ge(o,n)||o<0)&&ge(e*t**o,r)}(e,t,r)),arity:re(3)}};const uo={"golomb-seq":e=>function(e){const t=[0,1];for(let r=2;r<=e;r+=1)t.push(1+t[r-t[t[r-1]]]);return t.slice(1)}(e),"golomb?":()=>!0,"golomb-take-while":e=>function(e){const t=[0,1];return wt(e(1,0),r=>r?function r(n){const o=1+t[n-t[t[n-1]]];return wt(e(o,n-1),e=>e?(t.push(o),r(n+1)):t.slice(1))}(2):[])}(e)};function mo(e){if(e<=0)return!1;const t=new Set;for(;1!==e&&!t.has(e);)t.add(e),e=po(e);return 1===e}function po(e){let t=0;for(;e>0;){const r=e%10;t+=r*r,e=Math.floor(e/10)}return t}const ho={"happy-seq":e=>{const t=[];for(let r=1;t.length<e;r++){let e=r;const n=new Set;for(;1!==e&&!n.has(e);)n.add(e),e=String(e).split("").reduce((e,t)=>e+Number(t)**2,0);1===e&&t.push(r)}return t},"happy?":e=>mo(e),"happy-take-while":e=>{const t=[];return function r(n){return mo(n)?wt(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(1)}},go={"juggler-seq":e=>{let t=e;const r=[t];for(;t>1;)t=t%2==0?Math.floor(Math.sqrt(t)):Math.floor(t**1.5),r.push(t);return r},noNth:!0};function fo(e){let t="",r=1;for(let n=0;n<e.length;n++)n+1<e.length&&e[n]===e[n+1]?r++:(t+=r.toString()+e[n],r=1);return t}const yo={string:!0,"look-and-say-seq":e=>{const t=["1"];for(let r=1;r<e;r+=1){const e=t[r-1].replace(/(\d)\1*/g,e=>`${e.length}${e[0]}`);t[r]=e}return t},"look-and-say-take-while":e=>{const t=[];return wt(e("1",0),r=>{if(!r)return t;return t.push("1"),function r(n){const o=t[n-1].replace(/(\d)\1*/g,e=>`${e.length}${e[0]}`);return wt(e(o,n),e=>e?(t.push(o),r(n+1)):t)}(1)})},"look-and-say?":e=>function(e){let t="1";if(t===e)return!0;for(;;){if(t=fo(t),t===e)return!0;if(t.length>e.length)return!1}}(e)};function vo(e){const t=[];for(let e=1;e<=2e3;e++)t.push(e);let r=[1];for(let e=1;e<t.length;e++)t[e]%2!=0&&r.push(t[e]);const n=[1];let o=1;return wt(e(1,0),t=>{if(!t)return[];let a=1;return function t(){const i=r[a];return wt(e(i,o),e=>{if(!e)return n;n.push(i),o++;const s=i,c=[];for(let e=0;e<r.length;e++)(e+1)%s!==0&&c.push(r[e]);if(r=c,a++,a>=r.length-5){let e=r[r.length-1]+2;for(;r.length<a+1e3;)r.push(e),e+=2}return t()})}()})}const bo={"lucky-seq":e=>function(e){const t=[];let r=1;const n=e*(e<100?20:30);for(;t.length<n;)t.push(r),r+=2;let o=1;for(;o<t.length&&o<e;){const e=t[o];let r=0;for(let n=0;n<t.length;n++)(n+1)%e!==0&&(t[r++]=t[n]);t.length=r,o<t.length&&o++}return t.slice(0,e)}(e),"lucky?":e=>vo(t=>t<=e).includes(e),"lucky-take-while":e=>vo(e)};const wo={"padovan-seq":e=>{const t=[1,1,1];for(let r=3;r<e;r+=1)t[r]=t[r-2]+t[r-3];return t.slice(0,e)},"padovan?":e=>function(e){if(!Number.isInteger(e)||e<=0)return!1;if(1===e)return!0;const t=[1,1,1,2,2,3,4,5,7,9,12,16,21,28,37,49,65,86,114,151,200,265,351,465,616,816,1081,1432,1897,2513,3329,4410,5842,7739,10252,13581,17991,23833,31572,41824,55405,73396,97229];if(t.includes(e))return!0;if(e>t[t.length-1]&&e<=Number.MAX_SAFE_INTEGER){let r,n=t[t.length-3],o=t[t.length-2],a=t[t.length-1];for(;a<e;){if(r=n+o,n=o,o=a,a=r,a===e)return!0;if(!Number.isSafeInteger(a))return!1}}return!1}(e),"padovan-take-while":e=>{const t=[];return wt(e(1,0),r=>r?(t.push(1),wt(e(1,1),r=>r?(t.push(1),wt(e(1,2),r=>{if(!r)return t;t.push(1);let n=1,o=1,a=1;return function r(i){const s=n+o;return n=o,o=a,a=s,wt(e(a,i),e=>e?(t.push(a),r(i+1)):t)}(4)})):t)):t)}},xo={"perfect-cube-seq":e=>{const t=[];for(let r=1;r<=e;r++)t.push(r**3);return t},"perfect-cube?":e=>e>0&&Number.isInteger(Math.cbrt(e)),"perfect-cube-take-while":e=>{const t=[];return function r(n){const o=n**3;return wt(e(o,n),e=>e?(t.push(o),r(n+1)):t)}(1)}};function ko(e){if(e<2)return 1===e?[1,2]:null;const t=Math.floor(Math.log2(e))+1;for(let r=2;r<=t;r++){const t=e**(1/r),n=Math.round(t);if(ge(n**r,e))return[n,r]}return null}const qo={"perfect-power-seq":e=>{const t=[];for(let r=1;t.length<e;r++)ko(r)&&t.push(r);return t},"perfect-power?":e=>null!==ko(e),"perfect-power-take-while":e=>{const t=[];return function r(n){return ko(n)?wt(e(n,t.length),e=>e?(t.push(n),r(n+1)):t):r(n+1)}(1)}},Ao={"perfect-square-seq":e=>{const t=[];for(let r=1;r<=e;r++)t.push(r**2);return t},"perfect-square?":e=>e>0&&Number.isInteger(Math.sqrt(e)),"perfect-square-take-while":e=>{const t=[];return function r(n){const o=n**2;return wt(e(o,n),e=>e?(t.push(o),r(n+1)):t)}(1)}},No={"polygonal-seq":{evaluate:([e,t],r)=>{Y(e,r,{integer:!0,gte:3}),Y(t,r,{integer:!0,positive:!0});const n=[];for(let r=1;r<=t;r+=1)n[r-1]=(r*r*(e-2)-r*(e-4))/2;return n},arity:re(2)},"polygonal-take-while":{evaluate:([e,t],r,n,{executeFunction:o})=>{Y(e,r,{integer:!0,gte:3}),F(t,r);const a=e,i=t,s=[];return function e(t){const c=(t*t*(a-2)-t*(a-4))/2;return wt(o(i,[c,t],n,r),r=>r?(s.push(c),e(t+1)):s)}(1)},arity:re(2)},"polygonal-nth":{evaluate:([e,t],r)=>(Y(e,r,{integer:!0,gte:3}),Y(t,r,{integer:!0,positive:!0}),(t*t*(e-2)-t*(e-4))/2),arity:re(2)},"polygonal?":{evaluate:([e,t],r)=>{if(Y(t,r,{integer:!0}),Y(e,r,{integer:!0,gte:3}),t<=0)return!1;const n=e-2,o=e-4,a=8*n*t+o*o,i=Math.sqrt(a);if(!Number.isInteger(i))return!1;const s=i+o;if(s%(2*n)!=0)return!1;const c=s/(2*n);return Number.isInteger(c)&&c>0},arity:re(2)}};const $o={"recaman-seq":e=>function(e){if(1===e)return[0];const t=[0],r=new Set([0]);for(let n=1;n<e;n++){let e=t[n-1]-n;(e<=0||r.has(e))&&(e=t[n-1]+n),t.push(e),r.add(e)}return t}(e),"recaman-take-while":e=>{const t=[],r=new Set([0]);return wt(e(0,0),n=>{if(!n)return t;return t.push(0),function n(o){let a=t[o-1]-o;return(a<=0||r.has(a))&&(a=t[o-1]+o),wt(e(a,o),e=>e?(t.push(a),r.add(a),n(o+1)):t)}(1)})},"recaman?":()=>!0},Eo={"thue-morse-seq":e=>{const t=[];for(let r=0;r<e;r+=1)t[r]=To(r)%2;return t},"thue-morse-take-while":e=>{const t=[];return function r(n){const o=To(n)%2;return wt(e(o,n),e=>e?(t.push(o),r(n+1)):t)}(0)},"thue-morse?":e=>1===e||0===e};function To(e){let t=0;for(;e;)t+=1&e,e>>=1;return t}const So={};function zo(e){for(const[t,r]of Object.entries(e)){if(So[t])throw new Error(`Duplicate normal expression key found: ${t}`);So[t]=r}}function jo(e,t){return{[`${e}-seq`]:Co(e=>t.slice(0,e),t.length),[`${e}-take-while`]:Ro(e=>function r(n){return n>=t.length?t.slice(0,n):wt(e(t[n],n),e=>e?r(n+1):t.slice(0,n))}(0),t.length),[`${e}-nth`]:Mo(()=>t,t.length),[`${e}?`]:Po(e=>t.includes(e))}}function Io(e){for(const[t,r]of Object.entries(e)){if(So[t])throw new Error(`Duplicate normal expression key found: ${t}`);t.endsWith("seq")?(So[t]=Co(r,e.maxLength),e.noNth||(So[t.replace(/seq$/,"nth")]=Mo(r,e.maxLength))):t.endsWith("take-while")?So[t]=Ro(r,e.maxLength):t.endsWith("?")&&(e.string?So[t]=Oo(r):So[t]=Po(r))}}function Co(e,t){return{evaluate:(n,o)=>{const a=n[0]??t;Y(a,o,{integer:!0,positive:!0,lte:t});const i=e(a,o);if("number"==typeof i[0]&&i.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",o);return i},arity:"number"==typeof t?{max:1}:re(1)}}function Ro(e,t){return{evaluate:(t,n,o,{executeFunction:a})=>{const i=t[0];F(i,n);const s=e((e,t)=>wt(a(i,[e,t],o),e=>!!e),n);return wt(s,e=>{if("number"==typeof e[0]&&e.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",n);return e})},arity:"number"==typeof t?{max:1}:re(1)}}function Mo(e,t){return{evaluate:(n,o)=>{const a=n[0];Y(a,o,{integer:!0,positive:!0,lte:t});const i=e(a,o);if("number"==typeof i[0]&&i.some(e=>e>Number.MAX_SAFE_INTEGER))throw new r("Result exceeds maximum safe integer",o);return i[a-1]},arity:re(1)}}function Po(e){return{evaluate:(t,r)=>{const n=t[0];return Y(n,r),e(n,r)},arity:re(1)}}function Oo(e){return{evaluate:(t,r)=>{const n=t[0];return G(n,r),e(n,r)},arity:re(1)}}function Do(e,t){for(;0!==t;){const r=t;t=e%t,e=r}return Math.abs(e)}function Vo(e,t){return Math.floor(e*t/Do(e,t))}function Uo(e){if(1===e)return 1;const t=Yn(e);return new Set(t).size!==t.length?0:t.length%2==0?1:-1}function Fo(e,t){if(0===t)return[e,1,0];const[r,n,o]=Fo(t,e%t);return[r,o,n-Math.floor(e/t)*o]}function Wo(e,t){const[r,n]=Fo(e,t);if(1!==r)throw new Error(`Modular inverse does not exist (gcd(${e}, ${t}) = ${r})`);return(n%t+t)%t}Io(Zn),Io({"collatz-seq":e=>{let t=e;const r=[t];for(;1!==t;)t%2==0?t/=2:t=3*t+1,r.push(t);return r},noNth:!0}),Io(io),Io(co),Io(uo),Io(ho),Io(go),Io(yo),Io(bo),Io(wo),Io(Ao),Io(xo),Io(qo),Io(oo),Io($o),Io(Eo),zo(jo("tribonacci",[0,1,1,2,4,7,13,24,44,81,149,274,504,927,1705,3136,5768,10609,19513,35890,66012,121415,223317,410744,755476,1389537,2555757,4700770,8646064,15902591,29249425,53798080,98950096,181997601,334745777,615693474,1132436852,2082876103,3831006429,7046319384,12960201916,23837527729,43844049029,80641778674,148323355432,272809183135,501774317241,922906855808,1697490356184,3122171529233,5742568741225,0x99b36012952,19426970897100,35731770264967,65720971788709,0x6df08059d9f8,0xca35cf00a924,408933139743937,752145307699165,0x4ea34736b35c2,0x90a3317d5c260,4680045560037375,8607945812375585])),zo(jo("catalan",[1,2,5,14,42,132,429,1430,4862,16796,58786,208012,742900,2674440,9694845,35357670,129644790,477638700,1767263190,6564120420,24466267020,91482563640,343059613650,1289904147324,4861946401452,18367353072152,69533550916004,0xefe09af96cd8,0x38f88b34d6a68,0xd8db5c347b610])),zo(jo("factorial",Wn)),zo(jo("fibonacci",[0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,1134903170,1836311903,2971215073,4807526976,7778742049,12586269025,20365011074,32951280099,53316291173,86267571272,139583862445,225851433717,365435296162,591286729879,956722026041,1548008755920,2504730781961,4052739537881,6557470319842,0x9a661ca20bb,0xf9d297a859d,27777890035288,44945570212853,72723460248141,0x6b04f4c2fe42,0xad2934c6d08f,308061521170129,498454011879264,806515533049393,0x4a2dce62b0d91,0x780626e057bc2,0xc233f54308953,5527939700884757,8944394323791464])),zo(jo("lucas",[2,1,3,4,7,11,18,29,47,76,123,199,322,521,843,1364,2207,3571,5778,9349,15127,24476,39603,64079,103682,167761,271443,439204,710647,1149851,1860498,3010349,4870847,7881196,12752043,20633239,33385282,54018521,87403803,141422324,228826127,370248451,599074578,969323029,1568397607,2537720636,4106118243,6643838879,10749957122,17393796001,28143753123,45537549124,73681302247,119218851371,192900153618,312119004989,505019158607,817138163596,1322157322203,2139295485799,3461452808002,5600748293801,9062201101803,0xd55fbe3dc94,23725150497407,38388099893011,62113250390418,0x5b67cb4878a5,0x93e5a9822a37,0xef4d74caa2dc,425730551631123,688846502588399,0x3f5b3b1643d02,0x66834447bacf1,0xa5de7f5dfe9f3,4721424167835364,7639424778862807])),zo(jo("mersenne",[3,7,31,127,2047,8191,131071,524287,2147483647])),zo(jo("partition",Ln)),zo(jo("pell",[1,2,5,12,29,70,169,408,985,2378,5741,13860,33461,80782,195025,470832,1136689,2744210,6625109,15994428,38613965,93222358,225058681,543339720,1311738121,3166815962,7645370045,18457556052,44560482149,107578520350,259717522849,627013566048,1513744654945,3654502875938,8822750406821,21300003689580,51422757785981,0x70e8e1937766,299713796309065,723573111879672,0x634c28af7f039,0xefb9b143d586a])),zo(jo("perfect",[6,28,496,8128,33550336,8589869056,137438691328])),zo(jo("sylvester",[2,6,42,1806,3263442,0x9afa8dc8416])),zo(jo("bell",[1,2,5,15,52,203,877,4140,21147,115975,678570,4213597,27644437,190899322,1382958545,10480142147,82864869804,682076806159,5832742205057,51724158235372,474869816156751,4506715738447323])),zo(eo),zo(ro),zo(lo),zo(No);const Go={"coprime?":{evaluate:([e,t],r)=>(Y(e,r,{integer:!0}),Y(t,r,{integer:!0}),1===Do(e,t)),arity:re(2)},"divisible-by?":{evaluate:([e,t],r)=>(Y(e,r,{integer:!0}),Y(t,r,{integer:!0}),0!==t&&e%t===0),arity:re(2)},gcd:{evaluate:([e,t],r)=>(Y(e,r),Y(t,r),Do(e,t)),arity:re(2)},lcm:{evaluate:([e,t],r)=>(Y(e,r),Y(t,r),Vo(e,t)),arity:re(2)},multinomial:{evaluate:([...e],t)=>{Ce(e,t);return Gn(e.reduce((e,r)=>(Y(r,t,{integer:!0,nonNegative:!0}),e+r),0))/e.reduce((e,t)=>e*Gn(t),1)},arity:{min:1}},"amicable?":{evaluate:([e,t],r)=>{Y(e,r,{integer:!0,positive:!0}),Y(t,r,{integer:!0,positive:!0});const n=Un(e).reduce((e,t)=>e+t,0),o=Un(t).reduce((e,t)=>e+t,0);return n===t&&o===e&&e!==t},arity:re(2)},"euler-totient":{evaluate:([e],t)=>{Y(e,t,{integer:!0,positive:!0});let r=e;for(let t=2;t*t<=e;t+=1)if(e%t===0){for(;e%t===0;)e/=t;r-=r/t}return e>1&&(r-=r/e),r},arity:re(1)},mobius:{evaluate:([e],t)=>{if(Y(e,t,{integer:!0,positive:!0}),1===e)return 1;const r=Yn(e);return new Set(r).size!==r.length?0:r.length%2==0?1:-1},arity:re(1)},mertens:{evaluate:([e],t)=>{if(Y(e,t,{integer:!0,positive:!0}),1===e)return 1;let r=0;for(let t=1;t<=e;t++){r+=Uo(t)}return r},arity:re(1)},sigma:{evaluate:([e],t)=>(Y(e,t,{integer:!0,positive:!0}),Vn(e).reduce((e,t)=>e+t,0)),arity:re(1)},"carmichael-lambda":{evaluate:([e],t)=>{if(Y(e,t,{integer:!0,positive:!0}),1===e)return 1;const r=Yn(e),n=new Map;for(const e of r)n.set(e,(n.get(e)||0)+1);const o=[];for(const[e,t]of n.entries())2===e?1===t?o.push(1):2===t?o.push(2):o.push(2**(t-2)):o.push((e-1)*e**(t-1));return o.reduce((e,t)=>Vo(e,t),1)},arity:re(1)},"cartesian-product":{evaluate:(e,t)=>{e.forEach(e=>{ve(e,t)});return e.reduce((e,t)=>{const r=[];return e.forEach(e=>{t.forEach(t=>{r.push([...e,t])})}),r},[[]])},arity:{min:1}},"perfect-power":{evaluate:([e],t)=>{Y(e,t,{integer:!0,positive:!0});return ko(e)||null},arity:re(1)},"mod-exp":{evaluate:([e,t,r],n)=>(Y(e,n,{finite:!0}),Y(t,n,{integer:!0,positive:!0}),Y(r,n,{integer:!0,positive:!0}),function(e,t,r){if(1===r)return 0;let n=1;for(e%=r;t>0;)t%2==1&&(n=n*e%r),t>>=1,e=e*e%r;return n}(e,t,r)),arity:re(3)},"mod-inv":{evaluate:([e,t],n)=>{Y(e,n,{integer:!0,positive:!0}),Y(t,n,{integer:!0,positive:!0});try{return Wo(e,t)}catch(e){throw new r(e,n)}},arity:re(2)},"extended-gcd":{evaluate:([e,t],r)=>(Y(e,r,{integer:!0}),Y(t,r,{integer:!0}),Fo(e,t)),arity:re(2)},"chinese-remainder":{evaluate:([e,t],n)=>{if(Ce(e,n),Ce(t,n),e.length!==t.length)throw new r("Remainders and moduli must have the same length.",n);try{return function(e,t){for(let e=0;e<t.length;e++)for(let r=e+1;r<t.length;r++){const n=Fo(t[e],t[r])[0];if(1!==n)throw new Error(`Moduli must be pairwise coprime, but gcd(${t[e]}, ${t[r]}) = ${n}`)}const r=t.reduce((e,t)=>e*t,1);let n=0;for(let o=0;o<e.length;o++){const a=e[o],i=t[o],s=r/i;n=(n+a*s*Wo(s,i))%r}return n}(e,t)}catch(e){throw new r(e.message,n)}},arity:re(2)},"stirling-first":{evaluate:([e,t],r)=>{Y(e,r,{integer:!0,positive:!0}),Y(t,r,{integer:!0,positive:!0,lte:e});const n=Array.from({length:e+1},()=>Array(t+1).fill(0));n[0][0]=1;for(let r=1;r<=e;r++)for(let e=1;e<=Math.min(r,t);e++)n[r][e]=n[r-1][e-1]+(r-1)*n[r-1][e];return n[e][t]},arity:re(2)},"stirling-second":{evaluate:([e,t],r)=>{if(Y(e,r,{integer:!0,positive:!0}),Y(t,r,{integer:!0,positive:!0,lte:e}),1===t)return 1;if(t===e)return 1;const n=Array.from({length:e+1},()=>Array(t+1).fill(0));n[0][0]=1;for(let r=1;r<=e;r++)for(let e=1;e<=Math.min(r,t);e++)n[r][e]=e*n[r-1][e]+n[r-1][e-1];return n[e][t]},arity:re(2)}};function Bo(e){for(const[t,r]of Object.entries(e)){if(Go[t])throw new Error(`Duplicate normal expression key found: ${t}`);Go[t]=r}}!function(e){for(const[t,r]of Object.entries(e)){if(Go[t])throw new Error(`Duplicate normal expression key found: ${t}`);Go[t]=r}}(So),Bo(Bn),Bo(Fn),Bo(Pn),Bo(Jn),Bo(_n),Bo(Xn),Bo(On),Bo(Hn);for(const[e,t]of Object.entries(Cn))Go[e]&&(Go[e].docs=t);const Lo={name:"number-theory",functions:Go,source:"{}",docs:Cn};function _o(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>{if(!t.docs)throw new Error(`Missing docs for function "${e}"`);return[e,t.docs]}))}const Ko={"string-repeat":{evaluate:([e,t],r)=>(G(e,r),Y(t,r,{integer:!0,nonNegative:!0}),e.repeat(t)),arity:re(2),docs:{category:"string",returns:{type:"string"},args:{a:{type:"string"},b:{type:"integer"},s:{type:"string"},n:{type:"integer"}},variants:[{argumentNames:["s","n"]}],description:"Repeates $s $n times.",seeAlso:["str","repeat"],examples:['let { string-repeat } = import(string);\n"*" string-repeat 10','let { string-repeat } = import(string);\nstring-repeat("*", 10)','let { string-repeat } = import(string);\nstring-repeat("***", 0)']}},"from-char-code":{evaluate:([e],t)=>{Y(e,t,{finite:!0});const n=ce(e);try{return String.fromCodePoint(n)}catch(e){throw new r(e,t)}},arity:re(1),docs:{category:"string",returns:{type:"string"},args:{code:{type:"number"}},variants:[{argumentNames:["code"]}],description:"Return character for code point $code.",seeAlso:["string.to-char-code"],examples:["let { from-char-code } = import(string);\nfrom-char-code(65)","let { from-char-code } = import(string);\nfrom-char-code(0)"]}},"to-char-code":{evaluate:([e],t)=>(G(e,t,{nonEmpty:!0}),v(e.codePointAt(0),t)),arity:re(1),docs:{category:"string",returns:{type:"number"},args:{c:{type:"string"}},variants:[{argumentNames:["c"]}],description:"Return code point for first character in $c.",seeAlso:["string.from-char-code"],examples:['let { to-char-code } = import(string);\nto-char-code("A")','let { to-char-code } = import(string);\nto-char-code("Albert")']}},"trim-left":{evaluate:([e],t)=>(G(e,t),e.replace(/^\s+/,"")),arity:re(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns a new string with leading whitespaces removed.",seeAlso:["trim","string.trim-right"],examples:['let { trim-left } = import(string);\ntrim-left(" Albert ")','let { trim-left } = import(string);\ntrim-left(" ")','let { trim-left } = import(string);\ntrim-left("")']}},"trim-right":{evaluate:([e],t)=>(G(e,t),e.replace(/\s+$/,"")),arity:re(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns a new string with trailing whitespaces removed.",seeAlso:["trim","string.trim-left"],examples:['let { trim-right } = import(string);\ntrim-right(" Albert ")','let { trim-right } = import(string);\ntrim-right(" ")','let { trim-right } = import(string);\ntrim-right("")']}},"split-lines":{evaluate:([e],t)=>(G(e,t),e.split(/\r\n|\n|\r/).filter(e=>""!==e)),arity:re(1),docs:{category:"string",returns:{type:"string",array:!0},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Divides $s into an array of substrings, each representing a line.",seeAlso:["split"],examples:['let { split-lines } = import(string);\nsplit-lines("Albert\nMojir\n")','let { split-lines } = import(string);\nsplit-lines("Albert\n\nMojir")','let { split-lines } = import(string);\nsplit-lines("Albert\nMojir\n\n")','let { split-lines } = import(string);\nsplit-lines("")']}},"pad-left":{evaluate:([e,t,r],n)=>(G(e,n),Y(t,n,{integer:!0}),void 0!==r&&G(r,n),e.padStart(t,r)),arity:{min:2,max:3},docs:{category:"string",returns:{type:"string"},args:{a:{type:"string"},b:{type:"integer"},s:{type:"string"},length:{type:"integer"},padString:{type:"string"}},variants:[{argumentNames:["s","length"]},{argumentNames:["s","length","padString"]}],description:"Pads from the start of $s with `padString` (multiple times, if needed) until the resulting string reaches the given $length.",seeAlso:["string.pad-right"],examples:['let { pad-left } = import(string);\n"Albert" pad-left 20','let { pad-left } = import(string);\npad-left("Albert", 20)','let { pad-left } = import(string);\npad-left("Albert", 20, "-*-")','let { pad-left } = import(string);\npad-left("Albert", 5)','let { pad-left } = import(string);\npad-left("Albert", -1)']}},"pad-right":{evaluate:([e,t,r],n)=>(G(e,n),Y(t,n,{integer:!0}),void 0!==r&&G(r,n),e.padEnd(t,r)),arity:{min:2,max:3},docs:{category:"string",returns:{type:"string"},args:{a:{type:"string"},b:{type:"integer"},s:{type:"string"},length:{type:"integer"},padString:{type:"string"}},variants:[{argumentNames:["s","length"]},{argumentNames:["s","length","padString"]}],description:"Pads from the start of $s with `padString` (multiple times, if needed) until the resulting string reaches the given `length`.",seeAlso:["string.pad-left"],examples:['let { pad-right } = import(string);\n"Albert" pad-right 20','let { pad-right } = import(string);\npad-right("Albert", 20)','let { pad-right } = import(string);\npad-right("Albert", 20, "-*-")','let { pad-right } = import(string);\npad-right("Albert", 5)','let { pad-right } = import(string);\npad-right("Albert", -1)']}},template:{evaluate:([e,...t],r)=>{G(e,r),ve(t,r);const n=e.split("||||");if(n.length<=1)return Ho(n[0],t,r);{const e=t[0];Y(e,r,{integer:!0,nonNegative:!0});const o=[`${e}`,...t.slice(1)];if(2===n.length){return Ho(n[1===e?0:1],o,r)}return Ho(n[Math.min(e,n.length-1)],o,r)}},arity:{min:1,max:10},docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"},params:{type:"any",rest:!0}},variants:[{argumentNames:["s","params"]}],description:"Applies placeholders to a string. Support for basic pluralization - see examples. If pluralization is used, first placeholder must be a number.",seeAlso:["str"],examples:['let { template } = import(string);\ntemplate("Hi, $1 and $2", "Carl", "Larry")','let { template } = import(string);\ntemplate("Hi $1, $2, $3, $4, $5, $6, $7, $8 and $9", "A", "B", "C", "D", "E", "F", "G", "H", "I")','let { template } = import(string);\ntemplate("$1 book||||$1 books", 0)','let { template } = import(string);\ntemplate("$1 book||||$1 books", 1)','let { template } = import(string);\ntemplate("$1 book||||$1 books", 2)','let { template } = import(string);\ntemplate("No book||||$1 book||||$1 books", 0)','let { template } = import(string);\ntemplate("No book||||$1 book||||$1 books", 1)','let { template } = import(string);\ntemplate("No book||||$1 book||||$1 books", 10)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 0)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 1)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 2)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 3)','let { template } = import(string);\ntemplate("No book||||One book||||Two books||||Three books||||$1 books", 4)'],hideOperatorForm:!0}},"encode-base64":{evaluate:([e],t)=>(G(e,t),btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16))))),arity:re(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns a Base64 encoded string from $s.",seeAlso:["string.decode-base64"],examples:['let { encode-base64 } = import(string);\nencode-base64("Albert")']}},"decode-base64":{evaluate:([e],t)=>{G(e,t);try{return decodeURIComponent(Array.prototype.map.call(atob(e),e=>`%${`00${e.charCodeAt(0).toString(16)}`.slice(-2)}`).join(""))}catch(e){throw new r(e,t)}},arity:re(1),docs:{category:"string",returns:{type:"string"},args:{base64string:{type:"string"}},variants:[{argumentNames:["base64string"]}],description:"Returns a Base64 decoded string from $base64string.",seeAlso:["string.encode-base64"],examples:['let { decode-base64 } = import(string);\ndecode-base64("QWxiZXJ0IPCfkLs=")']}},"encode-uri-component":{evaluate:([e],t)=>(G(e,t),encodeURIComponent(e)),arity:re(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns an escaped `URI` string.",seeAlso:["string.decode-uri-component"],examples:['let { encode-uri-component } = import(string);\nencode-uri-component("Hi everyone!?")']}},"decode-uri-component":{evaluate:([e],t)=>{G(e,t);try{return decodeURIComponent(e)}catch(e){throw new r(e,t)}},arity:re(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns an un-escaped `URI` string.",seeAlso:["string.encode-uri-component"],examples:['let { decode-uri-component } = import(string);\ndecode-uri-component("Hi%20everyone!%3F%20%F0%9F%91%8D")']}},capitalize:{evaluate:([e],t)=>(G(e,t),e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()),arity:re(1),docs:{category:"string",returns:{type:"string"},args:{s:{type:"string"}},variants:[{argumentNames:["s"]}],description:"Returns $s with the first character converted to uppercase and the rest to lowercase.",seeAlso:["lower-case","upper-case"],examples:['let { capitalize } = import(string);\ncapitalize("albert")','let { capitalize } = import(string);\ncapitalize("ALBERT")','let { capitalize } = import(string);\ncapitalize("aLBERT")','let { capitalize } = import(string);\ncapitalize("")']}}},Jo=/\$\$/g;function Ho(e,t,r){for(let n=0;n<9;n+=1){const o=new RegExp(`(\\$\\$|[^$]|^)\\$${n+1}`,"g");if(o.test(e)){const a=_(t[n],r);e=e.replace(o,`$1${a}`)}}return e=e.replace(Jo,"$")}const Yo={name:"string",functions:Ko,source:"{}",docs:_o(Ko)};function Xo(e,t){if(j(e)){if("string"==typeof t&&ae(e,t))return le(e[t])}else if(H(t,{nonNegative:!0,integer:!0})&&t>=0&&t<e.length)return le(e[t])}function Qo(e,t,r,n){if(M(e,n),Array.isArray(e)||"string"==typeof e){if(Y(t,n,{integer:!0}),Y(t,n,{gte:0}),Y(t,n,{lte:e.length}),"string"==typeof e)return G(r,n,{char:!0}),`${e.slice(0,t)}${r}${e.slice(t+1)}`;const o=[...e];return o[t]=r,o}G(t,n);const o={...e};return o[t]=r,o}const Zo={"get-in":{evaluate:(e,t)=>{let r=le(e[0]);const n=e[1]??[],o=le(e[2]);ve(n,t);for(const e of n){if(K(e,t),!C(r))return o;{const t=Xo(r,e);if(void 0===t)return o;r=t}}return r},arity:{min:2,max:3},docs:{category:"collection",returns:{type:"any"},args:{a:{type:"collection"},b:{type:"array"},"not-found":{type:"any"}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","not-found"]}],description:"Returns the value in a nested collection, where $b is an array of keys. Returns $not-found if the key is not present. If $not-found is not set, `null` is returned.",seeAlso:["get","collection.assoc-in","collection.update-in"],examples:['\nlet cu = import(collection);\ncu.get-in(\n [[1, 2, 3], [4, { a: "Kalle" }, 6]],\n [1, 1, "a", 0]\n)','\nlet cu = import(collection);\ncu.get-in(\n [[1, 2, 3], [4, { a: "Kalle" }, 6]],\n [1, 1, "b", 0]\n)','\nlet cu = import(collection);\ncu.get-in(\n [[1, 2, 3], [4, { a: "Kalle" }, 6]],\n [1, 1, "b", 0],\n "Lisa"\n)']}},"assoc-in":{evaluate:([e,t,r],n)=>{if(M(e,n),ve(t,n),E(r,n),1===t.length)return K(t[0],n),Qo(e,t[0],r,n);const{coll:o,innerCollMeta:a}=function(e,t,r){const n=me(e);return{coll:n,innerCollMeta:t.slice(0,t.length-1).reduce((e,t)=>{const n=e.coll;let o;return Array.isArray(n)?(Y(t,r),o=R(n[t],r)):(I(n,r),G(t,r),ae(e.coll,t)||(n[t]={}),o=R(n[t],r)),{coll:o,parent:n}},{coll:n,parent:{}})}}(e,t,n),i=_(t[t.length-1],n),s=_(t[t.length-2],n);return Array.isArray(a.parent)?(Y(s,n),a.parent[s]=Qo(a.coll,i,r,n)):(G(s,n),a.parent[s]=Qo(a.coll,i,r,n)),o},arity:re(3),docs:{category:"collection",returns:{type:"collection"},args:{coll:{type:"collection"},ks:{type:["number","string"],array:!0},value:{type:"any"}},variants:[{argumentNames:["coll","ks","value"]}],description:"\nAssociates a value in the nested collection $coll, where $ks is an array of keys and $value is the new value.\n\nIf any levels do not exist, objects will be created - and the corresponding keys must be of type string.",seeAlso:["assoc","collection.get-in","collection.update-in"],examples:['\nlet cu = import(collection);\ncu.assoc-in(\n {},\n ["a", "b", "c"],\n "Albert"\n)','\nlet cu = import(collection);\ncu.assoc-in(\n [1, 2, [1, 2, 3]],\n [2, 1],\n "Albert"\n)','\nlet cu = import(collection);\ncu.assoc-in(\n [1, 2, { name: "albert" }],\n [2, "name", 0],\n "A"\n)']}},update:{evaluate:()=>{throw new Error("update: Dvala implementation should be used instead")},arity:{min:3},docs:{category:"collection",returns:{type:"collection"},args:{coll:{type:"collection"},key:{type:["string","number"]},fun:{type:"function"},"fun-args":{type:"any",rest:!0}},variants:[{argumentNames:["coll","key","fun"]},{argumentNames:["coll","key","fun","fun-args"]}],description:"\nUpdates a value in the $coll collection, where $key is a key. $fun is a function\nthat will take the old value and any supplied $fun-args and\nreturn the new value.\nIf the key does not exist, `null` is passed as the old value.",seeAlso:["collection.update-in","assoc"],examples:['\nlet cu = import(collection);\nlet x = { a: 1, b: 2 };\ncu.update(x, "a", inc)','\nlet cu = import(collection);\nlet x = { a: 1, b: 2 };\ncu.update(\n x,\n "c",\n val -> null?(val) ? 0 : inc(val)\n)']}},"update-in":{evaluate:()=>{throw new Error("update-in: Dvala implementation should be used instead")},arity:{min:3},docs:{category:"collection",returns:{type:"collection"},args:{coll:{type:"collection"},ks:{type:"array"},fun:{type:"function"},"fun-args":{type:"any",rest:!0}},variants:[{argumentNames:["coll","ks","fun"]},{argumentNames:["coll","ks","fun","fun-args"]}],description:"Updates a value in the $coll collection, where $ks is an array of\nkeys and $fun is a function that will take the old value and\nany supplied $fun-args and return the new value. If any levels do not exist,\nobjects will be created - and the corresponding keys must be of type string.",seeAlso:["collection.update","collection.assoc-in","collection.get-in"],examples:['\nlet cu = import(collection);\ncu.update-in(\n { a: [1, 2, 3] },\n ["a", 1],\n -> null?($) ? 0 : inc($)\n)','\nlet cu = import(collection);\ncu.update-in(\n { a: { foo: "bar"} },\n ["a", "foo"],\n -> null?($) ? "?" : "!"\n)','\nlet cu = import(collection);\ncu.update-in(\n { a: { foo: "bar"} },\n ["a", "baz"],\n -> null?($) ? "?" : "!"\n)','\nlet cu = import(collection);\ncu.update-in(\n { a: [1, 2, 3] },\n ["a", 1],\n *,\n 10,\n 10,\n 10,\n)']}},filteri:{evaluate:()=>{throw new Error("filteri: Dvala implementation should be used instead")},arity:re(2),docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function",description:"The function to call for each element in the collection. The function should take two arguments: the element itself and the index."}},variants:[{argumentNames:["a","b"]}],description:"Creates a new collection with all elements that pass the test implemented by $b. The function is called for each element in the collection, and it should take two arguments: the element itself and the index.",seeAlso:["filter","collection.mapi"],examples:["let cu = import(collection); cu.filteri([1, 2, 3], (x, i) -> i % 2 == 0)","let cu = import(collection); cu.filteri([1, 2, 3], (x, i) -> x % 2 == 0)","let cu = import(collection); cu.filteri([1, 2, 3], (x, i) -> x + i > 3)"]}},mapi:{evaluate:()=>{throw new Error("mapi: Dvala implementation should be used instead")},arity:re(2),docs:{category:"collection",returns:{type:"collection"},args:{a:{type:"collection"},b:{type:"function",description:"The function to call for each element in the collection. The function should take two arguments: the element itself and the index."}},variants:[{argumentNames:["a","b"]}],description:"Creates a new collection populated with the results of calling $b on every element in $a. The function is called for each element in the collection, and it should take two arguments: the element itself and the index.",seeAlso:["map","collection.filteri"],examples:["let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x + i)","let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x * i)","let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x - i)","let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x / i)","let cu = import(collection); cu.mapi([1, 2, 3], (x, i) -> x % inc(i))"]}},reducei:{evaluate:()=>{throw new Error("reducei: Dvala implementation should be used instead")},arity:re(3),docs:{category:"collection",returns:{type:"any"},args:{coll:{type:"collection"},fun:{type:"function",description:"The function to call for each element in the collection. The function should take three arguments: the accumulator, the element itself, and the index."},initial:{type:"any",description:"The initial value to use as the accumulator."}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Runs $fun function on each element of the $coll, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.",seeAlso:["reduce","collection.reducei-right","collection.reductionsi"],examples:["let cu = import(collection); cu.reducei([1, 2, 3], (acc, x, i) -> acc + x + i, 0)",'let cu = import(collection); cu.reducei("Albert", (acc, x, i) -> acc ++ x ++ i, "")','let cu = import(collection); cu.reducei({ a: 1, b: 2 }, -> $1 ++ $3, "")']}},"reduce-right":{evaluate:()=>{throw new Error("reduce-right: Dvala implementation should be used instead")},arity:re(3),docs:{category:"collection",returns:{type:"any"},args:{fun:{type:"function"},coll:{type:"collection"},initial:{type:"any"}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Runs $fun function on each element of the $coll (starting from the last item), passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value.",seeAlso:["reduce","collection.reducei-right"],examples:['let cu = import(collection); cu.reduce-right(["A", "B", "C"], str, "")',"let cu = import(collection); cu.reduce-right({ a: 1, b: 2 }, +, 0)"]}},"reducei-right":{evaluate:()=>{throw new Error("reducei-right: Dvala implementation should be used instead")},arity:re(3),docs:{category:"collection",returns:{type:"any"},args:{coll:{type:"collection"},fun:{type:"function",description:"The function to call for each element in the collection. The function should take three arguments: the accumulator, the element itself, and the index."},initial:{type:"any",description:"The initial value to use as the accumulator."}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Runs $fun function on each element of the $coll (starting from the last item), passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.",seeAlso:["collection.reducei","collection.reduce-right"],examples:["let cu = import(collection); cu.reducei-right([1, 2, 3], (acc, x, i) -> acc + x + i, 0)",'let cu = import(collection); cu.reducei-right("Albert", (acc, x, i) -> acc ++ x ++ i, "")','let cu = import(collection); cu.reducei-right({ a: 1, b: 2 }, -> $1 ++ $3, "")']}},reductions:{evaluate:()=>{throw new Error("reductions: Dvala implementation should be used instead")},arity:re(3),docs:{category:"collection",returns:{type:"any",array:!0},args:{fun:{type:"function"},coll:{type:"collection"},initial:{type:"any"}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Returns an array of the intermediate values of the reduction (see `reduce`) of $coll by $fun.",seeAlso:["reduce","collection.reductionsi"],examples:["let cu = import(collection); cu.reductions([1, 2, 3], +, 0)","let cu = import(collection); cu.reductions([1, 2, 3], +, 10)","let cu = import(collection); cu.reductions([], +, 0)","let cu = import(collection); cu.reductions({ a: 1, b: 2 }, +, 0)","\nlet cu = import(collection);\ncu.reductions(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + (even?(value) ? value : 0),\n 0\n)"]}},reductionsi:{evaluate:()=>{throw new Error("reductionsi: Dvala implementation should be used instead")},arity:re(3),docs:{category:"collection",returns:{type:"any",array:!0},args:{coll:{type:"collection"},fun:{type:"function",description:"The function to call for each element in the collection. The function should take three arguments: the accumulator, the element itself, and the index."},initial:{type:"any",description:"The initial value to use as the accumulator."}},variants:[{argumentNames:["coll","fun","initial"]}],description:"Returns an array of the intermediate values of the reduction (see `reduce`) of $coll by $fun. The function is called for each element in the collection, and it should take three arguments: the accumulator, the element itself, and the index.",seeAlso:["collection.reductions","collection.reducei"],examples:["let cu = import(collection); cu.reductionsi([1, 2, 3], (acc, x, i) -> acc + x + i, 0)",'let cu = import(collection); cu.reductionsi("Albert", (acc, x, i) -> acc ++ x ++ i, "")','let cu = import(collection); cu.reductionsi({ a: 1, b: 2 }, -> $1 ++ $3, "")']}},"not-empty":{evaluate:([e],t)=>null===e?null:(M(e,t),"string"==typeof e||Array.isArray(e)?e.length>0?e:null:Object.keys(e).length>0?e:null),arity:re(1),docs:{category:"collection",returns:{type:"any"},args:{coll:{type:["collection","null"]}},variants:[{argumentNames:["coll"]}],description:"Returns `null` if $coll is empty or `null`, otherwise $coll.",seeAlso:["empty?","not-empty?"],examples:["let cu = import(collection); cu.not-empty([])","let cu = import(collection); cu.not-empty([1, 2, 3])","let cu = import(collection); cu.not-empty({})","let cu = import(collection); cu.not-empty({ a: 2 })",'let cu = import(collection); cu.not-empty("")','let cu = import(collection); cu.not-empty("Albert")',"let cu = import(collection); cu.not-empty(null)"]}},"every?":{evaluate:()=>{throw new Error("every?: Dvala implementation should be used instead")},arity:re(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:"collection"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns `true` if all entries in $a pass the test implemented by $b, otherwise returns `false`.",seeAlso:["collection.any?","collection.not-every?","collection.not-any?","functional.every-pred","grid.cell-every?"],examples:["let cu = import(collection); cu.every?([1, 2, 3], number?)","let cu = import(collection); cu.every?([1, 2, 3], even?)",'\nlet cu = import(collection);\ncu.every?(\n ["Albert", "Mojir", 160, [1, 2]],\n string?,\n)',"\nlet cu = import(collection);\ncu.every?(\n [50, 100, 150, 200],\n -> $ > 10,\n)","let cu = import(collection); cu.every?([], number?)",'let cu = import(collection); cu.every?("", number?)',"let cu = import(collection); cu.every?({}, number?)","\nlet cu = import(collection);\ncu.every?(\n { a: 2, b: 4},\n -> even?(second($))\n)","\nlet cu = import(collection);\ncu.every?(\n { a: 2, b: 3 },\n -> even?(second($))\n)"]}},"any?":{evaluate:()=>{throw new Error("any?: Dvala implementation should be used instead")},arity:re(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:"collection"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns `true` if any element in $a pass the test implemented by $b, otherwise returns `false`.",seeAlso:["collection.every?","collection.not-any?","collection.not-every?","functional.some-pred","some","grid.some?"],examples:['\nlet cu = import(collection);\ncu.any?(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nlet cu = import(collection);\ncu.any?(\n [50, 100, 150, 200],\n x -> x > 10\n)","let cu = import(collection); cu.any?([], number?)",'let cu = import(collection); cu.any?("", number?)',"let cu = import(collection); cu.any?({}, number?)","\nlet cu = import(collection);\ncu.any?(\n { a: 2, b: 3 },\n -> even?(second($))\n)","\nlet cu = import(collection);\ncu.any?(\n { a: 1, b: 3 },\n -> even?(second($))\n)"]}},"not-any?":{evaluate:()=>{throw new Error("not-any?: Dvala implementation should be used instead")},arity:re(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:"collection"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns `false` if any element in $a pass the test implemented by $b, otherwise returns `true`.",seeAlso:["collection.any?","collection.every?","collection.not-every?"],examples:['\nlet cu = import(collection);\ncu.not-any?(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nlet cu = import(collection);\ncu.not-any?(\n [50, 100, 150, 200],\n x -> x > 10\n)","let cu = import(collection); cu.not-any?([], number?)",'let cu = import(collection); cu.not-any?("", number?)',"let cu = import(collection); cu.not-any?({}, number?)","\nlet cu = import(collection);\ncu.not-any?(\n { a: 2, b: 3 },\n -> even?(second($))\n)","\nlet cu = import(collection);\ncu.not-any?(\n { a: 1, b: 3 },\n -> even?(second($))\n)"]}},"not-every?":{evaluate:()=>{throw new Error("not-every?: Dvala implementation should be used instead")},arity:re(2),docs:{category:"collection",returns:{type:"boolean"},args:{a:{type:"collection"},b:{type:"function"}},variants:[{argumentNames:["a","b"]}],description:"Returns `true` if at least one element in $a does not pass the test implemented by $b, otherwise returns `false`.",seeAlso:["collection.every?","collection.any?","collection.not-any?"],examples:['\nlet cu = import(collection);\ncu.not-every?(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nlet cu = import(collection);\ncu.not-every?(\n [50, 100, 150, 200],\n x -> x > 10\n)","let cu = import(collection); cu.not-every?([], number?)",'let cu = import(collection); cu.not-every?("", number?)',"let cu = import(collection); cu.not-every?({}, number?)","\nlet cu = import(collection);\ncu.not-every?(\n { a: 2, b: 4 },\n -> even?(second($))\n)","\nlet cu = import(collection);\ncu.not-every?(\n { a: 2, b: 3 },\n -> even?(second($))\n)"]}}},ea={name:"collection",functions:Zo,source:'{\n update: (coll, key, fn, ...extra-params) ->\n assoc(coll, key, apply(fn, [get(coll, key), ...extra-params])),\n\n update-in: (coll, ks, fn, ...extra-params) -> do\n let k = first(ks);\n if count(ks) == 1 then\n assoc(coll, k, apply(fn, [get(coll, k), ...extra-params]))\n else\n let inner = get(coll, k);\n let inner-coll = null?(inner) ? {} : inner;\n assoc(coll, k, apply(self, [inner-coll, slice(ks, 1), fn, ...extra-params]))\n end\n end,\n\n filteri: (coll, fn) -> do\n cond\n case array?(coll) then\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> if fn(first(pair), second(pair)) then [...acc, first(pair)] else acc end,\n []\n )\n\n case string?(coll) then\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> if fn(first(pair), second(pair)) then ++(acc, first(pair)) else acc end,\n ""\n )\n\n case object?(coll) then\n reduce(keys(coll), (acc, k) ->\n if fn(coll(k), k) then assoc(acc, k, coll(k)) else acc end,\n {}\n )\n\n case true then\n perform(effect(dvala.error), "Expected collection")\n end\n end,\n\n mapi: (coll, fn) -> do\n cond\n case array?(coll) then\n for (i in range(count(coll))) -> fn(nth(coll, i), i)\n\n case string?(coll) then\n reduce(\n for (i in range(count(coll))) -> fn(nth(coll, i), i),\n (acc, ch) -> ++(acc, ch),\n ""\n )\n\n case object?(coll) then\n reduce(keys(coll), (acc, k) ->\n assoc(acc, k, fn(coll(k), k)),\n {}\n )\n\n case true then\n perform(effect(dvala.error), "Expected collection")\n end\n end,\n\n reducei: (coll, fn, initial) -> do\n cond\n case string?(coll) then\n loop (acc = initial, i = 0) -> do\n if i >= count(coll) then\n acc\n else\n recur(fn(acc, nth(coll, i), i), i + 1)\n end\n end\n\n case array?(coll) then\n loop (acc = initial, i = 0) -> do\n if i >= count(coll) then\n acc\n else\n recur(fn(acc, nth(coll, i), i), i + 1)\n end\n end\n\n case object?(coll) then\n reduce(keys(coll), (acc, k) -> fn(acc, coll(k), k), initial)\n\n case true then\n perform(effect(dvala.error), "Expected collection")\n end\n end,\n\n reduce-right: (coll, fn, initial) -> do\n cond\n case string?(coll) then\n reduce(reverse(coll), fn, initial)\n\n case array?(coll) then\n reduce(reverse(coll), fn, initial)\n\n case object?(coll) then\n reduce(reverse(keys(coll)), (acc, k) -> fn(acc, coll(k)), initial)\n\n case true then\n perform(effect(dvala.error), "Expected collection")\n end\n end,\n\n reducei-right: (coll, fn, initial) -> do\n cond\n case string?(coll) then\n let len = count(coll);\n loop (acc = initial, i = len - 1) -> do\n if i < 0 then\n acc\n else\n recur(fn(acc, nth(coll, i), i), i - 1)\n end\n end\n\n case array?(coll) then\n let len = count(coll);\n loop (acc = initial, i = len - 1) -> do\n if i < 0 then\n acc\n else\n recur(fn(acc, nth(coll, i), i), i - 1)\n end\n end\n\n case object?(coll) then\n reduce(reverse(keys(coll)), (acc, k) -> fn(acc, coll(k), k), initial)\n\n case true then\n perform(effect(dvala.error), "Expected collection")\n end\n end,\n\n reductions: (coll, fn, initial) -> do\n let items = cond\n case string?(coll) then\n if count(coll) == 0 then [] else for (i in range(count(coll))) -> nth(coll, i) end\n\n case array?(coll) then coll\n\n case object?(coll) then\n for (k in keys(coll)) -> coll(k)\n\n case true then\n perform(effect(dvala.error), "Expected collection")\n end;\n if count(items) == 0 then\n [initial]\n else\n reduce(items, (acc, elem) -> do\n let prev = last(acc);\n [...acc, fn(prev, elem)]\n end, [initial])\n end\n end,\n\n reductionsi: (coll, fn, initial) -> do\n cond\n case string?(coll) then do\n if count(coll) == 0 then\n [initial]\n else\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> do\n let prev = last(acc);\n [...acc, fn(prev, first(pair), second(pair))]\n end,\n [initial]\n )\n end\n end\n\n case array?(coll) then do\n if count(coll) == 0 then\n [initial]\n else\n reduce(\n for (i in range(count(coll))) -> [nth(coll, i), i],\n (acc, pair) -> do\n let prev = last(acc);\n [...acc, fn(prev, first(pair), second(pair))]\n end,\n [initial]\n )\n end\n end\n\n case object?(coll) then do\n let ks = keys(coll);\n if count(ks) == 0 then\n [initial]\n else\n reduce(ks, (acc, k) -> do\n let prev = last(acc);\n [...acc, fn(prev, coll(k), k)]\n end, [initial])\n end\n end\n\n case true then\n perform(effect(dvala.error), "Expected collection")\n end\n end,\n\n "every?": (coll, fn) -> do\n let items = cond\n case array?(coll) then coll\n case string?(coll) then for (i in range(count(coll))) -> nth(coll, i)\n case object?(coll) then for (k in keys(coll)) -> [k, coll(k)]\n case true then perform(effect(dvala.error), "Expected collection")\n end;\n loop (i = 0) ->\n cond\n case i >= count(items) then true\n case not(fn(nth(items, i))) then false\n case true then recur(i + 1)\n end\n end,\n\n "any?": (coll, fn) -> do\n let items = cond\n case array?(coll) then coll\n case string?(coll) then for (i in range(count(coll))) -> nth(coll, i)\n case object?(coll) then for (k in keys(coll)) -> [k, coll(k)]\n case true then perform(effect(dvala.error), "Expected collection")\n end;\n loop (i = 0) ->\n cond\n case i >= count(items) then false\n case fn(nth(items, i)) then true\n case true then recur(i + 1)\n end\n end,\n\n "not-any?": (coll, fn) -> do\n let items = cond\n case array?(coll) then coll\n case string?(coll) then for (i in range(count(coll))) -> nth(coll, i)\n case object?(coll) then for (k in keys(coll)) -> [k, coll(k)]\n case true then perform(effect(dvala.error), "Expected collection")\n end;\n loop (i = 0) ->\n cond\n case i >= count(items) then true\n case fn(nth(items, i)) then false\n case true then recur(i + 1)\n end\n end,\n\n "not-every?": (coll, fn) -> do\n let items = cond\n case array?(coll) then coll\n case string?(coll) then for (i in range(count(coll))) -> nth(coll, i)\n case object?(coll) then for (k in keys(coll)) -> [k, coll(k)]\n case true then perform(effect(dvala.error), "Expected collection")\n end;\n loop (i = 0) ->\n cond\n case i >= count(items) then false\n case not(fn(nth(items, i))) then true\n case true then recur(i + 1)\n end\n end\n}',docs:_o(Zo)};const ta={position:{evaluate:()=>{throw new Error("position: Dvala implementation should be used instead")},arity:re(2),docs:{category:"sequence",returns:{type:["number","null"]},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:["sequence","null"]},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns the index of the first elements that passes the test implemented by $fun. If no element was found, `null` is returned.",seeAlso:["index-of","some","find"],examples:['\nlet su = import(sequence);\nsu.position(\n ["Albert", "Mojir", 160, [1, 2]],\n string?\n)',"\nlet su = import(sequence);\nsu.position(\n [5, 10, 15, 20],\n -> $ > 10\n)","\nlet su = import(sequence);\nsu.position(\n [5, 10, 15, 20],\n -> $ > 100\n)","\nlet su = import(sequence);\nsu.position(\n null,\n -> $ > 100\n)"]}},"last-index-of":{evaluate:([e,t],r)=>{if(E(t,r),null===e)return null;if(z(e,r),"string"==typeof e){G(t,r);const n=e.lastIndexOf(t);return-1!==n?n:null}{const n=e.findLastIndex(e=>se($(e,r),t),r);return-1!==n?n:null}},arity:re(2),docs:{category:"sequence",returns:{type:["number","null"]},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:["sequence","null"]},x:{type:"any"}},variants:[{argumentNames:["seq","x"]}],description:"Returns the last index of $x in $seq. If element is not present in $seq `null` is returned.",seeAlso:["index-of"],examples:["let su = import(sequence); su.last-index-of([[1], [2], [1], [2]], [1])",'let su = import(sequence); su.last-index-of(["Albert", "Mojir", 160, [1, 2]], "Mojir")',"let su = import(sequence); su.last-index-of([5, 10, 15, 20, 15], 15)","let su = import(sequence); su.last-index-of([5, 10, 15, 20], 1)","let su = import(sequence); su.last-index-of(null, 1)"]}},splice:{evaluate:(e,t)=>{const[r,n,o,...a]=e;z(r,t),Y(n,t,{integer:!0}),Y(o,t,{integer:!0,nonNegative:!0});const i=n<0?r.length+n:n;return Array.isArray(r)?[...r.slice(0,i),...a,...r.slice(i+o)]:(a.forEach(e=>G(e,t)),`${r.substring(0,i)}${a.join("")}${r.substring(i+o)}`)},arity:{min:3},docs:{category:"sequence",returns:{type:"sequence"},args:{seq:{type:"sequence",rest:!0},start:{type:"integer"},deleteCount:{type:"integer"},items:{type:"any",rest:!0}},variants:[{argumentNames:["seq","start","deleteCount"]},{argumentNames:["seq","start","deleteCount","items"]}],description:"Returns a a spliced array. Removes $deleteCount elements from $seq starting at $start and replaces them with $items. If $start is negative, it is counting from the end of the array.",seeAlso:["slice","sequence.remove-at"],examples:['let su = import(sequence); su.splice([1, 2, 3, 4, 5], 2, 2, "x")','let su = import(sequence); su.splice([1, 2, 3, 4, 5], -2, 1, "x")','let su = import(sequence); su.splice("Albert", 2, 2, "fo")']}},"sort-by":{evaluate:()=>{throw new Error("sort-by: Dvala implementation should be used instead")},arity:{min:2,max:3},docs:{category:"sequence",returns:{type:"any",rest:!0},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},keyfn:{type:"function"},comparer:{type:"function"}},variants:[{argumentNames:["seq","keyfn"]},{argumentNames:["seq","keyfn","comparer"]}],description:"Returns a sorted sequence of the items in $seq, where the sort order is determined by comparing `(keyfn item)`. If no $comparer is supplied, uses builtin `compare`.",seeAlso:["sort","compare"],examples:['let su = import(sequence); su.sort-by(["Albert", "Mojir", "Nina"], count)','let su = import(sequence); su.sort-by(["Albert", "Mojir", "Nina"], count)','let su = import(sequence); su.sort-by("Albert", lower-case, -> $2 compare $1)']}},unshift:{evaluate:([e,...t],r)=>{if(z(e,r),"string"==typeof e)return we(t,r),[...t,e].join("");const n=[...e];return n.unshift(...t),n},arity:{min:2},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:"sequence"},values:{type:"any",rest:!0}},variants:[{argumentNames:["seq","values"]}],description:"Returns copy of $seq with $values added to the beginning.",seeAlso:["push","++"],examples:["let su = import(sequence); su.unshift([1, 2, 3], 4)","let su = import(sequence); su.unshift([1, 2, 3], 4)","let su = import(sequence); su.unshift([1, 2, 3], 4, 5, 6)","\nlet su = import(sequence);\nlet l = [1, 2, 3];\nsu.unshift(l, 4);\nl"]}},distinct:{evaluate:([e],t)=>{if(z(e,t),Array.isArray(e)){const r=[];for(const n of e)E(n,t),r.some(e=>se(e,n,t))||r.push(n);return r}return Array.from(new Set(e.split(""))).join("")},arity:re(1),docs:{category:"sequence",returns:{type:"sequence"},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"Returns a copy of $seq with no duplicates.",seeAlso:["sequence.frequencies"],examples:["let su = import(sequence); su.distinct([[1], [2], [3], [1], [3], [5]])","let su = import(sequence); su.distinct([1, 2, 3, 1, 3, 5])",'let su = import(sequence); su.distinct("Albert Mojir")',"let su = import(sequence); su.distinct([])",'let su = import(sequence); su.distinct("")']}},remove:{evaluate:()=>{throw new Error("remove: Dvala implementation should be used instead")},arity:re(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns a new sequence of items in $seq for witch `pred(item)` returns a falsy value.",seeAlso:["filter","sequence.remove-at"],examples:["let su = import(sequence); su.remove([1, 2, 3, 1, 3, 5], odd?)","let su = import(sequence); su.remove([1, 2, 3, 1, 3, 5], even?)",'let su = import(sequence); su.remove("Albert Mojir", -> "aoueiyAOUEIY" contains? $)']}},"remove-at":{evaluate:([e,t],r)=>{Y(t,r,{integer:!0}),z(e,r);const n=t<0?e.length+t:t;return n<0||n>=e.length?e:Array.isArray(e)?e.filter((e,t)=>t!==n):`${e.substring(0,n)}${e.substring(n+1)}`},arity:re(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence"},n:{type:"number"}},variants:[{argumentNames:["seq","n"]}],description:"Returns a new sequence of all items in $seq except item at position $n. If $n is negative, it is counting from the end of the sequence.",seeAlso:["sequence.remove","sequence.splice"],examples:["let su = import(sequence); su.remove-at([1, 2, 3, 1, 3, 5], 2)",'let su = import(sequence); su.remove-at("Albert", -2)',"let su = import(sequence); su.remove-at([1, 2, 3, 1, 3, 5], 0)","let su = import(sequence); su.remove-at([1, 2, 3, 1, 3, 5], -1)",'let su = import(sequence); su.remove-at("Albert Mojir", 6)']}},"split-at":{evaluate:([e,t],r)=>{Y(t,r,{integer:!0}),z(e,r);const n=t<0?e.length+t:t;return[e.slice(0,n),e.slice(n)]},arity:re(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"integer"},seq:{type:"sequence"},n:{type:"number"}},variants:[{argumentNames:["seq","n"]}],description:"Returns a pair of sequence `[take(pos input), drop(pos input)]`.",seeAlso:["sequence.split-with","take","drop"],examples:["let su = import(sequence); su.split-at([1, 2, 3, 4, 5], 2)",'let su = import(sequence); su.split-at("Albert", -2)',"let su = import(sequence); su.split-at([1, 2, 3, 4, 5], -2)",'let su = import(sequence); su.split-at("Albert", 2)']}},"split-with":{evaluate:()=>{throw new Error("split-with: Dvala implementation should be used instead")},arity:re(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns a pair of sequences `[take-while(input, fun), drop-while(input, fun)]`.",seeAlso:["sequence.split-at","take-while","drop-while"],examples:["let su = import(sequence); su.split-with([1, 2, 3, 4, 5], odd?)","let su = import(sequence); su.split-with([1, 2, 3, 4, 5], -> $ > 3)",'let su = import(sequence); su.split-with("Albert", -> $ <= "o")']}},frequencies:{evaluate:([e],t)=>{z(e,t);return("string"==typeof e?e.split(""):e).reduce((e,r)=>(G(r,t),ae(e,r)?e[r]=e[r]+1:e[r]=1,e),{})},arity:re(1),docs:{category:"sequence",returns:{type:"object"},args:{seq:{type:"sequence"}},variants:[{argumentNames:["seq"]}],description:"Returns an object from distinct items in $seq to the number of times they appear. Note that all items in $seq must be valid object keys i.e. strings.",seeAlso:["sequence.group-by","sequence.distinct","vector.count-values"],examples:['let su = import(sequence); su.frequencies(["Albert", "Mojir", "Nina", "Mojir"])','let su = import(sequence); su.frequencies("Pneumonoultramicroscopicsilicovolcanoconiosis")']}},"group-by":{evaluate:()=>{throw new Error("group-by: Dvala implementation should be used instead")},arity:re(2),docs:{category:"sequence",returns:{type:"object"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Returns an object of the elements of $seq keyed by the result of $fun on each element. The value at each key will be an array of the corresponding elements.",seeAlso:["sequence.frequencies","sequence.partition-by"],examples:['let su = import(sequence); su.group-by([{ name: "Albert" }, { name: "Albert" }, { name: "Mojir" }], "name")','let su = import(sequence); su.group-by([{name: "Albert"}, {name: "Albert"}, {name: "Mojir"}], "name")','let su = import(sequence); su.group-by("Albert Mojir", -> "aoueiAOUEI" contains? $ ? "vowel" : "other")']}},partition:{evaluate:(e,t)=>{const r=S(e[0],t),n=ce(X(e[1],t)),o=e.length>=3?ce(X(e[2],t)):n,a=4===e.length?null===e[3]?[]:function(e,t){return ve(e,t),e}(e[3],t):void 0;return ra(n,o,r,a,t)},arity:{min:2,max:4},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"number"},seq:{type:"sequence"},n:{type:"number"},step:{type:"number"},pad:{type:"array"}},variants:[{argumentNames:["seq","n"]},{argumentNames:["seq","n","step"]},{argumentNames:["seq","n","step","pad"]}],description:"Returns an array of sequences of $n items each, at offsets $step apart. If $step is not supplied, defaults to $n. If a $pad array is supplied, use its elements as necessary to complete last partition upto $n items. In case there are not enough padding elements, return a partition with less than $n items.",seeAlso:["sequence.partition-all","sequence.partition-by"],examples:["let su = import(sequence); su.partition(range(20), 4)","let su = import(sequence); su.partition(range(20), 4)","let su = import(sequence); su.partition(range(22), 4)","let su = import(sequence); su.partition(range(20), 4, 6)","let su = import(sequence); su.partition(range(20), 4, 3)",'let su = import(sequence); su.partition(range(20), 3, 6, ["a"])','let su = import(sequence); su.partition(range(20), 4, 6, ["a"])','let su = import(sequence); su.partition(range(20), 4, 6, ["a", "b", "c", "d"])','let su = import(sequence); su.partition(["a", "b", "c", "d", "e", "f"], 3, 1)',"let su = import(sequence); su.partition([1, 2, 3, 4], 10)","let su = import(sequence); su.partition([1, 2, 3, 4], 10, 10)","let su = import(sequence); su.partition([1, 2, 3, 4], 10, 10, [])","let su = import(sequence); su.partition([1, 2, 3, 4], 10, 10, null)",'let su = import(sequence); su.partition("superfragilistic", 5)','let su = import(sequence); su.partition("superfragilistic", 5, 5, null)',"let su = import(sequence); let foo = [5, 6, 7, 8]; su.partition(foo, 2, 1, foo)"]}},"partition-all":{evaluate:(e,t)=>{const r=S(e[0],t),n=ce(X(e[1],t));return ra(n,3===e.length?ce(X(e[2],t)):n,r,[],t)},arity:{min:2,max:3},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"number"},seq:{type:"sequence"},n:{type:"number"},step:{type:"number"}},variants:[{argumentNames:["seq","n"]},{argumentNames:["seq","n","step"]}],description:"Returns an array of sequences like partition, but may include partitions with fewer than n items at the end.",seeAlso:["sequence.partition","sequence.partition-by"],examples:["let su = import(sequence); su.partition-all([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 4)","let su = import(sequence); su.partition-all([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 4)","let su = import(sequence); su.partition([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 4)","let su = import(sequence); su.partition-all([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 2, 4)"]}},"partition-by":{evaluate:()=>{throw new Error("partition-by: Dvala implementation should be used instead")},arity:re(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"function"},seq:{type:"sequence"},fun:{type:"function"}},variants:[{argumentNames:["seq","fun"]}],description:"Applies $fun to each value in $seq, splitting it each time $fun returns a new value. Returns an array of sequences.",seeAlso:["sequence.partition","sequence.partition-all","sequence.group-by"],examples:["let su = import(sequence); su.partition-by([1, 2, 3, 4, 5], odd?)","let su = import(sequence); su.partition-by([1, 2, 3, 4, 5], -> $ == 3)","let su = import(sequence); su.partition-by([1, 1, 1, 2, 2, 3, 3], odd?)",'let su = import(sequence); su.partition-by("Leeeeeerrroyyy", identity)']}},"ends-with?":{evaluate:([e,t],r)=>(z(e,r),"string"==typeof e?(G(t,r),e.endsWith(t)):se($(e.at(-1),r),$(t,r),r)),arity:re(2),docs:{category:"sequence",returns:{type:"boolean"},args:{a:{type:"sequence"},b:{type:"sequence"},seq:{type:"sequence"},suffix:{type:"sequence"}},variants:[{argumentNames:["seq","suffix"]}],description:"Returns `true` if $seq ends with $suffix, otherwise `false`.",seeAlso:["sequence.starts-with?"],examples:["let su = import(sequence); su.ends-with?([[1], [2], [3], [4], [5]], [5])","let su = import(sequence); su.ends-with?([[1], [2], [3], [4], [5]], 5)","let su = import(sequence); su.ends-with?([1, 2, 3, 4, 5], 5)","let su = import(sequence); su.ends-with?([1, 2, 3, 4, 5], [5])",'let su = import(sequence); su.ends-with?("Albert", "rt")','let su = import(sequence); su.ends-with?("Albert", "RT")']}},"starts-with?":{evaluate:([e,t],r)=>(z(e,r),"string"==typeof e?(G(t,r),e.startsWith(t)):se($(e[0],r),$(t,r),r)),arity:re(2),docs:{category:"sequence",returns:{type:"boolean"},args:{a:{type:"sequence"},b:{type:"sequence"},seq:{type:"sequence"},prefix:{type:"sequence"}},variants:[{argumentNames:["seq","prefix"]}],description:"Returns `true` if $seq starts with $prefix, otherwise `false`.",seeAlso:["sequence.ends-with?"],examples:["let su = import(sequence); su.starts-with?([[1], [2], [3], [4], [5]], [1])","let su = import(sequence); su.starts-with?([1, 2, 3, 4, 5], 1)","let su = import(sequence); su.starts-with?([1, 2, 3, 4, 5], [1])",'let su = import(sequence); su.starts-with?("Albert", "Al")','let su = import(sequence); su.starts-with?("Albert", "al")']}},interleave:{evaluate:([...e],t)=>{const r="string"==typeof e[0],n=r?e.map(e=>(G(e,t),e.split(""))):e.map(e=>(ve(e,t),e)),o=Math.min(...n.map(e=>e.length)),a=[];for(let e=0;e<o;e+=1)for(const t of n)e<t.length&&a.push(t[e]);return r?a.join(""):a},arity:{min:1},docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"sequence"},seqs:{type:"sequence",rest:!0}},variants:[{argumentNames:["seqs"]}],description:"Returns a sequence of the first item from each of the $seqs, then the second item from each of the $seqs, until all items from the shortest seq are exhausted.",seeAlso:["sequence.interpose","zipmap"],examples:["let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6])",'let su = import(sequence); su.interleave("Albert", ".,.,.,")',"let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6])","let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [7, 8, 9])","let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [7, 8])","let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [7])","let su = import(sequence); su.interleave([1, 2, 3], [4, 5, 6], [])","let su = import(sequence); su.interleave([1, 2, 3], [])","let su = import(sequence); su.interleave([])"]}},interpose:{evaluate:([e,t],r)=>{if(z(e,r),"string"==typeof e)return G(t,r),e.split("").join(t);if(0===e.length)return[];const n=[];for(let r=0;r<e.length-1;r+=1)n.push(e[r],t);return n.push(e[e.length-1]),n},arity:re(2),docs:{category:"sequence",returns:{type:"sequence"},args:{a:{type:"sequence"},b:{type:"any"},seq:{type:"sequence"},separator:{type:"any"}},variants:[{argumentNames:["seq","separator"]}],description:"Returns a sequence of the elements of $seq separated by $separator. If $seq is a string, the separator must be a string.",seeAlso:["sequence.interleave","join"],examples:['let su = import(sequence); su.interpose("Albert", "-")','let su = import(sequence); su.interpose([1, 2, 3, 4, 5], "a")','let su = import(sequence); su.interpose(["Albert", "Mojir", "Nina"], ", ")','let su = import(sequence); su.interpose("Albert", ".")']}}};function ra(e,t,r,n,o){Y(t,o,{positive:!0});const a="string"==typeof r,i=[];let s=0;e:for(;s<r.length;){const o=[];for(let a=s;a<s+e;a+=1)if(a>=r.length){const e=a-r.length;if(!n){s+=t;continue e}if(e>=n.length)break;o.push(n[e])}else o.push(r[a]);i.push(o),s+=t}return a?i.map(e=>e.join("")):i}const na={name:"sequence",functions:ta,source:'{\n position: (seq, fn) -> do\n let items = cond\n case null?(seq) then null\n case string?(seq) then for (i in range(count(seq))) -> nth(seq, i)\n case true then seq\n end;\n if null?(items) then null\n else\n loop (i = 0) ->\n cond\n case i >= count(items) then null\n case fn(nth(items, i)) then i\n case true then recur(i + 1)\n end\n end\n end,\n\n sort-by: (seq, keyfn, ...args) -> do\n let items = if string?(seq) then for (i in range(count(seq))) -> nth(seq, i) else [...seq] end;\n let keyed = map(items, (elem) -> [keyfn(elem), elem]);\n let sorted = if count(args) == 0 then\n sort(keyed, (a, b) -> compare(first(a), first(b)))\n else\n sort(keyed, (a, b) -> first(args)(first(a), first(b)))\n end;\n let result = map(sorted, second);\n if string?(seq) then join(result, "") else result end\n end,\n\n remove: (seq, fn) -> do\n let result = filter(\n if string?(seq) then for (i in range(count(seq))) -> nth(seq, i) else seq end,\n (elem) -> not(fn(elem))\n );\n if string?(seq) then join(result, "") else result end\n end,\n\n split-with: (seq, fn) -> do\n let items = if string?(seq) then for (i in range(count(seq))) -> nth(seq, i) else seq end;\n let idx = loop (i = 0) ->\n cond\n case i >= count(items) then -1\n case not(fn(nth(items, i))) then i\n case true then recur(i + 1)\n end;\n if idx == -1 then\n [seq, if array?(seq) then [] else "" end]\n else\n [slice(seq, 0, idx), slice(seq, idx)]\n end\n end,\n\n group-by: (seq, fn) -> do\n let items = if string?(seq) then for (i in range(count(seq))) -> nth(seq, i) else seq end;\n reduce(items, (result, val) -> do\n let key = fn(val);\n let existing = get(result, key);\n assoc(result, key, if null?(existing) then [val] else [...existing, val] end)\n end, {})\n end,\n\n partition-by: (seq, fn) -> do\n let items = if string?(seq) then for (i in range(count(seq))) -> nth(seq, i) else seq end;\n if count(items) == 0 then\n []\n else\n do\n let result = reduce(rest(items), (acc, elem) -> do\n let value = fn(elem);\n if value != first(acc) then\n [value, [...second(acc), [elem]]]\n else\n [value, [...slice(second(acc), 0, count(second(acc)) - 1), [...last(second(acc)), elem]]]\n end\n end, [fn(first(items)), [[first(items)]]]);\n let groups = second(result);\n if string?(seq) then\n map(groups, (group) -> join(group, ""))\n else\n groups\n end\n end\n end\n end\n}',docs:_o(ta)};function oa(e){return([t],n)=>{const[o,a]=function(e,t){if(Ie(e))return["vector",e];if(Ve(e))return["matrix",e];if(!H(e))throw new r("Invalid parameter type: "+typeof e,t);return["number",e]}(t,n);return"number"===o?e(a):"vector"===o?a.map(t=>e(t)):a.map(t=>t.map(t=>e(t)))}}const aa={sin:{evaluate:oa(e=>Math.sin(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `sin` function computes the sine of an angle (in radians), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the sine of each element while preserving the original structure.",seeAlso:["math.asin","math.sinh","math.cos","math.tan","math.to-rad"],examples:["let { sin } = import(math);\nsin(0)","let { sin } = import(math);\nsin(1)","let { sin } = import(math);\nsin(PI)","let { sin } = import(math);\nsin(-0.5)","let { sin } = import(math);\nsin([1, 2, 3])","let { sin } = import(math);\nsin([[1, 2], [3, 4]])"]}},asin:{evaluate:oa(e=>Math.asin(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `asin` function computes the arcsine (inverse sine) of a `number` in radians, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the arcsine of each element while preserving the original structure.",seeAlso:["math.sin","math.asinh","math.acos","math.atan"],examples:["let { asin } = import(math);\nasin(0)","let { asin } = import(math);\nasin(1)","let { asin } = import(math);\nasin(-0.5)","let { asin } = import(math);\nasin([1, 2, 3])","let { asin } = import(math);\nasin([[1, 2], [3, 4]])"]}},sinh:{evaluate:oa(e=>Math.sinh(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `sinh` function computes the hyperbolic sine of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the hyperbolic sine of each element while preserving the original structure.",seeAlso:["math.asinh","math.sin","math.cosh","math.tanh"],examples:["let { sinh } = import(math);\nsinh(0)","let { sinh } = import(math);\nsinh(1)","let { sinh } = import(math);\nsinh(-0.5)","let { sinh } = import(math);\nsinh([0.1, 0.2, 0.3])","let { sinh } = import(math);\nsinh([[0.1, 0.2], [0.3, 0.4]])"]}},asinh:{evaluate:oa(e=>Math.asinh(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `asinh` function computes the inverse hyperbolic sine of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the inverse hyperbolic sine of each element while preserving the original structure.",seeAlso:["math.sinh","math.asin","math.acosh","math.atanh"],examples:["let { asinh } = import(math);\nasinh(10)","let { asinh } = import(math);\nasinh(90)","let { asinh } = import(math);\nasinh(50)","let { asinh } = import(math);\nasinh([10, 20, 30])","let { asinh } = import(math);\nasinh([[10, 20], [30, 40]])"]}},cos:{evaluate:oa(e=>Math.cos(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `cos` function computes the cosine of an angle (in radians), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the cosine of each element while preserving the original structure.",seeAlso:["math.acos","math.cosh","math.sin","math.tan","math.to-rad"],examples:["let { cos } = import(math);\ncos(0)","let { cos } = import(math);\ncos(1)","let { cos } = import(math);\ncos(PI)","let { cos } = import(math);\ncos(-0.5)","let { cos } = import(math);\ncos([1, 2, 3])","let { cos } = import(math);\ncos([[1, 2], [3, 4]])"]}},acos:{evaluate:oa(e=>Math.acos(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `acos` function computes the arccosine (inverse cosine) of a `number` in radians, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the arccosine of each element while preserving the original structure.",seeAlso:["math.cos","math.acosh","math.asin","math.atan"],examples:["let { acos } = import(math);\nacos(0)","let { acos } = import(math);\nacos(1)","let { acos } = import(math);\nacos(-0.5)","let { acos } = import(math);\nacos([0.1, 0.2, 0.3])","let { acos } = import(math);\nacos([[0.1, 0.2], [0.3, 0.4]])"]}},cosh:{evaluate:oa(e=>Math.cosh(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `cosh` function computes the hyperbolic cosine of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the hyperbolic cosine of each element while preserving the original structure.",seeAlso:["math.acosh","math.cos","math.sinh","math.tanh"],examples:["let { cosh } = import(math);\ncosh(0)","let { cosh } = import(math);\ncosh(1)","let { cosh } = import(math);\ncosh(-0.5)","let { cosh } = import(math);\ncosh([0.1, 0.2, 0.3])","let { cosh } = import(math);\ncosh([[0.1, 0.2], [0.3, 0.4]])"]}},acosh:{evaluate:oa(e=>Math.acosh(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `acosh` function computes the inverse hyperbolic cosine of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the inverse hyperbolic cosine of each element while preserving the original structure.",seeAlso:["math.cosh","math.acos","math.asinh","math.atanh"],examples:["let { acosh } = import(math);\nacosh(1)","let { acosh } = import(math);\nacosh(2)","let { acosh } = import(math);\nacosh(100)","let { acosh } = import(math);\nacosh(50)","let { acosh } = import(math);\nacosh([1, 2, 3])","let { acosh } = import(math);\nacosh([[1, 2], [3, 4]])"]}},tan:{evaluate:oa(e=>Math.tan(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `tan` function computes the tangent of an angle (in radians), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the tangent of each element while preserving the original structure.",seeAlso:["math.atan","math.tanh","math.sin","math.cos","math.to-rad"],examples:["let { tan } = import(math);\ntan(0)","let { tan } = import(math);\ntan(1)","let { tan } = import(math);\ntan(PI)","let { tan } = import(math);\ntan(-0.5)","let { tan } = import(math);\ntan([1, 2, 3])","let { tan } = import(math);\ntan([[1, 2], [3, 4]])"]}},atan:{evaluate:oa(e=>Math.atan(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `atan` function computes the arctangent (inverse tangent) of a `number` in radians, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the arctangent of each element while preserving the original structure.",seeAlso:["math.tan","math.atanh","math.asin","math.acos"],examples:["let { atan } = import(math);\natan(0)","let { atan } = import(math);\natan(1)","let { atan } = import(math);\natan(-0.5)","let { atan } = import(math);\natan([0.1, 0.2, 0.3])","let { atan } = import(math);\natan([[0.1, 0.2], [0.3, 0.4]])"]}},tanh:{evaluate:oa(e=>Math.tanh(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `tanh` function computes the hyperbolic tangent of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the hyperbolic tangent of each element while preserving the original structure.",seeAlso:["math.atanh","math.tan","math.sinh","math.cosh"],examples:["let { tanh } = import(math);\ntanh(0)","let { tanh } = import(math);\ntanh(1)","let { tanh } = import(math);\ntanh(-0.5)","let { tanh } = import(math);\ntanh(50)"]}},atanh:{evaluate:oa(e=>Math.atanh(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `atanh` function computes the inverse hyperbolic tangent of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the inverse hyperbolic tangent of each element while preserving the original structure.",seeAlso:["math.tanh","math.atan","math.asinh","math.acosh"],examples:["let { atanh } = import(math);\natanh(0)","let { atanh } = import(math);\natanh(0.9)","let { atanh } = import(math);\natanh(-0.5)","let { atanh } = import(math);\natanh([0.1, 0.2, 0.3])","let { atanh } = import(math);\natanh([[0.1, 0.2], [0.3, 0.4]])"]}},ln:{evaluate:oa(e=>Math.log(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `ln` function computes the natural logarithm (base `e`) of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the natural logarithm of each element while preserving the original structure.",seeAlso:["math.log2","math.log10","^"],examples:["let { ln } = import(math);\nln(0.01)","let { ln } = import(math);\nln(2.5)","let { ln } = import(math);\nln(E)","let { ln } = import(math);\nln([1, 2, 3])","let { ln } = import(math);\nln([[1, 2], [3, 4]])"]}},log2:{evaluate:oa(e=>Math.log2(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `log2` function computes the base `2` logarithm of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the base-2 logarithm of each element while preserving the original structure.",seeAlso:["math.ln","math.log10"],examples:["let { log2 } = import(math);\nlog2(0.01)","let { log2 } = import(math);\nlog2(2 ^ 12)","let { log2 } = import(math);\nlog2(2.5)","let { log2 } = import(math);\nlog2([1, 2, 3])","let { log2 } = import(math);\nlog2([[1, 2], [3, 4]])"]}},log10:{evaluate:oa(e=>Math.log10(e)),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `log10` function computes the base `10` logarithm of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the base-10 logarithm of each element while preserving the original structure.",seeAlso:["math.ln","math.log2"],examples:["let { log10 } = import(math);\nlog10(0.01)","let { log10 } = import(math);\nlog10(10 ^ 12)","let { log10 } = import(math);\nlog10(2.5)","let { log10 } = import(math);\nlog10([1, 2, 3])","let { log10 } = import(math);\nlog10([[1, 2], [3, 4]])"]}},"to-rad":{evaluate:oa(e=>e*Math.PI/180),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `to-rad` function converts an angle from degrees to radians, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it converts each element while preserving the original structure.",seeAlso:["math.to-deg","math.sin","math.cos","math.tan"],examples:["let { to-rad } = import(math);\nto-rad(0)","let { to-rad } = import(math);\nto-rad(90)","let { to-rad } = import(math);\nto-rad(180)","let { to-rad } = import(math);\nto-rad(360)","let { to-rad } = import(math);\nto-rad([0, 90, 180])","let { to-rad } = import(math);\nto-rad([[0, 90], [180, 360]])"]}},"to-deg":{evaluate:oa(e=>180*e/Math.PI),arity:re(1),docs:{category:"math",returns:{type:["number","vector","matrix"]},args:{x:{type:["number","vector","matrix"]}},variants:[{argumentNames:["x"]}],description:"The `to-deg` function converts an angle from radians to degrees, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it converts each element while preserving the original structure.",seeAlso:["math.to-rad"],examples:["let { to-deg } = import(math);\nto-deg(0)","let { to-deg } = import(math);\nto-deg(PI)","let { to-deg } = import(math);\nto-deg(PI / 2)","let { to-deg } = import(math);\nto-deg(3 * PI / 2)","let { to-deg } = import(math);\nto-deg([0, PI, PI / 2])","let { to-deg } = import(math);\nto-deg([[0, PI], [PI / 2, 3 * PI / 2]])"]}}},ia={name:"math",functions:aa,source:"{}",docs:_o(aa)};const sa={juxt:{evaluate:(e,t)=>{e.forEach(e=>F(e,t));const n=function(e){return e.reduce((e,t)=>{if(null===e)return null;const r="number"==typeof t||C(t)?re(1):t.arity,{min:n,max:o}=r,{min:a,max:i}=e,s="number"==typeof n&&"number"==typeof a?Math.max(n,a):"number"==typeof n?n:"number"==typeof a?a:void 0,c="number"==typeof o&&"number"==typeof i?Math.min(o,i):"number"==typeof o?o:"number"==typeof i?i:void 0;return"number"==typeof s&&"number"==typeof c&&s>c?null:{min:s,max:c}},{})}(e);if(null===n)throw new r("All functions must accept the same number of arguments",t);return{[u]:!0,sourceCodeInfo:t,functionType:"Juxt",params:e,arity:n}},arity:{min:1},docs:{category:"functional",returns:{type:"function"},args:{a:{type:"function"},b:{type:"function"},fun:{type:"function"},fns:{type:"function",rest:!0}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","fns"]}],description:"Takes one or many function and returns a function that is the juxtaposition of those functions.\nThe returned function takes a variable number of args,\nand returns a vector containing the result of applying each function to the args (left-to-right).",seeAlso:["comp"],examples:["let { juxt } = import(functional);\njuxt(+, *, min, max)(\n 3,\n 4,\n 6,\n)",'let { juxt } = import(functional);\njuxt("a", "b")(\n {\n a: 1,\n b: 2,\n c: 3,\n d: 4\n }\n)',"let { juxt } = import(functional);\njuxt(+, *, min, max) apply range(1, 11)"]}},complement:{evaluate:([e],t)=>{const r=U(e,t);return{[u]:!0,sourceCodeInfo:t,functionType:"Complement",function:r,arity:Z(r)}},arity:re(1),docs:{category:"functional",returns:{type:"function"},args:{fun:{type:"function"}},variants:[{argumentNames:["fun"]}],description:"Takes a function $fun and returns a new function that takes the same arguments as f, has the same effects, if any, and returns the opposite truth value.",seeAlso:["comp","functional.every-pred","functional.some-pred"],examples:["let { complement } = import(functional);\ncomplement(>)(1, 3)","let { complement } = import(functional);\ncomplement(<)(1, 3)","let { complement } = import(functional);\ncomplement(+)(1, 3)","let { complement } = import(functional);\ncomplement(+)(0, 0)"]}},"every-pred":{evaluate:(e,t)=>({[u]:!0,sourceCodeInfo:t,functionType:"EveryPred",params:e,arity:{min:1,max:1}}),arity:{min:1},docs:{category:"functional",returns:{type:"function"},args:{fun:{type:"function"},fns:{type:"function",rest:!0}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","fns"]}],description:"\nTakes a number of predicates and returns a function that returns `true` if all predicates\nreturn a truthy value against all of its arguments, else it returns `false`.",seeAlso:["functional.some-pred","functional.complement","collection.every?"],examples:['let { every-pred } = import(functional);\nevery-pred(string?, -> count($) > 3)(\n "Albert",\n "Mojir"\n)','let { every-pred } = import(functional);\n(string? every-pred -> count($) > 3)(\n "Albert",\n "M"\n)'],hideOperatorForm:!0}},"some-pred":{evaluate:(e,t)=>({[u]:!0,sourceCodeInfo:t,functionType:"SomePred",params:e,arity:{min:1,max:1}}),arity:{min:1},docs:{category:"functional",returns:{type:"function"},args:{fun:{type:"function"},fns:{type:"function",rest:!0}},variants:[{argumentNames:["fun"]},{argumentNames:["fun","fns"]}],description:"Takes a number of `predicates` and returns a function that returns `true` if at least one of the `predicates` return a truthy `true` value against at least one of its arguments, else it returns `false`.",seeAlso:["functional.every-pred","functional.complement","collection.any?"],examples:['let { some-pred } = import(functional);\nsome-pred(string?, -> count($) > 3)("Albert", "Mojir")','let { some-pred } = import(functional);\nsome-pred(string?, -> count($) > 3)("a", "M")','let { some-pred } = import(functional);\nsome-pred(string?, -> count($) > 3)("a", [1, 2, 3])',"let { some-pred } = import(functional);\nsome-pred(string?, -> count($) > 3)([1, 2, 3], [2])"],hideOperatorForm:!0}},fnull:{evaluate:([e,...t],r)=>{const n=U(e,r);return{[u]:!0,sourceCodeInfo:r,functionType:"Fnull",function:n,params:t,arity:Z(n)}},arity:{min:2},docs:{category:"functional",returns:{type:"function"},args:{a:{type:"function"},b:{type:"any"},fun:{type:"function"},arg:{type:"any"},args:{type:"any",rest:!0}},variants:[{argumentNames:["fun","arg"]},{argumentNames:["fun","arg","args"]}],description:"Takes a function $fun, and returns a function that calls $fun, replacing a null argument to the corresponding argument.",seeAlso:["identity","constantly"],examples:["let { fnull } = import(functional);\nfnull(inc, 0)(1)","let { fnull } = import(functional);\nfnull(inc, 0)(null)","let { fnull } = import(functional);\n(inc fnull 0)(null)","let { fnull } = import(functional);\nfnull(+, 1, 2)(null, 0)","let { fnull } = import(functional);\nfnull(+, 1, 2)(0, null)","let { fnull } = import(functional);\nfnull(+, 1, 2)(null, null)","let { fnull } = import(functional);\nfnull(+, 1, 2)(null, null, 3, 4)"]}}},ca={name:"functional",functions:sa,source:"{}",docs:_o(sa)};function la(e,t){return{a:{type:e},b:{type:t}}}const ua={"bit-not":{evaluate:([e],t)=>(Y(e,t,{integer:!0}),~e),arity:re(1),docs:{category:"bitwise",returns:{type:"integer"},args:{a:{type:"integer"}},variants:[{argumentNames:["a"]}],description:"Returns bitwise `not` of $a.",seeAlso:["&","|","xor","bitwise.bit-and-not"],examples:["let { bit-not } = import(bitwise);\nbit-not(0)","let { bit-not } = import(bitwise);\nbit-not(255)"]}},"bit-and-not":{evaluate:([e,...t],r)=>(Y(e,r,{integer:!0}),t.reduce((e,t)=>(Y(t,r,{integer:!0}),e&~t),e)),arity:{min:2},docs:{category:"bitwise",returns:{type:"integer"},args:{...la("integer","integer"),c:{type:"integer",rest:!0}},variants:[{argumentNames:["a","b"]},{argumentNames:["a","b","c"]}],description:"Returns bitwise `and` with complement.",seeAlso:["&","|","xor","bitwise.bit-not"],examples:["let { bit-and-not } = import(bitwise);\n0b0011 bit-and-not 0b0110","let { bit-and-not } = import(bitwise);\nbit-and-not(0b0011, 0b0110)","let { bit-and-not } = import(bitwise);\nbit-and-not(0b0011, 0b0110, 0b1001)"]}},"bit-flip":{evaluate:([e,t],r)=>{Y(e,r,{integer:!0}),Y(t,r,{integer:!0,nonNegative:!0});return e^1<<t},arity:re(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...la("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Flips bit number $b.",seeAlso:["bitwise.bit-set","bitwise.bit-clear","bitwise.bit-test"],examples:["let { bit-flip } = import(bitwise);\n0b0011 bit-flip 1","let { bit-flip } = import(bitwise);\nbit-flip(0b0011, 1)","let { bit-flip } = import(bitwise);\nbit-flip(0b1100, 1)"]}},"bit-set":{evaluate:([e,t],r)=>{Y(e,r,{integer:!0}),Y(t,r,{integer:!0,nonNegative:!0});return e|1<<t},arity:re(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...la("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Sets bit number $b.",seeAlso:["bitwise.bit-flip","bitwise.bit-clear","bitwise.bit-test"],examples:["let { bit-set } = import(bitwise);\n0b0010 bit-set 1","let { bit-set } = import(bitwise);\nbit-set(0b0011, 1)","let { bit-set } = import(bitwise);\nbit-set(0b1100, 1)"]}},"bit-clear":{evaluate:([e,t],r)=>{Y(e,r,{integer:!0}),Y(t,r,{integer:!0,nonNegative:!0});return e&~(1<<t)},arity:re(2),docs:{category:"bitwise",returns:{type:"integer"},args:{...la("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Clears bit number $b.",seeAlso:["bitwise.bit-flip","bitwise.bit-set","bitwise.bit-test"],examples:["let { bit-clear } = import(bitwise);\n0b0011 bit-clear 1","let { bit-clear } = import(bitwise);\nbit-clear(0b0011, 1)","let { bit-clear } = import(bitwise);\nbit-clear(0b1100, 1)"]}},"bit-test":{evaluate:([e,t],r)=>{Y(e,r,{integer:!0}),Y(t,r,{integer:!0,nonNegative:!0});return!!(e&1<<t)},arity:re(2),docs:{category:"bitwise",returns:{type:"boolean"},args:{...la("integer","integer")},variants:[{argumentNames:["a","b"]}],description:"Checks if bit number $b is set.",seeAlso:["bitwise.bit-flip","bitwise.bit-set","bitwise.bit-clear"],examples:["let { bit-test } = import(bitwise);\n0b0011 bit-test 1","let { bit-test } = import(bitwise);\nbit-test(0b0011, 1)","let { bit-test } = import(bitwise);\nbit-test(0b1100, 1)"]}}},ma={name:"bitwise",functions:ua,source:"{}",docs:_o(ua)};const pa={baseUnit:"rad",description:"angle",units:{deg:Math.PI/180,rad:1,grad:Math.PI/200,turn:2*Math.PI}};function da(e,t){switch(e){case"c":return t;case"f":return 9*t/5+32;case"k":return t+273.15}}function ha(e,t){switch(e){case"c":return t;case"f":return 5*(t-32)/9;case"k":return t-273.15}}const ga=["c","f","k"],fa={angstrom:"ångströms",um:"micrometers",mm:"millimeters",cm:"centimeters",m:"meters",km:"kilometers",in:"inches",ft:"feet",yd:"yards",mi:"miles",nmi:"nautical miles",mg:"milligrams",g:"grams",kg:"kilograms",t:"metric tons",oz:"ounces",lb:"pounds",st:"stones",ml:"milliliters",cl:"centiliters",dl:"deciliters",l:"liters",tsp:"teaspoons",tbsp:"tablespoons","fl-oz":"fluid ounces",cup:"cups",pt:"pints",qt:"quarts",gal:"gallons",ms:"milliseconds",s:"seconds",min:"minutes",h:"hours",day:"days",week:"weeks",mm2:"square millimeters",cm2:"square centimeters",m2:"square meters",km2:"square kilometers",in2:"square inches",ft2:"square feet",yd2:"square yards",acre:"acres",hectare:"hectares","m/s":"meters per second","km/h":"kilometers per hour",mph:"miles per hour",kn:"knots","ft/s":"feet per second",b:"bytes",kb:"kilobytes",mb:"megabytes",gb:"gigabytes",tb:"terabytes",pb:"petabytes",pa:"pascals",kpa:"kilopascals",bar:"bars",atm:"atmospheres",psi:"pounds per square inch",mmhg:"millimeters of mercury",j:"joules",kj:"kilojoules",cal:"calories",kcal:"kilocalories",wh:"watt-hours",kwh:"kilowatt-hours",btu:"British thermal units",w:"watts",kw:"kilowatts",mw:"megawatts",hp:"horsepower",hz:"hertz",khz:"kilohertz",mhz:"megahertz",ghz:"gigahertz",deg:"degrees",rad:"radians",grad:"gradians",turn:"turns",c:"Celsius",f:"Fahrenheit",k:"Kelvin"};function ya(e){const t={},r=Object.keys(e.units);for(const n of r)for(const o of r){if(n===o)continue;const a=e.units[n]/e.units[o],i=`${n}->${o}`,s=fa[n],c=fa[o],l=[`convert.${o}->${n}`,...r.filter(e=>e!==n&&e!==o).map(e=>`convert.${n}->${e}`)];t[i]={evaluate:([e],t)=>(Y(e,t),e*a),arity:re(1),docs:{category:"convert",returns:{type:"number"},args:{value:{type:"number",description:`Value in ${s}`}},variants:[{argumentNames:["value"]}],description:`Converts a value from ${s} (\`${n}\`) to ${c} (\`${o}\`).`,seeAlso:l,examples:[`let { ${i} } = import(convert);\n${i}(1)`]}}}return t}const va={...ya({baseUnit:"m",description:"length",units:{angstrom:1e-10,um:1e-6,mm:.001,cm:.01,m:1,km:1e3,in:.0254,ft:.3048,yd:.9144,mi:1609.344,nmi:1852}}),...ya({baseUnit:"kg",description:"weight",units:{mg:1e-6,g:.001,kg:1,t:1e3,oz:.028349523125,lb:.45359237,st:6.35029318}}),...ya({baseUnit:"l",description:"volume",units:{ml:.001,cl:.01,dl:.1,l:1,tsp:.00492892159375,tbsp:.01478676478125,"fl-oz":.0295735295625,cup:.2365882365,pt:.473176473,qt:.946352946,gal:3.785411784}}),...ya({baseUnit:"s",description:"time",units:{ms:.001,s:1,min:60,h:3600,day:86400,week:604800}}),...ya({baseUnit:"m2",description:"area",units:{mm2:1e-6,cm2:1e-4,m2:1,km2:1e6,in2:64516e-8,ft2:.09290304,yd2:.83612736,acre:4046.8564224,hectare:1e4}}),...ya({baseUnit:"m/s",description:"speed",units:{"m/s":1,"km/h":1/3.6,mph:.44704,kn:.514444,"ft/s":.3048}}),...ya({baseUnit:"b",description:"data",units:{b:1,kb:1e3,mb:1e6,gb:1e9,tb:1e12,pb:1e15}}),...ya({baseUnit:"pa",description:"pressure",units:{pa:1,kpa:1e3,bar:1e5,atm:101325,psi:6894.757293168,mmhg:133.322387415}}),...ya({baseUnit:"j",description:"energy",units:{j:1,kj:1e3,cal:4.184,kcal:4184,wh:3600,kwh:36e5,btu:1055.06}}),...ya({baseUnit:"w",description:"power",units:{w:1,kw:1e3,mw:1e6,hp:745.7}}),...ya({baseUnit:"hz",description:"frequency",units:{hz:1,khz:1e3,mhz:1e6,ghz:1e9}}),...ya(pa),...function(){const e={};for(const t of ga)for(const r of ga){if(t===r)continue;const n=`${t}->${r}`,o=fa[t],a=fa[r],i=[`convert.${r}->${t}`,...ga.filter(e=>e!==t&&e!==r).map(e=>`convert.${t}->${e}`)];e[n]={evaluate:([e],n)=>{Y(e,n);const o=ha(t,e);return da(r,o)},arity:re(1),docs:{category:"convert",returns:{type:"number"},args:{value:{type:"number",description:`Value in ${o}`}},variants:[{argumentNames:["value"]}],description:`Converts a temperature from ${o} (\`${t}\`) to ${a} (\`${r}\`).`,seeAlso:i,examples:[`let { ${n} } = import(convert);\n${n}(100)`]}}}return e}()},ba={name:"convert",functions:va,source:"{}",docs:_o(va)};function wa(){return"undefined"!=typeof process&&"function"==typeof process.stdout?.write}function xa(e){return"string"==typeof e?e:null===e?"null":"number"==typeof e||"boolean"==typeof e?String(e):x(e)?"Builtin"===e.functionType?`<builtin function ${e.normalBuiltinSymbolType}>`:`<function ${e.n??"λ"}>`:D(e)?`<effect ${e.name}>`:P(e)?`/${e.s}/${e.f}`:"object"==typeof e&&e instanceof RegExp?`${e}`:JSON.stringify(ka(e),null,2)}function ka(e){if(e===Number.POSITIVE_INFINITY)return"∞";if(e===Number.NEGATIVE_INFINITY)return"-∞";if(x(e))return xa(e);if(D(e))return xa(e);if(P(e))return xa(e);if(Array.isArray(e))return e.map(ka);if("object"==typeof e&&null!==e){const t={};for(const[r,n]of Object.entries(e))t[r]=ka(n);return t}return e}const qa={"dvala.io.print":{handler:function(e,t){const r=e[0],n=xa(r);return wa()?process.stdout.write(n):console.log(n),{type:"Value",value:r,k:t}},arity:re(1),docs:{category:"effect",description:"Writes a value to stdout without a trailing newline. Accepts any value — strings are printed as-is, other values are auto-formatted. In Node.js uses `process.stdout.write(str)`, in browsers uses `console.log(str)`. Resumes with the original value (identity).",returns:{type:"any"},args:{value:{type:"any",description:"Value to print."}},variants:[{argumentNames:["value"]}],examples:['perform(effect(dvala.io.print), "hello")',"perform(effect(dvala.io.print), 42)"],seeAlso:["-effect-dvala.io.println","-effect-dvala.io.error","-effect-dvala.io.read-line","perform","effect"]}},"dvala.io.println":{handler:function(e,t){const r=e[0],n=xa(r);return wa()?process.stdout.write(`${n}\n`):"function"==typeof globalThis.alert?globalThis.alert(n):console.log(n),{type:"Value",value:r,k:t}},arity:re(1),docs:{category:"effect",description:'Writes a value to stdout followed by a newline. Accepts any value — strings are printed as-is, other values are auto-formatted. In Node.js uses `process.stdout.write(str + "\\n")`, in browsers uses `alert(str)`. Resumes with the original value (identity).',returns:{type:"any"},args:{value:{type:"any",description:"Value to print."}},variants:[{argumentNames:["value"]}],examples:['perform(effect(dvala.io.println), "hello")',"perform(effect(dvala.io.println), [1, 2, 3])"],seeAlso:["-effect-dvala.io.print","-effect-dvala.io.error","-effect-dvala.io.read-line","perform","effect"]}},"dvala.io.error":{handler:(e,t)=>{const r=e[0],n=xa(r);return wa()?process.stderr.write(`${n}\n`):console.error(n),{type:"Value",value:r,k:t}},arity:re(1),docs:{category:"effect",description:'Writes a value to stderr followed by a newline. Accepts any value — strings are printed as-is, other values are auto-formatted. In Node.js uses `process.stderr.write(str + "\\n")`, in browsers uses `console.error(str)`. Resumes with the original value (identity).',returns:{type:"any"},args:{value:{type:"any",description:"Value to write to stderr."}},variants:[{argumentNames:["value"]}],examples:['perform(effect(dvala.io.error), "something went wrong")'],seeAlso:["-effect-dvala.io.print","-effect-dvala.io.println","perform","effect"]}},"dvala.io.read-line":{handler:(e,t,n)=>{const o="string"==typeof e[0]?e[0]:"";if("function"==typeof globalThis.prompt){return{type:"Value",value:globalThis.prompt(o)??null,k:t}}throw new r('dvala.io.read-line is not supported in this environment. In Node.js, register a "dvala.io.read-line" host handler.',n)},arity:{min:0,max:1},docs:{category:"effect",description:"Reads one line of user input. In browsers uses `window.prompt()`. In Node.js uses `readline`. Resumes with the user's input string, or `null` on cancel.",returns:{type:["string","null"]},args:{message:{type:"string",description:"Optional prompt message to display."}},variants:[{argumentNames:[]},{argumentNames:["message"]}],examples:["effect(dvala.io.read-line)"],seeAlso:["-effect-dvala.io.read-stdin","-effect-dvala.io.print","-effect-dvala.io.println","perform","effect"]}},"dvala.io.read-stdin":{handler:(e,t,n)=>{if(!wa()||!process.stdin)throw new r("dvala.io.read-stdin is not supported in this environment. Node.js is required.",n);return new Promise((e,r)=>{const n=[];process.stdin.setEncoding("utf-8"),process.stdin.on("data",e=>n.push(e)),process.stdin.on("end",()=>e({type:"Value",value:n.join(""),k:t})),process.stdin.on("error",e=>r(e)),process.stdin.resume()})},arity:re(0),docs:{category:"effect",description:"Reads all of stdin until EOF (Node.js only). Resumes with the full stdin content as a string.",returns:{type:"string"},args:{},variants:[{argumentNames:[]}],examples:["effect(dvala.io.read-stdin)"],seeAlso:["-effect-dvala.io.read-line","perform","effect"]}},"dvala.random":{handler:(e,t)=>({type:"Value",value:Math.random(),k:t}),arity:re(0),docs:{category:"effect",description:"Returns a random floating-point number in the range [0, 1). Equivalent to `Math.random()` in JavaScript.",returns:{type:"number"},args:{},variants:[{argumentNames:[]}],examples:["perform(effect(dvala.random))"],seeAlso:["-effect-dvala.random.int","-effect-dvala.random.uuid","-effect-dvala.random.item","-effect-dvala.random.shuffle","perform","effect"]}},"dvala.random.uuid":{handler:(e,t)=>({type:"Value",value:"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),k:t}),arity:re(0),docs:{category:"effect",description:"Generates a UUID v4 string.",returns:{type:"string"},args:{},variants:[{argumentNames:[]}],examples:["perform(effect(dvala.random.uuid))"],seeAlso:["-effect-dvala.random","perform","effect"]}},"dvala.random.int":{handler:(e,t,n)=>{const o=e[0],a=e[1];if("number"!=typeof o||!Number.isInteger(o))throw new r(`dvala.random.int: min must be an integer, got ${"number"==typeof o?o:typeof o}`,n);if("number"!=typeof a||!Number.isInteger(a))throw new r(`dvala.random.int: max must be an integer, got ${"number"==typeof a?a:typeof a}`,n);if(a<=o)throw new r(`dvala.random.int: max (${a}) must be greater than min (${o})`,n);return{type:"Value",value:Math.floor(Math.random()*(a-o))+o,k:t}},arity:re(2),docs:{category:"effect",description:"Returns a random integer in the range [min, max).",returns:{type:"integer"},args:{min:{type:"integer",description:"Minimum value (inclusive)."},max:{type:"integer",description:"Maximum value (exclusive). Must be greater than min."}},variants:[{argumentNames:["min","max"]}],examples:["perform(effect(dvala.random.int), 1, 100)"],seeAlso:["-effect-dvala.random","-effect-dvala.random.item","perform","effect"]}},"dvala.random.item":{handler:(e,t,n)=>{const o=e[0];if(!Array.isArray(o))throw new r("dvala.random.item: argument must be an array, got "+typeof o,n);if(0===o.length)throw new r("dvala.random.item: cannot pick from an empty array",n);return{type:"Value",value:o[Math.floor(Math.random()*o.length)],k:t}},arity:re(1),docs:{category:"effect",description:"Picks a random element from a non-empty array.",returns:{type:"any"},args:{array:{type:"array",description:"Non-empty array to pick from."}},variants:[{argumentNames:["array"]}],examples:['perform(effect(dvala.random.item), ["a", "b", "c"])'],seeAlso:["-effect-dvala.random","-effect-dvala.random.shuffle","-effect-dvala.random.int","perform","effect"]}},"dvala.random.shuffle":{handler:(e,t,n)=>{const o=e[0];if(!Array.isArray(o))throw new r("dvala.random.shuffle: argument must be an array, got "+typeof o,n);const a=Array.from(o);for(let e=a.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),r=a[e];a[e]=a[t],a[t]=r}return{type:"Value",value:a,k:t}},arity:re(1),docs:{category:"effect",description:"Returns a new array with the elements of the input array in random order. Uses the Fisher-Yates shuffle algorithm.",returns:{type:"array"},args:{array:{type:"array",description:"Array to shuffle."}},variants:[{argumentNames:["array"]}],examples:["perform(effect(dvala.random.shuffle), [1, 2, 3, 4, 5])"],seeAlso:["-effect-dvala.random","-effect-dvala.random.item","perform","effect"]}},"dvala.time.now":{handler:(e,t)=>({type:"Value",value:Date.now(),k:t}),arity:re(0),docs:{category:"effect",description:"Returns the current timestamp in milliseconds since the Unix epoch. Equivalent to `Date.now()` in JavaScript.",returns:{type:"number"},args:{},variants:[{argumentNames:[]}],examples:["perform(effect(dvala.time.now))"],seeAlso:["-effect-dvala.time.zone","-effect-dvala.sleep","perform","effect"]}},"dvala.time.zone":{handler:(e,t)=>({type:"Value",value:Intl.DateTimeFormat().resolvedOptions().timeZone,k:t}),arity:re(0),docs:{category:"effect",description:'Returns the current IANA timezone string, e.g. `"Europe/Stockholm"` or `"America/New_York"`.',returns:{type:"string"},args:{},variants:[{argumentNames:[]}],examples:["perform(effect(dvala.time.zone))"],seeAlso:["-effect-dvala.time.now","perform","effect"]}},"dvala.checkpoint":{handler:(e,t)=>({type:"Value",value:null,k:t}),arity:{min:0,max:1},docs:{category:"effect",description:"Captures a snapshot of the current program state (continuation stack). The snapshot is stored in an in-memory list accessible via `ctx.snapshots` in host handlers. Optionally accepts a metadata value for domain context (e.g., step labels, timestamps). The standard fallback resumes with `null`, but host handlers can override the resume value. The snapshot is always captured regardless of whether a handler intercepts.",returns:{type:"null"},args:{meta:{type:"any",description:"Optional metadata to attach to the snapshot."}},variants:[{argumentNames:[]},{argumentNames:["meta"]}],examples:["perform(effect(dvala.checkpoint))",'perform(effect(dvala.checkpoint), { step: "analysis-done" })'],seeAlso:["perform","effect"]}},"dvala.sleep":{handler:(e,t,n)=>{const o=e[0];if("number"!=typeof o||o<0)throw new r(`dvala.sleep requires a non-negative number argument, got ${"number"==typeof o?o:typeof o}`,n);return new Promise(e=>{setTimeout(()=>e({type:"Value",value:null,k:t}),o)})},arity:re(1),docs:{category:"effect",description:"Waits for the specified number of milliseconds before resuming. Resumes with `null`. Only works in async execution (`run`) — `runSync` will throw when a Promise surfaces.",returns:{type:"null"},args:{ms:{type:"number",description:"The number of milliseconds to sleep. Must be a non-negative number."}},variants:[{argumentNames:["ms"]}],examples:["effect(dvala.sleep)"],seeAlso:["-effect-dvala.time.now","perform","effect"]}}};new Set(Object.keys(qa));const Aa=qa;function Na(e){const t=qa[e];if(t)return(e,r,n)=>(ee(t.arity,e.length,n),t.handler(e,r,n))}const $a={"-type-number":{datatype:!0,title:"number",category:"datatype",description:"A `number`",examples:["42","3.14"]},"-type-string":{datatype:!0,title:"string",category:"datatype",description:"A `string`",examples:['"hello"','""']},"-type-object":{datatype:!0,title:"object",category:"datatype",description:"An `object`, a collection of key-value pairs where keys are `strings`",examples:["{}","{ a: 1, b: 2}"]},"-type-array":{datatype:!0,title:"array",category:"datatype",description:"An `array`",examples:["[]","[1, 2, 3]",'["a", null, true]']},"-type-vector":{datatype:!0,title:"vector",category:"datatype",description:"An `array` of `numbers`",examples:["[]","[1, 2, 3]"]},"-type-matrix":{datatype:!0,title:"matrix",category:"datatype",description:"A `matrix`, a two-dimensional `array` with `numbers` where each row has the same number of columns. A `matrix` is also a `grid`.",examples:["[[42]]","[[1, 2], [3, 4]]","[[1, 2], [3, 4], [5, 6]]"]},"-type-grid":{datatype:!0,title:"grid",category:"datatype",description:"A `grid`, a two-dimensional `array` where each row has the same number of columns",examples:["[[]]","[[1, 2], [3, 4]]",'[["a", "b"], [3, 4], [5, 6]]']},"-type-boolean":{datatype:!0,title:"boolean",category:"datatype",description:"A `boolean`",examples:["true","false"]},"-type-function":{datatype:!0,title:"function",category:"datatype",description:"A `function`",examples:["x -> x + 1","(a, b, c) -> (a + b) * c","() -> 42","-> $1 + $2"]},"-type-integer":{datatype:!0,title:"integer",category:"datatype",description:"An `integer`",examples:["42","-42"]},"-type-any":{datatype:!0,title:"any",category:"datatype",description:"`Any` value",examples:["42",'"hello"',"true","null"]},"-type-null":{datatype:!0,title:"null",category:"datatype",description:"The value `null`",examples:["null"]},"-type-collection":{datatype:!0,title:"collection",category:"datatype",description:"A collection, an `object`, an `array` or a `string`",examples:["{ foo: 42 }","[1, 2, 3]",'"hello"']},"-type-sequence":{datatype:!0,title:"sequence",category:"datatype",description:"A sequence, an `array` or a `string`",examples:["[1, 2, 3]",'"hello"']},"-type-regexp":{datatype:!0,title:"regexp",category:"datatype",description:"A regular expression",examples:['regexp("^\\\\s*(.*)$")','#"^\\s*(.*)$"','#"albert"ig']},"-type-effect":{datatype:!0,title:"effect",category:"datatype",description:"An effect, created with the `effect` special expression. Effects are used with `perform` to trigger algebraic effects.",examples:["effect(dvala.io.println)","effect(dvala.time.now)"]},"-type-never":{datatype:!0,title:"never",category:"datatype",description:"A value that can never be created",examples:['\n// perform(effect(dvala.error), "error") will never return a value\ndo perform(effect(dvala.error), "error") with case effect(dvala.error) then (args) -> "never" end']}},Ea={"-short-regexp":{shorthand:!0,title:'#"pattern"',category:"shorthand",description:"Shorthand for `regexp(pattern)`. Only difference is that escaping is not needed.",examples:['#"^\\s*(.*)$"','#"albert"ig'],seeAlso:["regexp","re-match","replace","replace-all"]},"-short-fn":{shorthand:!0,title:"-> expression",category:"shorthand",description:"\nShorthand for `(args, ...) -> expression`.\n`$1, $2, $3, ...` are shorthand for the first, second, third, ... argument.\n\nYou can reference the first argument using either `$1` or `$`.\nHowever, please note that `$1` and `$` are mutually exclusive and cannot be used simultaneously.\nE.g. `-> $ * $1` is not valid.",examples:["-> $1 + $2","(-> $ * $)(9)"]}};function Ta(e){const t={};for(const[r,n]of Object.entries(e)){const e=n.docs;if(!e)throw new Error(`Missing docs for expression "${r}"`);t[r]={title:r,category:e.category,description:e.description,returns:e.returns,args:e.args,variants:e.variants,examples:e.examples,...e.seeAlso?{seeAlso:e.seeAlso}:{},...e.hideOperatorForm?{noOperatorDocumentation:!0}:{}}}return t}function Sa(e){const t={};for(const[r,n]of Object.entries(e.docs??{})){const o=`${e.name}.${r}`;t[o]={title:o,category:n.category,description:n.description,returns:n.returns,args:n.args,variants:n.variants,examples:n.examples,...n.seeAlso?{seeAlso:n.seeAlso}:{},...n.hideOperatorForm?{noOperatorDocumentation:!0}:{}}}return t}const za=Ta(J),ja=Ta(oe),Ia=Ta(ke),Ca=Ta(xe),Ra=Ta(et),Ma=Ta(_e),Pa=Ta(ot({},{})),Oa=Ta(Je),Da=Ta(He),Va=Ta(Ye),Ua=Ta(Xe),Fa=Ta(qe),Wa=Ta(Ze),Ga=Ta(at);const Ba=function(){const e={};for(const[t,r]of Object.entries(ar)){const n=ir[r],o=n?.docs;o&&(br(o)?e[t]={title:t,category:o.category,description:o.description,returns:o.returns,args:o.args,variants:o.variants,examples:o.examples,...o.seeAlso?{seeAlso:o.seeAlso}:{},...o.hideOperatorForm?{noOperatorDocumentation:!0}:{}}:e[t]={title:t,category:o.category,description:o.description,customVariants:o.customVariants,...o.details?{details:o.details}:{},...o.returns?{returns:o.returns}:{},examples:o.examples,...o.seeAlso?{seeAlso:o.seeAlso}:{}})}return e}();function La(e){return"returns"in e&&"args"in e&&"variants"in e&&!("effect"in e)}const _a={...za,...ja,...Ca,...Ia,...Fa,...Ma,...Ra,...Pa,...Oa,...Da,...Va,...Ua,...Wa,...Ga},Ka={...Sa(kr),...Sa($r),...Sa(un),...Sa(qn),...Sa(In),...Sa(Lo),...Sa(Yo),...Sa(ea),...Sa(na),...Sa(ia),...Sa(ca),...Sa(ma),...Sa(ba)};Object.entries(_a).forEach(([e,t])=>{if(!lt[e])throw new Error(`Missing normal expression ${e} in normalExpressions`);const r=lt[e].arity;!t.noOperatorDocumentation&&te(r)&&(t._isOperator=!0,yr(e)&&(t._prefereOperator=!0))}),Object.entries(Ba).forEach(([e,t])=>{if(La(t)){const r=ir[ar[e]]?.arity;r&&te(r)&&(t._isOperator=!0)}});const Ja=Xa({...{..._a,...Ba},...Ea,...$a});const Ha=function(){const e={};for(const[t,r]of Object.entries(Aa)){e[`-effect-${t}`]={effect:!0,title:t,category:"effect",description:r.docs.description,args:r.docs.args,returns:r.docs.returns,variants:r.docs.variants,examples:r.docs.examples,...r.docs.seeAlso?{seeAlso:r.docs.seeAlso}:{}}}return e}(),Ya=Xa({...Ja,...Ka,...Ha});function Xa(e){return Object.fromEntries(Object.entries(e).sort(([e,t],[r,n])=>{const o="special-expression"===t.category?"":t.category,a="special-expression"===n.category?"":n.category;return o!==a?o.localeCompare(a):e.localeCompare(r)}))}var Qa;function Za(e){return"object"==typeof e&&null!==e&&"string"==typeof e.program&&Array.isArray(e.fileModules)}function ei(e){return i.UserDefinedSymbol===e[0]}function ti(e,t){return function(e,t){if(!ei(e))throw y("UserDefinedSymbolNode",e,t)}(e,t),e}function ri(e){return i.NormalBuiltinSymbol===e[0]}function ni(e){return i.SpecialBuiltinSymbol===e[0]}function oi(e){return!!function(e){return e[0]===i.NormalExpression}(e)&&function(e){const t=e[0];return i.UserDefinedSymbol===t||i.NormalBuiltinSymbol===t||i.SpecialBuiltinSymbol===t}(e[1][0])}function ai(e){return e[0]===i.Spread}Object.values(Ya).forEach(e=>{e.title=e.title.replace(/"/g,""")}),Qa=_a,Object.assign(it,Qa),function(e){Object.assign(st,e)}(Ha);const ii=(e,t,r,n)=>{const o=Array.isArray(e)?e:[[i.SpecialExpression,[ar.block,e.body,void 0]]],a=new Set;for(const e of o)si(e,t,r,n)?.forEach(e=>a.add(e));return a};function si(e,t,n,o){const a=e[0];switch(a){case i.UserDefinedSymbol:{const r=e;return null===t.lookUp(r)?new Set([r[1]]):null}case i.NormalBuiltinSymbol:case i.SpecialBuiltinSymbol:case i.String:case i.Number:case i.ReservedSymbol:case i.Binding:return null;case i.NormalExpression:{const r=e,a=new Set;if(oi(r)){const[,[e]]=r;if(ei(e)){null===t.lookUp(e)&&a.add(e[1])}}else{const[,[e]]=r;si(e,t,n,o)?.forEach(e=>a.add(e))}for(const e of r[1][1])si(e,t,n,o)?.forEach(e=>a.add(e));return a}case i.SpecialExpression:{const r=e,a=r[1][0];return(0,n.specialExpressions[a].getUndefinedSymbols)(r,t,{getUndefinedSymbols:ii,builtin:n,evaluateNode:o})}case i.Spread:return si(e[1],t,n,o);default:throw new r(`Unhandled node type: ${a}`,e[2])}}function ci(e,t){return"Symbol"===e?.[0]&&(!t||e[1]===t)}function li(e,t){return function(e,t){ci(e,t)||zi("Symbol",void 0,e)}(e,t),e}function ui(e,t){return"ReservedSymbol"===e?.[0]&&(!t||e[1]===t)}function mi(e,t){ui(e,t)||zi("ReservedSymbol",t,e)}function pi(e,t){return mi(e,t),e}function di(e,t){return"Operator"===e?.[0]&&(!t||e[1]===t)}function hi(e,t){di(e,t)||zi("Operator",t,e)}function gi(e){return"Number"===e?.[0]}function fi(e){return"BasePrefixedNumber"===e?.[0]}function yi(e){return"LParen"===e?.[0]}function vi(e){yi(e)||zi("LParen",void 0,e)}function bi(e){return"RParen"===e?.[0]}function wi(e){bi(e)||zi("RParen",void 0,e)}function xi(e){return"LBracket"===e?.[0]}function ki(e){return function(e){xi(e)||zi("LBracket",void 0,e)}(e),e}function qi(e){return"RBracket"===e?.[0]}function Ai(e){qi(e)||zi("RBracket",void 0,e)}function Ni(e){return"LBrace"===e?.[0]}function $i(e){return function(e){Ni(e)||zi("LBrace",void 0,e)}(e),e}function Ei(e){return"RBrace"===e?.[0]}function Ti(e){return"string"===e?.[0]}function Si(e){return"Operator"===e?.[0]&&gr(e[1])}function zi(e,t,n){const o=n?`${n[0]} '${n[1]}'`:"end of input";throw new r(`Unexpected token: ${o}, expected ${e}${t?` '${t}'`:""}`,n?.[2])}function ji(e,t){return t&&(e[2]=t),e}function Ii(e,t){return void 0!==ar[e]&&"fn"!==e&&"defn"!==e?ji([i.SpecialBuiltinSymbol,ar[e]],t):void 0!==ut[e]?ji([i.NormalBuiltinSymbol,ut[e]],t):ji([i.UserDefinedSymbol,e],t)}function Ci(e){return e.substring(1,e.length-1).replace(/(\\{2})|(\\')|\\(.)/g,(e,t,r,n)=>t?"\\":r?"'":`\\${n}`)}const Ri=Object.entries(ut).reduce((e,[t,r])=>(e[r]=t,e),[]),Mi=Object.entries(ar).reduce((e,[t,r])=>(e[r]=t,e),[]);function Pi(e){return ei(e)?e[1]:ri(e)?Ri[e[1]]:Mi[e[1]]}function Oi(e,t,r){const n=ji([i.NormalExpression,[e,t]],r);return ri(e)&&ee(mt[e[1]].arity,n[1][1].length,r),n}function Di(e){if(e.isAtEnd())return!0;const t=e.tryPeek();return di(t)?[";",",",":"].includes(t[1]):!!ui(t)&&["else","when","while","case","let","then","end","do"].includes(t[1])}function Vi(e,t,n,o,a){const s=e[1];switch(s){case"^":case"*":case"/":case"%":case"+":case"-":case"<<":case">>":case">>>":case"++":case"<":case"<=":case"≤":case">":case">=":case"≥":case"==":case"!=":case"&":case"xor":case"|":case"|>":return Oi(t,[n,o],a);case"&&":case"||":case"??":return ji([i.SpecialExpression,[ar[s],[n,o]]],a);default:throw new r(`Unknown binary operator: ${s}`,a)}}class Ui{tokens;position;storedPosition=0;parseExpression;constructor(e){this.tokens=e.tokens,this.position=0}advance(){this.position+=1}tryPeek(){return this.tokens[this.position]}peek(){const e=this.tokens[this.position];if(!e){const e=this.tokens.at(-1),t=e?e[2]:void 0;throw new r("Unexpected end of input",t)}return e}isAtEnd(){return this.position>=this.tokens.length}peekSourceCodeInfo(){const e=this.tryPeek();return e?e[2]:this.tokens.at(-1)?.[2]}storePosition(){return this.storedPosition=this.position}restorePosition(){this.position=this.storedPosition}peekAhead(e){return this.tokens[this.position+e]}getPosition(){return this.position}getTokenAt(e){return this.tokens[e]}}function Fi(e,t){switch(e){case"^":return 12;case"*":case"/":case"%":return 11;case"+":case"-":return 10;case"<<":case">>":case">>>":return 9;case"++":return 8;case"<":case"<=":case"≤":case">":case">=":case"≥":return 7;case"==":case"!=":return 6;case"&":case"xor":case"|":return 5;case"&&":case"||":case"??":return 4;case"|>":return 2;default:throw new r(`Unknown binary operator: ${e}`,t)}}function Wi(e,t){const n=[];for(;!e.isAtEnd()&&!Gi(e,t);)di(e.tryPeek(),";")?e.advance():n.push(e.parseExpression());if(function(e,t){if(!Gi(e,t))throw new r(`Expected ${t.map(e=>e[1]).join(" or ")}`,e.peekSourceCodeInfo())}(e,t),0===n.length)throw new r("Expected expression",e.peekSourceCodeInfo());return 1===n.length?n[0]:ji([i.SpecialExpression,[ar.block,n,void 0]],e.peekSourceCodeInfo())}function Gi(e,t){for(const r of t)if(ui(e.tryPeek(),r))return!0;return!1}function Bi(e){const t=pi(e.tryPeek(),"do");e.advance();const n=[];for(;!e.isAtEnd()&&!ui(e.tryPeek(),"end")&&!ui(e.tryPeek(),"with");)if(n.push(e.parseExpression()),di(e.tryPeek(),";"))e.advance();else if(!ui(e.tryPeek(),"end")&&!ui(e.tryPeek(),"with"))throw new r("Expected end",e.peekSourceCodeInfo());let o;if(ui(e.tryPeek(),"with"))for(e.advance(),o=[];!e.isAtEnd()&&!ui(e.tryPeek(),"end");){mi(e.tryPeek(),"case"),e.advance();const t=e.parseExpression();mi(e.tryPeek(),"then"),e.advance();const r=Wi(e,["case","end"]);o.push([t,r])}return mi(e.tryPeek(),"end"),e.advance(),ji([i.SpecialExpression,[ar.block,n,o]],t[2])}function Li(e){const t=e.peek();if(e.advance(),!ci(t))throw new r(`Expected symbol token, got ${t[0]}`,t[2]);return"'"===t[1][0]?Ii(Ci(t[1]),t[2]):Ii(t[1],t[2])}function _i(e,t){e.advance();const r=t[1].substring(1,t[1].length-1).replace(/(\\{2})|(\\")|(\\n)|(\\t)|(\\r)|(\\b)|(\\f)|\\(.)/g,(e,t,r,n,o,a,i,s,c)=>t?"\\":n?"\n":o?"\t":a?"\r":i?"\b":s?"\f":r?'"':c);return ji([i.String,r],t[2])}function Ki(e){const t=e.peek();e.advance();const r=t[1],n="-"===r[0],o=(n?r.substring(1):r).replace(/_/g,"");return ji([i.Number,n?-Number(o):Number(o)],t[2])}function Ji(e,{requireDefaultValue:t,noRest:n,allowLiteralPatterns:o}={}){const a=e.tryPeek();if(o&&ui(a,"_"))return e.advance(),ji([bt,[]],a[2]);if(o&&Yi(a)){if(gi(a)||fi(a)){const t=Ki(e);return ji([vt,[t]],a[2])}if(Ti(a)){const t=_i(e,a);return ji([vt,[t]],a[2])}if(ui(a,"true")){e.advance();const t=ji([i.ReservedSymbol,"true"],a[2]);return ji([vt,[t]],a[2])}if(ui(a,"false")){e.advance();const t=ji([i.ReservedSymbol,"false"],a[2]);return ji([vt,[t]],a[2])}if(ui(a,"null")){e.advance();const t=ji([i.ReservedSymbol,"null"],a[2]);return ji([vt,[t]],a[2])}}if(ci(a)){const n=Li(e);if(!ei(n))throw new r("Expected user defined symbol",a[2]);const o=Hi(e);if(t&&!o)throw new r("Expected assignment",e.peekSourceCodeInfo());return ji([ht,[n,o]],a[2])}if(di(a,"...")){if(n)throw new r("Rest element not allowed",a[2]);e.advance();const t=ti(Li(e));if(di(e.tryPeek(),"="))throw new r("Rest argument can not have default value",e.peekSourceCodeInfo());return ji([gt,[t[1],void 0]],a[2])}if(xi(a)){e.advance();const n=[];let i=e.peek(),s=!1;for(;!qi(i);){if(s)throw new r("Rest argument must be last",i[2]);if(di(i,",")){n.push(null),e.advance(),i=e.peek();continue}const t=Ji(e,{allowLiteralPatterns:o});t[0]===gt&&(s=!0),n.push(t),i=e.peek(),qi(i)||(hi(i,","),e.advance()),i=e.peek()}e.advance();const c=Hi(e);if(t&&!c)throw new r("Expected assignment",e.peekSourceCodeInfo());return ji([yt,[n,c]],a[2])}if(Ni(a)){e.advance();const n={};let i=e.peek(),s=!1;for(;!Ei(i);){if(s)throw new r("Rest argument must be last",i[2]);di(i,"...")&&(s=!0,e.advance());const t=Li(e),c=Pi(t);if(i=e.peek(),ui(i,"as")){if(s)throw new r("Rest argument can not have alias",i[2]);e.advance();const t=ti(Li(e));if(n[t[1]])throw new r(`Duplicate binding name: ${t}`,i[2]);n[c]=ji([ht,[t,Hi(e)]],a[2])}else if(Ei(i)||di(i,",")||di(i,"=")){const o=ti(t,t[2]);if(n[o[1]])throw new r(`Duplicate binding name: ${o}`,i[2]);if(s&&di(e.tryPeek(),"="))throw new r("Rest argument can not have default value",e.peekSourceCodeInfo());n[o[1]]=ji(s?[gt,[o[1],Hi(e)]]:[ht,[o,Hi(e)]],a[2])}else if(di(i,":")){if(e.advance(),i=e.peek(),o){if(!Ni(i)&&!xi(i)&&!Yi(i))throw new r("Expected literal, object or array pattern",i[2])}else if(!Ni(i)&&!xi(i))throw new r("Expected object or array",i[2]);n[c]=Ji(e,{allowLiteralPatterns:o})}Ei(e.peek())||(hi(e.peek(),","),e.advance()),i=e.peek()}e.advance(),i=e.peek();const c=Hi(e);if(t&&!c)throw new r("Expected assignment",i[2]);return ji([ft,[n,c]],a[2])}throw new r("Expected symbol",e.peekSourceCodeInfo())}function Hi(e){if(di(e.tryPeek(),"="))return e.advance(),e.parseExpression()}function Yi(e){return gi(e)||fi(e)||Ti(e)||ui(e,"true")||ui(e,"false")||ui(e,"null")}function Xi(e,t){e.advance();const r=Ji(e,{requireDefaultValue:!0,noRest:!0}),n=r[1][1];r[1][1]=void 0;const o=ji([i.Binding,[r,n]],t[2]);return ji([i.SpecialExpression,[ar.let,o]],t[2])}function Qi(e){const t=function(e){const t=li(e.tryPeek()),r=ti(Li(e));mi(e.tryPeek(),"in"),e.advance();const n=e.parseExpression();return ji([i.Binding,[ji([ht,[r,void 0]],t[2]),n]],t[2])}(e),n=[];let o=e.peek();Zi(o,["let","when","while"]);const a=[];if("let"===o[1])for(n.push("&let");ci(o,"let");){const t=Xi(e,o),n=a.flatMap(e=>Object.keys(zt(e[1][0])));if(Object.keys(zt(t[1][1][1][0])).some(e=>n.includes(e)))throw new r("Duplicate binding",t[1][1][2]);a.push(t[1][1]),o=e.peek(),Zi(o,["let","when","while"]),o=e.peek()}let s,c;for(;ui(o,"when")||ui(o,"while");){e.advance(),"when"===o[1]?(n.push("&when"),s=e.parseExpression()):(n.push("&while"),c=e.parseExpression()),o=e.peek();Zi(o,n.includes("&when")&&n.includes("&while")?[]:n.includes("&when")?["while"]:["when"]),o=e.peek()}return Zi(o,[]),[t,a,s,c]}function Zi(e,t){if(!function(e,t){if(di(e,",")||bi(e))return!0;for(const r of t){if("let"===r&&ci(e,"let"))return!0;if(["when","while"].includes(r)&&ui(e,r))return!0}return!1}(e,t)){const n=`${[...t,","].map(e=>`"${e}"`).join(", ")} or ")"`;throw new r(`Expected symbol ${n}`,e[2])}}const es=(1+Math.sqrt(5))/2,ts={E:Math.E,"-E":-Math.E,"ε":Math.E,"-ε":-Math.E,PI:Math.PI,"-PI":-Math.PI,"π":Math.PI,"-π":-Math.PI,PHI:es,"-PHI":-es,"φ":es,"-φ":-es,POSITIVE_INFINITY:Number.POSITIVE_INFINITY,"∞":Number.POSITIVE_INFINITY,NEGATIVE_INFINITY:Number.NEGATIVE_INFINITY,"-∞":Number.NEGATIVE_INFINITY,MAX_SAFE_INTEGER:Number.MAX_SAFE_INTEGER,MIN_SAFE_INTEGER:Number.MIN_SAFE_INTEGER,MAX_VALUE:Number.MAX_VALUE,MIN_VALUE:Number.MIN_VALUE,NaN:Number.NaN},rs={true:!0,false:!1,null:null,do:null,else:null,case:null,each:null,in:null,when:null,while:null,function:null,as:null,then:null,end:null,with:null,_:null,...ts};function ns(e){const t=pi(e.tryPeek());e.advance();const r=t[1];return function(e){return e in ts}(r)?ji([i.Number,ts[r]],t[2]):ji([i.ReservedSymbol,t[1]],t[2])}const os=/^\$([1-9]\d?)?$/;function as(e){const t=e.peek();if(yi(t)&&ci(e.peekAhead(1))&&di(e.peekAhead(2),"->"))return null;try{const n=function(e){const t=e.peek();if(ci(t))return[ji([ht,[Li(e),void 0]],t[2])];vi(t),e.advance();let n=!1,o=!1;const a=[];for(;!e.isAtEnd()&&!bi(e.peek())&&!ci(e.peek(),"let");){if(n)throw new r("Rest argument must be last",e.peekSourceCodeInfo());const t=Ji(e);if(void 0!==t[1][1]&&(o=!0),t[0]===gt&&(n=!0),o&&!t[1][1])throw new r("Default arguments must be last",e.peekSourceCodeInfo());if(a.push(t),!di(e.peek(),",")&&!bi(e.peek())&&!ci(e.peek(),"let"))throw new r("Expected comma or closing parenthesis",e.peekSourceCodeInfo());di(e.peek(),",")&&e.advance()}if(!bi(e.peek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());return e.advance(),a}(e);if(!di(e.peek(),"->"))return null;let o;if(e.advance(),ui(e.peek(),"do")){const t=Bi(e),r=t[1][2];o=r&&r.length>0?[t]:t[1][1]}else o=[e.parseExpression()];return ji([i.SpecialExpression,[ar["0_lambda"],[n,o]]],t[2])}catch{return null}}function is(e,t){if(e.advance(),ni(t)&&t[1]===ar.effect)return function(e,t){const n=t[2],o=e.peek();if(!ci(o))throw new r("effect expects a dotted name identifier",o[2]);let a=o[1];e.advance();for(;di(e.tryPeek(),".");){e.advance();const t=e.peek();if(!ci(t))throw new r("Expected identifier after dot in effect name",t[2]);a+=`.${t[1]}`,e.advance()}if(!bi(e.tryPeek()))throw new r("Expected closing parenthesis after effect name",e.peekSourceCodeInfo());return e.advance(),ji([i.SpecialExpression,[ar.effect,a]],n)}(e,t);const n=[];for(;!e.isAtEnd()&&!bi(e.tryPeek());){di(e.tryPeek(),"...")?(e.advance(),n.push(ji([i.Spread,e.parseExpression()],e.peekSourceCodeInfo()))):n.push(e.parseExpression());const t=e.tryPeek();if(!di(t,",")&&!bi(t))throw new r("Expected comma or closing parenthesis",e.tryPeek()?.[2]);di(t,",")&&e.advance()}if(!bi(e.tryPeek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());if(e.advance(),!ni(t))return ri(t)||ei(t)?Oi(t,n,t[2]):ji([i.NormalExpression,[t,n]],t[2]);{const e=t[1];if(e===ar.import){if(1!==n.length)throw new r(`import expects exactly 1 argument, got ${n.length}`,t[2]);const o=n[0];if(!ei(o))throw new r("import expects a module name (symbol), got a non-symbol argument",o[2]??t[2]);const a=o[1];return ji([i.SpecialExpression,[e,a]],t[2])}const o=e;switch(ee(sr.specialExpressions[o].arity,n.length,t[2]),o){case ar["||"]:case ar["&&"]:case ar.recur:case ar.array:case ar.object:case ar["??"]:return ji([i.SpecialExpression,[o,n]],t[2]);case ar["defined?"]:{const[e]=n;return ji([i.SpecialExpression,[o,e]],t[2])}case ar.perform:{const[e,...r]=n;return ji([i.SpecialExpression,[o,e,r]],t[2])}case ar.parallel:case ar.race:return ji([i.SpecialExpression,[o,n]],t[2]);case ar["0_lambda"]:throw new r(`${o} is not allowed`,t[2]);default:throw new r(`Unknown special expression: ${o}`,t[2])}}}function ss(e){const t=$i(e.tryPeek());e.advance();const n=[];for(;!e.isAtEnd()&&!Ei(e.tryPeek());){if(di(e.tryPeek(),"..."))e.advance(),n.push(ji([i.Spread,e.parseExpression()],e.peekSourceCodeInfo()));else{const t=e.tryPeek();if(Ti(t)){const r=_i(e,t);n.push(ji([i.String,r[1]],t[2]))}else if(ci(t)){const r=t[1].startsWith("'")?Ci(t[1]):t[1];n.push(ji([i.String,r],t[2])),e.advance()}else{if(!xi(t))throw new r("Expected key to be a symbol or a string",e.peekSourceCodeInfo());e.advance(),n.push(e.parseExpression()),Ai(e.tryPeek()),e.advance()}hi(e.tryPeek(),":"),e.advance(),n.push(e.parseExpression())}const t=e.tryPeek();if(!di(t,",")&&!Ei(t))throw new r("Expected comma or closing brace",e.peekSourceCodeInfo());di(t,",")&&e.advance()}var o;return Ei(o=e.tryPeek())||zi("RBrace",void 0,o),e.advance(),ji([i.SpecialExpression,[ar.object,n]],t[2])}function cs(e){let t=function(e){const t=e.peek();if(yi(t)){e.storePosition();const t=as(e);if(t)return t;e.restorePosition(),e.advance();const n=e.parseExpression();if(!bi(e.peek()))throw new r("Expected closing parenthesis",e.peekSourceCodeInfo());return e.advance(),n}if(di(t)){const n=t[1];if(gr(n))return e.advance(),ji(void 0!==ar[n]?[i.SpecialBuiltinSymbol,ar[n]]:[i.NormalBuiltinSymbol,ut[n]],t[2]);if("->"===n)return function(e){const t=e.peek();e.advance();const n=e.getPosition();let o;if(ui(e.peek(),"do")){const t=Bi(e),r=t[1][2];o=r&&r.length>0?[t]:t[1][1]}else o=[e.parseExpression()];const a=e.getPosition()-1;let s=0,c="NOT_SET";for(let o=n;o<=a;o+=1){const n=e.getTokenAt(o);if(ci(n)){const e=os.exec(n[1]);if(e){const n=e[1]??"1";if("1"===n){if(!e[1]&&"WITH_1"===c||e[1]&&"NAKED"===c)throw new r("Please make up your mind, either use $ or $1",t[2]);c=e[1]?"WITH_1":"NAKED"}if(s=Math.max(s,Number(n)),s>20)throw new r("Can't specify more than 20 arguments",t[2])}}}const l=[];for(let e=1;e<=s;e+=1)1===e&&"NAKED"===c?l.push(ji([ht,[[i.UserDefinedSymbol,"$"],void 0]],t[2])):l.push(ji([ht,[[i.UserDefinedSymbol,`$${e}`],void 0]],t[2]));return ji([i.SpecialExpression,[ar["0_lambda"],[l,o]]],t[2])}(e);throw new r(`Illegal operator: ${n}`,t[2])}if(Ni(t))return ss(e);if(xi(t))return function(e){const t=ki(e.tryPeek());e.advance();const n=[];for(;!e.isAtEnd()&&!qi(e.tryPeek());){di(e.tryPeek(),"...")?(e.advance(),n.push(ji([i.Spread,e.parseExpression()],e.peekSourceCodeInfo()))):n.push(e.parseExpression());const t=e.tryPeek();if(!di(t,",")&&!qi(t))throw new r("Expected comma or closing parenthesis",e.peekSourceCodeInfo());di(t,",")&&e.advance()}return Ai(e.tryPeek()),e.advance(),ji([i.SpecialExpression,[ar.array,n]],t[2])}(e);const n=t[0];switch(n){case"Number":case"BasePrefixedNumber":return Ki(e);case"string":return _i(e,t);case"Symbol":{e.storePosition();const t=as(e);return t||(e.restorePosition(),Li(e))}case"ReservedSymbol":return ns(e);case"RegexpShorthand":return function(e){const t=e.peek();e.advance();const r=t[1].lastIndexOf('"'),n=t[1].substring(2,r),o=t[1].substring(r+1),a=ji([i.String,n],t[2]),s=ji([i.String,o],t[2]);return ji([i.NormalExpression,[ji([i.NormalBuiltinSymbol,ut.regexp],t[2]),[a,s]]],t[2])}(e);default:throw new r(`Unknown token type: ${n}`,t[2])}}(e),n=e.tryPeek();for(;di(n,".")||xi(n)||yi(n);)if("."===n[1]){e.advance();const o=e.tryPeek();if(!ci(o))throw new r("Expected symbol",e.peekSourceCodeInfo());t=ls(t,ji([i.String,o[1]],o[2]),n[2]),e.advance(),n=e.tryPeek()}else if(xi(n)){e.advance();const o=e.parseExpression();if(!qi(e.tryPeek()))throw new r("Expected closing bracket",e.peekSourceCodeInfo());t=ls(t,o,n[2]),e.advance(),n=e.tryPeek()}else yi(n)&&(t=is(e,t),n=e.tryPeek());return t}function ls(e,t,r){return ji([i.NormalExpression,[[i.NormalBuiltinSymbol,ut.get],[e,t]]],r)}function us(e,t=0){const n=e.tryPeek();let o;if(ci(n))switch(n[1]){case"let":return Xi(e,n);case"if":case"unless":o=function(e,t){const r="unless"===t[1];e.advance();const n=e.parseExpression();mi(e.tryPeek(),"then"),e.advance();const o=Wi(e,["else","end"]);let a;return ui(e.tryPeek(),"else")&&(e.advance(),a=Wi(e,["end"])),e.advance(),ji(r?[i.SpecialExpression,[ar.unless,[n,o,a]]]:[i.SpecialExpression,[ar.if,[n,o,a]]],t[2])}(e,n);break;case"cond":o=function(e,t){e.advance();const r=[];for(;!e.isAtEnd()&&!ui(e.tryPeek(),"end");){mi(e.tryPeek(),"case"),e.advance();const t=e.parseExpression();mi(e.tryPeek(),"then"),e.advance();const n=Wi(e,["case","end"]);if(r.push([t,n]),ui(e.tryPeek(),"end"))break}return mi(e.tryPeek()),e.advance(),ji([i.SpecialExpression,[ar.cond,r]],t[2])}(e,n);break;case"match":o=function(e,t){e.advance();const r=e.parseExpression(),n=[];for(;!e.isAtEnd()&&!ui(e.tryPeek(),"end");){mi(e.tryPeek(),"case"),e.advance();const t=Ji(e,{allowLiteralPatterns:!0});let r;ui(e.tryPeek(),"when")&&(e.advance(),r=e.parseExpression()),mi(e.tryPeek(),"then"),e.advance();const o=Wi(e,["case","end"]);if(n.push([t,o,r]),ui(e.tryPeek(),"end"))break}return mi(e.tryPeek(),"end"),e.advance(),ji([i.SpecialExpression,[ar.match,r,n]],t[2])}(e,n);break;case"for":case"doseq":o=function(e,t){const n="doseq"===t[1];e.advance(),vi(e.tryPeek()),e.advance();const o=[];for(;!e.isAtEnd()&&!bi(e.tryPeek());){const t=Qi(e),n=o.flatMap(e=>Object.keys(zt(e[0][1][0]))),a=zt(t[0][1][0]);if(Object.keys(a).some(e=>n.includes(e)))throw new r("Duplicate binding",t[0][2]);o.push(t),di(e.tryPeek(),",")&&e.advance()}wi(e.tryPeek()),e.advance(),hi(e.tryPeek(),"->"),e.advance();const a=e.parseExpression();return ji(n?[i.SpecialExpression,[ar.doseq,o,a]]:[i.SpecialExpression,[ar.for,o,a]],t[2])}(e,n);break;case"loop":o=function(e,t){e.advance(),vi(e.tryPeek()),e.advance();const n=[];let o=e.tryPeek();for(;!e.isAtEnd()&&!bi(o);){const t=Ji(e,{requireDefaultValue:!0,noRest:!0}),r=t[1][1];t[1][1]=void 0,n.push(ji([i.Binding,[t,r]],t[2])),di(e.tryPeek(),",")&&e.advance(),o=e.tryPeek()}if(0===n.length)throw new r("Expected binding",e.peekSourceCodeInfo());wi(o),e.advance(),hi(e.tryPeek(),"->"),e.advance();const a=e.parseExpression();return ji([i.SpecialExpression,[ar.loop,n,a]],t[2])}(e,n)}else ui(n,"do")&&(o=Bi(e));o||=cs(e);let a=e.tryPeek();for(;!Di(e);){if(Si(a)){const r=a[1],n=Fi(r,a[2]);if(n<=t&&(12!==n||12!==t))break;const s=ji(ar[r]?[i.SpecialBuiltinSymbol,ar[r]]:[i.NormalBuiltinSymbol,ut[r]],a[2]);e.advance();o=Vi(a,s,o,us(e,n),a[2])}else if(ci(a)){if(!dr(a[1]))break;const n=3;if(n<=t)break;const i=Li(e),s=us(e,n);if(ni(i))throw new r("Special expressions are not allowed in binary functional operators",i[2]);o=Oi(i,[o,s],a[2])}else{if("?"!==a?.[1])break;{if(1<=t)break;e.advance();const n=us(e);if(!di(e.tryPeek(),":"))throw new r("Expected :",e.peekSourceCodeInfo());e.advance();const a=us(e);o=ji([i.SpecialExpression,[ar.if,[o,n,a]]],o[2])}}a=e.tryPeek()}return o}function ms(e){e.tokens.forEach(e=>{if("Error"===e[0])throw new r(e[3],e[2])});const t=[],n=function(e){const t=new Ui(e);return t.parseExpression=(e=0)=>us(t,e),t}(e);for(;!n.isAtEnd();)if(t.push(us(n,0)),di(n.tryPeek(),";"))n.advance();else if(!n.isAtEnd())throw new r("Expected ;",n.peekSourceCodeInfo());return t}function ps(e,{removeWhiteSpace:t}){const r=e.tokens.filter(e=>!(function(e){return"SingleLineComment"===e?.[0]}(e)||function(e){return"MultiLineComment"===e?.[0]}(e)||function(e){return"Shebang"===e?.[0]}(e)||t&&function(e){return"Whitespace"===e?.[0]}(e)));return{...e,tokens:r}}const ds=["(",")","[","]","{","}","'",'"',"`",",",".",";"," ","\n","\r","\t"],hs=["0","1","2","3","4","5","6","7","8","9",...ds],gs=new Set(ds),fs=new Set(hs),ys=/\s/,vs=[0],bs=(e,t)=>{if('"'!==e[t])return vs;let r='"',n=1,o=e[t+n],a=!1;for(;o&&('"'!==o||a);)n+=1,a?(a=!1,r+=o):("\\"===o&&(a=!0),r+=o),o=e[t+n];return o?(r+='"',[n+1,["string",r]]):[n,["Error",r,void 0,`Unclosed string at position ${t}`]]};function ws(e,t,r,n){return t===r.slice(n,n+t.length)?[t.length,[e,t]]:vs}const xs=/\d/,ks=/[0-7]/,qs=/[0-9a-f]/i,As=/[01]/,Ns=/[\s)\]}(,;]/,$s=(e,t)=>{let r=e[t];if("'"===r){let n=1,o=e[t+n],a=!1;for(;"'"!==o||a;){if(void 0===o)return[n,["Error",r,void 0,`Unclosed quoted symbol at position ${t}`]];n+=1,a?(a=!1,r+=o):("\\"===o&&(a=!0),r+=o),o=e[t+n]}return r+="'",[n+1,["Symbol",r]]}if(!fs.has(r)){const n=t;let o=e[t+=1];for(;o&&!gs.has(o);)r+=o,o=e[t+=1];return r.endsWith(":")?[t-n-1,["Symbol",r.slice(0,-1)]]:[t-n,["Symbol",r]]}return vs},Es=[(e,t)=>{let r=e[t];if(!r||!ys.test(r))return vs;let n=r;for(r=e[t+=1];r&&ys.test(r);)n+=r,r=e[t+=1];return[n.length,["Whitespace",n]]},(e,t)=>{if("/"===e[t]&&"*"===e[t+1]){let r=2,n="/*";for(;("*"!==e[t+r]||"/"!==e[t+r+1])&&t+r+1<e.length;)n+=e[t+r],r+=1;return t+r+1>=e.length?[r,["Error",n,void 0,`Unclosed multi-line comment at position ${t}`]]:(n+="*/",r+=2,[r,["MultiLineComment",n]])}return vs},(e,t)=>{if("/"===e[t]&&"/"===e[t+1]){let r=2,n="//";for(;"\n"!==e[t+r]&&t+r<e.length;)n+=e[t+r],r+=1;return[r,["SingleLineComment",n]]}return vs},(e,t)=>{const r=$s(e,t);if(0===r[0]||!r[1])return vs;let n=r[1][1];n=n.startsWith("'")?n.slice(1,n.length-1):n;return void 0===rs[n]?vs:[r[0],["ReservedSymbol",n]]},(e,t)=>ws("LParen","(",e,t),(e,t)=>ws("RParen",")",e,t),(e,t)=>ws("LBracket","[",e,t),(e,t)=>ws("RBracket","]",e,t),(e,t)=>ws("LBrace","{",e,t),(e,t)=>ws("RBrace","}",e,t),bs,(e,t)=>{if("#"!==e[t])return vs;const[r,n]=bs(e,t+1);if(!n)return vs;if("Error"===n[0]){return[r+1,["Error",`#${n[1]}`,void 0,`Unclosed regexp at position ${t}`]]}t+=r+1;let o=r+1,a="";for(;"g"===e[t]||"i"===e[t];)if(a+=e[t],o+=1,t+=1,a.includes(e[t]))return[o,["Error",`#${n[1]}${a}`,void 0,`Duplicated regexp option "${e[t]}"`]];return[o,["RegexpShorthand",`#${n[1]}${a}`]]},(e,t)=>{if("0"!==e[t])return vs;const r=e[t+1],n="b"===r||"B"===r?"binary":"o"===r||"O"===r?"octal":"x"===r||"X"===r?"hex":null;if(null===n)return vs;let o;for(o=t+2;o<e.length;o+=1){const t=e[o];if("binary"===n&&!As.test(t))break;if("octal"===n&&!ks.test(t))break;if("hex"===n&&!qs.test(t))break}const a=o-t;if(a<=2)return vs;const i=e[o];return i&&!Ns.test(i)?vs:[a,["BasePrefixedNumber",e.substring(t,o)]]},(e,t)=>{let r;const n="-"===e[t],o="+"===e[t],a=n||o?t+1:t;let i=!1,s=!1;for(r=a;r<e.length;r+=1){const n=e[r];if("_"===n){if(!xs.test(e[r-1])||!xs.test(e[r+1]))return r===a?vs:[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]]}else if("."===n){if(r===a)return vs;if(i||s)return[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]];i=!0}else if("e"===n||"E"===n){if(r===a)return vs;if(s)return[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]];if("."===e[r-1]||"+"===e[r-1]||"-"===e[r-1])return[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]];"+"!==e[r+1]&&"-"!==e[r+1]||(r+=1),s=!0}else if(!xs.test(n))break}if((n||o)&&r===a)return vs;const c=r-t;if(0===c)return vs;const l=e[r];return l&&":"!==l&&!Ns.test(l)?[r-t+1,["Error",e.substring(t,r+1),void 0,`Invalid number format at position ${r+1}`]]:[c,["Number",e.substring(t,r)]]},(e,t)=>{const r=e.slice(t,t+3);if(t+2<e.length&&yr(r))return[3,["Operator",r]];const n=e.slice(t,t+2);if(t+1<e.length&&yr(n))return[2,["Operator",n]];const o=e[t]??"";return yr(o)?[1,["Operator",o]]:vs},$s];function Ts(e,t,r){let n=0;const o={tokens:[],filePath:r,hasDebugData:t};for(;n<e.length;){const a=t?Ss(e,n,r):void 0,i=zs(e,n),[s,c]=i;n+=s,c&&(a&&(c[2]=a),o.tokens.push(c))}return o}function Ss(e,t,r){const n=e.substring(0,t+1).split(/\r\n|\r|\n/),o=n[n.length-1],a=function(e,t){return e.split(/\r\n|\r|\n/)[t]}(e,n.length-1);return{code:a,position:{line:n.length,column:o.length},filePath:r}}function zs(e,t){const r=t;if(0===t){const[n,o]=((e,t)=>{if("#"===e[t]&&"!"===e[t+1]){let r=2,n="#!";for(;"\n"!==e[t+r]&&t+r<e.length;)n+=e[t+r],r+=1;return[r,["SingleLineComment",n]]}return vs})(e,t);if(t+=n,n>0)return[t-r,o]}for(const n of Es){const[o,a]=n(e,t);if(t+=o,0!==o)return[t-r,a]}return[1,["Error",e[r],void 0,"Unrecognized character"]]}function js(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function Is(e,t){if("*"===t)return!0;if(t.endsWith(".*")){const r=t.slice(0,-2);return e===r||e.startsWith(`${r}.`)}return e===t}function Cs(e,t){if(!t)return[];const r=[];for(const[n,o]of Object.entries(t))Is(e,n)&&r.push([n,o]);return r}class Rs{k;snapshots;nextSnapshotIndex;meta;effectName;effectArgs;_brand="SuspensionSignal";constructor(e,t,r,n,o,a){this.k=e,this.snapshots=t,this.nextSnapshotIndex=r,this.meta=n,this.effectName=o,this.effectArgs=a}}function Ms(e){return e instanceof Rs}class Ps{continuation;value;trimToIndex;_brand="ResumeFromSignal";constructor(e,t,r){this.continuation=e,this.value=t,this.trimToIndex=r}}function Os(e){return e instanceof Ps}const Ds=new Map;function Vs(e){let t=Ds.get(e);return t||(t={[p]:!0,name:e},Ds.set(e,t)),t}class Us{_contexts;globalContext;values;modules;valueModules;pure;constructor({contexts:e,values:t,modules:r,valueModules:n,pure:o}){this.globalContext=v(e[0]),this._contexts=e,this.values=t,this.modules=r??new Map,this.valueModules=n??new Map,this.pure=o??!1}getContextsRaw(){return this._contexts}getHostValues(){return this.values}getModuleScopeBindings(){const e=this._contexts[0],t={};for(const[r,n]of Object.entries(e))t[r]=n.value;return t}getGlobalContextIndex(){return this._contexts.indexOf(this.globalContext)}static fromDeserialized(e){const t=new Us({contexts:e.contexts,values:e.values,modules:e.modules,pure:e.pure});return e.globalContextIndex>=0&&e.globalContextIndex<e.contexts.length&&(t.globalContext=e.contexts[e.globalContextIndex]),t}setContextsFromDeserialized(e,t){this._contexts=e,t>=0&&t<e.length&&(this.globalContext=e[t])}getModule(e){return this.modules.get(e)}getValueModule(e){return this.valueModules.has(e)?{value:this.valueModules.get(e),found:!0}:{value:void 0,found:!1}}registerValueModule(e,t){this.valueModules.set(e,t)}create(e){const t=this.globalContext,r=new Us({contexts:[e,...this._contexts],values:this.values,modules:this.modules,valueModules:this.valueModules,pure:this.pure});return r.globalContext=t,r}new(e){return new Us({contexts:[{},e],modules:this.modules,valueModules:this.valueModules,pure:this.pure})}addValues(e,t){const n=this._contexts[0];for(const[o,a]of Object.entries(e)){if(n[o])throw new r(`Cannot redefine value "${o}"`,t);const e=Fs(o);if(e)throw new r(`Cannot shadow ${e}`,t);n[o]={value:le(a)}}}getValue(e){for(const t of this._contexts){const r=t[e];if(r)return r.value}return this.values?.[e]}lookUp(e){const t=e[1];for(const e of this._contexts){const r=e[t];if(r)return r}const r=this.values?.[t];return void 0!==r?{value:le(r)}:null}evaluateSymbol(e){if(ni(e)){const t=e[1];switch(t){case ar["&&"]:case ar["||"]:case ar.array:case ar.object:case ar["defined?"]:case ar.recur:case ar["??"]:{const r=v(sr.specialExpressions[t],e[2]);return{[u]:!0,functionType:"SpecialBuiltin",specialBuiltinSymbolType:t,sourceCodeInfo:e[2],arity:r.arity}}default:throw new r(`Unknown special builtin symbol type: ${t}`,e[2])}}if(ri(e)){const t=e[1],r=mt[t],n=r.name;return{[u]:!0,functionType:"Builtin",normalBuiltinSymbolType:t,sourceCodeInfo:e[2],arity:r.arity,name:n}}const t=this.lookUp(e);if(w(n=t)&&void 0!==n.value)return t.value;var n;throw new a(e[1],e[2])}}function Fs(e){return lr.includes(e)?`special expression "${e}"`:cr.includes(e)?`builtin function "${e}"`:"self"===e?`builtin value "${e}"`:null}function Ws(e){const t=Fs(e);if(t)throw new r(`Cannot shadow ${t}`,void 0)}function Gs(e={},t,n){const o=e.globalContext??{},a=e.contexts?[o,...e.contexts]:[o];let i;if(e.bindings)for(const[t,n]of Object.entries(e.bindings)){if(t.includes("."))throw new r(`Dots are not allowed in binding keys: "${t}"`,void 0);Ws(t),i||(i={}),i[t]=n}const s=new Us({contexts:a,values:i,modules:t,pure:n});return e.globalModuleScope?s:s.create({})}function Bs(e,t){return Math.imul(e^255&t,16777619)}function Ls(e,t){return e=Bs(e,t),e=Bs(e,t>>>8),e=Bs(e,t>>>16),e=Bs(e,t>>>24)}function _s(e,t){for(let r=0;r<t.length;r++){const n=t.charCodeAt(r);e=Bs(e,n),e=Bs(e,n>>>8)}return e}function Ks(e){let t=2166136261;if(null===e)return t=Bs(t,0),t>>>0;if(void 0===e)return t=Bs(t,7),t>>>0;const r=typeof e;if("boolean"===r)return t=Bs(t,e?1:2),t>>>0;if("number"===r)return t=Bs(t,3),t=_s(t,Object.is(e,-0)?"-0":String(e)),t>>>0;if("string"===r)return t=Bs(t,4),t=_s(t,e),t>>>0;if(Array.isArray(e)){t=Bs(t,5),t=Ls(t,e.length);for(let r=0;r<e.length;r++)t=Ls(t,Ks(e[r]));return t>>>0}t=Bs(t,6);const n=Object.keys(e).sort();t=Ls(t,n.length);for(const r of n)t=_s(t,r),t=Ls(t,Ks(e[r]));return t>>>0}function Js(e,t){if(e===t)return!0;if(null===e||null===t)return!1;if(typeof e!=typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Js(e[r],t[r]))return!1;return!0}if("object"!=typeof e)return!1;const r=e,n=t,o=Object.keys(r),a=Object.keys(n);if(o.length!==a.length)return!1;for(const e of o){if(!(e in n))return!1;if(!Js(r[e],n[e]))return!1}return!0}function Hs(e){if(null===e)return 4;if(void 0===e)return 9;const t=typeof e;if("boolean"===t)return e?4:5;if("number"===t)return String(e).length;if("string"===t)return e.length+2;if(Array.isArray(e)){let t=2;for(let r=0;r<e.length;r++)t+=Hs(e[r])+1;return t}const r=e,n=Object.keys(r);let o=2;for(const e of n)o+=e.length+2+1+Hs(r[e])+1;return o}function Ys(e,t,r,n){if(null===e||"object"!=typeof e)return Ks(e);if(Array.isArray(e))for(let r=0;r<e.length;r++)Ys(e[r],t,{parent:e,key:r});else{const r=e;for(const e of Object.keys(r))Ys(r[e],t,{parent:r,key:e})}const o=Ks(e),a=Hs(e);if(r&&a>=1){let n,i=t.get(o);i||(i=[],t.set(o,i));for(const t of i)if(Js(t.value,e)){n=t;break}n?n.locations.push(r):i.push({hash:o,value:Qs(e),size:a,locations:[r]})}return o}function Xs(e,t){if(null===e||"object"!=typeof e)return e;if(function(e){return null!==e&&"object"==typeof e&&"__poolRef"in e&&"number"==typeof e.__poolRef&&1===Object.keys(e).length}(e)){const r=e.__poolRef;if(!(r in t))throw new Error(`Unknown pool ref: ${r}`);return Xs(t[r],t)}if(Array.isArray(e))return e.map(e=>Xs(e,t));const r=e,n={};for(const e of Object.keys(r))n[e]=Xs(r[e],t);return n}function Qs(e){if(null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map(e=>Qs(e));const t=e,r={};for(const e of Object.keys(t))r[e]=Qs(t[e]);return r}function Zs(e,t){const r=new Map;let n=0;function o(e){if(e instanceof Us){if(r.has(e))return;r.set(e,n++);for(const t of e.getContextsRaw())for(const e of Object.values(t))o(e.value)}else if(Array.isArray(e))for(const t of e)o(t);else if(null!==e&&"object"==typeof e)for(const t of Object.values(e))o(t)}function a(e,t){if(e instanceof Us)return{__csRef:r.get(e)};if(Array.isArray(e))return e.map((e,t)=>a(e));if(null!==e&&"object"==typeof e){const t={};for(const[r,n]of Object.entries(e))t[r]=a(n);return t}return e}o(e),void 0!==t&&o(t);const i=Array.from(r.entries()).map(([e,t])=>({id:t,contexts:e.getContextsRaw().map((e,t)=>{const r={};for(const[t,n]of Object.entries(e))r[t]={value:a(n.value)};return r}),globalContextIndex:e.getGlobalContextIndex(),pure:e.pure})),s=a(e),c=void 0!==t?a(t):void 0;return{version:2,contextStacks:i,k:s,...void 0!==c?{meta:c}:{}}}function ec(e,t,r,n){const o=Zs(e,n);t.length>0&&(o.snapshots=t),o.nextSnapshotIndex=r;const a=[o.contextStacks,o.k];if(void 0!==o.meta&&a.push(o.meta),o.snapshots)for(const e of o.snapshots)a.push(e);const{roots:i,pool:s}=function(e,t=200){const r=e.map(e=>Qs(e)),n=new Map;for(let e=0;e<r.length;e++)Ys(r[e],n,null);const o={};let a=0;const i=Array.from(n.values()).flat().filter(e=>e.locations.length>1&&e.size>=t).sort((e,t)=>t.size-e.size),s=new Map;for(const e of i){if(s.has(e))continue;const t=a++;o[t]=e.value,s.set(e,t);for(const r of e.locations)Array.isArray(r.parent),r.parent[r.key]={__poolRef:t}}return{roots:r,pool:o}}(a,200);let c=0;if(o.contextStacks=i[c++],o.k=i[c++],void 0!==o.meta&&(o.meta=i[c++]),o.snapshots)for(let e=0;e<o.snapshots.length;e++)o.snapshots[e]=i[c++];return Object.keys(s).length>0&&(o.pool=s),o}function tc(e,t){let n=e;if(2!==n.version)throw new r(`Unsupported suspension blob version: ${n.version} (expected 2)`,void 0);if(n.pool&&Object.keys(n.pool).length>0){const e=n.pool;n={...n,contextStacks:Xs(n.contextStacks,e),k:Xs(n.k,e),...void 0!==n.meta?{meta:Xs(n.meta,e)}:{},...n.snapshots?{snapshots:n.snapshots.map(t=>Xs(t,e))}:{}},delete n.pool}const o=new Map;for(const e of n.contextStacks){const r=e.contexts.map(()=>({})),n=Us.fromDeserialized({contexts:r,globalContextIndex:e.globalContextIndex,values:t?.values,modules:t?.modules,pure:e.pure});o.set(e.id,n)}function a(e){if(function(e){return null!==e&&"object"==typeof e&&"__csRef"in e&&"number"==typeof e.__csRef}(e)){const t=o.get(e.__csRef);if(!t)throw new r(`Invalid suspension blob: unknown context stack ref ${e.__csRef}`,void 0);return t}if(Array.isArray(e))return e.map(a);if(null!==e&&"object"==typeof e){const t={};for(const[r,n]of Object.entries(e))t[r]=a(n);return t}return e}for(const e of n.contextStacks){const t=o.get(e.id),r=e.contexts.map(e=>{const t=e,r={};for(const[e,n]of Object.entries(t))r[e]={value:a(n.value)};return r});t.setContextsFromDeserialized(r,e.globalContextIndex)}return{k:a(n.k),meta:void 0!==n.meta?a(n.meta):void 0,snapshots:n.snapshots??[],nextSnapshotIndex:n.nextSnapshotIndex??0}}function rc(e,t){switch(e[0]){case i.Number:case i.String:return e[1];case i.NormalBuiltinSymbol:case i.SpecialBuiltinSymbol:case i.UserDefinedSymbol:return t.evaluateSymbol(e);case i.ReservedSymbol:return uc(e);case i.NormalExpression:{const n=function(e,t){const n=e[2];return wt(function(e,t){const n=[],o=[],a=At(e,(e,a)=>ai(e)?wt(rc(e[1],t),t=>{if(!Array.isArray(t))throw new r(`Spread operator requires an array, got ${g(e)}`,e[2]);n.push(...t)}):e[0]!==i.ReservedSymbol||"_"!==e[1]?wt(rc(e,t),e=>{n.push(e)}):void o.push(a));return wt(a,()=>({params:n,placeholders:o}))}(e[1][1],t),({params:o,placeholders:i})=>{if(oi(e)){const s=e[1][0];if(i.length>0){return wt(rc(s,t),e=>({[u]:!0,function:U(e,n),functionType:"Partial",params:o,placeholders:i,sourceCodeInfo:n,arity:re(i.length)}))}if(ri(s)){const n=s[1],a=sr.allNormalExpressions[n];if(t.pure&&!1===a.pure)throw new r(`Cannot call impure function '${a.name}' in pure mode`,e[2]);return a.dvalaImpl?ac(a.dvalaImpl,o,t,e[2]):a.evaluate(o,e[2],t,{executeFunction:nc})}{const r=t.getValue(s[1]);if(void 0!==r)return nc(U(r,n),o,t,n);throw new a(s[1],e[2])}}return wt(rc(e[1][0],t),e=>{const r=U(e,n);if(i.length>0){return{[u]:!0,function:r,functionType:"Partial",params:o,placeholders:i,sourceCodeInfo:n,arity:re(i.length)}}return nc(r,o,t,n)})})}(e,t);return wt(n,t=>{if("number"==typeof t&&Number.isNaN(t))throw new r("Number is NaN",e[2]);return je(t)})}case i.SpecialExpression:{const n={type:"Eval",node:e,env:t,k:[]};try{return je(Rc(n))}catch(n){if(n instanceof r&&n.message.includes("Unexpected async operation")){return Mc({type:"Eval",node:e,env:t,k:[]}).then(e=>je(e))}throw n}}default:throw new r(`${c(e[0])}-node cannot be evaluated`,e[2])}}function nc(e,t,n,o){if(x(e))return oc(e,t,n,o);if(Array.isArray(e))return sc(e,t,o);if(j(e))return ic(e,t,o);if("string"==typeof e)return cc(e,t,o);if(H(e))return lc(e,t,o);throw new r("Unexpected function type",o)}function oc(e,t,n,o){switch(e.functionType){case"UserDefined":return ac(e,t,n,o);case"Partial":return function(e,t,n,o){const a=[...e.params];if(t.length!==e.placeholders.length)throw new r(`(partial) expects ${e.placeholders.length} arguments, got ${t.length}.`,o);const i=[...t];for(const t of e.placeholders)a.splice(t,0,i.shift());return nc(e.function,a,n,o)}(e,t,n,o);case"Comp":return function(e,t,n,o){const{params:a}=e;if(0===a.length){if(1!==t.length)throw new r(`(comp) expects one argument, got ${g(t.length)}.`,o);return $(t[0],o)}let i=t;for(let e=a.length-1;e>=0;e--){const t=a[e];i=wt(i,e=>wt(nc(U(t,o),e,n,o),e=>[e]))}return wt(i,e=>$(e[0],o))}(e,t,n,o);case"Constantly":return e.value;case"Juxt":return function(e,t,r,n){return function(e,t){const r=[];for(let n=0;n<e.length;n++){const o=t(e[n],n);if(o instanceof Promise)return xt(o,r,e,t,n);r.push(o)}return r}(e.params,e=>nc(U(e,n),t,r,n))}(e,t,n,o);case"Complement":return wt(nc(e.function,t,n,o),e=>!e);case"EveryPred":return function(e,t,r,n){const o=[];for(const a of e.params)for(const e of t)o.push(()=>nc(U(a,n),[e],r,n));return kt(o,(e,t)=>!!e&&wt(t(),e=>!!e),!0)}(e,t,n,o);case"SomePred":return function(e,t,r,n){const o=[];for(const a of e.params)for(const e of t)o.push(()=>nc(U(a,n),[e],r,n));return kt(o,(e,t)=>!!e||wt(t(),e=>!!e),!1)}(e,t,n,o);case"Fnull":return function(e,t,r,n){const o=t.map((t,r)=>null===t?le(e.params[r]):t);return nc(U(e.function,n),o,r,n)}(e,t,n,o);case"EffectMatcher":return function(e,t,r){ee({min:1,max:1},t.length,e.sourceCodeInfo??r);const n=t[0];V(n,r);const o=n.name;if("string"===e.matchType)return Is(o,e.pattern);const a=new RegExp(e.pattern,e.flags);return a.test(o)}(e,t,o);case"Builtin":{const a=sr.allNormalExpressions[e.normalBuiltinSymbolType];return a.dvalaImpl?ac(a.dvalaImpl,t,n,o):function(e,t,n,o){const a=v(sr.allNormalExpressions[e.normalBuiltinSymbolType],o);if(n.pure&&!1===a.pure)throw new r(`Cannot call impure function '${e.name}' in pure mode`,o);if(a.dvalaImpl)return ac(a.dvalaImpl,t,n,o);return a.evaluate(t,o,n,{executeFunction:nc})}(e,t,n,o)}case"SpecialBuiltin":return function(e,t,n,o){const a=v(sr.specialExpressions[e.specialBuiltinSymbolType],o);if(a.evaluateAsNormalExpression)return a.evaluateAsNormalExpression(t,o,n,{executeFunction:nc});throw new r(`Special builtin function ${e.specialBuiltinSymbolType} is not supported as normal expression.`,o)}(e,t,n,o);case"Module":return function(e,t,n,o){const a=n.getModule(e.moduleName);if(!a)throw new r(`Module '${e.moduleName}' not found.`,o);const i=a.functions[e.functionName];if(!i)throw new r(`Function '${e.functionName}' not found in module '${e.moduleName}'.`,o);if(n.pure&&!1===i.pure)throw new r(`Cannot call impure function '${e.functionName}' in pure mode`,o);if(ee(i.arity,t.length,o),i.dvalaImpl)return ac(i.dvalaImpl,t,n,o);return i.evaluate(t,o,n,{executeFunction:nc})}(e,t,n,o)}}function ac(e,n,o,a){function i(n){if(!Q(e.arity,n.length))throw new r(`Expected ${e.arity} arguments, got ${n.length}.`,a);const s=e.evaluatedfunction,c=s[0],l=c.filter(e=>e[0]!==gt).length,u=o.create(e.evaluatedfunction[2]),m={self:{value:e}},p=[];let d,h;for(let e=0;e<n.length;e+=1)if(e<l){const t=e;d=wt(d,()=>{const e=le(n[t]);return wt(Tt(c[t],e,e=>rc(e,u.create(m))),e=>{Object.entries(e).forEach(([e,t])=>{m[e]={value:t}})})})}else p.push(le(n[e]));for(let e=n.length;e<l;e++){const t=e;h=wt(h,()=>{const e=c[t];return wt(rc(e[1][1],o.create(m)),t=>wt(Tt(e,t,e=>rc(e,o.create(m))),e=>{Object.entries(e).forEach(([e,t])=>{m[e]={value:t}})}))})}return wt(d,()=>wt(h,()=>{const e=c.find(e=>e[0]===gt),r=void 0!==e?wt(Tt(e,p,e=>rc(e,o.create(m))),e=>{Object.entries(e).forEach(([e,t])=>{m[e]={value:t}})}):void 0;return wt(r,()=>{const e=u.create(m),r=kt(s[1],(t,r)=>rc(r,e),null);return r instanceof Promise?r.catch(e=>{if(e instanceof t)return i(e.params);throw e}):r})}))}for(;;)try{return i(n)}catch(e){if(e instanceof t){n=e.params;continue}throw e}}function ic(e,t,n){if(1!==t.length)throw new r("Object as function requires one string parameter.",n);const o=t[0];return G(o,n),le(e[o])}function sc(e,t,n){if(1!==t.length)throw new r("Array as function requires one non negative integer parameter.",n);const o=t[0];return Y(o,n,{integer:!0,nonNegative:!0}),le(e[o])}function cc(e,t,n){if(1!==t.length)throw new r("String as function requires one Obj parameter.",n);const o=le(t[0]);if(j(o))return le(o[e]);if(H(o,{integer:!0}))return le(e[o]);throw new r(`string as function expects Obj or integer parameter, got ${g(o)}`,n)}function lc(e,t,n){if(Y(e,void 0,{integer:!0}),1!==t.length)throw new r("Number as function requires one Arr parameter.",n);const o=t[0];return z(o,n),le(o[e])}function uc(e){const t=e[1];if(!["true","false","null"].includes(t))throw new r(`Reserved symbol ${t} cannot be evaluated`,e[2]);return v(rs[t],e[2])}function mc(e,t,n){switch(e[0]){case i.Number:case i.String:return{type:"Value",value:e[1],k:n};case i.NormalBuiltinSymbol:case i.SpecialBuiltinSymbol:case i.UserDefinedSymbol:return{type:"Value",value:t.evaluateSymbol(e),k:n};case i.ReservedSymbol:return{type:"Value",value:uc(e),k:n};case i.NormalExpression:return function(e,t,r){const n=e[1][1],o=e[2],a={type:"NanCheck",sourceCodeInfo:o},s={type:"EvalArgs",node:e,index:0,params:[],placeholders:[],env:t,sourceCodeInfo:o};let c=0;for(;c<n.length;){const e=n[c];if(e[0]!==i.ReservedSymbol||"_"!==e[1])break;s.placeholders.push(s.params.length),c++}if(s.index=c,c>=n.length)return pc(s,[a,...r]);const l=n[c],u=[s,a,...r];if(ai(l))return{type:"Eval",node:l[1],env:t,k:u};return{type:"Eval",node:l,env:t,k:u}}(e,t,n);case i.SpecialExpression:return function(e,t,n){const o=e[2],a=e[1][0];switch(a){case ar.if:case ar.unless:{const[r,i,s]=e[1][1];return{type:"Eval",node:r,env:t,k:[{type:"IfBranch",thenNode:i,elseNode:s,inverted:a===ar.unless,env:t,sourceCodeInfo:o},...n]}}case ar["&&"]:{const r=e[1][1];if(0===r.length)return{type:"Value",value:!0,k:n};const a={type:"And",nodes:r,index:1,env:t,sourceCodeInfo:o};return 1===r.length?{type:"Eval",node:r[0],env:t,k:n}:{type:"Eval",node:r[0],env:t,k:[a,...n]}}case ar["||"]:{const r=e[1][1];if(0===r.length)return{type:"Value",value:!1,k:n};const a={type:"Or",nodes:r,index:1,env:t,sourceCodeInfo:o};return 1===r.length?{type:"Eval",node:r[0],env:t,k:n}:{type:"Eval",node:r[0],env:t,k:[a,...n]}}case ar["??"]:{const r=e[1][1];if(0===r.length)return{type:"Value",value:null,k:n};const a=r[0];if(ei(a)&&null===t.lookUp(a)){if(1===r.length)return{type:"Value",value:null,k:n};const e={type:"Qq",nodes:r,index:2,env:t,sourceCodeInfo:o},a=r[1];return ei(a)&&null===t.lookUp(a)?function(e,t){return yc(e,t)}(e,n):2===r.length?{type:"Eval",node:a,env:t,k:n}:{type:"Eval",node:a,env:t,k:[e,...n]}}const i={type:"Qq",nodes:r,index:1,env:t,sourceCodeInfo:o};return 1===r.length?{type:"Eval",node:a,env:t,k:n}:{type:"Eval",node:a,env:t,k:[i,...n]}}case ar.cond:{const r=e[1][1];if(0===r.length)return{type:"Value",value:null,k:n};const a={type:"Cond",phase:"test",cases:r,index:0,env:t,sourceCodeInfo:o};return{type:"Eval",node:r[0][0],env:t,k:[a,...n]}}case ar.match:{const r=e[1][1],a=e[1][2];return{type:"Eval",node:r,env:t,k:[{type:"Match",phase:"matchValue",matchValue:null,cases:a,index:0,bindings:{},env:t,sourceCodeInfo:o},...n]}}case ar.block:{const r=e[1][1],a=e[1][2],i={},s=t.create(i);let c=n;if(a&&a.length>0){c=[{type:"TryWith",handlers:a.map(([e,r])=>({effectRef:rc(e,t),handlerNode:r})),env:t,sourceCodeInfo:o},...n]}if(0===r.length)return{type:"Value",value:null,k:c};if(1===r.length)return{type:"Eval",node:r[0],env:s,k:c};const l={type:"Sequence",nodes:r,index:1,env:s,sourceCodeInfo:o};return{type:"Eval",node:r[0],env:s,k:[l,...c]}}case ar.let:{const r=e[1][1],a=r[1][0];return{type:"Eval",node:r[1][1],env:t,k:[{type:"LetBind",target:a,env:t,sourceCodeInfo:o},...n]}}case ar.loop:{const r=e[1][1],a=e[1][2];if(0===r.length){const e={},i={type:"LoopIterate",bindingNodes:r,bindingContext:e,body:a,env:t.create(e),sourceCodeInfo:o};return{type:"Eval",node:a,env:t.create(e),k:[i,...n]}}const i={type:"LoopBind",phase:"value",bindingNodes:r,index:0,context:{},body:a,env:t,sourceCodeInfo:o};return{type:"Eval",node:r[0][1][1],env:t,k:[i,...n]}}case ar.for:case ar.doseq:{const r=e[1][1],i=e[1][2],s=a===ar.for;if(0===r.length)return{type:"Value",value:s?[]:null,k:n};const c={},l=t.create(c),u={type:"ForLoop",returnResult:s,bindingNodes:r,body:i,result:[],phase:"evalCollection",bindingLevel:0,levelStates:[],context:c,env:l,sourceCodeInfo:o};return{type:"Eval",node:r[0][0][1][1],env:l,k:[u,...n]}}case ar.recur:{const r=e[1][1];if(0===r.length)return Ac([],n,o);const a={type:"Recur",nodes:r,index:1,params:[],env:t,sourceCodeInfo:o};if(1===r.length){const e={...a,index:1};return{type:"Eval",node:r[0],env:t,k:[e,...n]}}return{type:"Eval",node:r[0],env:t,k:[a,...n]}}case ar.array:{const r=e[1][1];if(0===r.length)return{type:"Value",value:[],k:n};const a=r[0],i=ai(a),s={type:"ArrayBuild",nodes:r,index:0,result:[],isSpread:i,env:t,sourceCodeInfo:o};return{type:"Eval",node:i?a[1]:a,env:t,k:[s,...n]}}case ar.object:{const r=e[1][1];if(0===r.length)return{type:"Value",value:{},k:n};const a=r[0],i=ai(a),s={type:"ObjectBuild",nodes:r,index:0,result:{},currentKey:null,isSpread:i,env:t,sourceCodeInfo:o};return{type:"Eval",node:i?a[1]:a,env:t,k:[s,...n]}}case ar["0_lambda"]:{const r=function(e,t){const r={},n=e[0].reduce((e,t)=>(Object.keys(zt(t)).forEach(t=>{e[t]={value:null}}),e),{});return ii(e[1],t.new(n),sr,rc).forEach(e=>{const n=t.getValue(e);N(n)&&(r[e]={value:n})}),[e[0],e[1],r]}(e[1][1],t),o=r[0].filter(e=>e[0]!==gt&&void 0===e[1][1]).length,a={min:o>0?o:void 0,max:r[0].some(e=>e[0]===gt)?void 0:r[0].length};return{type:"Value",value:{[u]:!0,sourceCodeInfo:e[2],functionType:"UserDefined",name:void 0,evaluatedfunction:r,arity:a,docString:""},k:n}}case ar["defined?"]:{const r=e[1][1];if(!ei(r))return{type:"Value",value:!0,k:n};return{type:"Value",value:null!==t.lookUp(r),k:n}}case ar.import:{const a=e[1][1],i=t.getValueModule(a);if(i.found)return{type:"Value",value:i.value,k:n};const s=t.getModule(a);if(!s)throw new r(`Unknown module: '${a}'`,o);const c={};for(const[e,t]of Object.entries(s.functions))c[e]={[u]:!0,sourceCodeInfo:o,functionType:"Module",moduleName:a,functionName:e,arity:t.arity};if(s.source){const e=ms(ps(Ts(s.source,!1,void 0),{removeWhiteSpace:!0})),r=t.create({}),i={type:"ImportMerge",tsFunctions:c,moduleName:a,module:s,env:t,sourceCodeInfo:o};if(1===e.length)return{type:"Eval",node:e[0],env:r,k:[i,...n]};const l={type:"Sequence",nodes:e,index:1,env:r};return{type:"Eval",node:e[0],env:r,k:[l,i,...n]}}return t.registerValueModule(a,c),{type:"Value",value:c,k:n}}case ar.effect:return{type:"Value",value:Vs(e[1][1]),k:n};case ar.perform:{const r=[e[1][1],...e[1][2]];if(1===r.length){const e={type:"PerformArgs",argNodes:r,index:1,params:[],env:t,sourceCodeInfo:o};return{type:"Eval",node:r[0],env:t,k:[e,...n]}}const a={type:"PerformArgs",argNodes:r,index:1,params:[],env:t,sourceCodeInfo:o};return{type:"Eval",node:r[0],env:t,k:[a,...n]}}case ar.parallel:return{type:"Parallel",branches:e[1][1],env:t,k:n};case ar.race:return{type:"Race",branches:e[1][1],env:t,k:n};default:throw new r(`Unknown special expression type: ${a}`,o)}}(e,t,n);default:throw new r(`${c(e[0])}-node cannot be evaluated`,e[2])}}function pc(e,t){const{node:n,params:o,placeholders:i,env:s,sourceCodeInfo:c}=e;if(oi(n)){const e=n[1][0];if(i.length>0){const r=s.evaluateSymbol(e);return{type:"Value",value:{[u]:!0,function:U(r,c),functionType:"Partial",params:o,placeholders:i,sourceCodeInfo:c,arity:re(i.length)},k:t}}if(ri(e)){const n=e[1],a=sr.allNormalExpressions[n];if(s.pure&&!1===a.pure)throw new r(`Cannot call impure function '${a.name}' in pure mode`,c);if(a.dvalaImpl)return hc(a.dvalaImpl,o,s,c,t);return Ic(a.evaluate(o,c,s,{executeFunction:nc}),t)}const l=s.getValue(e[1]);if(void 0!==l)return dc(U(l,c),o,i,s,c,t);throw new a(e[1],c)}return{type:"Eval",node:n[1][0],env:s,k:[{type:"CallFn",params:o,placeholders:i,env:s,sourceCodeInfo:c},...t]}}function dc(e,t,n,o,a,i){if(n.length>0){return{type:"Value",value:{[u]:!0,function:e,functionType:"Partial",params:t,placeholders:n,sourceCodeInfo:a,arity:re(n.length)},k:i}}if(x(e))return function(e,t,r,n,o){switch(e.functionType){case"UserDefined":return hc(e,t,r,n,o);case"Partial":case"Comp":case"Constantly":case"Juxt":case"Complement":case"EveryPred":case"SomePred":case"Fnull":case"EffectMatcher":case"SpecialBuiltin":return Ic(oc(e,t,r,n),o);case"Module":{const a=r.getModule(e.moduleName),i=a?.functions[e.functionName];if(i?.dvalaImpl)return ee(i.arity,t.length,n),hc(i.dvalaImpl,t,r,n,o);return Ic(oc(e,t,r,n),o)}case"Builtin":{const a=sr.allNormalExpressions[e.normalBuiltinSymbolType];if(a.dvalaImpl)return hc(a.dvalaImpl,t,r,n,o);return Ic(oc(e,t,r,n),o)}}}(e,t,o,a,i);if(Array.isArray(e))return{type:"Value",value:sc(e,t,a),k:i};if(j(e))return{type:"Value",value:ic(e,t,a),k:i};if("string"==typeof e)return{type:"Value",value:cc(e,t,a),k:i};if(H(e))return{type:"Value",value:lc(e,t,a),k:i};throw new r("Unexpected function type",a)}function hc(e,t,n,o,a){if(!Q(e.arity,t.length))throw new r(`Expected ${e.arity} arguments, got ${t.length}.`,o);const i=e.evaluatedfunction,s=i[0],c=s.filter(e=>e[0]!==gt).length,l=n.create(e.evaluatedfunction[2]),u={self:{value:e}},m=[];for(let r=0;r<t.length;r+=1)if(r<c){const i=le(t[r]),c=Tt(s[r],i,e=>rc(e,l.create(u)));if(c instanceof Promise){return Ic(ac(e,t,n,o),a)}Object.entries(c).forEach(([e,t])=>{u[e]={value:t}})}else m.push(le(t[r]));for(let r=t.length;r<c;r++){const i=s[r],c=rc(i[1][1],l.create(u));if(c instanceof Promise){return Ic(ac(e,t,n,o),a)}const m=Tt(i,c,e=>rc(e,l.create(u)));if(m instanceof Promise){return Ic(ac(e,t,n,o),a)}Object.entries(m).forEach(([e,t])=>{u[e]={value:t}})}const p=s.find(e=>e[0]===gt);if(p){const r=Tt(p,m,e=>rc(e,l.create(u)));if(r instanceof Promise){return Ic(ac(e,t,n,o),a)}Object.entries(r).forEach(([e,t])=>{u[e]={value:t}})}const d=i[1],h=l.create(u);if(0===d.length)return{type:"Value",value:null,k:a};const g={type:"FnBody",fn:e,bodyIndex:1,env:h,outerEnv:n,sourceCodeInfo:o};return d.length,{type:"Eval",node:d[0],env:h,k:[g,...a]}}function gc(e,t,n){switch(e.type){case"Sequence":return function(e,t,r){const{nodes:n,index:o,env:a}=e;if(o>=n.length)return{type:"Value",value:t,k:r};const i={...e,index:o+1};if(o===n.length-1)return{type:"Eval",node:n[o],env:a,k:r};return{type:"Eval",node:n[o],env:a,k:[i,...r]}}(e,t,n);case"IfBranch":return function(e,t,r){const{thenNode:n,elseNode:o,inverted:a,env:i}=e,s=a?!t:t;if(s)return{type:"Eval",node:n,env:i,k:r};if(o)return{type:"Eval",node:o,env:i,k:r};return{type:"Value",value:null,k:r}}(e,t,n);case"Cond":return function(e,t,r){const{cases:n,index:o,env:a}=e;if("test"===e.phase){if(t)return{type:"Eval",node:n[o][1],env:a,k:r};const i=o+1;if(i>=n.length)return{type:"Value",value:null,k:r};const s={...e,index:i};return{type:"Eval",node:n[i][0],env:a,k:[s,...r]}}return{type:"Value",value:t,k:r}}(e,t,n);case"Match":return function(e,t,r){const{cases:n,env:o}=e;if("matchValue"===e.phase){const n=t;return fc({...e,matchValue:n,phase:"guard"},r)}if("guard"===e.phase){if(!t){return fc({...e,index:e.index+1,bindings:{}},r)}const a={};for(const[t,r]of Object.entries(e.bindings))a[t]={value:r};const i=o.create(a);return{type:"Eval",node:n[e.index][1],env:i,k:r}}return{type:"Value",value:t,k:r}}(e,t,n);case"And":return function(e,t,r){if(!t)return{type:"Value",value:t,k:r};const{nodes:n,index:o,env:a}=e;if(o>=n.length)return{type:"Value",value:t,k:r};if(o===n.length-1)return{type:"Eval",node:n[o],env:a,k:r};const i={...e,index:o+1};return{type:"Eval",node:n[o],env:a,k:[i,...r]}}(e,t,n);case"Or":return function(e,t,r){if(t)return{type:"Value",value:t,k:r};const{nodes:n,index:o,env:a}=e;if(o>=n.length)return{type:"Value",value:t,k:r};if(o===n.length-1)return{type:"Eval",node:n[o],env:a,k:r};const i={...e,index:o+1};return{type:"Eval",node:n[o],env:a,k:[i,...r]}}(e,t,n);case"Qq":return function(e,t,r){if(null!==t)return{type:"Value",value:t,k:r};return yc(e,r)}(e,t,n);case"ArrayBuild":return function(e,t,n){const{nodes:o,result:a,env:i,sourceCodeInfo:s}=e;if(e.isSpread){if(!Array.isArray(t))throw new r("Spread value is not an array",s);a.push(...t)}else a.push(t);const c=e.index+1;if(c>=o.length)return{type:"Value",value:a,k:n};const l=o[c],u=ai(l),m={...e,index:c,isSpread:u};return{type:"Eval",node:u?l[1]:l,env:i,k:[m,...n]}}(e,t,n);case"ObjectBuild":return function(e,t,n){const{nodes:o,result:a,env:i,sourceCodeInfo:s}=e;if(e.isSpread){if(!w(t))throw new r("Spread value is not an object",s);Object.assign(a,t);const c=e.index+1;if(c>=o.length)return{type:"Value",value:a,k:n};const l=o[c],u=ai(l),m={...e,index:c,currentKey:null,isSpread:u};return{type:"Eval",node:u?l[1]:l,env:i,k:[m,...n]}}if(null===e.currentKey){G(t,s);const a=o[e.index+1];if(void 0===a)throw new r("Missing value for key",s);return{type:"Eval",node:a,env:i,k:[{...e,currentKey:t},...n]}}{a[e.currentKey]=t;const r=e.index+2;if(r>=o.length)return{type:"Value",value:a,k:n};const s=o[r],c=ai(s),l={...e,index:r,currentKey:null,isSpread:c};return{type:"Eval",node:c?s[1]:s,env:i,k:[l,...n]}}}(e,t,n);case"LetBind":return function(e,t,r){const{target:n,env:o,sourceCodeInfo:a}=e,i=Tt(n,t,e=>rc(e,o));return wt(i,e=>(o.addValues(e,a),{type:"Value",value:t,k:r}))}(e,t,n);case"LoopBind":return function(e,t,r){const{bindingNodes:n,index:o,context:a,body:i,env:s,sourceCodeInfo:c}=e,l=n[o],u=Tt(l[1][0],t,e=>rc(e,s.create(a)));return wt(u,t=>{Object.entries(t).forEach(([e,t])=>{a[e]={value:t}});const l=o+1;if(l>=n.length){const e=s.create(a);return{type:"Eval",node:i,env:e,k:[{type:"LoopIterate",bindingNodes:n,bindingContext:a,body:i,env:e,sourceCodeInfo:c},...r]}}const u={...e,index:l};return{type:"Eval",node:n[l][1][1],env:s.create(a),k:[u,...r]}})}(e,t,n);case"LoopIterate":return function(e,t,r){return{type:"Value",value:t,k:r}}(0,t,n);case"ForLoop":return function(e,t,n){const{returnResult:o,bindingNodes:a,result:i,env:s,sourceCodeInfo:c,context:l}=e,{asColl:u,isSeq:m}={asColl:(e,t)=>{if("string"==typeof e||Array.isArray(e)||j(e))return e;throw new r(`Expected collection, got ${g(e)}`,t)},isSeq:e=>"string"==typeof e||Array.isArray(e)};switch(e.phase){case"evalCollection":{const r=u(t,c),o=m(r)?r:Object.entries(r);if(0===o.length)return vc(e,n);const i=[...e.levelStates];i[e.bindingLevel]={collection:o,index:0};const p=a[e.bindingLevel];return wt(Tt(p[0][1][0],$(o[0],c),e=>rc(e,s)),t=>{Object.entries(t).forEach(([e,t])=>{l[e]={value:t}});const r=p[1];return r.length>0?wc(e,i,r,0,n):xc(e,i,n)})}case"evalLet":throw new r("ForLoop evalLet should not reach applyFrame",c);case"evalWhen":{if(!t)return bc(e,n);const r=a[e.bindingLevel][3];if(r){const t={...e,phase:"evalWhile"};return{type:"Eval",node:r,env:s,k:[t,...n]}}return kc(e,n)}case"evalWhile":if(!t){const t=[...e.levelStates];return t[e.bindingLevel]={...t[e.bindingLevel],index:Number.POSITIVE_INFINITY},bc({...e,levelStates:t},n)}return kc(e,n);case"evalBody":return o&&i.push(t),bc(e,n);case"evalElement":throw new r(`Unexpected ForLoop phase: ${e.phase}`,c)}return{type:"Value",value:null,k:n}}(e,t,n);case"Recur":return function(e,t,r){const{nodes:n,index:o,params:a,env:i}=e;if(a.push(t),o>=n.length)return Ac(a,r,e.sourceCodeInfo);const s={...e,index:o+1};return{type:"Eval",node:n[o],env:i,k:[s,...r]}}(e,t,n);case"PerformArgs":return function(e,t,r){const{argNodes:n,index:o,params:a,env:i}=e;if(a.push(t),o>=n.length){const t=a[0];V(t,e.sourceCodeInfo);return{type:"Perform",effect:t,args:a.slice(1),k:r,sourceCodeInfo:e.sourceCodeInfo}}const s={...e,index:o+1};return{type:"Eval",node:n[o],env:i,k:[s,...r]}}(e,t,n);case"TryWith":return function(e,t){return{type:"Value",value:e,k:t}}(t,n);case"EffectResume":return function(e,t){return{type:"Value",value:t,k:e.resumeK}}(e,t);case"ParallelResume":return function(e,t,r){return{type:"ParallelResume",value:t,branchCount:e.branchCount,completedBranches:e.completedBranches,suspendedBranches:e.suspendedBranches,k:r}}(e,t,n);case"EvalArgs":return function(e,t,n){const{node:o,params:a,placeholders:s,env:c}=e,l=o[1][1],u=l[e.index];if(ai(u)){if(!Array.isArray(t))throw new r(`Spread operator requires an array, got ${g(t)}`,u[2]);a.push(...t)}else a.push(t);let m=e.index+1;for(;m<l.length;){const e=l[m];if(e[0]!==i.ReservedSymbol||"_"!==e[1])break;s.push(a.length),m++}if(m>=l.length)return pc({...e,index:m},n);const p={...e,index:m},d=l[m];if(ai(d))return{type:"Eval",node:d[1],env:c,k:[p,...n]};return{type:"Eval",node:d,env:c,k:[p,...n]}}(e,t,n);case"CallFn":return function(e,t,r){const n=U(t,e.sourceCodeInfo);return dc(n,e.params,e.placeholders,e.env,e.sourceCodeInfo,r)}(e,t,n);case"FnBody":return function(e,t,r){const{fn:n,bodyIndex:o,env:a}=e,i=n.evaluatedfunction[1];if(o>=i.length)return{type:"Value",value:t,k:r};const s={...e,bodyIndex:o+1};return{type:"Eval",node:i[o],env:a,k:[s,...r]}}(e,t,n);case"BindingDefault":return function(e,t,n){const{target:o,record:a,env:i,sourceCodeInfo:s}=e,c=Tt(o,t,e=>rc(e,i));if(c instanceof Promise)throw new r("Async binding default evaluation not supported in trampoline yet",s);return Object.assign(a,c),{type:"Value",value:t,k:n}}(e,t,n);case"NanCheck":return function(e,t,n){if("number"==typeof t&&Number.isNaN(t))throw new r("Number is NaN",e.sourceCodeInfo);return{type:"Value",value:je(t),k:n}}(e,t,n);case"DebugStep":return function(e,t,r){if("awaitValue"===e.phase){const n={expression:e.sourceCodeInfo?.code??"",value:t,location:e.sourceCodeInfo?{line:e.sourceCodeInfo.position.line,column:e.sourceCodeInfo.position.column}:{line:0,column:0},env:jc(e.env)},o={type:"DebugStep",phase:"awaitPerform",sourceCodeInfo:e.sourceCodeInfo,env:e.env};return{type:"Perform",effect:Vs("dvala.debug.step"),args:[n],k:[o,...r]}}return{type:"Value",value:t,k:r}}(e,t,n);case"ImportMerge":{const r=j(t)?t:{};for(const[t,n]of Object.entries(r)){const r=e.module.functions[t];r&&q(n)&&(r.dvalaImpl=n)}const o={};for(const[t,n]of Object.entries(r))e.module.functions[t]||(o[t]=n);const a={...e.tsFunctions,...o};return e.env.registerValueModule(e.moduleName,a),{type:"Value",value:a,k:n}}default:throw new r(`Unhandled frame type: ${e.type}`,void 0)}}function fc(e,t){const{matchValue:n,cases:o,index:a,env:i,sourceCodeInfo:s}=e;for(let c=a;c<o.length;c++){const[a,l,u]=o[c],m=It(a,n,e=>rc(e,i));if(m instanceof Promise)throw new r("Async pattern matching not supported in trampoline yet",s);if(null===m)continue;if(u){const r={};for(const[e,t]of Object.entries(m))r[e]={value:t};return{type:"Eval",node:u,env:i.create(r),k:[{...e,phase:"guard",index:c,bindings:m},...t]}}const p={};for(const[e,t]of Object.entries(m))p[e]={value:t};return{type:"Eval",node:l,env:i.create(p),k:t}}return{type:"Value",value:null,k:t}}function yc(e,t){const{nodes:r,env:n}=e;let{index:o}=e;for(;o<r.length;){const e=r[o];if(!ei(e)||null!==n.lookUp(e))break;o++}if(o>=r.length)return{type:"Value",value:null,k:t};if(o===r.length-1)return{type:"Eval",node:r[o],env:n,k:t};const a={...e,index:o+1};return{type:"Eval",node:r[o],env:n,k:[a,...t]}}function vc(e,t){return{type:"Value",value:e.returnResult?e.result:null,k:t}}function bc(e,t){const{bindingNodes:r,env:n,sourceCodeInfo:o,context:a}=e,i=[...e.levelStates],s=e.bindingLevel,c=i[s],l=c.index+1;if(l>=c.collection.length)return 0===s?vc(e,t):bc({...e,bindingLevel:s-1},t);i[s]={...c,index:l};const u=r[s];return wt(Tt(u[0][1][0],$(c.collection[l],o),e=>rc(e,n)),r=>{Object.entries(r).forEach(([e,t])=>{a[e]={value:t}});const n=u[1];return n.length>0?wc({...e,levelStates:i,bindingLevel:s},i,n,0,t):xc({...e,levelStates:i,bindingLevel:s},i,t)})}function wc(e,t,r,n,o){const{env:a,context:i}=e;let s;for(let e=n;e<r.length;e++){const t=e;s=wt(s,()=>{const e=r[t],[n,o]=e[1];return wt(rc(o,a),e=>wt(Tt(n,e,e=>rc(e,a)),e=>{Object.entries(e).forEach(([e,t])=>{i[e]={value:t}})}))})}return wt(s,()=>xc({...e,levelStates:t},t,o))}function xc(e,t,r){const{bindingNodes:n,env:o}=e,a=n[e.bindingLevel],i=a[2],s=a[3];if(i){return{type:"Eval",node:i,env:o,k:[{...e,levelStates:t,phase:"evalWhen"},...r]}}if(s){return{type:"Eval",node:s,env:o,k:[{...e,levelStates:t,phase:"evalWhile"},...r]}}return kc({...e,levelStates:t},r)}function kc(e,t){const{bindingNodes:r,body:n,env:o}=e,a=e.bindingLevel+1;if(a<r.length){return{type:"Eval",node:r[a][0][1][1],env:o,k:[{...e,phase:"evalCollection",bindingLevel:a},...t]}}const i={...e,phase:"evalBody"};return{type:"Eval",node:n,env:o.create(e.context),k:[i,...t]}}function qc(e,t,r,n,o){const a=Vs("dvala.error"),i=[e.shortMessage];for(let r=0;r<t.length;r++){const n=t[r];if("TryWith"===n.type)for(const o of n.handlers)if(Nc(o,a,n.env,e.sourceCodeInfo))return $c(o,n,i,t,r,e.sourceCodeInfo)}const s=Cs("dvala.error",r);return s.length>0?Ec("dvala.error",s,i,t,n,e.sourceCodeInfo,o):null}function Ac(e,t,n){for(let o=0;o<t.length;o++){const a=t[o];if("LoopIterate"===a.type){const{bindingNodes:i,bindingContext:s,body:c,env:l}=a,u=t.slice(o+1);if(e.length!==i.length)throw new r(`recur expected ${i.length} parameters, got ${e.length}`,n);const m=At(i,(t,r)=>wt(Tt(t[1][0],le(e[r]),e=>rc(e,l)),e=>{Object.entries(e).forEach(([e,t])=>{s[e]={value:t}})}));return wt(m,()=>{const e=l.getContextsRaw()[0];if(e!==s)for(const[t,r]of Object.entries(s))e[t]=r;const t={type:"LoopIterate",bindingNodes:i,bindingContext:s,body:c,env:l,sourceCodeInfo:a.sourceCodeInfo};return{type:"Eval",node:c,env:l,k:[t,...u]}})}if("FnBody"===a.type){const{fn:r,outerEnv:n}=a,i=t.slice(o+1);return hc(r,e,n,a.sourceCodeInfo,i)}}throw new r("recur called outside of loop or function body",n)}function Nc(e,t,n,o){if(D(e.effectRef))return e.effectRef.name===t.name;if(x(e.effectRef)){const a=nc(e.effectRef,[t],n,o);if(a instanceof Promise)throw new r("Effect handler predicates must be synchronous",o);return!!a}return!1}function $c(e,t,r,n,o,a){const i=[{type:"EffectResume",resumeK:n,sourceCodeInfo:a},...n.slice(o+1)];return dc(U(rc(e.handlerNode,t.env),t.sourceCodeInfo),[r],[],t.env,a,i)}function Ec(e,t,o,a,i,s,c){const l=i??(new AbortController).signal,u=Array.from(o);function m(e,t){switch(e.kind){case"step":return e.step;case"asyncResume":return e.promise.then(e=>({type:"Value",value:e,k:a}),e=>({type:"Error",error:e instanceof r?e:new r(e instanceof Error?e:`${e}`,s),k:a}));case"throw":throw e.error;case"next":return p(t)}}function p(i){if(i>=t.length){if("dvala.error"===e){const e="string"==typeof u[0]?u[0]:String(u[0]??"Unknown error");throw new n(e,s)}if("dvala.checkpoint"===e)return{type:"Value",value:null,k:a};throw new r(`Unhandled effect: '${e}'`,s)}const[p,d]=t[i];if("*"===p){const t=Na(e);if(t)return t(o,a,s)}let h,g=!1;function f(e){if(g)throw new r(`Effect handler called ${e}() after already calling another operation`,s);g=!0}const y=d({effectName:e,args:u,signal:l,resume:e=>{f("resume"),h=e instanceof Promise?{kind:"asyncResume",promise:e}:{kind:"step",step:{type:"Value",value:e,k:a}}},fail:t=>{f("fail");h={kind:"step",step:{type:"Error",error:new r(t??`Effect handler failed for '${e}'`,s),k:a}}},suspend:t=>{f("suspend"),h={kind:"throw",error:new Rs(a,c?c.snapshots:[],c?c.nextSnapshotIndex:0,t,e,u)}},next:()=>{f("next"),h={kind:"next"}},get snapshots(){return c?[...c.snapshots]:[]},checkpoint:e=>{if(!c)throw new r("checkpoint is not available outside effect-enabled execution",s);const t={continuation:Zs(a),timestamp:Date.now(),index:c.nextSnapshotIndex++,runId:c.runId,...void 0!==e?{meta:e}:{}};return c.snapshots.push(t),void 0!==c.maxSnapshots&&c.snapshots.length>c.maxSnapshots&&c.snapshots.shift(),t},resumeFrom:(e,t)=>{if(g)throw new r("Effect handler called resumeFrom() after already calling another operation",s);if(!c)throw new r("resumeFrom is not available outside effect-enabled execution",s);const n=c.snapshots.find(t=>t.index===e.index&&t.runId===e.runId);if(!n)throw new r(`Invalid snapshot: no snapshot with index ${e.index} found in current run`,s);g=!0,h={kind:"throw",error:new Ps(n.continuation,t,n.index)}}});if(!(y instanceof Promise)){if(!h)throw new r(`Effect handler for '${e}' did not call resume(), fail(), suspend(), or next()`,s);return m(h,i+1)}return h?(y.catch(()=>{}),m(h,i+1)):y.then(()=>{if(!h)throw new r(`Effect handler for '${e}' did not call resume(), fail(), suspend(), or next()`,s);return m(h,i+1)},e=>{if(h)return m(h,i+1);if(Ms(e)||Os(e))throw e;return{type:"Error",error:e instanceof r?e:new r(e instanceof Error?e:`${e}`,s),k:a}})}return l.aborted&&Sc(a,void 0,e,u),p(0)}function Tc(e,t){const r=new AbortController;return e.aborted||t.aborted?(r.abort(),r.signal):(e.addEventListener("abort",()=>r.abort(),{once:!0}),t.addEventListener("abort",()=>r.abort(),{once:!0}),r.signal)}function Sc(e,t,r,n){throw new Rs(e,[],0,t,r,n)}async function zc(e,t,r,n){return Uc({type:"Eval",node:e,env:t,k:[]},r,n)}function jc(e){const t={},r=e.getHostValues();if(r)for(const[e,n]of Object.entries(r))t[e]=n;const n=e.getContextsRaw();for(let e=n.length-1;e>=0;e--)for(const[r,o]of Object.entries(n[e]))t[r]=o.value;return t}function Ic(e,t){return e instanceof Promise?e.then(e=>({type:"Value",value:e,k:t}),e=>({type:"Error",error:e instanceof r?e:new r(`${e}`,void 0),k:t})):{type:"Value",value:e,k:t}}function Cc(e,t,o,a){try{switch(e.type){case"Value":{if(0===e.k.length)return e;const[t,...r]=e.k;return gc(t,e.value,r)}case"Eval":return mc(e.node,e.env,e.k);case"Apply":return gc(e.frame,e.value,e.k);case"Perform":return function(e,t,o,a,i,s,c){if("dvala.checkpoint"===e.name&&c){const e=t[0],r={continuation:Zs(o),timestamp:Date.now(),index:c.nextSnapshotIndex++,runId:c.runId,...void 0!==e?{meta:e}:{}};c.snapshots.push(r),void 0!==c.maxSnapshots&&c.snapshots.length>c.maxSnapshots&&c.snapshots.shift()}for(let r=0;r<o.length;r++){const n=o[r];if("TryWith"===n.type)for(const i of n.handlers)if(Nc(i,e,n.env,a))return $c(i,n,t,o,r,a)}const l=Cs(e.name,i);if(l.length>0)return Ec(e.name,l,t,o,s,a,c);const u=Na(e.name);if(u)return u(t,o,a);if("dvala.error"===e.name){const e="string"==typeof t[0]?t[0]:String(t[0]??"Unknown error");throw new n(e,a)}throw new r(`Unhandled effect: '${e.name}'`,a)}(e.effect,e.args,e.k,e.sourceCodeInfo,t,o,a);case"Parallel":return async function(e,t,n,o,a){const i=new AbortController,s=a?Tc(a,i.signal):i.signal,c=e.map(async(e,r)=>{const n=await zc(e,t,o,s);return"suspended"===n.type&&i.abort(),{index:r,result:n}}),l=await Promise.allSettled(c),u=[],m=[],p=[];for(const e of l)if("rejected"===e.status)p.push(new r(`${e.reason}`,void 0));else{const{index:t,result:r}=e.value;switch(r.type){case"completed":u.push({index:t,value:r.value});break;case"suspended":m.push({index:t,snapshot:r.snapshot});break;case"error":p.push(r.error)}}if(p.length>0)throw p[0];if(m.length>0){const t=[{type:"ParallelResume",branchCount:e.length,completedBranches:u,suspendedBranches:m.slice(1)},...n],r=m[0];return Sc(t,r.snapshot.meta,r.snapshot.effectName,r.snapshot.effectArgs)}const d=Array.from({length:e.length});for(const{index:e,value:t}of u)d[e]=t;return{type:"Value",value:d,k:n}}(e.branches,e.env,e.k,t,o);case"Race":return async function(e,t,n,o,a){const i=a??(new AbortController).signal,s=e.map(()=>new AbortController),c=()=>{for(const e of s)e.abort(i.reason)};i.addEventListener("abort",c,{once:!0});try{let a=-1,i=null;const c=e.map(async(e,r)=>{const n=s[r].signal,c=await zc(e,t,o,n);if("completed"===c.type&&a<0){a=r,i=c.value;for(let e=0;e<s.length;e++)e!==r&&s[e].abort("race: branch lost")}return c}),l=await Promise.allSettled(c);if(a>=0)return{type:"Value",value:i,k:n};const u=[],m=[];for(let e=0;e<l.length;e++){const t=l[e];if("rejected"===t.status)m.push(new r(`${t.reason}`,void 0));else{const e=t.value;switch(e.type){case"suspended":u.push(e.snapshot.meta??null);break;case"error":m.push(e.error)}}}u.length>0&&Sc(n,{type:"race",branches:u});const p=m.map(e=>e.message).join("; ");throw new r(`race: all branches failed: ${p}`,void 0)}finally{i.removeEventListener("abort",c)}}(e.branches,e.env,e.k,t,o);case"ParallelResume":return function(e){const{value:t,branchCount:r,completedBranches:n,suspendedBranches:o,k:a}=e,i=new Set(n.map(e=>e.index)),s=new Set(o.map(e=>e.index));let c=-1;for(let e=0;e<r;e++)if(!i.has(e)&&!s.has(e)){c=e;break}const l=[...n,{index:c,value:t}];if(o.length>0){const e=o[0];return Sc([{type:"ParallelResume",branchCount:r,completedBranches:l,suspendedBranches:o.slice(1)},...a],e.snapshot.meta,e.snapshot.effectName,e.snapshot.effectArgs)}const u=Array.from({length:r});for(const{index:e,value:t}of l)u[e]=t;return{type:"Value",value:u,k:a}}(e);case"Error":{const r=qc(e.error,e.k,t,o,a);if(null!==r)return r;throw e.error}}}catch(n){if(Ms(n))throw n;if(n instanceof r){const r=qc(n,"Value"===e.type?e.k.slice(1):e.k,t,o,a);if(null!==r)return r}throw n}}function Rc(e,t){let n=e;for(;;){if(n instanceof Promise)throw new r("Unexpected async operation in synchronous context. Use async.run() for async operations.",void 0);if("Value"===n.type&&0===n.k.length)return n.value;n=Cc(n,t)}}async function Mc(e){let t=e;for(;;){if(t instanceof Promise&&(t=await t),"Value"===t.type&&0===t.k.length)return t.value;t=Cc(t)}}function Pc(e,t){if(0===e.length)return{type:"Value",value:null,k:[]};if(1===e.length)return{type:"Eval",node:e[0],env:t,k:[]};const r={type:"Sequence",nodes:e,index:1,env:t};return{type:"Eval",node:e[0],env:t,k:[r]}}function Oc(e,t){const n=Pc(e.body,t);try{return Rc(n)}catch(n){if(n instanceof r&&n.message.includes("Unexpected async operation")){return Mc(Pc(e.body,t))}throw n}}function Dc(e,t){const n={type:"Eval",node:e,env:t,k:[]};try{return Rc(n)}catch(n){if(n instanceof r&&n.message.includes("Unexpected async operation")){return Mc({type:"Eval",node:e,env:t,k:[]})}throw n}}async function Vc(e,t,n,o,a,i,s){const c=new AbortController,l=s?Tc(s,c.signal):c.signal,u={snapshots:a?.snapshots??[],nextSnapshotIndex:a?.nextSnapshotIndex??0,runId:js(),maxSnapshots:a?.maxSnapshots};if(e.length>0&&"ParallelResume"===e[0].type)return async function(e,t,n,o,a,i,s,c){const{branchCount:l,completedBranches:u,suspendedBranches:m}=e,p=new Set(u.map(e=>e.index)),d=new Set(m.map(e=>e.index));let h=-1;for(let e=0;e<l;e++)if(!p.has(e)&&!d.has(e)){h=e;break}const g=new AbortController,f=Tc(i,g.signal),y=Cs(n,a),v=(async()=>{let e;try{e=await Promise.resolve(Ec(n,y,o,[],f,void 0,s))}catch(e){if(Ms(e)){g.abort();const t={continuation:ec(e.k,e.snapshots,e.nextSnapshotIndex,e.meta),timestamp:Date.now(),index:s.nextSnapshotIndex++,runId:s.runId,meta:e.meta,effectName:e.effectName,effectArgs:e.effectArgs};return{index:h,result:{type:"suspended",snapshot:t}}}const t=e instanceof r?e:new r(`${e}`,void 0);return{index:h,result:{type:"error",error:t}}}const t=await Uc(e,a,f,s,void 0,c);return"suspended"===t.type&&g.abort(),{index:h,result:t}})(),b=m.map(async e=>{const{effectName:t,effectArgs:r}=e.snapshot;if(!t||!r)return{index:e.index,result:{type:"suspended",snapshot:e.snapshot}};const n=tc(e.snapshot.continuation,c),o=await Vc(n.k,t,r,a,{snapshots:n.snapshots,nextSnapshotIndex:n.nextSnapshotIndex},c,f);return"suspended"===o.type&&g.abort(),{index:e.index,result:o}}),w=await Promise.allSettled([v,...b]),x=[...u],k=[],q=[];for(const e of w)if("rejected"===e.status)q.push(new r(`${e.reason}`,void 0));else{const{index:t,result:r}=e.value;"completed"===r.type?x.push({index:t,value:r.value}):"suspended"===r.type?k.push({index:t,snapshot:r.snapshot}):q.push(r.error)}if(q.length>0)return{type:"error",error:q[0]};if(k.length>0){const e=k[0];return{type:"suspended",snapshot:{continuation:ec([{type:"ParallelResume",branchCount:l,completedBranches:x,suspendedBranches:k.slice(1)},...t],s.snapshots,s.nextSnapshotIndex,e.snapshot.meta),timestamp:Date.now(),index:s.nextSnapshotIndex++,runId:s.runId,meta:e.snapshot.meta,effectName:e.snapshot.effectName,effectArgs:e.snapshot.effectArgs}}}const A=Array.from({length:l});for(const{index:e,value:t}of x)A[e]=t;return Uc({type:"Value",value:A,k:t},a,i,s,void 0,c)}(e[0],e.slice(1),t,n,o,l,u,i);const m=Cs(t,o);let p;try{p=await Promise.resolve(Ec(t,m,n,e,l,void 0,u))}catch(e){if(Ms(e)){return{type:"suspended",snapshot:{continuation:ec(e.k,e.snapshots,e.nextSnapshotIndex,e.meta),timestamp:Date.now(),index:u.nextSnapshotIndex++,runId:u.runId,meta:e.meta,effectName:e.effectName,effectArgs:e.effectArgs}}}return e instanceof r?{type:"error",error:e}:{type:"error",error:new r(`${e}`,void 0)}}return Uc(p,o,l,u,u.maxSnapshots,i)}async function Uc(e,t,n,o,a,s){const c=null!=t&&"dvala.debug.step"in t,l={snapshots:o?o.snapshots:[],nextSnapshotIndex:o?o.nextSnapshotIndex:0,runId:js(),...void 0!==a?{maxSnapshots:a}:{}};let u=e;for(;;)try{for(;;){if(u instanceof Promise&&(u=await u),"Value"===u.type&&0===u.k.length)return{type:"completed",value:u.value};if(c&&"Eval"===u.type&&u.node[2]){const e=u.node[0];if(e===i.NormalExpression||e===i.SpecialExpression){const e={type:"DebugStep",phase:"awaitValue",sourceCodeInfo:u.node[2],env:u.env};u={...u,k:[e,...u.k]}}}u=Cc(u,t,n,l)}}catch(e){if(Os(e)){const{k:t}=tc(e.continuation,s),r=l.snapshots.findIndex(t=>t.index>e.trimToIndex);-1!==r&&l.snapshots.splice(r),u={type:"Value",value:e.value,k:t};continue}if(Ms(e)){return{type:"suspended",snapshot:{continuation:ec(e.k,e.snapshots,e.nextSnapshotIndex,e.meta),timestamp:Date.now(),index:l.nextSnapshotIndex++,runId:l.runId,meta:e.meta,effectName:e.effectName,effectArgs:e.effectArgs}}}return e instanceof r?{type:"error",error:e}:{type:"error",error:new r(`${e}`,void 0)}}}const Fc=new Set([...cr,...lr,...Object.keys(rs)]);class Wc{originalProgram;originalPosition;prefixProgram="";suffixProgram="";searchString="";suggestions=[];suggestionIndex=null;constructor(e,t,r={}){this.originalProgram=e,this.originalPosition=t;const n=Ts(this.originalProgram.slice(0,this.originalPosition),!1,void 0).tokens.at(-1);n&&"Error"!==n[0]&&(this.searchString=n[1],this.prefixProgram=this.originalProgram.slice(0,this.originalPosition-this.searchString.length),this.suffixProgram=this.originalProgram.slice(this.prefixProgram.length+this.searchString.length),this.originalProgram.slice(this.prefixProgram.length+this.searchString.length),this.suggestions=this.generateSuggestions(r))}getNextSuggestion(){return this.getAutoCompleteSuggestionResult(this.getNextSuggestionSymbol())}getPreviousSuggestion(){return this.getAutoCompleteSuggestionResult(this.getPreviousSuggestionSymbol())}getAutoCompleteSuggestionResult(e){return null===e?null:{program:this.prefixProgram+e+this.suffixProgram,position:this.prefixProgram.length+e.length}}getNextSuggestionSymbol(){return 0===this.suggestions.length?null:(null===this.suggestionIndex?this.suggestionIndex=0:(this.suggestionIndex+=1,this.suggestionIndex>=this.suggestions.length&&(this.suggestionIndex=0)),this.suggestions[this.suggestionIndex])}getPreviousSuggestionSymbol(){return 0===this.suggestions.length?null:(null===this.suggestionIndex?this.suggestionIndex=this.suggestions.length-1:(this.suggestionIndex-=1,this.suggestionIndex<0&&(this.suggestionIndex=this.suggestions.length-1)),this.suggestions[this.suggestionIndex])}getSuggestions(){return[...this.suggestions]}getSearchString(){return this.searchString}generateSuggestions(e){const t=new Set(["0_defn","0_lambda"]),r=this.generateWithPredicate(e,e=>!t.has(e)&&e.startsWith(this.searchString));r.forEach(e=>t.add(e));const n=this.generateWithPredicate(e,e=>!t.has(e)&&e.toLowerCase().startsWith(this.searchString.toLowerCase()));n.forEach(e=>t.add(e));const o=this.generateWithPredicate(e,e=>!t.has(e)&&e.includes(this.searchString));o.forEach(e=>t.add(e));const a=this.generateWithPredicate(e,e=>!t.has(e)&&e.includes(this.searchString.toLowerCase()));return a.forEach(e=>t.add(e)),[...r,...n,...o,...a]}generateWithPredicate(e,t){const r=new Set;return Fc.forEach(e=>{t(e)&&r.add(e)}),Object.keys(e.bindings??{}).filter(t).forEach(e=>r.add(e)),[...r].sort((e,t)=>e.localeCompare(t))}}const Gc={collection:'{\n map: (first-coll, ...args) -> do\n let fn = last(args);\n let other-colls = slice(args, 0, count(args) - 1);\n let all-colls = [first-coll, ...other-colls];\n\n cond\n case object?(first-coll) then do\n let expected-keys = keys(first-coll) |> sort;\n doseq (obj in other-colls) -> do\n if not(object?(obj)) then\n perform(effect(dvala.error), "Expected object")\n end;\n let obj-keys = keys(obj) |> sort;\n if not(obj-keys == expected-keys) then\n perform(effect(dvala.error), ++(\n "All objects must have the same keys. Expected: ",\n join(expected-keys, ", "),\n ". Found: ",\n join(obj-keys, ", ")\n ))\n end\n end;\n reduce(keys(first-coll), (acc, k) -> do\n let a = for (coll in all-colls) -> coll(k);\n assoc(acc, k, apply(fn, a))\n end, {})\n end\n\n case string?(first-coll) then do\n doseq (s in other-colls) -> do\n if not(string?(s)) then\n perform(effect(dvala.error), "Expected string")\n end\n end;\n let len = reduce(other-colls, (m, s) -> min(m, count(s)), count(first-coll));\n let mapped = for (i in range(len)) -> do\n let a = for (coll in all-colls) -> nth(coll, i);\n apply(fn, a)\n end;\n reduce(mapped, (acc, ch) -> do\n if not(string?(ch)) then\n perform(effect(dvala.error), "Expected string")\n end;\n ++(acc, ch)\n end, "")\n end\n\n case true then do\n doseq (x in other-colls) -> do\n if not(array?(x)) then\n perform(effect(dvala.error), "Expected array")\n end\n end;\n let len = reduce(other-colls, (m, x) -> min(m, count(x)), count(first-coll));\n for (i in range(len)) -> do\n let a = for (coll in all-colls) -> nth(coll, i);\n apply(fn, a)\n end\n end\n end\n end,\n\n filter: (coll, fn) -> do\n cond\n case array?(coll) then\n reduce(coll, (acc, elem) -> if fn(elem) then [...acc, elem] else acc end, [])\n\n case string?(coll) then\n reduce(coll, (acc, ch) -> if fn(ch) then ++(acc, ch) else acc end, "")\n\n case object?(coll) then\n reduce(keys(coll), (acc, k) -> do\n if fn(coll(k)) then\n assoc(acc, k, coll(k))\n else\n acc\n end\n end, {})\n\n case true then\n perform(effect(dvala.error), "Expected collection")\n end\n end,\n\n reduce: (coll, fn, initial) -> do\n cond\n case string?(coll) then\n loop (acc = initial, i = 0) -> do\n if i >= count(coll) then\n acc\n else\n recur(fn(acc, nth(coll, i)), i + 1)\n end\n end\n\n case array?(coll) then\n loop (acc = initial, i = 0) -> do\n if i >= count(coll) then\n acc\n else\n recur(fn(acc, nth(coll, i)), i + 1)\n end\n end\n\n case object?(coll) then do\n let values = vals(coll);\n loop (acc = initial, i = 0) -> do\n if i >= count(values) then\n acc\n else\n recur(fn(acc, nth(values, i)), i + 1)\n end\n end\n end\n\n case true then\n perform(effect(dvala.error), "Expected collection")\n end\n end\n}',sequence:'{\n some: (seq, fn) -> do\n if null?(seq) then null\n else do\n loop (i = 0) -> do\n if i >= count(seq) then\n null\n else do\n let elem = nth(seq, i);\n if fn(elem) then elem\n else recur(i + 1)\n end\n end\n end\n end\n end\n end\n end,\n\n take-while: (seq, fn) -> do\n let is-str = string?(seq);\n let len = count(seq);\n let idx = loop (i = 0) -> do\n if i >= len then\n len\n else if fn(nth(seq, i)) then\n recur(i + 1)\n else\n i\n end\n end\n end;\n slice(seq, 0, idx)\n end,\n\n drop-while: (seq, fn) -> do\n let is-str = string?(seq);\n let len = count(seq);\n let idx = loop (i = 0) -> do\n if i >= len then\n len\n else if fn(nth(seq, i)) then\n recur(i + 1)\n else\n i\n end\n end\n end;\n slice(seq, idx)\n end,\n\n sort: (seq, ...args) -> do\n let cmp = if count(args) == 0 then compare else first(args) end;\n let is-str = string?(seq);\n let arr = if is-str then split(seq, "") else seq end;\n let len = count(arr);\n\n // merge two sorted arrays\n let merge-arrays = (left, right) -> do\n let left-len = count(left);\n let right-len = count(right);\n loop (result = [], li = 0, ri = 0) -> do\n if li >= left-len then\n ++(result, slice(right, ri))\n else if ri >= right-len then\n ++(result, slice(left, li))\n else do\n let l = nth(left, li);\n let r = nth(right, ri);\n if cmp(l, r) <= 0 then\n recur(push(result, l), li + 1, ri)\n else\n recur(push(result, r), li, ri + 1)\n end\n end\n end\n end\n end\n end;\n\n // recursive merge-sort\n let merge-sort = (a) -> do\n let n = count(a);\n if n <= 1 then a\n else do\n let mid = floor(n / 2);\n let left = merge-sort(slice(a, 0, mid));\n let right = merge-sort(slice(a, mid));\n merge-arrays(left, right)\n end\n end\n end;\n\n let sorted = merge-sort(arr);\n if is-str then join(sorted, "") else sorted end\n end\n}\n',array:'{\n mapcat: (arr, fn) -> do\n flatten(map(arr, fn), 1)\n end,\n\n moving-fn: (arr, window-size, fn) -> do\n if window-size > count(arr) then\n perform(effect(dvala.error), "Expected window-size <= array length")\n end;\n for (i in range(count(arr) - window-size + 1)) -> do\n fn(slice(arr, i, i + window-size))\n end\n end,\n\n running-fn: (arr, fn) -> do\n for (i in range(count(arr))) -> do\n fn(slice(arr, 0, i + 1))\n end\n end\n}\n',functional:'{\n "|>": (a, b) -> b(a),\n\n apply: (fn, ...args) -> do\n let arr = last(args);\n let leading = slice(args, 0, count(args) - 1);\n fn(...leading, ...arr)\n end\n}\n',object:'{\n merge-with: (...args) -> do\n let fn = last(args);\n let objs = slice(args, 0, count(args) - 1);\n if not(function?(fn)) then\n perform(effect(dvala.error), str("Expected function, got: ", type(fn)))\n end;\n if count(objs) == 0 then\n perform(effect(dvala.error), "Expected at least one object argument")\n end;\n reduce(rest(objs), (result, obj) -> do\n if not(object?(obj)) then\n perform(effect(dvala.error), str("Expected object, got: ", type(obj)))\n end;\n reduce(keys(obj), (res, key) -> do\n if contains?(res, key) then\n assoc(res, key, fn(get(res, key), get(obj, key)))\n else\n assoc(res, key, get(obj, key))\n end\n end, result)\n end, do\n let f = first(objs);\n if not(object?(f)) then\n perform(effect(dvala.error), str("Expected object, got: ", type(f)))\n end;\n f\n end)\n end\n}\n'};let Bc=!1;class Lc{cache={};firstEntry=void 0;lastEntry=void 0;_size=0;maxSize;constructor(e){if(this.maxSize=null===e?null:ce(e),"number"==typeof this.maxSize&&this.maxSize<1)throw new Error(`1 is the minimum maxSize, got ${g(e)}`)}getContent(){return Object.entries(this.cache).reduce((e,[t,r])=>(e[t]=r.value,e),{})}get size(){return this._size}get(e){return this.cache[e]?.value}clear(){this.cache={},this.firstEntry=void 0,this.lastEntry=void 0,this._size=0}has(e){return!!this.cache[e]}set(e,t){if(this.has(e))throw new Error(`AstCache - key already present: ${e}`);const r={value:t,nextEntry:void 0,key:e};for(this.cache[e]=r,this._size+=1,this.lastEntry&&(this.lastEntry.nextEntry=r),this.lastEntry=r,this.firstEntry||(this.firstEntry=this.lastEntry);null!==this.maxSize&&this.size>this.maxSize;)this.dropFirstEntry()}dropFirstEntry(){const e=this.firstEntry;delete this.cache[e.key],this._size-=1,this.firstEntry=e.nextEntry}}function _c(e,t){const r=t?.modules?new Map(t.modules.map(e=>[e.name,e])):void 0,n=Gs({bindings:t?.bindings},r),o={body:ms(ps(Ts(e,!1,void 0),{removeWhiteSpace:!0})),hasDebugData:!1};return ii(o,n,sr,Dc)}function Kc(e){if(e)for(const[t,r]of Object.entries(e))Jc(r,`bindings["${t}"]`)}function Jc(e,t){if(null!=e&&"boolean"!=typeof e&&"string"!=typeof e)if("number"!=typeof e){if("function"==typeof e)throw new TypeError(`${t} is not serializable (function)`);if("object"!=typeof e)throw new TypeError(`${t} is not serializable`);if(u in e||m in e||p in e)return;if(Array.isArray(e))return void e.forEach((e,r)=>Jc(e,`${t}[${r}]`));if(Object.getPrototypeOf(e)!==Object.prototype)throw new TypeError(`${t} is not serializable (not a plain object)`);for(const[r,n]of Object.entries(e))Jc(n,`${t}.${r}`)}else if(!Number.isFinite(e))throw new TypeError(`${t} is not serializable (${e})`)}const Hc=[kr,$r,un,qn,In,Lo,ia,ca,Yo,ea,na,ma,ba];function Yc(e){return[`number-theory.${e}-seq`,`number-theory.${e}-nth`,`number-theory.${e}-take-while`,`number-theory.${e}?`]}function Xc(e){const t=e.replace(/^/,"");return[`vector.${e}`,`vector.moving-${t}`,`vector.centered-moving-${t}`,`vector.running-${t}`]}function Qc(e){return[`vector.moving-${e}`,`vector.centered-moving-${e}`,`vector.running-${e}`]}const Zc={collection:["filter","map","reduce","count","get","contains?","assoc","++"],collectionUtils:["collection.filteri","collection.mapi","collection.reducei","collection.reduce-right","collection.reducei-right","collection.reductions","collection.reductionsi","collection.get-in","collection.assoc-in","collection.update","collection.update-in","collection.not-empty","collection.every?","collection.not-every?","collection.any?","collection.not-any?"],array:["range","repeat","flatten","mapcat","moving-fn","running-fn"],sequence:["nth","push","pop","index-of","some","reverse","first","second","last","rest","next","sort","slice","take","take-last","drop","drop-last","take-while","drop-while"],sequenceUtils:["sequence.position","sequence.last-index-of","sequence.unshift","sequence.splice","sequence.sort-by","sequence.distinct","sequence.remove","sequence.remove-at","sequence.split-at","sequence.split-with","sequence.frequencies","sequence.group-by","sequence.partition","sequence.partition-all","sequence.partition-by","sequence.starts-with?","sequence.ends-with?","sequence.interleave","sequence.interpose"],math:["+","-","*","/","mod","%","quot","inc","dec","sqrt","cbrt","^","round","trunc","floor","ceil","min","max","abs","sign"],mathUtils:["math.ln","math.log2","math.log10","math.sin","math.cos","math.tan","math.asin","math.acos","math.atan","math.sinh","math.cosh","math.tanh","math.asinh","math.acosh","math.atanh","math.to-rad","math.to-deg"],functional:["|>","apply","identity","comp","constantly"],functionalUtils:["functional.juxt","functional.complement","functional.every-pred","functional.some-pred","functional.fnull"],meta:["doc","arity","effect-name","effect-matcher"],misc:["!=","==","<",">","<=",">=","not","iso-date->epoch","epoch->iso-date","boolean","compare","identical?","json-parse","json-stringify","type-of"],object:["dissoc","keys","vals","entries","find","merge","merge-with","zipmap","select-keys"],predicate:["boolean?","null?","number?","string?","function?","integer?","array?","object?","collection?","sequence?","regexp?","effect?","zero?","pos?","neg?","even?","odd?","finite?","negative-infinity?","positive-infinity?","false?","true?","empty?","not-empty?","vector?","grid?","matrix?"],regularExpression:["regexp","re-match","replace","replace-all"],string:["str","number","lower-case","upper-case","trim","split","join","blank?"],stringUtils:["string.string-repeat","string.from-char-code","string.to-char-code","string.trim-left","string.trim-right","string.pad-left","string.pad-right","string.split-lines","string.template","string.encode-base64","string.decode-base64","string.encode-uri-component","string.decode-uri-component","string.capitalize"],bitwise:["<<",">>",">>>","&","|","xor"],bitwiseUtils:["bitwise.bit-not","bitwise.bit-and-not","bitwise.bit-flip","bitwise.bit-clear","bitwise.bit-set","bitwise.bit-test"],assertion:["assert"],assertionUtils:["assertion.assert=","assertion.assert!=","assertion.assert-gt","assertion.assert-lt","assertion.assert-gte","assertion.assert-lte","assertion.assert-true","assertion.assert-false","assertion.assert-truthy","assertion.assert-falsy","assertion.assert-null","assertion.assert-throws","assertion.assert-throws-error","assertion.assert-not-throws","assertion.assert-array","assertion.assert-boolean","assertion.assert-collection","assertion.assert-function","assertion.assert-grid","assertion.assert-integer","assertion.assert-matrix","assertion.assert-number","assertion.assert-object","assertion.assert-regexp","assertion.assert-sequence","assertion.assert-string","assertion.assert-vector"],grid:["grid.cell-every?","grid.some?","grid.every-row?","grid.some-row?","grid.every-col?","grid.some-col?","grid.row","grid.col","grid.shape","grid.fill","grid.generate","grid.reshape","grid.transpose","grid.flip-h","grid.flip-v","grid.rotate","grid.crop","grid.slice-rows","grid.slice-cols","grid.splice-rows","grid.splice-cols","grid.concat-rows","grid.concat-cols","grid.cell-map","grid.cell-mapi","grid.cell-reduce","grid.cell-reducei","grid.push-rows","grid.unshift-rows","grid.pop-row","grid.shift-row","grid.push-cols","grid.unshift-cols","grid.pop-col","grid.shift-col","grid.from-array"],matrix:["matrix.mul","matrix.det","matrix.inv","matrix.adj","matrix.cofactor","matrix.minor","matrix.trace","matrix.symmetric?","matrix.triangular?","matrix.upper-triangular?","matrix.lower-triangular?","matrix.diagonal?","matrix.square?","matrix.orthogonal-matrix?","matrix.identity?","matrix.invertible?","matrix.hilbert","matrix.vandermonde","matrix.band","matrix.banded?","matrix.rank","matrix.frobenius-norm","matrix.one-norm","matrix.inf-norm","matrix.max-norm"],vector:["sum","mean","median","prod"],vectorUtils:["vector.monotonic?","vector.strictly-monotonic?","vector.increasing?","vector.decreasing?","vector.strictly-increasing?","vector.strictly-decreasing?","vector.mode","vector.min-index","vector.max-index","vector.sort-indices","vector.count-values","vector.linspace","vector.cumsum","vector.cumprod","vector.quartiles","vector.percentile","vector.quantile","vector.histogram","vector.ecdf","vector.outliers?","vector.outliers","vector.bincount","vector.winsorize","vector.mse","vector.mae","vector.rmse","vector.smape",...Qc("mean"),...Qc("median"),...Xc("variance"),...Xc("sample-variance"),...Qc("sum"),...Qc("prod"),...Xc("stdev"),...Xc("sample-stdev"),...Xc("iqr"),...Xc("span"),...Xc("geometric-mean"),...Xc("harmonic-mean"),...Xc("skewness"),...Xc("sample-skewness"),...Xc("kurtosis"),...Xc("sample-kurtosis"),...Xc("excess-kurtosis"),...Xc("sample-excess-kurtosis"),...Xc("rms"),...Xc("mad"),...Xc("medad"),...Xc("gini-coefficient"),...Xc("entropy"),...Xc("skewness")],linAlg:["linear-algebra.reflect","linear-algebra.refract","linear-algebra.lerp","linear-algebra.rotate2d","linear-algebra.rotate3d","linear-algebra.dot","linear-algebra.cross","linear-algebra.normalize-minmax","linear-algebra.normalize-zscore","linear-algebra.normalize-robust","linear-algebra.normalize-l1","linear-algebra.normalize-l2","linear-algebra.normalize-log","linear-algebra.angle","linear-algebra.projection","linear-algebra.orthogonal?","linear-algebra.parallel?","linear-algebra.collinear?","linear-algebra.cosine-similarity","linear-algebra.euclidean-distance","linear-algebra.euclidean-norm","linear-algebra.manhattan-distance","linear-algebra.manhattan-norm","linear-algebra.hamming-distance","linear-algebra.hamming-norm","linear-algebra.chebyshev-distance","linear-algebra.chebyshev-norm","linear-algebra.minkowski-distance","linear-algebra.minkowski-norm","linear-algebra.cov","linear-algebra.corr","linear-algebra.spearman-corr","linear-algebra.pearson-corr","linear-algebra.kendall-tau","linear-algebra.autocorrelation","linear-algebra.cross-correlation","linear-algebra.rref","linear-algebra.solve","linear-algebra.to-polar","linear-algebra.from-polar"],numberTheory:[...Yc("abundant"),...Yc("arithmetic"),...Yc("bell"),...Yc("catalan"),...Yc("composite"),...Yc("deficient"),...Yc("factorial"),...Yc("fibonacci"),...Yc("geometric"),...Yc("golomb"),...Yc("happy"),...Yc("look-and-say"),...Yc("lucas"),...Yc("lucky"),...Yc("mersenne"),...Yc("padovan"),...Yc("partition"),...Yc("pell"),...Yc("perfect"),...Yc("perfect-cube"),...Yc("perfect-power"),...Yc("perfect-square"),...Yc("polygonal"),...Yc("prime"),...Yc("recaman"),...Yc("sylvester"),...Yc("thue-morse"),...Yc("tribonacci"),"number-theory.collatz-seq","number-theory.juggler-seq","number-theory.bernoulli-seq","number-theory.bernoulli-take-while","number-theory.bernoulli-nth","number-theory.combinations","number-theory.count-combinations","number-theory.derangements","number-theory.count-derangements","number-theory.divisors","number-theory.count-divisors","number-theory.proper-divisors","number-theory.count-proper-divisors","number-theory.prime-factors","number-theory.count-prime-factors","number-theory.distinct-prime-factors","number-theory.count-distinct-prime-factors","number-theory.factorial","number-theory.partitions","number-theory.count-partitions","number-theory.permutations","number-theory.count-permutations","number-theory.power-set","number-theory.count-power-set","number-theory.coprime?","number-theory.divisible-by?","number-theory.gcd","number-theory.lcm","number-theory.multinomial","number-theory.amicable?","number-theory.euler-totient","number-theory.mobius","number-theory.mertens","number-theory.sigma","number-theory.carmichael-lambda","number-theory.cartesian-product","number-theory.perfect-power","number-theory.mod-exp","number-theory.mod-inv","number-theory.extended-gcd","number-theory.chinese-remainder","number-theory.stirling-first","number-theory.stirling-second"],convert:["convert.angstrom->um","convert.angstrom->mm","convert.angstrom->cm","convert.angstrom->m","convert.angstrom->km","convert.angstrom->in","convert.angstrom->ft","convert.angstrom->yd","convert.angstrom->mi","convert.angstrom->nmi","convert.um->angstrom","convert.um->mm","convert.um->cm","convert.um->m","convert.um->km","convert.um->in","convert.um->ft","convert.um->yd","convert.um->mi","convert.um->nmi","convert.mm->angstrom","convert.mm->um","convert.mm->cm","convert.mm->m","convert.mm->km","convert.mm->in","convert.mm->ft","convert.mm->yd","convert.mm->mi","convert.mm->nmi","convert.cm->angstrom","convert.cm->um","convert.cm->mm","convert.cm->m","convert.cm->km","convert.cm->in","convert.cm->ft","convert.cm->yd","convert.cm->mi","convert.cm->nmi","convert.m->angstrom","convert.m->um","convert.m->mm","convert.m->cm","convert.m->km","convert.m->in","convert.m->ft","convert.m->yd","convert.m->mi","convert.m->nmi","convert.km->angstrom","convert.km->um","convert.km->mm","convert.km->cm","convert.km->m","convert.km->in","convert.km->ft","convert.km->yd","convert.km->mi","convert.km->nmi","convert.in->angstrom","convert.in->um","convert.in->mm","convert.in->cm","convert.in->m","convert.in->km","convert.in->ft","convert.in->yd","convert.in->mi","convert.in->nmi","convert.ft->angstrom","convert.ft->um","convert.ft->mm","convert.ft->cm","convert.ft->m","convert.ft->km","convert.ft->in","convert.ft->yd","convert.ft->mi","convert.ft->nmi","convert.yd->angstrom","convert.yd->um","convert.yd->mm","convert.yd->cm","convert.yd->m","convert.yd->km","convert.yd->in","convert.yd->ft","convert.yd->mi","convert.yd->nmi","convert.mi->angstrom","convert.mi->um","convert.mi->mm","convert.mi->cm","convert.mi->m","convert.mi->km","convert.mi->in","convert.mi->ft","convert.mi->yd","convert.mi->nmi","convert.nmi->angstrom","convert.nmi->um","convert.nmi->mm","convert.nmi->cm","convert.nmi->m","convert.nmi->km","convert.nmi->in","convert.nmi->ft","convert.nmi->yd","convert.nmi->mi","convert.mg->g","convert.mg->kg","convert.mg->t","convert.mg->oz","convert.mg->lb","convert.mg->st","convert.g->mg","convert.g->kg","convert.g->t","convert.g->oz","convert.g->lb","convert.g->st","convert.kg->mg","convert.kg->g","convert.kg->t","convert.kg->oz","convert.kg->lb","convert.kg->st","convert.t->mg","convert.t->g","convert.t->kg","convert.t->oz","convert.t->lb","convert.t->st","convert.oz->mg","convert.oz->g","convert.oz->kg","convert.oz->t","convert.oz->lb","convert.oz->st","convert.lb->mg","convert.lb->g","convert.lb->kg","convert.lb->t","convert.lb->oz","convert.lb->st","convert.st->mg","convert.st->g","convert.st->kg","convert.st->t","convert.st->oz","convert.st->lb","convert.ml->cl","convert.ml->dl","convert.ml->l","convert.ml->tsp","convert.ml->tbsp","convert.ml->fl-oz","convert.ml->cup","convert.ml->pt","convert.ml->qt","convert.ml->gal","convert.cl->ml","convert.cl->dl","convert.cl->l","convert.cl->tsp","convert.cl->tbsp","convert.cl->fl-oz","convert.cl->cup","convert.cl->pt","convert.cl->qt","convert.cl->gal","convert.dl->ml","convert.dl->cl","convert.dl->l","convert.dl->tsp","convert.dl->tbsp","convert.dl->fl-oz","convert.dl->cup","convert.dl->pt","convert.dl->qt","convert.dl->gal","convert.l->ml","convert.l->cl","convert.l->dl","convert.l->tsp","convert.l->tbsp","convert.l->fl-oz","convert.l->cup","convert.l->pt","convert.l->qt","convert.l->gal","convert.tsp->ml","convert.tsp->cl","convert.tsp->dl","convert.tsp->l","convert.tsp->tbsp","convert.tsp->fl-oz","convert.tsp->cup","convert.tsp->pt","convert.tsp->qt","convert.tsp->gal","convert.tbsp->ml","convert.tbsp->cl","convert.tbsp->dl","convert.tbsp->l","convert.tbsp->tsp","convert.tbsp->fl-oz","convert.tbsp->cup","convert.tbsp->pt","convert.tbsp->qt","convert.tbsp->gal","convert.fl-oz->ml","convert.fl-oz->cl","convert.fl-oz->dl","convert.fl-oz->l","convert.fl-oz->tsp","convert.fl-oz->tbsp","convert.fl-oz->cup","convert.fl-oz->pt","convert.fl-oz->qt","convert.fl-oz->gal","convert.cup->ml","convert.cup->cl","convert.cup->dl","convert.cup->l","convert.cup->tsp","convert.cup->tbsp","convert.cup->fl-oz","convert.cup->pt","convert.cup->qt","convert.cup->gal","convert.pt->ml","convert.pt->cl","convert.pt->dl","convert.pt->l","convert.pt->tsp","convert.pt->tbsp","convert.pt->fl-oz","convert.pt->cup","convert.pt->qt","convert.pt->gal","convert.qt->ml","convert.qt->cl","convert.qt->dl","convert.qt->l","convert.qt->tsp","convert.qt->tbsp","convert.qt->fl-oz","convert.qt->cup","convert.qt->pt","convert.qt->gal","convert.gal->ml","convert.gal->cl","convert.gal->dl","convert.gal->l","convert.gal->tsp","convert.gal->tbsp","convert.gal->fl-oz","convert.gal->cup","convert.gal->pt","convert.gal->qt","convert.ms->s","convert.ms->min","convert.ms->h","convert.ms->day","convert.ms->week","convert.s->ms","convert.s->min","convert.s->h","convert.s->day","convert.s->week","convert.min->ms","convert.min->s","convert.min->h","convert.min->day","convert.min->week","convert.h->ms","convert.h->s","convert.h->min","convert.h->day","convert.h->week","convert.day->ms","convert.day->s","convert.day->min","convert.day->h","convert.day->week","convert.week->ms","convert.week->s","convert.week->min","convert.week->h","convert.week->day","convert.mm2->cm2","convert.mm2->m2","convert.mm2->km2","convert.mm2->in2","convert.mm2->ft2","convert.mm2->yd2","convert.mm2->acre","convert.mm2->hectare","convert.cm2->mm2","convert.cm2->m2","convert.cm2->km2","convert.cm2->in2","convert.cm2->ft2","convert.cm2->yd2","convert.cm2->acre","convert.cm2->hectare","convert.m2->mm2","convert.m2->cm2","convert.m2->km2","convert.m2->in2","convert.m2->ft2","convert.m2->yd2","convert.m2->acre","convert.m2->hectare","convert.km2->mm2","convert.km2->cm2","convert.km2->m2","convert.km2->in2","convert.km2->ft2","convert.km2->yd2","convert.km2->acre","convert.km2->hectare","convert.in2->mm2","convert.in2->cm2","convert.in2->m2","convert.in2->km2","convert.in2->ft2","convert.in2->yd2","convert.in2->acre","convert.in2->hectare","convert.ft2->mm2","convert.ft2->cm2","convert.ft2->m2","convert.ft2->km2","convert.ft2->in2","convert.ft2->yd2","convert.ft2->acre","convert.ft2->hectare","convert.yd2->mm2","convert.yd2->cm2","convert.yd2->m2","convert.yd2->km2","convert.yd2->in2","convert.yd2->ft2","convert.yd2->acre","convert.yd2->hectare","convert.acre->mm2","convert.acre->cm2","convert.acre->m2","convert.acre->km2","convert.acre->in2","convert.acre->ft2","convert.acre->yd2","convert.acre->hectare","convert.hectare->mm2","convert.hectare->cm2","convert.hectare->m2","convert.hectare->km2","convert.hectare->in2","convert.hectare->ft2","convert.hectare->yd2","convert.hectare->acre","convert.m/s->km/h","convert.m/s->mph","convert.m/s->kn","convert.m/s->ft/s","convert.km/h->m/s","convert.km/h->mph","convert.km/h->kn","convert.km/h->ft/s","convert.mph->m/s","convert.mph->km/h","convert.mph->kn","convert.mph->ft/s","convert.kn->m/s","convert.kn->km/h","convert.kn->mph","convert.kn->ft/s","convert.ft/s->m/s","convert.ft/s->km/h","convert.ft/s->mph","convert.ft/s->kn","convert.b->kb","convert.b->mb","convert.b->gb","convert.b->tb","convert.b->pb","convert.kb->b","convert.kb->mb","convert.kb->gb","convert.kb->tb","convert.kb->pb","convert.mb->b","convert.mb->kb","convert.mb->gb","convert.mb->tb","convert.mb->pb","convert.gb->b","convert.gb->kb","convert.gb->mb","convert.gb->tb","convert.gb->pb","convert.tb->b","convert.tb->kb","convert.tb->mb","convert.tb->gb","convert.tb->pb","convert.pb->b","convert.pb->kb","convert.pb->mb","convert.pb->gb","convert.pb->tb","convert.pa->kpa","convert.pa->bar","convert.pa->atm","convert.pa->psi","convert.pa->mmhg","convert.kpa->pa","convert.kpa->bar","convert.kpa->atm","convert.kpa->psi","convert.kpa->mmhg","convert.bar->pa","convert.bar->kpa","convert.bar->atm","convert.bar->psi","convert.bar->mmhg","convert.atm->pa","convert.atm->kpa","convert.atm->bar","convert.atm->psi","convert.atm->mmhg","convert.psi->pa","convert.psi->kpa","convert.psi->bar","convert.psi->atm","convert.psi->mmhg","convert.mmhg->pa","convert.mmhg->kpa","convert.mmhg->bar","convert.mmhg->atm","convert.mmhg->psi","convert.j->kj","convert.j->cal","convert.j->kcal","convert.j->wh","convert.j->kwh","convert.j->btu","convert.kj->j","convert.kj->cal","convert.kj->kcal","convert.kj->wh","convert.kj->kwh","convert.kj->btu","convert.cal->j","convert.cal->kj","convert.cal->kcal","convert.cal->wh","convert.cal->kwh","convert.cal->btu","convert.kcal->j","convert.kcal->kj","convert.kcal->cal","convert.kcal->wh","convert.kcal->kwh","convert.kcal->btu","convert.wh->j","convert.wh->kj","convert.wh->cal","convert.wh->kcal","convert.wh->kwh","convert.wh->btu","convert.kwh->j","convert.kwh->kj","convert.kwh->cal","convert.kwh->kcal","convert.kwh->wh","convert.kwh->btu","convert.btu->j","convert.btu->kj","convert.btu->cal","convert.btu->kcal","convert.btu->wh","convert.btu->kwh","convert.w->kw","convert.w->mw","convert.w->hp","convert.kw->w","convert.kw->mw","convert.kw->hp","convert.mw->w","convert.mw->kw","convert.mw->hp","convert.hp->w","convert.hp->kw","convert.hp->mw","convert.hz->khz","convert.hz->mhz","convert.hz->ghz","convert.khz->hz","convert.khz->mhz","convert.khz->ghz","convert.mhz->hz","convert.mhz->khz","convert.mhz->ghz","convert.ghz->hz","convert.ghz->khz","convert.ghz->mhz","convert.deg->rad","convert.deg->grad","convert.deg->turn","convert.rad->deg","convert.rad->grad","convert.rad->turn","convert.grad->deg","convert.grad->rad","convert.grad->turn","convert.turn->deg","convert.turn->rad","convert.turn->grad","convert.c->f","convert.c->k","convert.f->c","convert.f->k","convert.k->c","convert.k->f"],shorthand:["-short-regexp","-short-fn"],datatype:["-type-number","-type-string","-type-object","-type-array","-type-vector","-type-matrix","-type-grid","-type-boolean","-type-function","-type-integer","-type-any","-type-null","-type-collection","-type-sequence","-type-regexp","-type-effect","-type-never"]},el=[...[...[...Zc.collection,...Zc.array,...Zc.sequence,...Zc.math,...Zc.functional,...Zc.meta,...Zc.misc,...Zc.object,...Zc.predicate,...Zc.regularExpression,...Zc.string,...Zc.bitwise,...Zc.vector,...Zc.assertion],...[...Zc.matrix,...Zc.vectorUtils,...Zc.linAlg,...Zc.grid,...Zc.numberTheory,...Zc.mathUtils,...Zc.functionalUtils,...Zc.assertionUtils,...Zc.stringUtils,...Zc.collectionUtils,...Zc.sequenceUtils,...Zc.bitwiseUtils,...Zc.convert]],...Zc.shorthand,...Zc.datatype];exports.allBuiltinModules=Hc,exports.apiReference=Ja,exports.asDvalaFunction=function(e,t){return k(e,t),e},exports.asUserDefinedFunction=function(e,t){return A(e,t),e},exports.assertDvalaFunction=k,exports.assertModule=kr,exports.assertUserDefinedFunction=A,exports.bitwiseUtilsModule=ma,exports.createDvala=function(e){!function(){if(!Bc){Bc=!0;for(const[,e]of Object.entries(Gc)){const t=Oc({body:ms(ps(Ts(e,!1,void 0),{removeWhiteSpace:!0})),hasDebugData:!1},Gs());if(t instanceof Promise)throw new TypeError("Core dvala sources must be synchronous");if(!j(t))continue;const r=t;for(const[e,t]of Object.entries(r)){const r=lt[e];r&&x(t)&&"UserDefined"===t.functionType&&(r.dvalaImpl=t)}}}}();const t=e?.modules?new Map(e.modules.map(e=>[e.name,e])):void 0,n=e?.bindings,o=e?.effectHandlers,a=e?.debug??!1,i=e?.cache?new Lc(e.cache):null;function s(e,t){if(!t&&i){const t=i.get(e);if(t)return t}const r={body:ms(ps(Ts(e,a,t),{removeWhiteSpace:!0})),hasDebugData:a};return t||i?.set(e,r),r}function c(e){if(n||e)return{...n,...e}}function l(e){if(!o&&!e)return;const t={...e};if(o)for(const[e,r]of Object.entries(o))e in t||(t[e]=r);return t}function u(e,t){if(!e)return;if(t&&Object.keys(t).length>0)throw new TypeError("Cannot use pure mode with effect handlers")}return{run(e,n){Kc(n?.bindings);const o=c(n?.bindings),a=l(n?.effectHandlers),i=n?.pure??!1;u(i,a);const m=Gs({bindings:o},t,i);if(Za(e)){const t=m.pure;m.pure=!0;for(const[t,r]of e.fileModules){const e=s(r),n=m.create({});m.registerValueModule(t,Oc(e,n))}m.pure=t;const r=Oc(s(e.program),m);if(r instanceof Promise)throw new TypeError("Unexpected async result in run(). Use runAsync() for async operations.");return r}const p=s(e,n?.filePath);if(a)return function(e,t,n){const o=Pc(e.body,t);try{return Rc(o,n)}catch(o){if(o instanceof r&&o.message.includes("Unexpected async operation"))return Rc(Pc(e.body,t),n);throw o}}(p,m,a);const d=Oc(p,m);if(d instanceof Promise)throw new TypeError("Unexpected async result in run(). Use runAsync() for async operations.");return d},async runAsync(e,n){Kc(n?.bindings);const o=c(n?.bindings),a=l(n?.effectHandlers),i=n?.pure??!1;u(i,a);try{const r=Gs({bindings:o},t,i);if(Za(e)){const t=r.pure;r.pure=!0;for(const[t,n]of e.fileModules){const e=s(n),o=r.create({});r.registerValueModule(t,Oc(e,o))}r.pure=t}const c=s(Za(e)?e.program:e),l=await async function(e,t,r,n,o){const a=(new AbortController).signal;return Uc(Pc(e.body,t),r,a,void 0,n,o)}(c,r,a,n?.maxSnapshots,{values:o,modules:t});return"completed"===l.type?{...l,definedBindings:r.getModuleScopeBindings()}:l}catch(e){if(e instanceof r)return{type:"error",error:e};if(e instanceof TypeError)throw e;return{type:"error",error:new r(`${e}`,void 0)}}},getUndefinedSymbols(e){const r=t?[...t.values()]:void 0;return _c(e,{bindings:n,modules:r})},getAutoCompleter:(e,t)=>new Wc(e,t,{bindings:n})}},exports.functionalUtilsModule=ca,exports.getAutoCompleter=function(e,t,r={}){return new Wc(e,t,r)},exports.getUndefinedSymbols=_c,exports.gridModule=$r,exports.isApiName=function(e){return el.includes(e)},exports.isBuiltinFunction=function(e){return w(e)&&"Builtin"===e.functionType},exports.isCustomReference=function(e){return"customVariants"in e},exports.isDataType=function(e){return vr.includes(e)},exports.isDatatypeReference=function(e){return"datatype"in e},exports.isDvalaBundle=Za,exports.isDvalaError=function(e){return e instanceof r},exports.isDvalaFunction=x,exports.isFunctionReference=La,exports.isGrid=Oe,exports.isMatrix=Ve,exports.isShorthandReference=function(e){return"shorthand"in e},exports.isUserDefinedFunction=q,exports.isVector=Ie,exports.linearAlgebraModule=qn,exports.mathUtilsModule=ia,exports.matrixModule=In,exports.normalExpressionKeys=cr,exports.numberTheoryModule=Lo,exports.parseTokenStream=function(e){return{body:ms(ps(e,{removeWhiteSpace:!0})),hasDebugData:e.hasDebugData}},exports.resume=async function(e,t,n){try{const r=n?.modules?new Map(n.modules.map(e=>[e.name,e])):void 0,o=tc(e.continuation,{values:n?.bindings,modules:r}),a={values:n?.bindings,modules:r};return await async function(e,t,r,n,o){return Uc({type:"Value",value:t,k:e},r,(new AbortController).signal,n,n?.maxSnapshots,o)}(o.k,t,n?.handlers,{snapshots:o.snapshots,nextSnapshotIndex:o.nextSnapshotIndex,maxSnapshots:n?.maxSnapshots},a)}catch(e){return e instanceof r?{type:"error",error:e}:{type:"error",error:new r(`${e}`,void 0)}}},exports.retrigger=async function(e,t){if(!e.effectName||!e.effectArgs)return{type:"error",error:new r("Cannot retrigger: snapshot has no captured effect (suspended outside of an effect handler)",void 0)};try{const r=t?.modules?new Map(t.modules.map(e=>[e.name,e])):void 0,n={values:t?.bindings,modules:r},o=tc(e.continuation,n);return await Vc(o.k,e.effectName,e.effectArgs,t?.handlers,{snapshots:o.snapshots,nextSnapshotIndex:o.nextSnapshotIndex,maxSnapshots:t?.maxSnapshots},n)}catch(e){return e instanceof r?{type:"error",error:e}:{type:"error",error:new r(`${e}`,void 0)}}},exports.specialExpressionKeys=lr,exports.tokenizeSource=function(e,t=!1,r){return Ts(e,t,r)},exports.transformSymbols=function(e,t){return function(e,t){return{...e,tokens:e.tokens.map(e=>ci(e)?[e[0],t(e[1])]:e)}}(e,t)},exports.untokenize=function(e){return e.tokens.reduce((e,t)=>`${e}${t[1]}`,"")},exports.vectorModule=un;
|
|
2
|
-
//# sourceMappingURL=full.js.map
|