@mojir/lits 2.2.4 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cli/cli.js +1264 -909
- package/dist/cli/src/Lits/Lits.d.ts +8 -2
- package/dist/cli/src/builtin/bindingNode.d.ts +2 -1
- package/dist/cli/src/builtin/interface.d.ts +3 -2
- package/dist/cli/src/builtin/modules/number-theory/sequences/index.d.ts +2 -1
- package/dist/cli/src/evaluator/functionExecutors.d.ts +2 -1
- package/dist/cli/src/evaluator/index.d.ts +3 -2
- package/dist/cli/src/evaluator/interface.d.ts +3 -2
- package/dist/cli/src/utils/maybePromise.d.ts +54 -0
- package/dist/full.esm.js +1 -1
- package/dist/full.esm.js.map +1 -1
- package/dist/full.js +1 -1
- package/dist/full.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lits.iife.js +1 -1
- package/dist/lits.iife.js.map +1 -1
- package/dist/modules/assert.esm.js +1 -1
- package/dist/modules/assert.esm.js.map +1 -1
- package/dist/modules/assert.js +1 -1
- package/dist/modules/assert.js.map +1 -1
- package/dist/modules/collection.esm.js +1 -1
- package/dist/modules/collection.esm.js.map +1 -1
- package/dist/modules/collection.js +1 -1
- package/dist/modules/collection.js.map +1 -1
- package/dist/modules/grid.esm.js +1 -1
- package/dist/modules/grid.esm.js.map +1 -1
- package/dist/modules/grid.js +1 -1
- package/dist/modules/grid.js.map +1 -1
- package/dist/modules/number-theory.esm.js +1 -1
- package/dist/modules/number-theory.esm.js.map +1 -1
- package/dist/modules/number-theory.js +1 -1
- package/dist/modules/number-theory.js.map +1 -1
- package/dist/modules/sequence.esm.js +1 -1
- package/dist/modules/sequence.esm.js.map +1 -1
- package/dist/modules/sequence.js +1 -1
- package/dist/modules/sequence.js.map +1 -1
- package/dist/modules/src/Lits/Lits.d.ts +8 -2
- package/dist/modules/src/builtin/bindingNode.d.ts +2 -1
- package/dist/modules/src/builtin/interface.d.ts +3 -2
- package/dist/modules/src/builtin/modules/number-theory/sequences/index.d.ts +2 -1
- package/dist/modules/src/evaluator/functionExecutors.d.ts +2 -1
- package/dist/modules/src/evaluator/index.d.ts +3 -2
- package/dist/modules/src/evaluator/interface.d.ts +3 -2
- package/dist/modules/src/utils/maybePromise.d.ts +54 -0
- package/dist/modules/vector.esm.js +1 -1
- package/dist/modules/vector.esm.js.map +1 -1
- package/dist/modules/vector.js +1 -1
- package/dist/modules/vector.js.map +1 -1
- package/dist/src/Lits/Lits.d.ts +8 -2
- package/dist/src/builtin/bindingNode.d.ts +2 -1
- package/dist/src/builtin/interface.d.ts +3 -2
- package/dist/src/builtin/modules/number-theory/sequences/index.d.ts +2 -1
- package/dist/src/evaluator/functionExecutors.d.ts +2 -1
- package/dist/src/evaluator/index.d.ts +3 -2
- package/dist/src/evaluator/interface.d.ts +3 -2
- package/dist/src/utils/maybePromise.d.ts +54 -0
- package/dist/testFramework.esm.js +1 -1
- package/dist/testFramework.esm.js.map +1 -1
- package/dist/testFramework.js +1 -1
- package/dist/testFramework.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/utils/debug/getCodeMarker.ts","../src/errors.ts","../src/constants/constants.ts","../src/utils/symbols.ts","../src/utils/debug/debugTools.ts","../src/utils/debug/getSourceCodeInfo.ts","../src/utils/getAssertionError.ts","../src/typeGuards/index.ts","../src/typeGuards/litsFunction.ts","../src/typeGuards/number.ts","../src/typeGuards/lits.ts","../src/utils/arity.ts","../src/builtin/core/bitwise.ts","../src/typeGuards/string.ts","../src/utils/index.ts","../src/typeGuards/array.ts","../src/builtin/core/collection.ts","../src/builtin/core/array.ts","../src/builtin/core/sequence.ts","../src/typeGuards/annotatedArrays.ts","../src/builtin/core/math.ts","../src/builtin/core/misc.ts","../src/builtin/core/object.ts","../src/builtin/core/predicates.ts","../src/builtin/core/regexp.ts","../src/builtin/core/string.ts","../src/builtin/core/functional.ts","../src/builtin/core/meta.ts","../src/builtin/core/vector.ts","../src/utils/docString/generateDocString.ts","../src/builtin/normalExpressions/index.ts","../src/builtin/specialExpressions/and.ts","../src/builtin/specialExpressions/cond.ts","../src/builtin/specialExpressions/switch.ts","../src/typeGuards/astNode.ts","../src/builtin/specialExpressions/defined.ts","../src/parser/types.ts","../src/builtin/bindingNode.ts","../src/builtin/specialExpressions/def.ts","../src/builtin/specialExpressions/block.ts","../src/builtin/specialExpressions/functions.ts","../src/builtin/specialExpressions/if.ts","../src/builtin/specialExpressions/unless.ts","../src/builtin/specialExpressions/let.ts","../src/builtin/specialExpressions/loop.ts","../src/builtin/specialExpressions/loops.ts","../src/builtin/specialExpressions/or.ts","../src/builtin/specialExpressions/qq.ts","../src/builtin/specialExpressions/recur.ts","../src/builtin/specialExpressions/throw.ts","../src/builtin/specialExpressions/try.ts","../src/builtin/specialExpressions/array.ts","../src/builtin/specialExpressions/object.ts","../src/builtin/specialExpressionTypes.ts","../src/builtin/index.ts","../src/getUndefinedSymbols/index.ts","../src/tokenizer/reservedNames.ts","../src/evaluator/functionExecutors.ts","../src/evaluator/index.ts"],"sourcesContent":["import type { SourceCodeInfo } from '../../tokenizer/token'\n\nexport function getCodeMarker(sourceCodeInfo: SourceCodeInfo): string {\n if (!sourceCodeInfo.position || !sourceCodeInfo.code)\n return ''\n\n const leftPadding = sourceCodeInfo.position.column - 1\n const rightPadding = sourceCodeInfo.code.length - leftPadding - 1\n return `${' '.repeat(Math.max(leftPadding, 0))}^${' '.repeat(Math.max(rightPadding, 0))}`\n}\n","import { getCodeMarker } from '../src/utils/debug/getCodeMarker'\nimport type { Arr } from './interface'\nimport type { SourceCodeInfo } from './tokenizer/token'\n\nfunction getLitsErrorMessage(message: string, sourceCodeInfo?: SourceCodeInfo) {\n if (!sourceCodeInfo) {\n return message\n }\n const location = `${sourceCodeInfo.position.line}:${sourceCodeInfo.position.column}`\n const filePathLine = sourceCodeInfo.filePath\n ? `\\n${sourceCodeInfo.filePath}:${location}`\n : `\\nLocation ${location}`\n const codeLine = `\\n${sourceCodeInfo.code}`\n const codeMarker = `\\n${getCodeMarker(sourceCodeInfo)}`\n return `${message}${filePathLine}${codeLine}${codeMarker}`\n}\n\nexport class RecurSignal extends Error {\n public params: Arr\n constructor(params: Arr) {\n super(`recur, params: ${params}`)\n Object.setPrototypeOf(this, RecurSignal.prototype)\n this.name = 'RecurSignal'\n this.params = params\n }\n}\n\nexport class LitsError extends Error {\n public readonly sourceCodeInfo?: SourceCodeInfo\n public readonly shortMessage: string\n constructor(err: unknown, sourceCodeInfo: SourceCodeInfo | undefined) {\n const message = err instanceof Error\n ? err.message\n : `${err}`\n\n super(getLitsErrorMessage(message, sourceCodeInfo))\n this.shortMessage = message\n this.sourceCodeInfo = sourceCodeInfo\n Object.setPrototypeOf(this, LitsError.prototype)\n this.name = 'LitsError'\n }\n\n public getCodeMarker(): string | undefined {\n return this.sourceCodeInfo && getCodeMarker(this.sourceCodeInfo)\n }\n}\n\nexport class UserDefinedError extends LitsError {\n public userMessage: string\n constructor(message: string, sourceCodeInfo?: SourceCodeInfo) {\n super(message, sourceCodeInfo)\n this.userMessage = message\n Object.setPrototypeOf(this, UserDefinedError.prototype)\n this.name = 'UserDefinedError'\n }\n}\n\nexport class AssertionError extends LitsError {\n constructor(message: string | Error, sourceCodeInfo?: SourceCodeInfo) {\n super(message, sourceCodeInfo)\n Object.setPrototypeOf(this, AssertionError.prototype)\n this.name = 'AssertionError'\n }\n}\n\nexport class UndefinedSymbolError extends LitsError {\n public symbol: string\n constructor(symbolName: string, sourceCodeInfo?: SourceCodeInfo) {\n const message = `Undefined symbol '${symbolName}'.`\n super(message, sourceCodeInfo)\n this.symbol = symbolName\n Object.setPrototypeOf(this, UndefinedSymbolError.prototype)\n this.name = 'UndefinedSymbolError'\n }\n}\n\nexport function isLitsError(error: unknown): error is LitsError {\n return error instanceof LitsError\n}\n","export const NodeTypes = {\n Number: 1,\n String: 2,\n NormalExpression: 3,\n SpecialExpression: 4,\n UserDefinedSymbol: 5,\n NormalBuiltinSymbol: 6,\n SpecialBuiltinSymbol: 7,\n ReservedSymbol: 8,\n Binding: 9,\n Spread: 10,\n} as const\n\nconst NodeTypesSet = new Set(Object.values(NodeTypes))\n\nexport type NodeType = typeof NodeTypes[keyof typeof NodeTypes]\n\nexport function getNodeTypeName(type: NodeType): keyof typeof NodeTypes {\n return Object.keys(NodeTypes).find(key => NodeTypes[key as keyof typeof NodeTypes] === type) as keyof typeof NodeTypes\n}\n\n// TODO, is this needed?\nexport function isNodeType(type: unknown): type is NodeType {\n return typeof type === 'number' && NodeTypesSet.has(type as NodeType)\n}\n\nconst functionTypes = [\n 'UserDefined',\n 'Partial',\n 'Comp',\n 'Constantly',\n 'Juxt',\n 'Complement',\n 'EveryPred',\n 'SomePred',\n 'Fnull',\n 'Builtin',\n 'SpecialBuiltin',\n 'NativeJsFunction',\n 'Module',\n] as const\n\nconst functionTypeSet = new Set(functionTypes)\n\nexport type FunctionType = typeof functionTypes[number]\n\nexport function isFunctionType(type: unknown): type is FunctionType {\n return typeof type === 'string' && functionTypeSet.has(type as FunctionType)\n}\n","export const FUNCTION_SYMBOL = '^^fn^^'\nexport const REGEXP_SYMBOL = '^^re^^'\n","import { getNodeTypeName, isFunctionType, isNodeType } from '../../constants/constants'\nimport type { AstNode, LitsFunction } from '../../parser/types'\nimport { FUNCTION_SYMBOL } from '../symbols'\n\nfunction isLitsFunction(func: unknown): func is LitsFunction {\n if (func === null || typeof func !== 'object')\n return false\n\n return FUNCTION_SYMBOL in func && 'functionType' in func && isFunctionType(func.functionType)\n}\n\nfunction isNode(value: unknown): value is AstNode {\n if (!Array.isArray(value) || value.length < 2)\n return false\n return isNodeType(value[0])\n}\n\nexport function valueToString(value: unknown): string {\n if (isLitsFunction(value))\n // eslint-disable-next-line ts/no-unsafe-member-access\n return `<function ${(value as any).name || '\\u03BB'}>`\n\n if (isNode(value))\n return `${getNodeTypeName(value[0])}-node`\n\n if (value === null)\n return 'null'\n\n if (typeof value === 'object' && value instanceof RegExp)\n return `${value}`\n\n if (typeof value === 'object' && value instanceof Error)\n return value.toString()\n\n return JSON.stringify(value)\n}\n","import type { SourceCodeInfo } from '../../tokenizer/token'\n\nexport function getSourceCodeInfo(anyValue: any, sourceCodeInfo: SourceCodeInfo | undefined): SourceCodeInfo | undefined {\n // eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access\n return anyValue?.sourceCodeInfo ?? sourceCodeInfo\n}\n","import { LitsError } from '../errors'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from './debug/debugTools'\nimport { getSourceCodeInfo } from './debug/getSourceCodeInfo'\n\nexport function getAssertionError(typeName: string, value: unknown, sourceCodeInfo?: SourceCodeInfo): LitsError {\n return new LitsError(`Expected ${typeName}, got ${valueToString(value)}.`, getSourceCodeInfo(value, sourceCodeInfo))\n}\n","import { LitsError } from '../errors'\nimport type { UnknownRecord } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from '../utils/debug/debugTools'\nimport { getSourceCodeInfo } from '../utils/debug/getSourceCodeInfo'\n\nfunction isNonUndefined<T>(value: T | undefined): value is T {\n return value !== undefined\n}\n\nexport function asNonUndefined<T>(value: T | undefined, sourceCodeInfo?: SourceCodeInfo): T {\n assertNonUndefined(value, sourceCodeInfo)\n return value\n}\n\nexport function assertNonUndefined<T>(value: T | undefined, sourceCodeInfo?: SourceCodeInfo): asserts value is T {\n if (!isNonUndefined(value))\n throw new LitsError('Unexpected undefined', getSourceCodeInfo(value, sourceCodeInfo))\n}\n\nexport function isUnknownRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\nexport function assertUnknownRecord(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is UnknownRecord {\n if (!isUnknownRecord(value)) {\n throw new LitsError(\n `Expected ${'UnknownRecord'}, got ${valueToString(value)}.`,\n getSourceCodeInfo(value, sourceCodeInfo),\n )\n }\n}\n\nexport function asUnknownRecord(value: unknown, sourceCodeInfo?: SourceCodeInfo): UnknownRecord {\n assertUnknownRecord(value, sourceCodeInfo)\n return value\n}\n","import type { LitsFunction, NativeJsFunction, NormalBuiltinFunction, UserDefinedFunction } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\nimport { FUNCTION_SYMBOL } from '../utils/symbols'\nimport { isUnknownRecord } from '.'\n\nexport function isLitsFunction(value: unknown): value is LitsFunction {\n if (value === null || typeof value !== 'object')\n return false\n\n return !!(value as LitsFunction)[FUNCTION_SYMBOL]\n}\nexport function asLitsFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): LitsFunction {\n assertLitsFunction(value, sourceCodeInfo)\n return value\n}\nexport function assertLitsFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is LitsFunction {\n if (!isLitsFunction(value))\n throw getAssertionError('LitsFunction', value, sourceCodeInfo)\n}\n\nexport function isUserDefinedFunction(value: unknown): value is UserDefinedFunction {\n return isLitsFunction(value) && value.functionType === 'UserDefined'\n}\nexport function asUserDefinedFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): UserDefinedFunction {\n assertUserDefinedFunction(value, sourceCodeInfo)\n return value\n}\nexport function assertUserDefinedFunction(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is UserDefinedFunction {\n if (!isUserDefinedFunction(value))\n throw getAssertionError('NativeJsFunction', value, sourceCodeInfo)\n}\n\nexport function isNativeJsFunction(value: unknown): value is NativeJsFunction {\n return isLitsFunction(value) && value.functionType === 'NativeJsFunction'\n}\nexport function asNativeJsFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): NativeJsFunction {\n assertNativeJsFunction(value, sourceCodeInfo)\n return value\n}\nexport function assertNativeJsFunction(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is NativeJsFunction {\n if (!isNativeJsFunction(value))\n throw getAssertionError('NativeJsFunction', value, sourceCodeInfo)\n}\n\nexport function isBuiltinFunction(value: unknown): value is NormalBuiltinFunction {\n return isUnknownRecord(value) && value.functionType === 'Builtin'\n}\n","import { LitsError } from '../errors'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from '../utils/debug/debugTools'\nimport { getSourceCodeInfo } from '../utils/debug/getSourceCodeInfo'\n\ntype SignOptions =\n | {\n positive?: true\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: true\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: true\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: true\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: true\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: true\n }\n\ntype GtOptions =\n | {\n gt?: number\n gte?: never\n }\n | {\n gt?: never\n gte?: number\n }\n\ntype LtOptions =\n | {\n lt?: number\n lte?: never\n }\n | {\n lt?: never\n lte?: number\n }\n\ntype NumberOptions = {\n integer?: true\n finite?: true\n} & SignOptions &\nGtOptions &\nLtOptions\n\nfunction getRangeString(options: NumberOptions): string {\n const hasUpperAndLowerBound\n = (typeof options.gt === 'number' || typeof options.gte === 'number')\n && (typeof options.lt === 'number' || typeof options.lte === 'number')\n if (hasUpperAndLowerBound) {\n return `${typeof options.gt === 'number' ? `${options.gt} < n ` : `${options.gte} <= n `}${\n typeof options.lt === 'number' ? `< ${options.lt}` : `<= ${options.lte}`\n }`\n }\n else if (typeof options.gt === 'number' || typeof options.gte === 'number') {\n return `${typeof options.gt === 'number' ? `n > ${options.gt}` : `n >= ${options.gte}`}`\n }\n else if (typeof options.lt === 'number' || typeof options.lte === 'number') {\n return `${typeof options.lt === 'number' ? `n < ${options.lt}` : `n <= ${options.lte}`}`\n }\n else { return '' }\n}\n\nfunction getSignString(options: NumberOptions): string {\n return options.positive\n ? 'positive'\n : options.negative\n ? 'negative'\n : options.nonNegative\n ? 'non negative'\n : options.nonPositive\n ? 'non positive'\n : options.nonZero\n ? 'non zero'\n : ''\n}\n\nfunction getNumberTypeName(options: NumberOptions): string {\n if (options.zero)\n return 'zero'\n\n const sign = getSignString(options)\n const numberType = options.integer ? 'integer' : 'number'\n const finite = options.finite ? 'finite' : ''\n const range = getRangeString(options)\n\n return [sign, finite, numberType, range].filter(x => !!x).join(' ')\n}\n\nexport function isNumber(value: unknown, options: NumberOptions = {}): value is number {\n if (typeof value !== 'number')\n return false\n\n if (Number.isNaN(value))\n return false\n\n if (options.integer && !Number.isInteger(value))\n return false\n\n if (options.finite && !Number.isFinite(value))\n return false\n\n if (options.zero && value !== 0)\n return false\n\n if (options.nonZero && value === 0)\n return false\n\n if (options.positive && value <= 0)\n return false\n\n if (options.negative && value >= 0)\n return false\n\n if (options.nonPositive && value > 0)\n return false\n\n if (options.nonNegative && value < 0)\n return false\n\n if (typeof options.gt === 'number' && value <= options.gt)\n return false\n\n if (typeof options.gte === 'number' && value < options.gte)\n return false\n\n if (typeof options.lt === 'number' && value >= options.lt)\n return false\n\n if (typeof options.lte === 'number' && value > options.lte)\n return false\n\n return true\n}\n\nexport function assertNumber(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n options: NumberOptions = {},\n): asserts value is number {\n if (!isNumber(value, options)) {\n throw new LitsError(\n `Expected ${getNumberTypeName(options)}, got ${valueToString(value)}.`,\n getSourceCodeInfo(value, sourceCodeInfo),\n )\n }\n}\n\nexport function asNumber(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: NumberOptions = {},\n): number {\n assertNumber(value, sourceCodeInfo, options)\n return value\n}\n","import type { Any, Coll, Obj, Seq } from '../interface'\nimport type { FunctionLike, RegularExpression } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\nimport { REGEXP_SYMBOL } from '../utils/symbols'\nimport { isLitsFunction } from './litsFunction'\n\nexport function isAny(value: unknown): value is Any {\n // TODO weak test\n return value !== undefined\n}\nexport function asAny(value: unknown, sourceCodeInfo?: SourceCodeInfo): Any {\n assertAny(value, sourceCodeInfo)\n return value\n}\nexport function assertAny(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Any {\n if (!isAny(value))\n throw getAssertionError('not undefined', value, sourceCodeInfo)\n}\n\nexport function isSeq(value: unknown): value is Seq {\n return Array.isArray(value) || typeof value === 'string'\n}\nexport function asSeq(value: unknown, sourceCodeInfo?: SourceCodeInfo): Seq {\n assertSeq(value, sourceCodeInfo)\n return value\n}\nexport function assertSeq(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Seq {\n if (!isSeq(value))\n throw getAssertionError('string or array', value, sourceCodeInfo)\n}\n\nexport function isObj(value: unknown): value is Obj {\n return !(\n value === null\n || typeof value !== 'object'\n || Array.isArray(value)\n || value instanceof RegExp\n || isLitsFunction(value)\n || isRegularExpression(value)\n )\n}\nexport function asObj(value: unknown, sourceCodeInfo?: SourceCodeInfo): Obj {\n assertObj(value, sourceCodeInfo)\n return value\n}\nexport function assertObj(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Obj {\n if (!isObj(value))\n throw getAssertionError('object', value, sourceCodeInfo)\n}\n\nexport function isColl(value: unknown): value is Coll {\n return isSeq(value) || isObj(value)\n}\nexport function asColl(value: unknown, sourceCodeInfo?: SourceCodeInfo): Coll {\n assertColl(value, sourceCodeInfo)\n return value\n}\nexport function assertColl(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Coll {\n if (!isColl(value))\n throw getAssertionError('string, array or object', value, sourceCodeInfo)\n}\n\nexport function isRegularExpression(regexp: unknown): regexp is RegularExpression {\n if (regexp === null || typeof regexp !== 'object')\n return false\n\n return !!(regexp as RegularExpression)[REGEXP_SYMBOL]\n}\nexport function asRegularExpression(value: unknown, sourceCodeInfo?: SourceCodeInfo): RegularExpression {\n assertRegularExpression(value, sourceCodeInfo)\n return value\n}\nexport function assertRegularExpression(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is RegularExpression {\n if (!isRegularExpression(value))\n throw getAssertionError('RegularExpression', value, sourceCodeInfo)\n}\n\nexport function isStringOrRegularExpression(value: unknown): value is string | RegularExpression {\n return isRegularExpression(value) || typeof value === 'string'\n}\nexport function asStringOrRegularExpression(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): string | RegularExpression {\n assertStringOrRegularExpression(value, sourceCodeInfo)\n return value\n}\nexport function assertStringOrRegularExpression(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is string | RegularExpression {\n if (!isStringOrRegularExpression(value))\n throw getAssertionError('string or RegularExpression', value, sourceCodeInfo)\n}\n\nfunction isFunctionLike(value: unknown): value is FunctionLike {\n if (typeof value === 'number')\n return true\n if (isColl(value))\n return true\n if (isLitsFunction(value))\n return true\n\n return false\n}\nexport function asFunctionLike(value: unknown, sourceCodeInfo?: SourceCodeInfo): FunctionLike {\n assertFunctionLike(value, sourceCodeInfo)\n return value\n}\nexport function assertFunctionLike(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is FunctionLike {\n if (!isFunctionLike(value))\n throw getAssertionError('FunctionLike', value, sourceCodeInfo)\n}\n","import type { Arity } from '../builtin/interface'\nimport { LitsError } from '../errors'\nimport type { FunctionLike } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isColl } from '../typeGuards/lits'\nimport { valueToString } from './debug/debugTools'\n\nexport function arityAccepts(arity: Arity, nbrOfParams: number): boolean {\n const { min, max } = arity\n if (typeof min === 'number' && nbrOfParams < min) {\n return false\n }\n if (typeof max === 'number' && nbrOfParams > max) {\n return false\n }\n return true\n}\n\nexport function arityAcceptsMin(arity: Arity, nbrOfParams: number): boolean {\n const { min } = arity\n if (typeof min === 'number' && nbrOfParams < min) {\n return false\n }\n return true\n}\n\nexport function getCommonArityFromFunctions(params: FunctionLike[]): Arity | null {\n return params.reduce((acc: Arity | null, param): Arity | null => {\n if (acc === null) {\n return null\n }\n const arity: Arity = (typeof param === 'number' || isColl(param)) ? toFixedArity(1) : param.arity\n const { min: aMin, max: aMax } = arity\n const { min: bMin, max: bMax } = acc\n const min = typeof aMin === 'number' && typeof bMin === 'number'\n ? Math.max(aMin, bMin)\n : typeof aMin === 'number' ? aMin : typeof bMin === 'number' ? bMin : undefined\n const max = typeof aMax === 'number' && typeof bMax === 'number'\n ? Math.min(aMax, bMax)\n : typeof aMax === 'number' ? aMax : typeof bMax === 'number' ? bMax : undefined\n\n if (typeof min === 'number' && typeof max === 'number' && min > max) {\n return null\n }\n\n return { min, max }\n }, {})\n}\n\nexport function getArityFromFunction(param: FunctionLike): Arity {\n return (typeof param === 'number' || isColl(param)) ? toFixedArity(1) : param.arity\n}\n\nexport function assertNumberOfParams(arity: Arity, length: number, sourceCodeInfo: SourceCodeInfo | undefined): void {\n const { min, max } = arity\n if (typeof min === 'number' && length < min) {\n throw new LitsError(\n `Wrong number of arguments, expected at least ${min}, got ${valueToString(length)}.`,\n sourceCodeInfo,\n )\n }\n\n if (typeof max === 'number' && length > max) {\n throw new LitsError(\n `Wrong number of arguments, expected at most ${max}, got ${valueToString(length)}.`,\n sourceCodeInfo,\n )\n }\n}\n\nexport function canBeOperator(count: Arity): boolean {\n if (typeof count.max === 'number' && count.max < 2) {\n return false\n }\n\n if (typeof count.min === 'number' && count.min > 2) {\n return false\n }\n\n return true\n}\n\nexport function toFixedArity(arity: number): Arity {\n return { min: arity, max: arity }\n}\n","import { assertNumber } from '../../typeGuards/number'\nimport { toFixedArity } from '../../utils/arity'\nimport type { Argument, BuiltinNormalExpressions } from '../interface'\n\nfunction getOperatorArgs(a: 'integer', b: 'integer'): Record<string, Argument> {\n return { a: { type: a }, b: { type: b } }\n}\n\nexport const bitwiseNormalExpression: BuiltinNormalExpressions = {\n '<<': {\n evaluate: ([num, count], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return num << count\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Shifts $a arithmetically left by $b bit positions.',\n seeAlso: ['>>', '>>>'],\n examples: [\n '1 << 10',\n '<<(1, 10)',\n '<<(-4, 2)',\n ],\n },\n },\n '>>': {\n evaluate: ([num, count], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return num >> count\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Shifts $a arithmetically right by $b bit positions.',\n seeAlso: ['<<', '>>>'],\n examples: [\n '2048 >> 10',\n '>>(2048, 10)',\n '>>>(-16, 2)',\n '>>(4, 10)',\n ],\n },\n },\n '>>>': {\n evaluate: ([num, count], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return num >>> count\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Shifts $a arithmetically right by $b bit positions without sign extension.',\n seeAlso: ['<<', '>>'],\n examples: [\n '-16 >>> 2',\n '>>>(2048, 10)',\n '>>>(-16, 2)',\n '>>>(4, 10)',\n '>>>(-1, 10)',\n ],\n },\n },\n '&': {\n evaluate: ([first, ...rest], sourceCodeInfo): number => {\n assertNumber(first, sourceCodeInfo, { integer: true })\n\n return rest.reduce((result: number, value) => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n return result & value\n }, first)\n },\n arity: { min: 2 },\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: {\n ...getOperatorArgs('integer', 'integer'),\n c: { type: 'integer', rest: true },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: 'Returns bitwise `and` of all arguments.',\n seeAlso: ['|', 'xor', 'bitwise.bit-not', 'bitwise.bit-and-not'],\n examples: [\n '0b0011 & 0b0110',\n '&(0b0011, 0b0110)',\n '&(0b0011, 0b0110, 0b1001)',\n ],\n },\n },\n '|': {\n evaluate: ([first, ...rest], sourceCodeInfo): number => {\n assertNumber(first, sourceCodeInfo, { integer: true })\n\n return rest.reduce((result: number, value) => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n return result | value\n }, first)\n },\n arity: { min: 2 },\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: {\n ...getOperatorArgs('integer', 'integer'),\n c: { type: 'integer', rest: true },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: 'Returns bitwise `or` of all arguments.',\n seeAlso: ['&', 'xor', 'bitwise.bit-not', 'bitwise.bit-and-not'],\n examples: [\n '0b0011 | 0b0110',\n '|(0b0011, 0b0110)',\n '|(0b1000, 0b0100, 0b0010)',\n ],\n },\n },\n 'xor': {\n evaluate: ([first, ...rest], sourceCodeInfo): number => {\n assertNumber(first, sourceCodeInfo, { integer: true })\n\n return rest.reduce((result: number, value) => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n return result ^ value\n }, first)\n },\n arity: { min: 2 },\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: {\n ...getOperatorArgs('integer', 'integer'),\n c: { type: 'integer', rest: true },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: 'Returns bitwise `xor` of all arguments.',\n seeAlso: ['&', '|', 'bitwise.bit-not', 'bitwise.bit-and-not'],\n examples: [\n '0b0011 xor 0b0110',\n 'xor(0b0011, 0b0110)',\n 'xor(0b11110000, 0b00111100, 0b10101010)',\n ],\n },\n },\n}\n","import type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\n\ntype StringAssertionOptions =\n | {\n nonEmpty?: true\n char?: never\n }\n | {\n nonEmpty?: never\n char?: true\n }\n\nexport function isString(value: unknown, options: StringAssertionOptions = {}): value is string {\n if (typeof value !== 'string')\n return false\n\n if (options.nonEmpty && value.length === 0)\n return false\n\n if (options.char && value.length !== 1)\n return false\n\n return true\n}\n\nexport function assertString(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: StringAssertionOptions = {},\n): asserts value is string {\n if (!isString(value, options)) {\n throw getAssertionError(\n `${options.nonEmpty ? 'non empty string' : options.char ? 'character' : 'string'}`,\n value,\n sourceCodeInfo,\n )\n }\n}\n\nexport function asString(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: StringAssertionOptions = {},\n): string {\n assertString(value, sourceCodeInfo, options)\n return value\n}\n\nexport function isStringOrNumber(value: unknown): value is string | number {\n return typeof value === 'string' || typeof value === 'number'\n}\nexport function asStringOrNumber(value: unknown, sourceCodeInfo?: SourceCodeInfo): string | number {\n assertStringOrNumber(value, sourceCodeInfo)\n return value\n}\nexport function assertStringOrNumber(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is string | number {\n if (!isStringOrNumber(value))\n throw getAssertionError('string or number', value, sourceCodeInfo)\n}\n","import type { Any, Coll, Obj } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asAny, isColl, isObj, isRegularExpression } from '../typeGuards/lits'\nimport { isNumber } from '../typeGuards/number'\nimport { asString, assertStringOrNumber } from '../typeGuards/string'\nimport { isUnknownRecord } from '../typeGuards'\nimport { LitsError } from '../errors'\n\nexport function collHasKey(coll: unknown, key: string | number): boolean {\n if (!isColl(coll))\n return false\n\n if (typeof coll === 'string' || Array.isArray(coll)) {\n if (!isNumber(key, { integer: true }))\n return false\n\n return key >= 0 && key < coll.length\n }\n return !!Object.getOwnPropertyDescriptor(coll, key)\n}\n\nexport function compare<T extends string | number>(a: T, b: T, sourceCodeInfo: SourceCodeInfo | undefined): number {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n\n if (typeof a === 'string' && typeof b === 'string') {\n return a < b ? -1 : a > b ? 1 : 0\n }\n if (typeof a === 'number' && typeof b === 'number') {\n return Math.sign((a) - (b))\n }\n throw new LitsError(`Cannot compare values of different types: ${typeof a} and ${typeof b}`, sourceCodeInfo)\n}\n\nexport function deepEqual(a: unknown, b: unknown, sourceCodeInfo?: SourceCodeInfo): boolean {\n if (a === b)\n return true\n\n if (typeof a === 'number' && typeof b === 'number')\n return approxEqual(a, b)\n\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length)\n return false\n\n for (let i = 0; i < a.length; i += 1) {\n if (!deepEqual(asAny(a[i], sourceCodeInfo), asAny(b[i], sourceCodeInfo), sourceCodeInfo))\n return false\n }\n return true\n }\n if (isRegularExpression(a) && isRegularExpression(b))\n return a.s === b.s && a.f === b.f\n\n if (isUnknownRecord(a) && isUnknownRecord(b)) {\n const aKeys = Object.keys(a)\n const bKeys = Object.keys(b)\n if (aKeys.length !== bKeys.length)\n return false\n\n for (let i = 0; i < aKeys.length; i += 1) {\n const key = asString(aKeys[i], sourceCodeInfo)\n if (!deepEqual(a[key], b[key], sourceCodeInfo))\n return false\n }\n return true\n }\n return false\n}\n\nexport function toNonNegativeInteger(num: number): number {\n return Math.max(0, Math.ceil(num))\n}\n\nexport function toAny(value: unknown): Any {\n return (value ?? null) as Any\n}\n\nfunction clone<T>(value: T): T {\n if (isObj(value)) {\n return Object.entries(value).reduce((result: Obj, entry) => {\n const [key, val] = entry\n result[key] = clone(val)\n return result\n }, {}) as T\n }\n if (Array.isArray(value))\n // eslint-disable-next-line ts/no-unsafe-return\n return value.map(item => clone(item)) as unknown as T\n\n return value\n}\n\nexport function cloneColl<T extends Coll>(value: T): T {\n return clone(value)\n}\n\nexport function joinSets<T>(...results: Set<T>[]): Set<T> {\n const result = new Set<T>()\n for (const symbols of results)\n symbols.forEach(symbol => result.add(symbol))\n\n return result\n}\n\nexport function addToSet<T>(target: Set<T>, source: Set<T>): void {\n source.forEach(symbol => target.add(symbol))\n}\n\nexport const EPSILON = 1e-10\n\nexport function approxEqual(a: number, b: number, epsilon: number = EPSILON): boolean {\n if (a === b) {\n return true\n }\n\n const diff = Math.abs(a - b)\n\n if (a === 0 || b === 0 || diff < epsilon) {\n // Use absolute error for values near zero\n return diff < epsilon\n }\n const absA = Math.abs(a)\n const absB = Math.abs(b)\n\n // Use relative error for larger values\n return diff / (absA + absB) < epsilon\n}\n\nexport function approxZero(value: number): boolean {\n return Math.abs(value) < EPSILON\n}\n\nexport function smartTrim(str: string, minIndent = 0): string {\n const lines = str.split('\\n')\n while (lines[0]?.match(/^\\s*$/)) {\n lines.shift() // Remove leading empty lines\n }\n while (lines[lines.length - 1]?.match(/^\\s*$/)) {\n lines.pop() // Remove trailing empty lines\n }\n const indent = lines.reduce((acc, line) => {\n if (line.match(/^\\s*$/))\n return acc // Skip empty lines\n const lineIndent = line.match(/^\\s*/)![0].length\n return Math.min(acc, lineIndent)\n }, Infinity)\n return lines.map(line => ' '.repeat(minIndent) + line.slice(indent)).join('\\n').trimEnd()\n}\n","import type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\n\n// isArray not needed, use Array.isArary\nexport function asArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): unknown[] {\n assertArray(value, sourceCodeInfo)\n return value\n}\nexport function assertArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is unknown[] {\n if (!Array.isArray(value))\n throw getAssertionError('array', value, sourceCodeInfo)\n}\n\nexport function isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every(v => typeof v === 'string')\n}\nexport function asStringArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): string[] {\n assertStringArray(value, sourceCodeInfo)\n return value\n}\nexport function assertStringArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is string[] {\n if (!isStringArray(value))\n throw getAssertionError('array of strings', value, sourceCodeInfo)\n}\n\nexport function isCharArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every(v => typeof v === 'string' && v.length === 1)\n}\nexport function asCharArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): string[] {\n assertCharArray(value, sourceCodeInfo)\n return value\n}\nexport function assertCharArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is string[] {\n if (!isCharArray(value))\n throw getAssertionError('array of strings', value, sourceCodeInfo)\n}\n","import type { ContextStack } from '../../evaluator/ContextStack'\nimport type { ExecuteFunction } from '../../evaluator/interface'\nimport type { Any, Arr, Coll, Obj, Seq } from '../../interface'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { collHasKey, deepEqual, toAny } from '../../utils'\nimport { asAny, asFunctionLike, assertAny, assertColl, assertFunctionLike, assertObj, assertSeq, isObj, isSeq } from '../../typeGuards/lits'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { assertNumber, isNumber } from '../../typeGuards/number'\nimport { assertString, assertStringOrNumber, isString, isStringOrNumber } from '../../typeGuards/string'\nimport type { FunctionLike } from '../../parser/types'\nimport { LitsError } from '../../errors'\nimport { toFixedArity } from '../../utils/arity'\n\nfunction mapObjects({\n colls,\n contextStack,\n executeFunction,\n fn,\n sourceCodeInfo,\n}: {\n colls: unknown[]\n fn: FunctionLike\n sourceCodeInfo: SourceCodeInfo | undefined\n contextStack: ContextStack\n executeFunction: ExecuteFunction\n}): Obj {\n assertObj(colls[0], sourceCodeInfo)\n const keys = Object.keys(colls[0])\n const params: Record<string, unknown[]> = {}\n colls.forEach((obj) => {\n assertObj(obj, sourceCodeInfo)\n const objKeys = Object.keys(obj)\n if (objKeys.length !== keys.length) {\n throw new LitsError(`All objects must have the same keys. Expected: ${keys.join(', ')}. Found: ${objKeys.join(', ')}`, sourceCodeInfo)\n }\n if (!objKeys.every(key => keys.includes(key))) {\n throw new LitsError(`All objects must have the same keys. Expected: ${keys.join(', ')}. Found: ${objKeys.join(', ')}`, sourceCodeInfo)\n }\n Object.entries(obj).forEach(([key, value]) => {\n if (!params[key])\n params[key] = []\n params[key].push(value)\n })\n })\n\n return keys.reduce((result: Obj, key) => {\n result[key] = executeFunction(fn, params[key]!, contextStack, sourceCodeInfo)\n return result\n }, {})\n}\n\nfunction get(coll: Coll, key: string | number): Any | undefined {\n if (isObj(coll)) {\n if (typeof key === 'string' && collHasKey(coll, key))\n return toAny(coll[key])\n }\n else {\n if (isNumber(key, { nonNegative: true, integer: true }) && key >= 0 && key < coll.length)\n return toAny(coll[key])\n }\n return undefined\n}\n\nfunction assoc(coll: Coll, key: string | number, value: Any, sourceCodeInfo?: SourceCodeInfo) {\n assertColl(coll, sourceCodeInfo)\n assertStringOrNumber(key, sourceCodeInfo)\n if (Array.isArray(coll) || typeof coll === 'string') {\n assertNumber(key, sourceCodeInfo, { integer: true })\n assertNumber(key, sourceCodeInfo, { gte: 0 })\n assertNumber(key, sourceCodeInfo, { lte: coll.length })\n if (typeof coll === 'string') {\n assertString(value, sourceCodeInfo, { char: true })\n return `${coll.slice(0, key)}${value}${coll.slice(key + 1)}`\n }\n const copy = [...coll]\n copy[key] = value\n return copy\n }\n assertString(key, sourceCodeInfo)\n const copy = { ...coll }\n copy[key] = value\n return copy\n}\n\nexport const collectionNormalExpression: BuiltinNormalExpressions = {\n 'filter': {\n evaluate: ([coll, fn]: Arr, sourceCodeInfo, contextStack, { executeFunction }): Coll => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n if (Array.isArray(coll)) {\n const result = coll.filter(elem => executeFunction(fn, [elem], contextStack, sourceCodeInfo))\n return result\n }\n if (isString(coll)) {\n return coll\n .split('')\n .filter(elem => executeFunction(fn, [elem], contextStack, sourceCodeInfo))\n .join('')\n }\n return Object.entries(coll)\n .filter(([, value]) => executeFunction(fn, [value], contextStack, sourceCodeInfo))\n .reduce((result: Obj, [key, value]) => {\n result[key] = value\n return result\n }, {})\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n coll: { type: 'collection' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['coll', 'fun'] }],\n description: 'Creates a new collection with all elements that pass the test implemented by $fun.',\n seeAlso: ['collection.filteri', 'map', 'sequence.remove'],\n examples: [\n `\nfilter(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)`,\n `\nfilter(\n [5, 10, 15, 20],\n -> $ > 10\n)`,\n `\nfilter(\n { a: 1, b: 2 },\n odd?\n)`,\n ],\n },\n },\n 'map': {\n evaluate: (params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const fn = asFunctionLike(params.at(-1), sourceCodeInfo)\n\n if (isObj(params[0])) {\n return mapObjects({\n colls: params.slice(0, -1),\n fn,\n sourceCodeInfo,\n contextStack,\n executeFunction,\n })\n }\n\n const seqs = params.slice(0, -1) as Seq[]\n assertSeq(seqs[0], sourceCodeInfo)\n\n const isStr = typeof seqs[0] === 'string'\n let len = seqs[0].length\n seqs.slice(1).forEach((seq) => {\n if (isStr) {\n assertString(seq, sourceCodeInfo)\n }\n else {\n assertArray(seq, sourceCodeInfo)\n }\n len = Math.min(len, seq.length)\n })\n\n const paramArray: unknown[][] = []\n for (let i = 0; i < len; i++) {\n paramArray.push(seqs.map(seq => seq[i]))\n }\n\n const mapped = paramArray.map(p => executeFunction(fn, p, contextStack, sourceCodeInfo))\n\n if (!isStr) {\n return mapped\n }\n mapped.forEach(char => assertString(char, sourceCodeInfo))\n return mapped.join('')\n },\n arity: { min: 2 },\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n colls: { type: 'collection', rest: true, description: 'At least one.' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['colls', 'fun'] }],\n description: 'Creates a new collection populated with the results of calling $fun on every element in $colls.',\n seeAlso: ['collection.mapi', 'filter', 'reduce', 'mapcat', 'grid.map', 'grid.mapi'],\n examples: [\n '[1, 2, 3] map -',\n '[1, 2, 3] map -> -($)',\n 'map([\"Albert\", \"Mojir\", 42], str)',\n 'map([1, 2, 3], inc)',\n 'map([1, 2, 3], [1, 10, 100], *)',\n 'map({ a: 1, b: 2 }, inc)',\n 'map({ a: 1, b: 2 }, { a: 10, b: 20 }, +)',\n ],\n },\n },\n 'reduce': {\n evaluate: ([coll, fn, initial], sourceCodeInfo, contextStack, { executeFunction }): Any => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n assertAny(initial, sourceCodeInfo)\n\n if (typeof coll === 'string') {\n assertString(initial, sourceCodeInfo)\n if (coll.length === 0)\n return initial\n\n return coll.split('').reduce((result: Any, elem) => {\n return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo)\n }, initial)\n }\n else if (Array.isArray(coll)) {\n if (coll.length === 0)\n return initial\n\n return coll.reduce((result: Any, elem) => {\n return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo)\n }, initial)\n }\n else {\n if (Object.keys(coll).length === 0)\n return initial\n\n return Object.entries(coll).reduce((result: Any, [, elem]) => {\n return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo)\n }, initial)\n }\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'any' },\n args: {\n fun: { type: 'function' },\n coll: { type: 'collection' },\n initial: { type: 'any' },\n },\n variants: [{ argumentNames: ['coll', 'fun', 'initial'] }],\n description: 'Runs $fun function on each element of the $coll, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value.',\n seeAlso: ['collection.reduce-right', 'collection.reducei', 'collection.reductions', 'map', 'grid.reduce', 'grid.reducei'],\n examples: [\n 'reduce([1, 2, 3], +, 0)',\n 'reduce([], +, 0)',\n 'reduce({ a: 1, b: 2 }, +, 0)',\n `\nreduce(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + (even?(value) ? value : 0),\n 0)`,\n ],\n },\n },\n 'get': {\n evaluate: (params, sourceCodeInfo) => {\n const [coll, key] = params\n const defaultValue = toAny(params[2])\n assertStringOrNumber(key, sourceCodeInfo)\n if (coll === null)\n return defaultValue\n\n assertColl(coll, sourceCodeInfo)\n const result = get(coll, key)\n return result === undefined ? defaultValue : result\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'collection',\n returns: { type: 'any' },\n args: {\n 'a': { type: 'collection' },\n 'b': { type: ['string', 'integer'] },\n 'not-found': { type: 'any', description: 'Default value to return if $b is not found.' },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'not-found'] },\n ],\n description: 'Returns value in $a mapped at $b.',\n seeAlso: ['collection.get-in', 'contains?', 'find', 'nth'],\n examples: [\n '[1, 2, 3] get 1',\n '{ a: 1 } get \"a\"',\n '\"Albert\" get \"3\"',\n `\nget(\n [1, 2, 3],\n 1, // Optional comma after last argument\n)`,\n `\nget(\n [],\n 1\n)`,\n `\nget(\n [],\n 1,\n \"default\"\n)`,\n `\nget(\n { a: 1 },\n \"a\"\n)`,\n `\nget(\n { a: 1 },\n \"b\"\n)`,\n `\nget(\n { a: 1 },\n \"b\",\n \"default\"\n)`,\n `\nget(\n null,\n \"a\"\n)`,\n `\nget(\n null,\n \"b\",\n \"default\"\n)`,\n ],\n },\n },\n 'count': {\n evaluate: ([coll], sourceCodeInfo): number => {\n if (coll === null)\n return 0\n\n if (typeof coll === 'string')\n return coll.length\n\n assertColl(coll, sourceCodeInfo)\n if (Array.isArray(coll))\n return coll.length\n\n return Object.keys(coll).length\n },\n arity: toFixedArity(1),\n docs: {\n category: 'collection',\n returns: { type: 'number' },\n args: {\n coll: { type: ['collection', 'null'] },\n },\n variants: [{ argumentNames: ['coll'] }],\n description: 'Returns number of elements in $coll.',\n seeAlso: ['empty?'],\n examples: [\n 'count([1, 2, 3])',\n 'count([])',\n 'count({ a: 1 })',\n 'count(\"\")',\n 'count(\"Albert\")',\n 'count(null)',\n ],\n },\n },\n 'contains?': {\n evaluate: ([coll, key], sourceCodeInfo): boolean => {\n if (coll === null)\n return false\n\n assertColl(coll, sourceCodeInfo)\n if (isString(coll)) {\n assertString(key, sourceCodeInfo)\n return coll.includes(key)\n }\n if (isSeq(coll)) {\n assertAny(key, sourceCodeInfo)\n return !!coll.find(elem => deepEqual(asAny(elem), key, sourceCodeInfo))\n }\n assertString(key, sourceCodeInfo)\n return key in coll\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['collection', 'null'] },\n b: { type: ['string', 'integer'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns `true` if $a contains $b, otherwise returns `false`. For strings, it checks if substring is included.',\n seeAlso: ['get', 'find', 'index-of'],\n examples: [\n '[1, 2, 3] contains? 1',\n 'null contains? 1',\n '{ a: 1, b: 2 } contains? \"a\"',\n `\ncontains?(\n [],\n 1\n)`,\n `\ncontains?(\n [1],\n 1\n)`,\n `\ncontains?(\n [1, 2, 3],\n 1\n)`,\n `\ncontains?(\n {},\n \"a\"\n)`,\n `\ncontains?(\n { a: 1, b: 2 },\n \"a\"\n)`,\n ],\n },\n },\n 'assoc': {\n evaluate: ([coll, key, value], sourceCodeInfo): Coll => {\n assertColl(coll, sourceCodeInfo)\n assertStringOrNumber(key, sourceCodeInfo)\n assertAny(value, sourceCodeInfo)\n return assoc(coll, key, value, sourceCodeInfo)\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n coll: { type: 'collection' },\n key: { type: ['string', 'number'] },\n value: { type: 'any' },\n kvs: { type: 'any', description: 'Key-value pairs to associate.', rest: true },\n },\n variants: [\n { argumentNames: ['coll', 'key', 'value'] },\n { argumentNames: ['coll', 'key', 'value', 'kvs'] },\n ],\n description: `\nAdd or replace the value of element $key to $value in $coll. Repeated for all key-value pairs in $kvs.\nIf $coll is an 'array', $key must be \\`number\\` satisfying \\`0 <=\\` $key \\`<= length\\`.`,\n seeAlso: ['collection.assoc-in', 'dissoc', 'merge', 'collection.update'],\n examples: [\n `\nassoc(\n [1, 2, 3],\n 1,\n \"Two\"\n)`,\n `\nassoc(\n [1, 2, 3],\n 3,\n \"Four\"\n)`,\n `\nassoc(\n { a: 1, b: 2 },\n \"a\",\n \"One\")`,\n `\nassoc(\n { a: 1, b: 2 },\n \"c\",\n \"Three\")`,\n `\nassoc(\n \"Albert\",\n 6,\n \"a\")`,\n ],\n },\n },\n '++': {\n evaluate: (params, sourceCodeInfo): Any => {\n if (!isNumber(params[0])) {\n assertColl(params[0], sourceCodeInfo)\n }\n if (Array.isArray(params[0])) {\n return params.reduce((result: Arr, arr) => {\n assertArray(arr, sourceCodeInfo)\n return result.concat(arr)\n }, [])\n }\n else if (isStringOrNumber(params[0])) {\n return params.reduce((result: string, s) => {\n assertStringOrNumber(s, sourceCodeInfo)\n return `${result}${s}`\n }, '')\n }\n else {\n return params.reduce((result: Obj, obj) => {\n assertObj(obj, sourceCodeInfo)\n return Object.assign(result, obj)\n }, {})\n }\n },\n arity: { min: 1 },\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'collection' },\n colls: { type: 'collection', rest: true },\n },\n variants: [\n { argumentNames: ['a'] },\n { argumentNames: ['a', 'colls'] },\n ],\n description: 'Concatenates collections into one collection.',\n seeAlso: ['mapcat', 'str', 'join', 'push', 'sequence.unshift'],\n examples: [\n '\"Albert\" ++ \" \" ++ \"Mojir\"',\n '\"Albert\" ++ \"Mojir\"',\n\n '++(\"Albert\", \"-\", \"Mojir\")',\n '++(\"Albert\")',\n\n '++(\"A\", \"l\", \"b\", \"e\", \"r\", \"t\")',\n '++([1, 2], [3, 4])',\n '++([], [3, 4])',\n '++([1, 2], [])',\n '++([1, 2], [3, 4], [5, 6])',\n '++([])',\n '++({ a: 1, b: 2 }, { b: 1, c: 2 })',\n '++({}, { a: 1 })',\n ],\n },\n },\n}\n","import type { Arr } from '../../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { asNumber, assertNumber } from '../../typeGuards/number'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { assertFunctionLike } from '../../typeGuards/lits'\nimport { toFixedArity } from '../../utils/arity'\n\nexport const arrayNormalExpression: BuiltinNormalExpressions = {\n 'range': {\n evaluate: (params, sourceCodeInfo): Arr => {\n const [first, second, third] = params\n let from: number\n let to: number\n let step: number\n assertNumber(first, sourceCodeInfo, { finite: true })\n\n if (params.length === 1) {\n from = 0\n to = first\n step = to >= 0 ? 1 : -1\n }\n else if (params.length === 2) {\n assertNumber(second, sourceCodeInfo, { finite: true })\n from = first\n to = second\n step = to >= from ? 1 : -1\n }\n else {\n assertNumber(second, sourceCodeInfo, { finite: true })\n assertNumber(third, sourceCodeInfo, { finite: true })\n from = first\n to = second\n step = third\n if (to > from)\n assertNumber(step, sourceCodeInfo, { positive: true })\n else if (to < from)\n assertNumber(step, sourceCodeInfo, { negative: true })\n else\n assertNumber(step, sourceCodeInfo, { nonZero: true })\n }\n\n const result: number[] = []\n\n for (let i = from; step < 0 ? i > to : i < to; i += step)\n result.push(i)\n\n return result\n },\n arity: { min: 1, max: 3 },\n docs: {\n category: 'array',\n returns: { type: 'number', array: true },\n args: {\n a: { type: 'number' },\n b: { type: 'number' },\n step: { type: 'number' },\n },\n variants: [\n { argumentNames: ['b'] },\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'step'] },\n ],\n description: `$range creates an array with a range of numbers from $a to $b (exclusive), by $step.\n\n$a defaults to 0.\n$step defaults to 1.`,\n seeAlso: ['repeat', 'vector.linspace'],\n examples: [\n 'range(4)',\n 'range(1, 4)',\n '1 range 10',\n 'range(0.4, 4.9)',\n `\nrange(\n 0.25, // start value\n 1, // end value (exclusive)\n 0.25, // step value\n)`,\n ],\n },\n },\n\n 'repeat': {\n evaluate: ([value, count], sourceCodeInfo): Arr => {\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n const result: Arr = []\n for (let i = 0; i < count; i += 1)\n result.push(value)\n\n return result\n },\n arity: toFixedArity(2),\n docs: {\n category: 'array',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'any' },\n b: { type: 'integer' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns an array with $a repeated $b times.',\n seeAlso: ['range', 'vector.ones', 'vector.zeros', 'vector.fill', 'vector.generate', 'string.string-repeat'],\n examples: [\n 'repeat(10, 3)',\n 'repeat(10, 0)',\n '\"Albert\" repeat 5',\n ],\n },\n },\n\n 'flatten': {\n evaluate: ([seq, depth], sourceCodeInfo): Arr => {\n assertArray(seq, sourceCodeInfo)\n\n const actualDepth = depth === undefined || depth === Number.POSITIVE_INFINITY\n ? Number.POSITIVE_INFINITY\n : asNumber(depth, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return seq.flat(actualDepth)\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'array',\n returns: { type: 'any', array: true },\n args: {\n x: { type: ['array', 'any'], description: 'If $x is not an array, `[ ]` is returned.' },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'Takes a nested array $x and flattens it.',\n seeAlso: ['mapcat'],\n examples: [\n 'flatten([1, 2, [3, 4], 5])',\n `\nlet foo = \"bar\";\nflatten([\n 1,\n \" 2 A \",\n [foo, [4, [\"ABC\"]]],\n 6,\n])`,\n ],\n hideOperatorForm: true,\n },\n },\n 'mapcat': {\n evaluate: ([arr, fn], sourceCodeInfo, contextStack, { executeFunction }): Arr | string => {\n assertArray(arr, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n return arr.map(elem => executeFunction(fn, [elem], contextStack, sourceCodeInfo)).flat(1)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'array',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n colls: { type: 'collection', array: true },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['colls', 'fun'] }],\n description: 'Returns the result of applying concat to the result of applying map to $fun and $colls.',\n seeAlso: ['flatten', 'map', '++'],\n examples: [\n '[[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]] mapcat reverse',\n 'mapcat([[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]], reverse)',\n '[[3, 2, 1, 0,], [6, 5, 4,], [9, 8, 7]] mapcat reverse',\n `\nlet foo = (n) -> do\n [n - 1, n, n + 1]\nend;\n[1, 2, 3] mapcat foo`,\n `\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ filter odd?\n)`,\n ],\n },\n },\n 'moving-fn': {\n evaluate: ([arr, windowSize, fn], sourceCodeInfo, contextStack, { executeFunction }): Arr => {\n assertArray(arr, sourceCodeInfo)\n assertNumber(windowSize, sourceCodeInfo, { integer: true, lte: arr.length })\n assertFunctionLike(fn, sourceCodeInfo)\n\n const result = []\n for (let i = 0; i <= arr.length - windowSize; i++) {\n const window = arr.slice(i, i + windowSize)\n const value = executeFunction(fn, [window], contextStack, sourceCodeInfo)\n result.push(value)\n }\n return result\n },\n arity: toFixedArity(3),\n docs: {\n category: 'array',\n returns: { type: 'array' },\n args: {\n arr: { type: 'array' },\n windowSize: { type: 'number', description: 'The size of the moving window.' },\n fn: { type: 'function' },\n },\n variants: [{ argumentNames: ['arr', 'windowSize', 'fn'] }],\n description: 'Returns the result of applying $fn to each moving window of size $windowSize in $arr.',\n seeAlso: ['running-fn', 'vector.moving-mean'],\n examples: [\n 'moving-fn([1, 2, 3], 2, sum)',\n 'moving-fn([1, 2, 3], 1, sum)',\n 'moving-fn([1, 2, 3], 3, sum)',\n ],\n },\n },\n 'running-fn': {\n evaluate: ([arr, fn], sourceCodeInfo, contextStack, { executeFunction }): Arr => {\n assertArray(arr, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n const result = []\n for (let i = 0; i < arr.length; i += 1) {\n const subArr = arr.slice(0, i + 1)\n result.push(executeFunction(fn, [subArr], contextStack, sourceCodeInfo))\n }\n return result\n },\n arity: toFixedArity(2),\n docs: {\n category: 'array',\n returns: { type: 'array' },\n args: {\n a: { type: 'array' },\n b: { type: 'function' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns the result of applying $b to each element of $a.',\n seeAlso: ['moving-fn', 'vector.running-mean'],\n examples: [\n 'running-fn([1, 2, 3], sum)',\n 'running-fn([1, 2, 3], max)',\n 'running-fn([1, 2, 3], min)',\n ],\n },\n },\n}\n","import type { Any, Arr, Seq } from '../../interface'\nimport { assertCharArray } from '../../typeGuards/array'\nimport { asAny, assertAny, assertFunctionLike, assertSeq } from '../../typeGuards/lits'\nimport { assertNumber } from '../../typeGuards/number'\nimport { assertString, assertStringOrNumber } from '../../typeGuards/string'\nimport { compare, deepEqual, toAny } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const sequenceNormalExpression: BuiltinNormalExpressions = {\n 'nth': {\n evaluate: (params, sourceCodeInfo): Any => {\n const [seq, i] = params\n const defaultValue = toAny(params[2])\n\n assertNumber(i, sourceCodeInfo, { integer: true })\n\n if (seq === null)\n return defaultValue\n\n assertSeq(seq, sourceCodeInfo)\n if (i >= 0 && i < seq.length) {\n const result = toAny(seq[i])\n return result\n }\n else {\n return defaultValue\n }\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: {\n 'a': { type: 'sequence' },\n 'b': { type: 'integer' },\n 'seq': { type: ['sequence', 'null'] },\n 'n': { type: 'integer' },\n 'not-found': { type: 'any' },\n },\n variants: [\n { argumentNames: ['seq', 'n'] },\n { argumentNames: ['seq', 'n', 'not-found'] },\n ],\n description: 'Accesses element $n of $seq. Accessing out-of-bounds indices returns $not-found, if present, else `null`.',\n seeAlso: ['first', 'second', 'last', 'get', 'slice'],\n examples: [\n '[1, 2, 3] nth 1',\n '\"A string\" nth 3',\n 'nth([1, 2, 3], 1)',\n 'nth([1, 2, 3], 3)',\n 'nth([1, 2, 3], -1)',\n 'nth([1, 2, 3], 3, 99)',\n 'nth(\"A string\", 1)',\n 'nth(\"A string\", 3)',\n 'nth(\"A string\", -3)',\n 'nth(\"A string\", 30, \"X\")',\n 'nth(null, 1)',\n 'nth(null, 1, \"Default value\")',\n ],\n },\n },\n 'first': {\n evaluate: ([array], sourceCodeInfo): Any => {\n if (array === null)\n return null\n\n assertSeq(array, sourceCodeInfo)\n const result = toAny(array[0])\n\n return result\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns the first element of $seq. If $seq is empty or `null`, `null` is returned.',\n seeAlso: ['second', 'last', 'nth', 'rest', 'next'],\n examples: [\n 'first([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'first([])',\n 'first(null)',\n ],\n },\n },\n 'last': {\n evaluate: ([array], sourceCodeInfo): Any => {\n if (array === null)\n return null\n\n assertSeq(array, sourceCodeInfo)\n const result = toAny(array.at(-1))\n\n return result\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns the last element of $seq. If $seq is empty, `null` is returned.',\n seeAlso: ['first', 'second', 'nth', 'pop'],\n examples: [\n 'last([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'last([1, 2])',\n 'last([1])',\n 'last([])',\n 'last(null)',\n ],\n },\n },\n 'pop': {\n evaluate: ([seq], sourceCodeInfo): Seq => {\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n return seq.substring(0, seq.length - 1)\n }\n\n return seq.slice(0, seq.length - 1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'], rest: true },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns a copy of $seq with last element removed. If $seq is empty `null` is returned.',\n seeAlso: ['push', 'sequence.shift', 'last'],\n examples: [\n 'pop([1, 2, 3])',\n 'pop([])',\n ],\n },\n },\n 'index-of': {\n evaluate: ([seq, value], sourceCodeInfo): number | null => {\n assertAny(value, sourceCodeInfo)\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n assertString(value, sourceCodeInfo)\n const index = seq.indexOf(value)\n return index !== -1 ? index : null\n }\n else {\n const index = seq.findIndex(item => deepEqual(asAny(item, sourceCodeInfo), value), sourceCodeInfo)\n return index !== -1 ? index : null\n }\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: ['number', 'null'] },\n args: {\n a: { type: 'sequence' },\n b: { type: 'any' },\n seq: { type: ['sequence', 'null'] },\n x: { type: 'any' },\n },\n variants: [{ argumentNames: ['seq', 'x'] }],\n description: 'Returns the index of $x in $seq. If element is not present in $seq `null` is returned.',\n seeAlso: ['sequence.last-index-of', 'sequence.position', 'contains?'],\n examples: [\n '[[1], [2], [1], [2]] index-of [1]',\n 'index-of([\"Albert\", \"Mojir\", 160, [1, 2]], \"Mojir\")',\n 'index-of([5, 10, 15, 20], 15)',\n 'index-of([5, 10, 15, 20], 1)',\n 'index-of(null, 1)',\n ],\n },\n },\n 'push': {\n evaluate: ([seq, ...values], sourceCodeInfo): Seq => {\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n assertCharArray(values, sourceCodeInfo)\n return [seq, ...values].join('')\n }\n else {\n return [...seq, ...values]\n }\n },\n arity: { min: 2 },\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'any' },\n seq: { type: 'sequence' },\n values: { type: 'any', rest: true, description: 'At least one.' },\n },\n variants: [{ argumentNames: ['seq', 'values'] }],\n description: 'Returns copy of $seq with $values added to the end of it.',\n seeAlso: ['sequence.unshift', 'pop', '++'],\n examples: [\n '[1, 2, 3] push 4',\n '\"Albert\" push \"!\"',\n 'push([1, 2, 3], 4)',\n 'push([1, 2, 3], 4, 5, 6)',\n `\nlet l = [1, 2, 3];\npush(l, 4);\nl`,\n ],\n },\n },\n 'rest': {\n evaluate: ([seq], sourceCodeInfo): Arr | string => {\n assertSeq(seq, sourceCodeInfo)\n if (Array.isArray(seq)) {\n if (seq.length <= 1)\n return []\n\n return seq.slice(1)\n }\n return seq.substring(1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'] },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n description: `If $seq is an array, returns a new array with all but the first element from $seq.\nIf $seq has less than two elements, an empty array is returned.\nFor string $seq returns all but the first characters in $seq.`,\n seeAlso: ['next', 'first', 'sequence.shift'],\n examples: [\n 'rest([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'rest([\"Albert\"])',\n 'rest([])',\n 'rest(\"Albert\")',\n 'rest(\"A\",)',\n 'rest(\"\")',\n ],\n },\n },\n 'next': {\n evaluate: ([seq], sourceCodeInfo): Arr | string | null => {\n assertSeq(seq, sourceCodeInfo)\n if (Array.isArray(seq)) {\n if (seq.length <= 1)\n return null\n\n return seq.slice(1)\n }\n if (seq.length <= 1)\n return null\n\n return seq.substring(1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'] },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'If $seq is an array, returns a new array with all but the first element from $seq. If $seq has less than two elements, `null` is returned. For string $seq returns all but the first characters in $seq. If length of string $seq is less than two, `null` is returned.',\n seeAlso: ['rest', 'first'],\n examples: [\n 'next([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'next([\"Albert\"])',\n 'next([])',\n 'next(\"Albert\")',\n 'next(\"A\",)',\n 'next(\"\")',\n ],\n },\n },\n 'reverse': {\n evaluate: ([seq], sourceCodeInfo): Any => {\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n if (Array.isArray(seq)) {\n return [...seq].reverse()\n }\n\n return seq.split('').reverse().join('')\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'] },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'If $seq is an array, creates a new array with the elements from $seq in reversed order. If $seq is a string, returns new reversed string.',\n seeAlso: ['sort'],\n examples: [\n 'reverse([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'reverse([])',\n 'reverse(\"Albert\")',\n 'reverse(null)',\n ],\n },\n },\n 'second': {\n evaluate: ([seq], sourceCodeInfo): Any => {\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n return toAny(seq[1])\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns the second element of $seq. If $seq has less than two elements or is `null`, `null` is returned.',\n seeAlso: ['first', 'last', 'nth'],\n examples: [\n 'second([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'second([1])',\n 'second([])',\n 'second(null)',\n ],\n },\n },\n 'slice': {\n evaluate: (params, sourceCodeInfo): Any => {\n const [seq, from, to] = params\n assertSeq(seq, sourceCodeInfo)\n assertNumber(from, sourceCodeInfo, { integer: true })\n\n if (params.length === 2) {\n if (Array.isArray(seq)) {\n return seq.slice(from)\n }\n return seq.slice(from)\n }\n\n assertNumber(to, sourceCodeInfo, { integer: true })\n if (Array.isArray(seq)) {\n return seq.slice(from, to)\n }\n return seq.slice(from, to)\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n seq: { type: 'sequence', rest: true },\n start: { type: 'integer', description: 'Defaults to `0`.' },\n stop: { type: 'integer', description: 'Defaults lenght of sequence + 1.' },\n },\n variants: [\n { argumentNames: ['seq'] },\n { argumentNames: ['seq', 'start'] },\n { argumentNames: ['seq', 'start', 'stop'] },\n ],\n description: 'Returns a copy of a portion of $seq from index $start (inclusive) to $stop (exclusive).',\n seeAlso: ['sequence.take', 'sequence.drop', 'sequence.splice', 'nth'],\n examples: [\n '[1, 2, 3, 4, 5] slice 2',\n 'slice([1, 2, 3, 4, 5], 2, 4)',\n 'slice([1, 2, 3, 4, 5], 2)',\n ],\n },\n },\n 'some': {\n evaluate: ([seq, fn]: Arr, sourceCodeInfo, contextStack, { executeFunction }): Any => {\n assertFunctionLike(fn, sourceCodeInfo)\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n\n if (seq.length === 0)\n return null\n\n if (typeof seq === 'string')\n return seq.split('').find(elem => executeFunction(fn, [elem], contextStack, sourceCodeInfo)) ?? null\n\n return toAny(seq.find(elem => executeFunction(fn, [elem], contextStack, sourceCodeInfo)))\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: ['sequence', 'null'] },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['seq', 'fun'] }],\n description: 'Returns the first element that passes the test implemented by $fun. I no element was found, `null` is returned.',\n seeAlso: ['sequence.position', 'collection.any?', 'find'],\n examples: [\n `\nsome(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)`,\n `\nsome(\n [5, 10, 15, 20],\n -> $ > 10\n)`,\n `\nsome(\n [1, 2, 3, 4],\n -> $ > 10\n)`,\n `\nsome(\n [],\n -> $ > 10\n)`,\n `\nsome(\n null,\n -> $ > 10\n)`,\n ],\n },\n },\n 'sort': {\n evaluate: (params: Arr, sourceCodeInfo, contextStack, { executeFunction }): Seq => {\n const [seq] = params\n const defaultComparer = params.length === 1\n const comparer = defaultComparer ? null : params[1]\n assertSeq(seq, sourceCodeInfo)\n\n if (typeof seq === 'string') {\n const result = seq.split('')\n if (defaultComparer) {\n result.sort((a, b) => compare(a, b, sourceCodeInfo))\n }\n else {\n assertFunctionLike(comparer, sourceCodeInfo)\n result.sort((a, b) => {\n const compareValue = executeFunction(comparer, [a, b], contextStack, sourceCodeInfo)\n assertNumber(compareValue, sourceCodeInfo, { finite: true })\n return compareValue\n })\n }\n return result.join('')\n }\n\n const result = [...seq]\n if (defaultComparer) {\n result.sort((a, b) => {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n return compare(a, b, sourceCodeInfo)\n })\n }\n else {\n result.sort((a, b) => {\n assertFunctionLike(comparer, sourceCodeInfo)\n const compareValue = executeFunction(comparer, [a, b], contextStack, sourceCodeInfo)\n assertNumber(compareValue, sourceCodeInfo, { finite: true })\n return compareValue\n })\n }\n return result\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'sequence',\n returns: { type: 'any', rest: true },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: 'sequence' },\n fun: { type: 'function' },\n },\n variants: [\n { argumentNames: ['seq'] },\n { argumentNames: ['seq', 'fun'] },\n ],\n description: 'Returns a new sequence with the elements from $seq sorted according to $fun. If no $fun is supplied, builtin `compare` will be used.',\n seeAlso: ['sequence.sort-by', 'compare', 'reverse', 'vector.sort-indices'],\n examples: [\n '[3, 1, 2] sort (a, b) -> b - a',\n 'sort([3, 1, 2])',\n `\nsort(\n [3, 1, 2],\n (a, b) -> cond case a < b then -1 case a > b then 1 case true then -1 end\n)`,\n `\nsort(\n [3, 1, 2],\n (a, b) -> cond case a > b then -1 case a < b then 1 case true then -1 end\n)`,\n ],\n },\n },\n}\n","import { LitsError } from '../errors'\nimport type { Any } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isNumber } from './number'\n\nconst annotatedArrays = new WeakSet<unknown[]>()\nconst vectors = new WeakSet<unknown[]>()\nconst notVectors = new WeakSet<unknown[]>()\nconst matrices = new WeakSet<unknown[]>()\nconst notMatrices = new WeakSet<unknown[]>()\nconst grids = new WeakSet<unknown[]>()\nconst notGrids = new WeakSet<unknown[]>()\n\nexport function annotate<T>(value: T): T {\n if (!Array.isArray(value)) {\n return value\n }\n if (annotatedArrays.has(value)) {\n return value\n }\n isVector(value)\n if (!isMatrix(value)) {\n isGrid(value)\n }\n\n return value\n}\nexport function isVector(vector: unknown): vector is number[] {\n if (!Array.isArray(vector)) {\n return false\n }\n\n if (vectors.has(vector)) {\n return true\n }\n if (notVectors.has(vector)) {\n return false\n }\n\n if (vector.every(elem => isNumber(elem))) {\n annotatedArrays.add(vector)\n vectors.add(vector)\n return true\n }\n notVectors.add(vector)\n return false\n}\n\nexport function assertVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is number[] {\n if (!isVector(vector)) {\n throw new LitsError(`Expected a vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function is2dVector(vector: unknown): vector is [number, number] {\n if (!isVector(vector)) {\n return false\n }\n return vector.length === 2\n}\nexport function assert2dVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is [number, number] {\n if (!is2dVector(vector)) {\n throw new LitsError(`Expected a 2d vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function is3dVector(vector: unknown): vector is [number, number, number] {\n if (!isVector(vector)) {\n return false\n }\n return vector.length === 3\n}\nexport function assert3dVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is [number, number, number] {\n if (!is3dVector(vector)) {\n throw new LitsError(`Expected a 3d vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function assertNonEmptyVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is number[] {\n assertVector(vector, sourceCodeInfo)\n if (vector.length === 0) {\n throw new LitsError(`Expected a non empty vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function isGrid(grid: unknown): grid is unknown[][] {\n if (!Array.isArray(grid)) {\n return false\n }\n if (grids.has(grid)) {\n return true\n }\n if (notGrids.has(grid)) {\n return false\n }\n if (grid.length === 0) {\n notGrids.add(grid)\n return false\n }\n if (!Array.isArray(grid[0])) {\n notGrids.add(grid)\n return false\n }\n const nbrOfCols = grid[0].length\n for (const row of grid.slice(1)) {\n if (!Array.isArray(row)) {\n notGrids.add(grid)\n return false\n }\n if (row.length !== nbrOfCols) {\n notGrids.add(grid)\n return false\n }\n }\n annotatedArrays.add(grid)\n grids.add(grid)\n return true\n}\n\nexport function assertGrid(grid: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts grid is Any[][] {\n if (!isGrid(grid)) {\n throw new LitsError(`Expected a grid, but got ${grid}`, sourceCodeInfo)\n }\n}\n\nexport function isMatrix(matrix: unknown): matrix is number[][] {\n if (!Array.isArray(matrix)) {\n return false\n }\n if (matrices.has(matrix)) {\n return true\n }\n if (notMatrices.has(matrix)) {\n return false\n }\n if (matrix.length === 0) {\n notMatrices.add(matrix)\n return false\n }\n if (!Array.isArray(matrix[0]) || matrix[0].length === 0) {\n notMatrices.add(matrix)\n return false\n }\n const nbrOfCols = matrix[0].length\n for (const row of matrix) {\n if (!Array.isArray(row) || row.length !== nbrOfCols || row.some(cell => !isNumber(cell))) {\n notMatrices.add(matrix)\n return false\n }\n }\n annotatedArrays.add(matrix)\n grids.add(matrix)\n matrices.add(matrix)\n return true\n}\n\nexport function assertMatrix(matrix: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts matrix is number[][] {\n if (!isMatrix(matrix)) {\n throw new LitsError(`Expected a matrix, but got ${matrix}`, sourceCodeInfo)\n }\n}\n\nexport function assertSquareMatrix(matrix: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts matrix is number[][] {\n if (!isMatrix(matrix)) {\n throw new LitsError(`Expected a matrix, but got ${matrix}`, sourceCodeInfo)\n }\n if (matrix.length !== matrix[0]!.length) {\n throw new LitsError(`Expected square matrix, but got ${matrix.length} and ${matrix[0]!.length}`, sourceCodeInfo)\n }\n}\n\nexport function isSquareMatrix(matrix: unknown): matrix is number[][] {\n if (!isMatrix(matrix)) {\n return false\n }\n if (matrix.length !== matrix[0]!.length) {\n return false\n }\n return true\n}\n","import { LitsError } from '../../errors'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { assertNonEmptyVector, isMatrix, isVector } from '../../typeGuards/annotatedArrays'\nimport { assertNumber, isNumber } from '../../typeGuards/number'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\ntype NumberVectorOrMatrix = number | number[] | number[][]\n\nfunction getNumberVectorOrMatrixOperation(\n params: unknown[],\n sourceCodeInfo: SourceCodeInfo | undefined,\n):\n | ['number', number[]]\n | ['vector', number[][]]\n | ['matrix', number[][][]] {\n let hasVector: boolean = false\n let hasMatrix: boolean = false\n for (const param of params) {\n if (isVector(param)) {\n hasVector = true\n }\n else if (isMatrix(param)) {\n hasMatrix = true\n }\n else if (!isNumber(param)) {\n throw new LitsError(`Invalid parameter type: ${typeof param}`, sourceCodeInfo)\n }\n }\n if (hasMatrix) {\n if (hasVector) {\n throw new LitsError('Cannot mix vector and matrix types', sourceCodeInfo)\n }\n let rows: number | null = null\n let cold: number | null = null\n for (const param of params) {\n if (isMatrix(param)) {\n if (rows === null) {\n rows = param.length\n cold = param[0]!.length\n }\n else {\n if (param.length !== rows || param[0]!.length !== cold) {\n throw new LitsError('Matrix dimensions do not match', sourceCodeInfo)\n }\n }\n }\n }\n const matrices = params.map((param) => {\n if (isMatrix(param)) {\n return param\n }\n return Array.from({ length: rows as number }, () => Array.from({ length: cold as number }, () => param as number))\n })\n return ['matrix', matrices]\n }\n if (hasVector) {\n let length: number | null = null\n for (const param of params) {\n if (isVector(param)) {\n if (length === null) {\n length = param.length\n }\n else {\n if (param.length !== length) {\n throw new LitsError('Vector lengths do not match', sourceCodeInfo)\n }\n }\n }\n }\n const vectors = params.map((param) => {\n if (isVector(param)) {\n return param\n }\n return Array.from({ length: length as number }, () => param as number)\n })\n\n return ['vector', vectors]\n }\n return ['number', params as number[]]\n}\n\nfunction unaryMathOp(\n fn: (val: number) => number,\n): (params: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) => NumberVectorOrMatrix {\n return (params, sourceCodeInfo) => {\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n if (operation === 'number') {\n return fn(operands[0]!)\n }\n else if (operation === 'vector') {\n return operands[0]!.map(val => fn(val))\n }\n else {\n return operands[0]!.map(row => row.map(val => fn(val)))\n }\n }\n}\n\nfunction binaryMathOp(\n fn: (a: number, b: number) => number,\n): (params: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) => NumberVectorOrMatrix {\n return (params, sourceCodeInfo) => {\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n if (operation === 'number') {\n return fn(operands[0]!, operands[1]!)\n }\n else if (operation === 'vector') {\n return operands[0]!.map((val, i) => fn(val, operands[1]![i]!))\n }\n else {\n return operands[0]!.map((row, i) => row.map((val, j) => fn(val, operands[1]![i]![j]!)))\n }\n }\n}\n\nfunction reduceMathOp(\n identity: number,\n fn: (a: number, b: number) => number,\n): (params: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) => NumberVectorOrMatrix {\n return (params, sourceCodeInfo) => {\n if (params.length === 0)\n return identity\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n if (operation === 'number') {\n return operands.reduce((a, b) => fn(a, b), identity)\n }\n else if (operation === 'vector') {\n const [first, ...rest] = operands\n return rest.reduce((acc, v) => acc.map((val, i) => fn(val, v[i]!)), first!)\n }\n else {\n const [first, ...rest] = operands\n return rest.reduce((acc, m) => acc.map((row, i) => row.map((val, j) => fn(val, m[i]![j]!))), first!)\n }\n }\n}\n\nexport const mathNormalExpression: BuiltinNormalExpressions = {\n 'inc': {\n evaluate: unaryMathOp(val => val + 1),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: 'number' },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `inc` function increments its argument by 1, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it increases each element by 1 while preserving the original structure.',\n seeAlso: ['dec', '+'],\n examples: [\n 'inc(0)',\n 'inc(1)',\n 'inc(100.1)',\n 'inc([1, 2, 3])',\n 'inc([[1, 2], [3, 4]])',\n ],\n },\n },\n 'dec': {\n evaluate: unaryMathOp(val => val - 1),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `dec` function decrements its argument by 1, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it decreases each element by 1 while preserving the original structure.',\n seeAlso: ['inc', '-'],\n examples: [\n 'dec(0)',\n 'dec(1)',\n 'dec(100.1)',\n 'dec([1, 2, 3])',\n 'dec([[1, 2], [3, 4]])',\n ],\n },\n },\n '+': {\n evaluate: reduceMathOp(0, (a, b) => a + b),\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n description: 'The `+` function performs addition of numbers and element-wise addition of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it adds the scalar to each element of the collection.',\n seeAlso: ['-', '*', '/', 'inc'],\n examples: [\n '1 + 2',\n '1 + 20 + 30',\n '+(1, 2, 3, 4)',\n '+()',\n '+(1)',\n '[1, 2, 3] + 2',\n '[1, 2, 3] + [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] + [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] + 2',\n ],\n },\n },\n '*': {\n evaluate: reduceMathOp(1, (a, b) => a * b),\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n description: 'The `*` function performs multiplication of `numbers` and element-wise multiplication of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it multiplies each element of the collection by the scalar.',\n seeAlso: ['/', '+', '-', '^'],\n examples: [\n '6 * 7',\n '-1 * 4',\n '*(4, 7)',\n '*(1, 2, 3, 4, 5)',\n '*()',\n '*(8)',\n '[1, 2, 3] * 2',\n '[1, 2, 3] * [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] * [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] * 2',\n ],\n },\n },\n '/': {\n evaluate: (params, sourceCodeInfo): NumberVectorOrMatrix => {\n if (params.length === 0) {\n return 1\n }\n\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n\n if (operation === 'number') {\n const [first, ...rest] = operands\n if (rest.length === 0) {\n return 1 / first!\n }\n return rest.reduce((result, param) => {\n return result / param\n }, first!)\n }\n else if (operation === 'vector') {\n const firstVector = operands[0]!\n const restVectors = operands.slice(1)\n return restVectors.reduce((acc, vector) => acc.map((val, i) => val / vector[i]!), firstVector)\n }\n else {\n const firstMatrix = operands[0]!\n const restMatrices = operands.slice(1)\n return restMatrices.reduce((acc, matrix) => acc.map((row, i) => row.map((val, j) => val / matrix[i]![j]!)), firstMatrix)\n }\n },\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n description: 'The `/` function performs division of `numbers` and element-wise division of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it divides each element of the collection by the scalar.',\n seeAlso: ['*', '+', '-', 'quot', 'mod', '%'],\n examples: [\n '12 / 100',\n '-1 / 4',\n '/(7, 4)',\n '/(1, 2, 4, 8)',\n '/()',\n '/(8)',\n '[1, 2, 3] / 2',\n '[1, 2, 3] / [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] / [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] / 2',\n ],\n },\n },\n '-': {\n evaluate: (params, sourceCodeInfo): NumberVectorOrMatrix => {\n if (params.length === 0) {\n return 0\n }\n\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n\n if (operation === 'number') {\n const [first, ...rest] = operands\n if (rest.length === 0)\n return -first!\n\n return rest.reduce((result, param) => {\n return result - param\n }, first!)\n }\n else if (operation === 'vector') {\n const firstVector = operands[0]!\n const restVectors = operands.slice(1)\n return restVectors.reduce((acc, vector) => acc.map((val, i) => val - vector[i]!), firstVector)\n }\n else {\n const firstMatrix = operands[0]!\n const restMatrices = operands.slice(1)\n return restMatrices.reduce((acc, matrix) => acc.map((row, i) => row.map((val, j) => val - matrix[i]![j]!)), firstMatrix)\n }\n },\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n description: 'Computes difference between first value and sum of the rest. When called with only one argument, it does negation.',\n seeAlso: ['+', '*', '/', 'dec', 'abs'],\n examples: [\n '50 - 8',\n '1 - 1 - 1',\n '-()',\n '-(4, 2)',\n '-(4, 3, 2, 1,)',\n '[1, 2, 3] - 2',\n '[1, 2, 3] - [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] - [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] - 2',\n ],\n },\n },\n 'quot': {\n evaluate: binaryMathOp((a, b) => Math.trunc(a / b)),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'The `quot` function performs integer division truncated toward zero, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies integer division between each element of the collection and the scalar.',\n seeAlso: ['mod', '%', '/', 'trunc'],\n examples: [\n 'quot(5, 3)',\n 'quot(5.2, 3.1)',\n 'quot(-5, 3)',\n '5 quot -3',\n '-5 quot -3',\n 'quot(5, 0)',\n 'quot(0, 5)',\n '[1, 2, 3] quot 2',\n '2 quot [1, 2, 3]',\n 'quot([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]',\n 'quot([[1, 2, 3], [4, 5, 6]], 2)',\n '[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]',\n ],\n },\n },\n 'mod': {\n evaluate: binaryMathOp((a, b) => a - b * Math.floor(a / b)),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'The `mod` function computes the modulo of division with the same sign as the divisor, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the modulo operation between each element of the collection and the scalar.',\n seeAlso: ['%', 'quot', '/'],\n examples: [\n 'mod(5, 3)',\n 'mod(5.2, 3.1)',\n 'mod(-5, 3)',\n '5 mod -3',\n '-5 mod -3',\n '[1, 2, 3] mod 2',\n '2 mod [1, 2, 3]',\n 'mod([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] mod [[7, 8, 9], [10, 11, 12]]',\n 'mod([[1, 2, 3], [4, 5, 6]], 2)',\n ],\n },\n },\n '%': {\n evaluate: binaryMathOp((a, b) => a % b),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'The `%` function computes the remainder of division with the same sign as the dividend, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the remainder operation between each element of the collection and the scalar.',\n seeAlso: ['mod', 'quot', '/'],\n examples: [\n '5 % 3',\n '5.2 % 3.1',\n '-5 % 3',\n '%(5, -3)',\n '%(-5, -3)',\n '[1, 2, 3] % 2',\n '2 % [1, 2, 3]',\n '%([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] % [[7, 8, 9], [10, 11, 12]]',\n '%([[1, 2, 3], [4, 5, 6]], 2)',\n ],\n },\n },\n 'sqrt': {\n evaluate: unaryMathOp(val => Math.sqrt(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `sqrt` function calculates the square root of `numbers` and computes element-wise square roots of `vectors` and `matrices`. When applied to collections, it returns the square root of each element while preserving the original structure.',\n seeAlso: ['cbrt', '^'],\n examples: [\n 'sqrt(0)',\n 'sqrt(9)',\n 'sqrt(2)',\n 'sqrt(0)',\n 'sqrt(9)',\n 'sqrt(2)',\n 'sqrt([1, 4, 9])',\n 'sqrt([[1, 4], [9, 16]])',\n ],\n },\n },\n 'cbrt': {\n evaluate: unaryMathOp(val => Math.cbrt(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `cbrt` function calculates the cube root of `numbers` and computes element-wise cube roots of `vectors` and `matrices`. When applied to collections, it returns the cube root of each element while preserving the original structure.',\n seeAlso: ['sqrt', '^'],\n examples: [\n 'cbrt(0)',\n 'cbrt(27)',\n 'cbrt(2)',\n 'cbrt(1)',\n 'cbrt(0)',\n 'cbrt(27)',\n 'cbrt(2)',\n 'cbrt(1)',\n 'cbrt([1, 8, 27])',\n 'cbrt([[1, 8], [27, 64]])',\n ],\n },\n },\n '^': {\n evaluate: binaryMathOp((a, b) => a ** b),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'The ^ function computes exponentiation, raising the first argument to the power of the second, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the power operation between each element of the collection and the scalar.',\n seeAlso: ['sqrt', 'cbrt', '*', 'math.ln'],\n examples: [\n '2 ^ 3',\n '2 ^ 0',\n '2 ^ -3',\n '^(-2, 3)',\n '^(-2, -3)',\n '[1, 2, 3] ^ 2',\n '2 ^ [1, 2, 3]',\n '^([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] ^ [[7, 8, 9], [10, 11, 12]]',\n '^([[1, 2, 3], [4, 5, 6]], 2)',\n ],\n },\n },\n 'round': {\n evaluate: ([value, decimals], sourceCodeInfo): NumberVectorOrMatrix => {\n const [operation, operands] = getNumberVectorOrMatrixOperation([value], sourceCodeInfo)\n if (operation === 'number') {\n if (decimals === undefined || decimals === 0) {\n return Math.round(operands[0]!)\n }\n else {\n assertNumber(decimals, sourceCodeInfo, { integer: true, positive: true })\n const factor = 10 ** decimals\n return Math.round(operands[0]! * factor) / factor\n }\n }\n else if (operation === 'vector') {\n const vector = operands[0]!\n if (decimals === undefined || decimals === 0) {\n return vector.map(val => Math.round(val))\n }\n else {\n assertNumber(decimals, sourceCodeInfo, { integer: true, positive: true })\n const factor = 10 ** decimals\n return vector.map(val => Math.round(val * factor) / factor)\n }\n }\n else {\n const matrix = operands[0]!\n if (decimals === undefined || decimals === 0) {\n return matrix.map(row => row.map(val => Math.round(val)))\n }\n else {\n assertNumber(decimals, sourceCodeInfo, { integer: true, positive: true })\n const factor = 10 ** decimals\n return matrix.map(row => row.map(val => Math.round(val * factor) / factor))\n }\n }\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: 'integer' },\n },\n variants: [\n { argumentNames: ['a'] },\n { argumentNames: ['a', 'b'] },\n ],\n description: 'The `round` function rounds a `number` to the nearest `integer` or to a specified number of `decimal` places, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it rounds each element while preserving the original structure.',\n seeAlso: ['floor', 'ceil', 'trunc'],\n examples: [\n 'round(2)',\n 'round(2.49)',\n 'round(2.5)',\n 'round(-2.49)',\n 'round(-2.5)',\n 'round(-2.501)',\n 'round(1.23456789, 4)',\n '1.123456789 round 2',\n 'round([1.23456789, 2.3456789], 1)',\n '[1.23456789, 2.3456789] round 4',\n '[[1.23456789, 2.3456789], [3.456789, 4.56789]] round 4',\n 'round([[1.23456789, 2.3456789], [3.456789, 4.56789]], 2)',\n ],\n },\n },\n 'trunc': {\n evaluate: unaryMathOp(val => Math.trunc(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['integer', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `trunc` function truncates `numbers` toward zero (removing decimal portions without rounding), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it truncates each element while preserving the original structure.',\n seeAlso: ['round', 'floor', 'ceil', 'quot'],\n examples: [\n 'trunc(2)',\n 'trunc(2.49)',\n 'trunc(2.5)',\n 'trunc(-2.49)',\n 'trunc(-2.5)',\n 'trunc(-2.501)',\n 'trunc([1.23456789, 2.3456789])',\n 'trunc([[1.23456789, 2.3456789], [3.456789, 4.56789]])',\n ],\n },\n },\n 'floor': {\n evaluate: unaryMathOp(val => Math.floor(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['integer', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `floor` function returns the largest `integer` less than or equal to a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the floor of each element while preserving the original structure.',\n seeAlso: ['ceil', 'round', 'trunc'],\n examples: [\n 'floor(2)',\n 'floor(2.49)',\n 'floor(2.5)',\n 'floor(-2.49)',\n 'floor(-2.5)',\n 'floor(-2.501)',\n 'floor([1.23456789, 2.3456789])',\n 'floor([[1.23456789, 2.3456789], [3.456789, 4.56789]])',\n ],\n },\n },\n 'ceil': {\n evaluate: unaryMathOp(val => Math.ceil(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['integer', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `ceil` function returns the smallest `integer` greater than or equal to a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the ceiling of each element while preserving the original structure.',\n seeAlso: ['floor', 'round', 'trunc'],\n examples: [\n 'ceil(2)',\n 'ceil(2.49)',\n 'ceil(2.5)',\n 'ceil(-2.49)',\n 'ceil(-2.5)',\n 'ceil(-2.501)',\n 'ceil([1.23456789, 2.3456789])',\n 'ceil([[1.23456789, 2.3456789], [3.456789, 4.56789]])',\n ],\n },\n },\n 'min': {\n evaluate: (params, sourceCodeInfo): number => {\n if (params.length === 1 && isVector(params[0])) {\n const vector = params[0]\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((m, val) => Math.min(m, val), Infinity)\n }\n const [first, ...rest] = params\n assertNumber(first, sourceCodeInfo)\n return rest.reduce((m: number, value) => {\n assertNumber(value, sourceCodeInfo)\n return Math.min(m, value)\n }, first)\n },\n arity: { min: 1 },\n docs: {\n category: 'math',\n returns: { type: 'number' },\n args: {\n a: { type: 'number' },\n b: { type: 'number' },\n xs: { type: 'number', rest: true },\n vector: { type: 'vector' },\n },\n variants: [\n { argumentNames: ['xs'] },\n { argumentNames: ['vector'] },\n ],\n description: 'Returns the smallest value. Accepts either multiple numbers or a single vector of numbers.',\n seeAlso: ['max', 'vector.span', 'vector.min-index'],\n examples: [\n '2 min 3',\n 'min(2, 0, 1)',\n 'min(2, -1, 1)',\n 'min([2, 0, -1])',\n '12 min 14',\n ],\n },\n },\n 'max': {\n evaluate: (params, sourceCodeInfo): number => {\n if (params.length === 1 && isVector(params[0])) {\n const vector = params[0]\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((m, val) => Math.max(m, val), -Infinity)\n }\n const [first, ...rest] = params\n assertNumber(first, sourceCodeInfo)\n return rest.reduce((m: number, value) => {\n assertNumber(value, sourceCodeInfo)\n return Math.max(m, value)\n }, first)\n },\n arity: { min: 1 },\n docs: {\n category: 'math',\n returns: { type: 'number' },\n args: {\n a: { type: 'number' },\n b: { type: 'number' },\n xs: { type: 'number', rest: true },\n vector: { type: 'vector' },\n },\n variants: [\n { argumentNames: ['xs'] },\n { argumentNames: ['vector'] },\n ],\n description: 'Returns the largest value. Accepts either multiple numbers or a single vector of numbers.',\n seeAlso: ['min', 'vector.span', 'vector.max-index'],\n examples: [\n '2 max 3',\n 'max(2, 0, 1)',\n 'max(2, -1, 1)',\n 'max([2, 0, -1])',\n '4 max 2',\n ],\n },\n },\n 'abs': {\n evaluate: unaryMathOp(val => Math.abs(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The abs function returns the absolute value (magnitude) of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the absolute value of each element while preserving the original structure.',\n seeAlso: ['sign', '-'],\n examples: [\n 'abs(-2.3)',\n 'abs(0)',\n 'abs(2.5)',\n 'abs([1, -2, 3])',\n 'abs([[1, -2], [3, -4]])',\n ],\n },\n },\n 'sign': {\n evaluate: unaryMathOp(val => Math.sign(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `sign` function returns the `sign` of a `number` (-1 for negative, 0 for zero, 1 for positive), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the sign of each element while preserving the original structure.',\n seeAlso: ['abs'],\n examples: [\n 'sign(-2.3)',\n 'sign(-0)',\n 'sign(0)',\n 'sign(12312)',\n 'sign([1, -2, 3])',\n 'sign([[1, -2], [3, -4]])',\n ],\n },\n },\n}\n","import { LitsError } from '../../errors'\nimport type { Any } from '../../interface'\nimport type { ModuleFunction } from '../../parser/types'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { asAny, assertAny } from '../../typeGuards/lits'\nimport { assertNumber } from '../../typeGuards/number'\nimport { asStringOrNumber, assertString, assertStringOrNumber } from '../../typeGuards/string'\nimport { compare, deepEqual } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport { FUNCTION_SYMBOL } from '../../utils/symbols'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nfunction isEqual([first, ...rest]: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) {\n const firstAny = asAny(first, sourceCodeInfo)\n for (const param of rest) {\n if (!deepEqual(firstAny, asAny(param, sourceCodeInfo), sourceCodeInfo))\n return false\n }\n return true\n}\n\nfunction isIdentical([first, ...rest]: unknown[]) {\n for (const param of rest) {\n if (param !== first)\n return false\n }\n return true\n}\n\nexport const miscNormalExpression: BuiltinNormalExpressions = {\n '==': {\n evaluate: (params, sourceCodeInfo): boolean => {\n return isEqual(params, sourceCodeInfo)\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n x: { type: 'any' },\n ys: { type: 'any', rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if all `values` are structaul equal to each other, otherwise result is `false`.',\n seeAlso: ['≠', 'identical?'],\n examples: [\n '1 == 1',\n '[1, 2] == [1, 2]',\n `\n{\n a: 1,\n b: 2,\n} == {\n b: 2,\n a: 1,\n}`,\n '==(1, 1)',\n '==(1.01, 1)',\n '==(\"1\", 1)',\n '==(\"2\", \"2\", \"2\", \"2\")',\n '==(2, 2, 1, 2)',\n '==([1, 2], [1, 2])',\n '==({ a: 1, b: 2 }, { b: 2, a: 1 })',\n ],\n },\n },\n '≠': {\n evaluate: (params, sourceCodeInfo): boolean => {\n return !isEqual(params, sourceCodeInfo)\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n x: { type: 'any' },\n ys: { type: 'any', rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if all `values` are not equal to each other, otherwise result is `false`. `(≠ a b c)` is same as `(! (== a b c))`.',\n seeAlso: ['==', 'identical?'],\n examples: [\n '1 ≠ 2',\n '3 ≠ 3',\n '≠(3)',\n '≠(3, 3, 2)',\n '≠(\"3\", \"2\", \"1\", \"0\",)',\n '≠(0, -0)',\n ],\n },\n },\n 'identical?': {\n evaluate: (params): boolean => {\n return isIdentical(params)\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns true if $a and $b are referential equal.',\n seeAlso: ['==', '≠'],\n examples: [\n 'identical?({ a: 10, b: 20 }, { b: 20, a: 10 })',\n 'identical?([1, true, null], [1, true, null])',\n 'identical?(0.3, 0.1 + 0.2)',\n ],\n },\n },\n '>': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) <= 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in decreasing order, `false` otherwise.',\n seeAlso: ['<', '>=', '<=', 'compare'],\n examples: [\n '>(1, 0)',\n '>(1.01, 1)',\n '>(1, 1)',\n '>(4, 3, 2, 1)',\n '>(3, 2, 2, 1)',\n ],\n },\n },\n\n '<': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) >= 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in increasing order, `false` otherwise.',\n seeAlso: ['>', '>=', '<=', 'compare'],\n examples: [\n '<(0, 1)',\n '<(1, 1.01)',\n '<(1, 1)',\n '<(1, 2, 2, 3)',\n '<(\"a\", \"b\")',\n ],\n },\n },\n '>=': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) < 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in non increasing order, `false` otherwise.',\n seeAlso: ['>', '<', '<=', 'compare'],\n examples: [\n '1 >= 1',\n '0 >= 1',\n '>=(1, 0)',\n '>=(1.01, 1)',\n '>=(1, 1)',\n '>=(4, 3, 2, 1)',\n '>=(3, 2, 2, 1)',\n ],\n },\n },\n '<=': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) > 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in non decreasing order, `false` otherwise.',\n seeAlso: ['>', '<', '>=', 'compare'],\n examples: [\n '1 <= 1',\n '<=(0, 1)',\n '<=(1, 1.01)',\n '<=(1, 1)',\n '<=(1, 2, 3, 4)',\n '<=(1, 2, 2, 3)',\n ],\n },\n },\n '!': {\n evaluate: ([first]): boolean => !first,\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Computes logical negation. Note that any other $x than `false`, `0`, `null` and `\\'\\'` is truthy.',\n seeAlso: ['boolean'],\n examples: [\n '!(3)',\n '!(true)',\n '!(\"A string\")',\n '!(0)',\n '!(false)',\n '!(null)',\n '!(\"\")',\n ],\n },\n },\n 'epoch->iso-date': {\n evaluate: ([ms], sourceCodeInfo): string => {\n assertNumber(ms, sourceCodeInfo)\n return new Date(ms).toISOString()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'string' },\n args: { ms: { type: 'number' } },\n variants: [{ argumentNames: ['ms'] }],\n description: 'Returns IOS date time string from `ms` (milliseconds elapsed since the UNIX epoch).',\n seeAlso: ['iso-date->epoch'],\n examples: [\n 'epoch->iso-date(1649756230899)',\n 'epoch->iso-date(0)',\n ],\n },\n },\n 'iso-date->epoch': {\n evaluate: ([dateTime], sourceCodeInfo): number => {\n assertString(dateTime, sourceCodeInfo)\n const ms = new Date(dateTime).valueOf()\n assertNumber(ms, sourceCodeInfo, { finite: true })\n return ms\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'number' },\n args: { iso: { type: 'string' } },\n variants: [{ argumentNames: ['iso'] }],\n description: 'Returns milliseconds elapsed since the UNIX epoch to `iso`.',\n seeAlso: ['epoch->iso-date'],\n examples: [\n 'iso-date->epoch(\"2022-04-12T09:37:10.899Z\")',\n 'iso-date->epoch(\"1980-01-01\")',\n ],\n },\n },\n 'write!': {\n evaluate: (params, sourceCodeInfo): Any => {\n // eslint-disable-next-line no-console\n console.log(...params)\n\n if (params.length > 0)\n return asAny(params[params.length - 1], sourceCodeInfo)\n\n return null\n },\n arity: {},\n docs: {\n category: 'misc',\n returns: { type: 'any' },\n args: { values: { type: 'any', rest: true } },\n variants: [{ argumentNames: ['values'] }],\n description: 'It logs the $values and then returns the last argument. If called with no arguments `null` is returned.',\n examples: [\n 'write!(\"A string\")',\n 'write!(100, \"items\")',\n 'write!(object(\"a\", 10))',\n 'write!([\"a\", \"b\", \"c\"])',\n 'write!(#\"^start\")',\n 'write!(null, true, false)',\n ],\n hideOperatorForm: true,\n },\n },\n 'boolean': {\n evaluate: ([value]): boolean => {\n return !!value\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Coerces $x to boolean.',\n seeAlso: ['!', 'boolean?', 'true?', 'false?'],\n examples: [\n 'boolean(0)',\n 'boolean(1)',\n 'boolean(null)',\n 'boolean(\"Albert\")',\n ],\n },\n },\n 'compare': {\n evaluate: ([a, b], sourceCodeInfo): number => {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n return compare(a, b, sourceCodeInfo)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'misc',\n returns: { type: 'number' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Compares two values. Returns `-1` if $a < $b, `1` if $a > $b and `0` if $a and $b have the same sort order.',\n seeAlso: ['<', '>', '<=', '>=', 'sort', 'sequence.sort-by'],\n examples: [\n 'compare(0, 1)',\n 'compare(0, 0)',\n 'compare(1, 0)',\n 'compare(\"Albert\", \"Mojir\")',\n ],\n },\n },\n 'json-parse': {\n evaluate: ([first], sourceCodeInfo): Any => {\n assertString(first, sourceCodeInfo)\n // eslint-disable-next-line ts/no-unsafe-return\n return JSON.parse(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'any' },\n args: { x: { type: 'string' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `JSON.parse(`$x`)`.',\n seeAlso: ['json-stringify'],\n examples: [\n 'json-parse(\"[1, 2, 3]\")',\n ],\n },\n },\n 'json-stringify': {\n evaluate: ([first, second], sourceCodeInfo): string => {\n assertAny(first, sourceCodeInfo)\n if (second === undefined)\n return JSON.stringify(first)\n\n assertNumber(second, sourceCodeInfo)\n return JSON.stringify(first, null, second)\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'misc',\n returns: { type: 'string' },\n args: {\n x: { type: 'any' },\n indent: { type: 'integer', description: 'Number of spaces to use for indentation.' },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'indent'] },\n ],\n description: 'Returns `JSON.stringify(`$x`)`. If second argument is provided, returns `JSON.stringify(`$x`, null, `$indent`)`.',\n seeAlso: ['json-parse'],\n examples: [\n 'json-stringify([1, 2, 3])',\n 'json-stringify({ a: { b: 10 }}, 2)',\n ],\n hideOperatorForm: true,\n },\n },\n 'import': {\n evaluate: ([importPath], sourceCodeInfo, contextStack): ModuleFunction | Record<string, ModuleFunction> => {\n assertString(importPath, sourceCodeInfo)\n\n // Check if importing a specific function (e.g., \"grid.row\")\n const dotIndex = importPath.indexOf('.')\n if (dotIndex !== -1) {\n const moduleName = importPath.substring(0, dotIndex)\n const functionName = importPath.substring(dotIndex + 1)\n\n const module = contextStack.getModule(moduleName)\n if (!module) {\n throw new LitsError(`Unknown module: '${moduleName}'`, sourceCodeInfo)\n }\n\n const expression = module.functions[functionName]\n\n if (!expression) {\n throw new LitsError(`Function '${functionName}' not found in module '${moduleName}'`, sourceCodeInfo)\n }\n\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Module',\n moduleName,\n functionName,\n arity: expression.arity,\n }\n }\n\n // Import entire module\n const moduleName = importPath\n const module = contextStack.getModule(moduleName)\n if (!module) {\n throw new LitsError(`Unknown module: '${moduleName}'`, sourceCodeInfo)\n }\n\n // Create an object where each key is a function name and value is a ModuleFunction\n const result: Record<string, ModuleFunction> = {}\n for (const [functionName, expression] of Object.entries(module.functions)) {\n result[functionName] = {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Module',\n moduleName,\n functionName,\n arity: expression.arity,\n }\n }\n return result\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'any' },\n args: {\n path: {\n type: 'string',\n description: 'The module path to import. Can be a module name (e.g., \"vector\", \"grid\") or a fully qualified function name (e.g., \"vector.mean\", \"grid.row\").',\n },\n },\n variants: [{ argumentNames: ['path'] }],\n description: 'Imports module functions. Use a module name (e.g., \"vector\") to import all functions as an object, or a fully qualified name (e.g., \"vector.mean\") to import a single function directly.',\n examples: [\n 'let v = import(\"vector\"); v.mean([1, 2, 3, 4])',\n 'let v-sum = import(\"vector.sum\"); v-sum([1, 2, 3])',\n 'let g = import(\"grid\"); g.row([[1, 2], [3, 4]], 0)',\n ],\n },\n },\n}\n","import type { Any, Arr, Obj } from '../../interface'\nimport { assertArray, assertStringArray } from '../../typeGuards/array'\nimport { assertFunctionLike, assertObj } from '../../typeGuards/lits'\nimport { asString, assertString } from '../../typeGuards/string'\nimport { collHasKey, toAny } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const objectNormalExpression: BuiltinNormalExpressions = {\n 'keys': {\n evaluate: ([obj], sourceCodeInfo): string[] => {\n assertObj(obj, sourceCodeInfo)\n return Object.keys(obj)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'object',\n returns: { type: 'any', array: true },\n args: { obj: { type: 'object' } },\n variants: [{ argumentNames: ['obj'] }],\n description: 'Returns array of all keys in $obj.',\n seeAlso: ['vals', 'entries', 'zipmap', 'select-keys'],\n examples: [\n 'keys({})',\n 'keys({ x: 10, y: true, z: \"A string\" })',\n 'keys(object(\"x\", 10, \"y\", true, \"z\", \"A string\"))',\n ],\n },\n },\n\n 'vals': {\n evaluate: ([obj], sourceCodeInfo): Arr => {\n assertObj(obj, sourceCodeInfo)\n return Object.values(obj)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'object',\n returns: { type: 'any', array: true },\n args: { obj: { type: 'object' } },\n variants: [{ argumentNames: ['obj'] }],\n description: 'Returns array of all values in $obj.',\n seeAlso: ['keys', 'entries', 'zipmap'],\n examples: [\n 'vals({})',\n 'vals({ x: 10, y: true, z: \"A string\" })',\n 'vals(object(\"x\", 10, \"y\", true, \"z\", \"A string\"))',\n ],\n },\n },\n\n 'entries': {\n evaluate: ([obj], sourceCodeInfo): Array<[string, unknown]> => {\n assertObj(obj, sourceCodeInfo)\n return Object.entries(obj)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'object',\n returns: { type: 'array' },\n args: { obj: { type: 'object' } },\n variants: [{ argumentNames: ['obj'] }],\n description: 'Returns nested array of all key - value pairs in $obj.',\n seeAlso: ['keys', 'vals', 'zipmap', 'find'],\n examples: [\n 'entries({})',\n 'entries({ x: 10, y: true, z: \"A string\" })',\n 'entries(object(\"x\", 10, \"y\", true, \"z\", \"A string\"))',\n ],\n },\n },\n\n 'find': {\n evaluate: ([obj, key], sourceCodeInfo): [string, unknown] | null => {\n assertObj(obj, sourceCodeInfo)\n assertString(key, sourceCodeInfo)\n if (collHasKey(obj, key))\n return [key, obj[key]]\n\n return null\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: ['array', 'null'] },\n args: {\n a: { type: 'object' },\n b: { type: 'string' },\n obj: { type: 'object' },\n key: { type: 'string' },\n },\n variants: [{ argumentNames: ['obj', 'key'] }],\n description: 'Returns entry (key-value pair) for $key, or `null` if $key not present in $obj.',\n seeAlso: ['get', 'contains?', 'entries', 'sequence.position', 'some'],\n examples: [\n '{ a: 1, \"b\": 2 } find \"a\"',\n 'find(object(\"a\", 1, \"b\", 2), \"b\")',\n 'find(object(\"a\", 1, \"b\", 2), \"c\")',\n ],\n },\n },\n\n 'dissoc': {\n evaluate: ([obj, key], sourceCodeInfo): Any => {\n assertObj(obj, sourceCodeInfo)\n assertString(key, sourceCodeInfo)\n const newObj = { ...obj }\n delete newObj[key]\n return newObj\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'object' },\n b: { type: 'string' },\n obj: { type: 'object' },\n key: { type: 'string' },\n },\n variants: [{ argumentNames: ['obj', 'key'] }],\n description: 'Return shallow copy of $obj with $key deleted.',\n seeAlso: ['assoc', 'select-keys'],\n examples: [\n '{ x: 10, y: 20 } dissoc \"y\"',\n 'dissoc({ x: 10, y: 20 }, \"x\")',\n 'dissoc({ x: 10 }, \"y\")',\n `\nlet o = { a: 5 };\ndissoc(o, \"a\");\no`,\n ],\n },\n },\n\n 'merge': {\n evaluate: (params, sourceCodeInfo): Any => {\n if (params.length === 0)\n return null\n\n const [first, ...rest] = params\n assertObj(first, sourceCodeInfo)\n\n return rest.reduce(\n (result: Obj, obj) => {\n assertObj(obj, sourceCodeInfo)\n return { ...result, ...obj }\n },\n { ...first },\n )\n },\n arity: { min: 0 },\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'object' },\n b: { type: 'object' },\n objs: { type: 'object', rest: true },\n },\n variants: [{ argumentNames: ['objs'] }],\n description: `Returns a new object created by merging together all arguments.\n\nIf two keys appears in more than one object the value from the last object is used.\nIf no arguments are provided \\`null\\` is returned.`,\n seeAlso: ['merge-with', 'assoc'],\n examples: [\n '{ x: 10 } merge { y: 20 }',\n 'merge(object(\"x\", 10), object(\"y\", 20))',\n 'merge(object(\"x\", 10), object(\"x\", 15, \"y\", 20))',\n ],\n },\n },\n\n 'merge-with': {\n evaluate: (params: Arr, sourceCodeInfo, contextStack, { executeFunction }): Any => {\n const first = params[0]\n const fn = params.at(-1)\n const rest = params.slice(1, -1)\n\n assertObj(first, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n return rest.reduce(\n (result: Obj, obj) => {\n assertObj(obj, sourceCodeInfo)\n Object.entries(obj).forEach((entry) => {\n const key = asString(entry[0], sourceCodeInfo)\n const val = toAny(entry[1])\n if (collHasKey(result, key))\n result[key] = executeFunction(fn, [result[key], val], contextStack, sourceCodeInfo)\n else\n result[key] = val\n })\n return result\n },\n { ...first },\n )\n },\n arity: { min: 2 },\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n objs: { type: 'object', rest: true },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['objs', 'fun'] }],\n description: `\nReturns a new object created by merging together all arguments.\nIf two keys appears in more than one object $fun is used to calculate the new value.\n\nIf no arguments are provided \\`null\\` is returned.`,\n seeAlso: ['merge'],\n examples: [\n 'merge-with(object(\"x\", 10), object(\"y\", 20), +)',\n 'merge-with(object(\"x\", 10), object(\"x\", 15, \"y\", 20), +)',\n 'merge-with({ x: 10 }, { x: 20 }, { x: 30 }, { x: 40 }, -)',\n ],\n hideOperatorForm: true,\n },\n },\n\n 'zipmap': {\n evaluate: ([keys, values], sourceCodeInfo): Any => {\n assertStringArray(keys, sourceCodeInfo)\n assertArray(values, sourceCodeInfo)\n\n const length = Math.min(keys.length, values.length)\n\n const result: Obj = {}\n\n for (let i = 0; i < length; i += 1) {\n const key = asString(keys[i], sourceCodeInfo)\n result[key] = toAny(values[i])\n }\n return result\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'array' },\n b: { type: 'array' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns a new object created by mapping $a to $b.',\n seeAlso: ['entries', 'keys', 'vals', 'sequence.interleave'],\n examples: [\n '[\"a\", \"b\", \"c\"] zipmap [1, 2, 3]',\n 'zipmap([\"a\", \"b\", \"c\"], [10, null, [1, 2, 3]])',\n 'zipmap([\"a\", \"b\", \"c\"], [1])',\n 'zipmap([], [10, null, [1, 2, 3]])',\n ],\n },\n },\n\n 'select-keys': {\n evaluate: ([obj, keys], sourceCodeInfo): Any => {\n assertStringArray(keys, sourceCodeInfo)\n assertObj(obj, sourceCodeInfo)\n\n return keys.reduce((result: Obj, key) => {\n if (collHasKey(obj, key))\n result[key] = toAny(obj[key])\n\n return result\n }, {})\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'object' },\n b: { type: 'array' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns an object containing only those entries in $a whose key is in $b.',\n seeAlso: ['dissoc', 'keys'],\n examples: [\n '{ a: 1, b: 2, c: 3 } select-keys [\"a\", \"b\"]',\n 'select-keys({ a: 1, b: 2, c: 3 }, [\"a\", \"b\"])',\n 'select-keys({ a: 1 }, [\"a\", \"b\"])',\n ],\n },\n },\n}\n","import { isLitsFunction } from '../../typeGuards/litsFunction'\nimport { assertColl, isColl, isObj, isRegularExpression, isSeq } from '../../typeGuards/lits'\nimport { assertNumber, isNumber } from '../../typeGuards/number'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { isGrid, isMatrix, isVector } from '../../typeGuards/annotatedArrays'\nimport { EPSILON } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\n\nexport const predicatesNormalExpression: BuiltinNormalExpressions = {\n 'function?': {\n evaluate: ([first]): boolean => isLitsFunction(first),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a function, otherwise `false`.',\n seeAlso: ['string?', 'number?', 'boolean?', 'null?', 'array?', 'object?', 'regexp?'],\n examples: [\n 'function?(+)',\n 'function?(/)',\n 'function?((x, y) -> x + y)',\n 'function?(false)',\n 'function?(\"false\")',\n 'function?([1, 2, 3])',\n ],\n },\n },\n\n 'string?': {\n evaluate: ([first]): boolean => typeof first === 'string',\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a string, otherwise `false`.',\n seeAlso: ['blank?', 'number?', 'boolean?', 'null?', 'array?', 'object?', 'regexp?', 'function?', 'collection?', 'sequence?'],\n examples: [\n 'string?(\"\")',\n 'string?(\"A string\")',\n 'string?(true ? \"A string\" : false)',\n 'string?(false)',\n 'string?([1, 2, 3])',\n 'string?(100)',\n ],\n },\n },\n\n 'number?': {\n evaluate: ([first]): boolean => typeof first === 'number',\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a number, otherwise `false`.',\n seeAlso: ['integer?', 'zero?', 'pos?', 'neg?', 'finite?', 'number', 'string?', 'boolean?', 'null?', 'function?'],\n examples: [\n 'number?(0)',\n 'number?(2)',\n 'number?(-0.12)',\n 'number?(false)',\n 'number?([1, 2, 3])',\n 'number?(\"A string\")',\n ],\n },\n },\n\n 'integer?': {\n evaluate: ([first]): boolean => typeof first === 'number' && isNumber(first, { integer: true }),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is an integer, otherwise `false`.',\n seeAlso: ['number?', 'number', 'even?', 'odd?'],\n examples: [\n 'integer?(0)',\n 'integer?(-12)',\n 'integer?(42)',\n 'integer?(10.1)',\n 'integer?((x, y) -> x + y)',\n 'integer?(false)',\n 'integer?(\"false\")',\n 'integer?([1, 2, 3])',\n ],\n },\n },\n\n 'boolean?': {\n evaluate: ([first]): boolean => typeof first === 'boolean',\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a `boolean`, otherwise `false`.',\n seeAlso: ['true?', 'false?', 'boolean', 'string?', 'number?', 'null?', 'function?'],\n examples: [\n 'boolean?(true)',\n 'boolean?(false)',\n 'boolean?([1, 2, 3])',\n 'boolean?(0)',\n 'boolean?(\"A string\")',\n ],\n },\n },\n\n 'null?': {\n evaluate: ([first]): boolean => first === null || first === undefined,\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `null`, otherwise `false`.',\n seeAlso: ['empty?', 'not-empty?', 'string?', 'number?', 'boolean?', 'function?'],\n examples: [\n 'null?(null)',\n 'null?(false)',\n 'null?([1, 2, 3])',\n 'null?(0)',\n 'null?(\"A string\")',\n ],\n },\n },\n\n 'zero?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo, { finite: true })\n return Math.abs(value) < EPSILON\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `0`, otherwise `false`.',\n seeAlso: ['pos?', 'neg?', 'even?', 'number?'],\n examples: [\n 'zero?(0)',\n 'zero?(-0.0)',\n 'zero?(1)',\n 'zero?(0.1)',\n ],\n },\n },\n\n 'pos?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return first > 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is greater than `0`, otherwise `false`.',\n seeAlso: ['neg?', 'zero?', 'number?'],\n examples: [\n 'pos?(0)',\n 'pos?(-0.0)',\n 'pos?(1)',\n 'pos?(-0.1)',\n ],\n },\n },\n\n 'neg?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return first < 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is less than `0`, otherwise `false`.',\n seeAlso: ['pos?', 'zero?', 'number?'],\n examples: [\n 'neg?(0)',\n 'neg?(-0.0)',\n 'neg?(1)',\n 'neg?(-0.1)',\n ],\n },\n },\n\n 'even?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return first % 2 === 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is even, otherwise `false`.',\n seeAlso: ['odd?', 'integer?', 'zero?'],\n examples: [\n 'even?(0)',\n 'even?(-0.0)',\n 'even?(-1)',\n 'even?(2.1)',\n ],\n },\n },\n\n 'odd?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return isNumber(first, { integer: true }) && first % 2 !== 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is odd, otherwise `false`.',\n seeAlso: ['even?', 'integer?'],\n examples: [\n 'odd?(1.0)',\n 'odd?(1.001)',\n 'odd?(-1)',\n 'odd?(2.1)',\n ],\n },\n },\n\n 'array?': {\n evaluate: ([first]): boolean => {\n return Array.isArray(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is an array, otherwise `false`.',\n seeAlso: ['sequence?', 'collection?', 'object?', 'string?', 'vector?', 'matrix?', 'grid?', 'function?'],\n examples: [\n 'array?([])',\n 'array?([1, 2, 3])',\n 'array?(object(\"a\", 10))',\n 'array?(42)',\n 'array?(10.1)',\n 'array?((x, y) -> x + y)',\n ],\n },\n },\n\n 'collection?': {\n evaluate: ([first]): boolean => {\n return isColl(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a collection i.e. an array, an object or a string, otherwise `false`.',\n seeAlso: ['sequence?', 'array?', 'object?', 'string?'],\n examples: [\n 'collection?([])',\n 'collection?([1, 2, 3])',\n 'collection?(object(\"a\", 10))',\n 'collection?(\"Albert\")',\n 'collection?(42)',\n 'collection?(10.1)',\n 'collection?((x, y) -> x + y)',\n ],\n },\n },\n\n 'sequence?': {\n evaluate: ([first]): boolean => {\n return isSeq(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a sequence i.e. an array or a string, otherwise `false`.',\n seeAlso: ['collection?', 'array?', 'string?'],\n examples: [\n 'sequence?([])',\n 'sequence?([1, 2, 3])',\n 'sequence?(object(\"a\", 10))',\n 'sequence?(\"Albert\")',\n 'sequence?(42)',\n 'sequence?(10.1)',\n 'sequence?((x, y) -> x + y)',\n ],\n },\n },\n\n 'object?': {\n evaluate: ([first]): boolean => isObj(first),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is an object, otherwise `false`.',\n seeAlso: ['collection?', 'array?', 'string?', 'function?'],\n examples: [\n 'object?(object(\"a\", 10))',\n 'object?(42)',\n 'object?(10.1)',\n 'object?((x, y) -> x + y)',\n 'object?(#\"^start\")',\n 'object?(\"false\")',\n 'object?([1, 2, 3])',\n ],\n },\n },\n\n 'regexp?': {\n evaluate: ([value]): boolean => isRegularExpression(value),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a regexp, otherwise `false`.',\n seeAlso: ['regexp', 'match', 'string?', 'function?'],\n examples: [\n 'regexp?(regexp(\"^start\"))',\n 'regexp?(#\"^start\")',\n 'regexp?(-12)',\n 'regexp?({})',\n 'regexp?(10.1)',\n 'regexp?((x, y) -> x + y)',\n 'regexp?(false)',\n 'regexp?(\"false\")',\n 'regexp?([1, 2, 3])',\n ],\n },\n },\n\n 'finite?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo)\n return Number.isFinite(value)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is finite, otherwise `false`.',\n seeAlso: ['positive-infinity?', 'negative-infinity?', 'number?'],\n examples: [\n 'finite?(1.0)',\n 'finite?(1 / 0)',\n 'finite?(-1 / 0)',\n ],\n },\n },\n\n 'positive-infinity?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo)\n return value === Number.POSITIVE_INFINITY\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x equals positive infinity, otherwise `false`.',\n seeAlso: ['negative-infinity?', 'finite?'],\n examples: [\n 'positive-infinity?(1.0)',\n 'positive-infinity?(1 / 0)',\n 'positive-infinity?(-1 / 0)',\n ],\n },\n },\n\n 'negative-infinity?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo)\n return value === Number.NEGATIVE_INFINITY\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x equals negative infinity, otherwise `false`.',\n seeAlso: ['positive-infinity?', 'finite?'],\n examples: [\n 'negative-infinity?(1.0)',\n 'negative-infinity?(1 / 0)',\n 'negative-infinity?(-1 / 0)',\n ],\n },\n },\n\n 'true?': {\n evaluate: ([value]): boolean => {\n return value === true\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `true`, otherwise `false`.',\n seeAlso: ['false?', 'boolean?', 'boolean'],\n examples: [\n 'true?(false)',\n 'true?(true)',\n 'true?(1)',\n 'true?(0)',\n ],\n },\n },\n\n 'false?': {\n evaluate: ([value]): boolean => {\n return value === false\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `true`, otherwise `false`.',\n seeAlso: ['true?', 'boolean?', 'boolean'],\n examples: [\n 'false?(false)',\n 'false?(true)',\n 'false?(1)',\n 'false?(0)',\n ],\n },\n },\n\n 'empty?': {\n evaluate: ([coll], sourceCodeInfo): boolean => {\n if (coll === null)\n return true\n\n assertColl(coll, sourceCodeInfo)\n if (typeof coll === 'string')\n return coll.length === 0\n\n if (Array.isArray(coll))\n return coll.length === 0\n\n return Object.keys(coll).length === 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: ['collection', 'string', 'null'] } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is empty or `null`, otherwise `false`.',\n seeAlso: ['not-empty?', 'collection.not-empty', 'null?', 'blank?', 'count'],\n examples: [\n 'empty?([])',\n 'empty?([1, 2, 3])',\n 'empty?({})',\n 'empty?({ a: 2 })',\n 'empty?(\"\")',\n 'empty?(\"Albert\")',\n 'empty?(null)',\n ],\n },\n },\n 'not-empty?': {\n evaluate: ([coll], sourceCodeInfo): boolean => {\n if (coll === null)\n return false\n\n assertColl(coll, sourceCodeInfo)\n if (typeof coll === 'string')\n return coll.length > 0\n\n if (Array.isArray(coll))\n return coll.length > 0\n\n return Object.keys(coll).length > 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: ['collection', 'string', 'null'] } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `false` if $x is empty or `null`, otherwise `true`.',\n seeAlso: ['empty?', 'collection.not-empty', 'null?'],\n examples: [\n 'not-empty?([])',\n 'not-empty?([1, 2, 3])',\n 'not-empty?({})',\n 'not-empty?({ a: 2 })',\n 'not-empty?(\"\")',\n 'not-empty?(\"Albert\")',\n 'not-empty?(null)',\n ],\n },\n },\n 'vector?': {\n evaluate: ([vector]): boolean => isVector(vector),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n description: 'Checks if a value is a `vector`. A `vector` is an array of `numbers`.',\n seeAlso: ['matrix?', 'grid?', 'array?'],\n returns: { type: 'boolean' },\n args: { value: { type: 'any', description: 'The value to check.' } },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'vector?(1)',\n 'vector?([1, 2, 3])',\n 'vector?([1, 2, \"3\"])',\n ],\n },\n },\n 'matrix?': {\n evaluate: ([matrix]): boolean => isMatrix(matrix),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n description: 'Checks if a value is a `matrix`. A `matrix` is an array of arrays of `numbers`.',\n seeAlso: ['vector?', 'grid?', 'array?'],\n returns: { type: 'boolean' },\n args: { value: { type: 'any', description: 'The value to check.' } },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'matrix?(1)',\n 'matrix?([1, 2, 3])',\n 'matrix?([[1, 2], [3, 4]])',\n 'matrix?([[1, 2], [3, \"4\"]])',\n 'matrix?([[1, 2], [3]])',\n ],\n },\n },\n 'grid?': {\n evaluate: ([table]): boolean => isGrid(table),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n description: 'Checks if a `value` is a `grid`. A `grid` is an `array` of `arrays` where all inner `arrays` have the same length.',\n seeAlso: ['vector?', 'matrix?', 'array?'],\n returns: { type: 'boolean' },\n args: { value: { type: 'any', description: 'The value to check.' } },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'grid?(\"1\")',\n 'grid?([\"1\", 2, 3])',\n 'grid?([[\"1\", 2], [3, 4]])',\n 'grid?([[\"1\", 2], [3, \"4\"]])',\n 'grid?([[\"1\", 2], [3]])',\n ],\n },\n },\n\n}\n","import { LitsError } from '../../errors'\nimport type { RegularExpression } from '../../parser/types'\nimport { assertRegularExpression, assertStringOrRegularExpression, isRegularExpression } from '../../typeGuards/lits'\nimport { assertString, isString } from '../../typeGuards/string'\nimport { toFixedArity } from '../../utils/arity'\nimport { REGEXP_SYMBOL } from '../../utils/symbols'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const regexpNormalExpression: BuiltinNormalExpressions = {\n 'regexp': {\n evaluate: ([sourceArg, flagsArg], sourceCodeInfo): RegularExpression => {\n assertString(sourceArg, sourceCodeInfo)\n const source = sourceArg || '(?:)'\n const flags = typeof flagsArg === 'string' ? flagsArg : ''\n\n try {\n // eslint-disable-next-line no-new\n new RegExp(source, flags) // Throws if invalid regexp\n }\n catch (e) {\n throw new LitsError(`Invalid regular expression: ${source} ${flags}`, sourceCodeInfo)\n }\n return {\n [REGEXP_SYMBOL]: true,\n sourceCodeInfo,\n s: source,\n f: flags,\n }\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'regular-expression',\n returns: { type: 'regexp' },\n args: {\n pattern: { type: 'string' },\n flags: { type: 'string', description: 'Optional flags for the regular expression. Possible values are the same as Javascript RegExp takes.' },\n },\n variants: [\n { argumentNames: ['pattern'] },\n { argumentNames: ['pattern', 'flags'] },\n ],\n description: 'Creates a RegExp from $pattern and $flags.',\n examples: [\n 'regexp(\"^\\\\s*(.*)$\")',\n '#\"^\\\\s*(.*)$\"',\n 'regexp(\"albert\", \"ig\")',\n '#\"albert\"ig',\n ],\n seeAlso: ['-short-regexp', 'match', 'replace', 'replace-all', 'regexp?'],\n hideOperatorForm: true,\n },\n },\n 'match': {\n evaluate: ([text, regexp], sourceCodeInfo): string[] | null => {\n assertRegularExpression(regexp, sourceCodeInfo)\n if (!isString(text))\n return null\n\n const regExp = new RegExp(regexp.s, regexp.f)\n const match = regExp.exec(text)\n if (match)\n return [...match]\n\n return null\n },\n arity: toFixedArity(2),\n docs: {\n category: 'regular-expression',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'regexp' },\n b: { type: 'string' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: `Matches $b against regular expression $a.\nIf $b is a string and matches the regular expression, a \\`match\\`-array is returned, otherwise \\`null\\` is returned.`,\n seeAlso: ['regexp', 'replace', 'replace-all', '-short-regexp', 'regexp?'],\n examples: [\n 'match(\" A string\", regexp(\"^\\\\\\\\s*(.*)$\"))',\n 'match(\" A string\", #\"^\\\\s*(.*)$\")',\n 'match(\"My name is Albert\", #\"albert\"i)',\n 'match(\"My name is Ben\", #\"albert\"i)',\n 'match(null, #\"albert\"i)',\n 'match(1, #\"albert\"i)',\n 'match({}, #\"albert\"i)',\n ],\n },\n },\n 'replace': {\n evaluate: ([str, regexp, value], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n assertStringOrRegularExpression(regexp, sourceCodeInfo)\n assertString(value, sourceCodeInfo)\n\n const matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, `${regexp.f}`) : regexp\n return str.replace(matcher, value)\n },\n arity: toFixedArity(3),\n docs: {\n category: 'regular-expression',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'string' },\n b: { type: ['regexp', 'string'] },\n x: { type: 'string' },\n },\n variants: [{ argumentNames: ['a', 'b', 'x'] }],\n description: 'Returns a new string with first match of regular expression $b replaced by $x.',\n seeAlso: ['replace-all', 'regexp', 'match', '-short-regexp'],\n examples: [\n 'replace(\"Duck duck\", \"u\", \"i\")',\n 'replace(\"Duck duck\", #\"u\", \"i\")',\n 'replace(\"abcABC\", regexp(\"a\", \"i\"), \"-\")',\n 'replace(\"abcABC\", regexp(\"a\", \"gi\"), \"-\")',\n 'replace(\"abcABC\", #\"a\"i, \"-\")',\n 'replace(\"abcABC\", #\"a\"gi, \"-\")',\n ],\n },\n },\n 'replace-all': {\n evaluate: ([str, regexp, value], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n assertStringOrRegularExpression(regexp, sourceCodeInfo)\n assertString(value, sourceCodeInfo)\n const matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, `${regexp.f.includes('g') ? regexp.f : `${regexp.f}g`}`) : regexp\n return str.replaceAll(matcher, value)\n },\n arity: toFixedArity(3),\n docs: {\n category: 'regular-expression',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'string' },\n b: { type: ['regexp', 'string'] },\n x: { type: 'string' },\n },\n variants: [{ argumentNames: ['a', 'b', 'x'] }],\n description: 'Returns a new string with all matches of regular expression $b replaced by $x.',\n seeAlso: ['replace', 'regexp', 'match', '-short-regexp'],\n examples: [\n 'replace-all(\"Duck duck\", \"u\", \"i\")',\n 'replace-all(\"Duck duck\", regexp(\"u\"), \"i\")',\n 'replace-all(\"abcABC\", regexp(\"a\", \"i\"), \"-\")',\n 'replace-all(\"abcABC\", regexp(\"a\", \"gi\"), \"-\")',\n 'replace-all(\"abcABC\", #\"a\"i, \"-\")',\n 'replace-all(\"abcABC\", #\"a\"gi, \"-\")',\n ],\n },\n },\n}\n","import { LitsError } from '../../errors'\nimport type { Arr } from '../../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { assertStringOrRegularExpression, isObj } from '../../typeGuards/lits'\nimport { assertNumber } from '../../typeGuards/number'\nimport { assertString, assertStringOrNumber } from '../../typeGuards/string'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nconst blankRegexp = /^\\s*$/\nexport const stringNormalExpression: BuiltinNormalExpressions = {\n 'str': {\n evaluate: (params: Arr) => {\n return params.reduce((result: string, param) => {\n const paramStr\n = param === undefined || param === null\n ? ''\n : isObj(param)\n ? JSON.stringify(param)\n : Array.isArray(param)\n ? JSON.stringify(param)\n : `${param}`\n return result + paramStr\n }, '')\n },\n arity: {},\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { values: { type: 'any', rest: true } },\n variants: [{ argumentNames: ['values'] }],\n description: 'Concatenats $values into one string. If `value` equals `null` empty string is returned.',\n seeAlso: ['++', 'join', 'string.template', 'string.string-repeat', 'number'],\n examples: [\n 'str(\"A string\", \", and another string\", \" ...and more\")',\n 'str(\"Just one string\")',\n 'str()',\n 'str(0, false, true, null, #\"^kalle\", [1, 2, 3], {a: \"a\"})',\n ],\n hideOperatorForm: true,\n },\n },\n\n 'number': {\n evaluate: ([str], sourceCodeInfo): number => {\n assertString(str, sourceCodeInfo)\n const number = Number(str)\n if (Number.isNaN(number))\n throw new LitsError(`Could not convert '${str}' to a number.`, sourceCodeInfo)\n\n return number\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'number' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Parses $s to a number.',\n seeAlso: ['str', 'number?', 'integer?'],\n examples: [\n 'number(\"10\")',\n 'number(\"010\")',\n 'number(\"-1.01\")',\n ],\n },\n },\n\n 'lower-case': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.toLowerCase()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns $s converted to lower case.',\n seeAlso: ['upper-case', 'string.capitalize'],\n examples: [\n 'lower-case(\"Albert\")',\n 'lower-case(\"\")',\n ],\n },\n },\n\n 'upper-case': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.toUpperCase()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns $s converted to upper case.',\n seeAlso: ['lower-case', 'string.capitalize'],\n examples: [\n 'upper-case(\"Albert\")',\n 'upper-case(\"\")',\n ],\n },\n },\n\n 'trim': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.trim()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns a new string with leading and trailing whitespaces removed.',\n seeAlso: ['string.trim-left', 'string.trim-right', 'blank?'],\n examples: [\n 'trim(\" Albert \")',\n 'trim(\" \")',\n 'trim(\"\")',\n ],\n },\n },\n\n 'join': {\n evaluate: ([stringList, delimiter], sourceCodeInfo): string => {\n assertArray(stringList, sourceCodeInfo)\n stringList.forEach(str => assertStringOrNumber(str, sourceCodeInfo))\n assertString(delimiter, sourceCodeInfo)\n return stringList.join(delimiter)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: {\n a: { type: 'array' },\n b: { type: 'string' },\n arr: { type: 'array' },\n delimiter: { type: 'string' },\n },\n variants: [{ argumentNames: ['arr', 'delimiter'] }],\n description: 'Returns a new string by concatenating all of the elements in $arr, separated by $delimiter.',\n seeAlso: ['split', 'str', '++', 'sequence.interpose'],\n examples: [\n 'map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str) join \", \"',\n '([0, 1, 2, 3, 4, 5, 6, 7, 8, 9] map str) join \", \"',\n 'join([\"Albert\", 10], \", \")',\n 'join([\"Albert\", \"Mojir\"], \" \")',\n 'join(map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str), \", \")',\n ],\n },\n },\n\n 'split': {\n evaluate: ([str, stringOrRegExpValue, limit], sourceCodeInfo): string[] => {\n assertString(str, sourceCodeInfo)\n assertStringOrRegularExpression(stringOrRegExpValue, sourceCodeInfo)\n if (limit !== undefined)\n assertNumber(limit, sourceCodeInfo, { integer: true, nonNegative: true })\n\n const delimiter\n = typeof stringOrRegExpValue === 'string'\n ? stringOrRegExpValue\n : new RegExp(stringOrRegExpValue.s, stringOrRegExpValue.f)\n return str.split(delimiter, limit)\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: {\n a: { type: 'string' },\n b: { type: 'string' },\n s: { type: 'string' },\n delimiter: { type: 'string' },\n limit: { type: 'integer' },\n },\n variants: [\n { argumentNames: ['s', 'delimiter'] },\n { argumentNames: ['s', 'delimiter', 'limit'] },\n ],\n description: 'Divides $s into an array of substrings. The division is done by searching for `delimiter`. If `limit` as provided, at most `limit` number of substrings are returned.',\n seeAlso: ['join', 'string.split-lines'],\n examples: [\n '\"Albert Mojir\" split \" \"',\n 'split(\"Albert Mojir\", \" \")',\n 'split(\"abcdefghijklmnopqrstuvw\", #\"[aoueiy]\")',\n 'split(\"0123456789\", \"\")',\n 'split(\"0123456789\", \"\", 5) map number',\n ],\n },\n },\n 'blank?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n if (value === null) {\n return true\n }\n assertString(value, sourceCodeInfo)\n return blankRegexp.test(value)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'boolean' },\n args: { s: { type: ['string', 'null'] } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns true if $s is null or only contains whitespace characters.',\n seeAlso: ['trim', 'empty?', 'string?'],\n examples: [\n 'blank?(\"\")',\n 'blank?(null)',\n 'blank?(\"\\n\")',\n 'blank?(\" \")',\n 'blank?(\".\")',\n ],\n },\n },\n}\n","import type { Any, Arr } from '../../interface'\nimport type {\n CompFunction,\n ConstantlyFunction,\n FunctionLike,\n} from '../../parser/types'\nimport { toAny } from '../../utils'\nimport { getArityFromFunction, toFixedArity } from '../../utils/arity'\nimport { FUNCTION_SYMBOL } from '../../utils/symbols'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { assertFunctionLike } from '../../typeGuards/lits'\n\nexport const functionalNormalExpression: BuiltinNormalExpressions = {\n '|>': {\n evaluate: ([value, func], sourceCodeInfo, contextStack, { executeFunction }): Any => {\n assertFunctionLike(func, sourceCodeInfo)\n return executeFunction(func, [value], contextStack, sourceCodeInfo)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'functional',\n returns: { type: 'any' },\n args: {\n a: { type: 'any' },\n b: { type: 'function' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Takes a value $a and a function $b, and returns the result of applying $b to $a.',\n seeAlso: ['apply', 'comp'],\n examples: [\n `\n1 |> inc |> inc`,\n `range(10)\n |> map(_, -> $ ^ 2) // [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]\n |> filter(_, odd?) // [1, 9, 25, 49, 81]\n |> reduce(_, +, 0) // 165\n |> sqrt // 12.84523257866513\n |> round(_, 2)`,\n ],\n },\n },\n 'apply': {\n evaluate: ([func, ...params]: Arr, sourceCodeInfo, contextStack, { executeFunction }): Any => {\n assertFunctionLike(func, sourceCodeInfo)\n const paramsLength = params.length\n const last = params[paramsLength - 1]\n assertArray(last, sourceCodeInfo)\n const applyArray = [...params.slice(0, -1), ...last]\n return executeFunction(func, applyArray, contextStack, sourceCodeInfo)\n },\n arity: { min: 2 },\n docs: {\n category: 'functional',\n returns: { type: 'any' },\n args: {\n a: { type: 'function' },\n b: { type: 'array' },\n fun: { type: 'function' },\n args: { type: 'array' },\n },\n variants: [{ argumentNames: ['fun', 'args'] }],\n description: 'Call supplied function $fun with specified arguments $args.',\n seeAlso: ['|>'],\n examples: [\n `\napply(+, [1, 2, 3])`,\n `\napply(\n (x, y) -> sqrt(x ^ 2 + y ^ 2),\n [3, 4]\n)`,\n `\n(x, y) -> sqrt(x ^ 2 + y ^ 2) apply [3, 4]`,\n ],\n },\n },\n\n 'identity': {\n evaluate: ([value]): Any => {\n return toAny(value)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'functional',\n returns: { type: 'any' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns $x.',\n seeAlso: ['constantly', 'functional.fnull'],\n examples: ['identity(1)', 'identity(\"Albert\")', 'identity({ a: 1 })', 'identity(null)'],\n },\n },\n\n 'comp': {\n evaluate: (params, sourceCodeInfo): CompFunction => {\n params.forEach(param => assertFunctionLike(param, sourceCodeInfo))\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Comp',\n params,\n arity: params.length > 0 ? getArityFromFunction(params.at(-1) as FunctionLike) : { min: 1, max: 1 },\n }\n },\n arity: {},\n docs: {\n category: 'functional',\n returns: { type: 'function' },\n args: {\n a: { type: 'function' },\n b: { type: 'function' },\n fns: { type: 'function', rest: true },\n },\n variants: [{ argumentNames: ['fns'] }],\n description: `Takes a variable number of functions and returns a function that is the composition of those.\n\n The returned function takes a variable number of arguments,\n applies the rightmost function to the args,\n the next function (right-to-left) to the result, etc.`,\n seeAlso: ['|>', 'functional.juxt', 'functional.complement'],\n examples: [\n `\nlet negative-quotient = comp(-, /);\nnegative-quotient(9, 3)`,\n `\nlet x = { bar: { foo: 42 } };\ncomp(\"foo\", \"bar\")(x)`,\n ],\n },\n },\n\n 'constantly': {\n evaluate: ([value], sourceCodeInfo): ConstantlyFunction => {\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Constantly',\n value: toAny(value),\n arity: {},\n }\n },\n arity: toFixedArity(1),\n docs: {\n category: 'functional',\n returns: { type: 'function' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns a function that takes any number of arguments and always returns $x.',\n seeAlso: ['identity', 'functional.fnull'],\n examples: [\n `\nlet always-true = constantly(true);\nalways-true(9, 3)`,\n ],\n },\n },\n\n}\n","import type { FunctionReference } from '../../../reference'\nimport { assertNonUndefined } from '../../typeGuards'\nimport { assertFunctionLike } from '../../typeGuards/lits'\nimport { isLitsFunction } from '../../typeGuards/litsFunction'\nimport { toFixedArity } from '../../utils/arity'\nimport { generateDocString } from '../../utils/docString/generateDocString'\nimport type { Arity, BuiltinNormalExpressions } from '../interface'\n\nexport function getMetaNormalExpression(normalExpressionReference: Record<string, FunctionReference>): BuiltinNormalExpressions {\n return {\n doc: {\n evaluate: ([fn], sourceCodeInfo): string => {\n assertNonUndefined(normalExpressionReference)\n assertFunctionLike(fn, sourceCodeInfo)\n if (!isLitsFunction(fn)) {\n return ''\n }\n if (fn.functionType === 'Builtin') {\n const reference = normalExpressionReference[fn.name]\n return reference ? generateDocString(reference) : ''\n }\n if (fn.functionType === 'UserDefined' || fn.functionType === 'NativeJsFunction') {\n return fn.docString\n }\n return ''\n },\n arity: toFixedArity(1),\n docs: {\n category: 'meta',\n returns: { type: 'string' },\n args: { fun: { type: 'function' } },\n variants: [{ argumentNames: ['fun'] }],\n description: 'Returns documentation string of the $fun.',\n seeAlso: ['arity'],\n examples: [\n 'doc(+)',\n `\nlet add = (x, y) -> do\n \"\"\"\n Adds two numbers.\n Args:\n x: First number.\n y: Second number.\n Returns:\n Sum of x and y.\n \"\"\"\n x + y;\nend;\n\ndoc(add)`,\n ],\n },\n },\n arity: {\n evaluate: ([fn], sourceCodeInfo): Arity => {\n assertFunctionLike(fn, sourceCodeInfo)\n return isLitsFunction(fn) ? fn.arity : toFixedArity(1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'meta',\n returns: { type: 'object' },\n args: { fun: { type: 'function' } },\n variants: [{ argumentNames: ['fun'] }],\n description: 'Returns arity of the $fun. The arity is an object with the properties: `min` and `max`. If the function has fixed arity, `min` and `max` are equal to the number of required parameters. If no restrictions apply, empty object is returned.',\n seeAlso: ['doc'],\n examples: [\n 'arity(+)',\n 'arity(defined?)',\n `\nlet add = (x, y = 0) -> do\n x + y;\nend;\n\narity(add)`,\n `\nlet foo = (k, ...x) -> do\n k + x;\nend;\n arity(foo)`,\n ],\n },\n },\n }\n}\n","import { assertNonEmptyVector, assertVector } from '../../typeGuards/annotatedArrays'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nfunction calcMedian(vector: number[]): number {\n const sorted = [...vector].sort((a, b) => a - b)\n const mid = Math.floor(sorted.length / 2)\n return sorted.length % 2 === 0\n ? (sorted[mid - 1]! + sorted[mid]!) / 2\n : sorted[mid]!\n}\n\nexport const vectorNormalExpression: BuiltinNormalExpressions = {\n sum: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc + val, 0)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to sum.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the **sum** of all elements in the `vector`. Returns `0` for an empty vector.',\n seeAlso: ['prod', 'mean', 'median', 'vector.sum'],\n examples: [\n 'sum([1, 2, 3, 4, 5])',\n 'sum([1, -2, 3])',\n 'sum([])',\n ],\n },\n },\n\n prod: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc * val, 1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to multiply.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the **product** of all elements in the `vector`. Returns `1` for an empty vector.',\n seeAlso: ['sum', 'mean', 'median', 'vector.prod'],\n examples: [\n 'prod([1, 2, 3, 4, 5])',\n 'prod([1, -2, 3])',\n 'prod([])',\n ],\n },\n },\n\n mean: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc + val, 0) / vector.length\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to calculate the mean of.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the arithmetic **mean** of all elements in the `vector`. Throws for an empty vector.',\n seeAlso: ['median', 'sum', 'prod', 'vector.mean'],\n examples: [\n 'mean([1, 2, 3, 4, 5])',\n 'mean([1, -2, 3])',\n ],\n },\n },\n\n median: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return calcMedian(vector)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to calculate the median of.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the **median** of all elements in the `vector`. For even-length vectors, returns the average of the two middle values. Throws for an empty vector.',\n seeAlso: ['mean', 'sum', 'prod', 'vector.median'],\n examples: [\n 'median([1, 2, 3, 4, 5])',\n 'median([1, 2, 3, 4])',\n 'median([3, 1, 4, 1, 5])',\n ],\n },\n },\n}\n","import { smartTrim } from '..'\nimport type { Argument, FunctionReference, TypedValue } from '../../../reference'\n\nexport function generateDocString(reference: FunctionReference): string {\n return smartTrim(`\n ${reference.title}\n\n ${reference.description\n .replace(/`(.+?)`/g, '$1')\n .replace(/\\$(\\w+)/g, '$1')\n .replace(/\\*\\*\\*(.+)\\*\\*\\*/g, '$1')\n .replace(/\\*\\*(.+)\\*\\*/g, '$1')\n }\n\n Signature:\n ${signature(reference).join('\\n ')}\n\n Arguments:\n ${argStrings(reference).join('\\n ')}\n\n Examples:\n${reference.examples.map(example => smartTrim(example, 4)).join('\\n\\n')}`)\n}\n\nfunction signature({ title, variants, args, returns, _isOperator }: FunctionReference): string[] {\n const functionForms = variants.map((variant) => {\n const form = ` ${title}(${variant.argumentNames.map((argName) => {\n let result = ''\n const arg = args[argName]!\n if (arg.rest) {\n result += '...'\n }\n result += argName\n return result\n }).join(', ')})`\n\n return `${form} -> ${type(returns)}`\n })\n\n const operatorForm = _isOperator ? ['', 'Operator:', ` a ${title} b -> ${type(returns)}`] : []\n\n return [\n ...functionForms,\n ...operatorForm,\n ]\n}\n\nfunction type(arg: Argument | TypedValue) {\n const argType = arg.type\n const types = Array.isArray(argType) ? argType : [argType]\n const typeString = types.join(' | ')\n return arg.array || arg.rest ? `Array<${typeString}>` : typeString\n}\n\nfunction argStrings(reference: FunctionReference): string[] {\n return Object.entries(reference.args).map(([argName, arg]) => `${argName}: ${type(arg)}`)\n}\n","import type { BuiltinNormalExpression, BuiltinNormalExpressions } from '../interface'\nimport type { Any } from '../../interface'\nimport type { FunctionReference } from '../../../reference'\nimport type { CoreNormalExpressionName } from '../../../reference/api'\n\n// Core categories - always available\nimport { bitwiseNormalExpression } from '../core/bitwise'\nimport { collectionNormalExpression } from '../core/collection'\nimport { arrayNormalExpression } from '../core/array'\nimport { sequenceNormalExpression } from '../core/sequence'\nimport { mathNormalExpression } from '../core/math'\nimport { miscNormalExpression } from '../core/misc'\nimport { objectNormalExpression } from '../core/object'\nimport { predicatesNormalExpression } from '../core/predicates'\nimport { regexpNormalExpression } from '../core/regexp'\nimport { stringNormalExpression } from '../core/string'\nimport { functionalNormalExpression } from '../core/functional'\nimport { getMetaNormalExpression } from '../core/meta'\nimport { vectorNormalExpression } from '../core/vector'\n\nconst normalExpressionReference: Record<string, FunctionReference> = {}\n\nexport function setNormalExpressionReference(reference: Record<CoreNormalExpressionName, FunctionReference>) {\n Object.assign(normalExpressionReference, reference)\n}\n\nconst expressions: BuiltinNormalExpressions = {\n // Core categories\n ...bitwiseNormalExpression,\n ...collectionNormalExpression,\n ...arrayNormalExpression,\n ...sequenceNormalExpression,\n ...mathNormalExpression,\n ...getMetaNormalExpression(normalExpressionReference),\n ...miscNormalExpression,\n ...objectNormalExpression,\n ...predicatesNormalExpression,\n ...regexpNormalExpression,\n ...stringNormalExpression,\n ...functionalNormalExpression,\n ...vectorNormalExpression,\n}\n\nObject.entries(expressions).forEach(([name, expression]) => {\n expression.name = name\n})\n\nexport const normalExpressions: BuiltinNormalExpressions = {\n ...expressions,\n}\n\nexport const normalExpressionTypes: Record<string, number> = {}\nexport const allNormalExpressions: BuiltinNormalExpression<Any>[] = []\n\nObject.entries(normalExpressions).forEach(([key, value], index) => {\n normalExpressionTypes[key] = index\n allNormalExpressions.push(value)\n})\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/lits'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type AndNode = SpecialExpressionNode<[typeof specialExpressionTypes['&&'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'any',\n },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n c: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: `\nComputes logical \\`and\\`. Evaluation of expressions starts from left.\nAs soon as an \\`expression\\` evaluates to a falsy value, the result is returned.\n\nIf all expressions evaluate to truthy values, the value of the last expression is returned.`,\n examples: [\n 'true && 1',\n '&&(1, 1)',\n '&&(3 > 2, \"string\")',\n '&&(3 < 2, \"string\")',\n '&&(true, true, true, true)',\n '&&(true, true, 0, true)',\n ],\n}\n\nexport const andSpecialExpression: BuiltinSpecialExpression<Any, AndNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n let value: Any = true\n\n for (const param of node[1][1]) {\n value = evaluateNode(param, contextStack)\n if (!value)\n break\n }\n\n return value\n },\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n let value: Any = true\n for (const param of params) {\n value = asAny(param, sourceCodeInfo)\n if (!value)\n break\n }\n return value\n },\n\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type CondNode = SpecialExpressionNode<[typeof specialExpressionTypes['cond'], [AstNode, AstNode][]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['cond cond-branch cond-branch ... end'],\n details: [\n ['cond-branch', 'case test then body', 'A branch of the cond expression.'],\n ['test', 'expression', 'The condition to test.'],\n ['body', 'expressions', 'The expressions to evaluate if the test is truthy.'],\n ],\n description: 'Used for branching. `cond-branches` are tested sequentially from the top. If no branch is tested truthy, `null` is returned.',\n examples: [\n `\ncond\n case false then write!(\"FALSE\")\n case true then write!(\"TRUE\")\nend`,\n `\ncond\n case false then write!(\"FALSE\")\n case null then write!(\"null\")\nend ?? write!(\"TRUE\")`,\n `\ncond\n case false then write!(\"FALSE\")\n case null then write!(\"null\")\nend ?? write!(\"TRUE\")`,\n ],\n}\n\nexport const condSpecialExpression: BuiltinSpecialExpression<Any, CondNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const params = node[1][1]\n for (const [test, form] of params) {\n const value = evaluateNode(test, contextStack)\n if (!value)\n continue\n\n return evaluateNode(form, contextStack)\n }\n return null\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1].flat(), contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type SwitchNode = SpecialExpressionNode<[typeof specialExpressionTypes['switch'], AstNode, [AstNode, AstNode][]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['switch value switch-branch switch-branch ... end'],\n details: [\n ['value', 'any', 'The value to test.'],\n ['switch-branch', 'case test then body', 'A branch of the switch expression.'],\n ['test', 'expression', 'The condition to test.'],\n ['body', 'expressions', 'The expressions to evaluate if the test is truthy.'],\n ],\n description: 'Used for branching. `switch-branches` are tested sequentially from the top against `value`. If no branch is tested truthy, `null` is returned.',\n examples: [\n `\nswitch 1\n case 1 then write!(\"One\")\n case 2 then write!(\"Two\")\nend`,\n `\nswitch 2\n case 1 then write!(\"One\")\n case 2 then write!(\"Two\")\nend`,\n `\nswitch 3\n case 1 then write!(\"One\")\n case 2 then write!(\"Two\")\nend`,\n ],\n}\n\nexport const switchSpecialExpression: BuiltinSpecialExpression<Any, SwitchNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const [, switchValueNode, cases] = node[1]\n const switchValue = evaluateNode(switchValueNode, contextStack)\n for (const [test, form] of cases) {\n const value = evaluateNode(test, contextStack)\n if (value === switchValue) {\n return evaluateNode(form, contextStack)\n }\n }\n return null\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols([node[1][1], ...node[1][2].flat()], contextStack, builtin, evaluateNode),\n}\n","import { NodeTypes } from '../constants/constants'\nimport type {\n AstNode,\n ExpressionNode,\n NormalBuiltinSymbolNode,\n NormalExpressionNode,\n NormalExpressionNodeWithName,\n SpecialBuiltinSymbolNode,\n SpreadNode,\n SymbolNode,\n UserDefinedSymbolNode,\n} from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\n\nexport function isSymbolNode(node: AstNode): node is SymbolNode {\n const nodeType = node[0]\n return NodeTypes.UserDefinedSymbol === nodeType\n || NodeTypes.NormalBuiltinSymbol === nodeType\n || NodeTypes.SpecialBuiltinSymbol === nodeType\n}\nexport function asSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): SymbolNode {\n assertSymbolNode(node, sourceCodeInfo)\n return node\n}\nexport function assertSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): asserts node is SymbolNode {\n if (!isSymbolNode(node))\n throw getAssertionError('SymbolNode', node, sourceCodeInfo)\n}\n\nexport function isUserDefinedSymbolNode(node: AstNode): node is UserDefinedSymbolNode {\n return NodeTypes.UserDefinedSymbol === node[0]\n}\nexport function asUserDefinedSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): UserDefinedSymbolNode {\n assertUserDefinedSymbolNode(node, sourceCodeInfo)\n return node\n}\nfunction assertUserDefinedSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): asserts node is UserDefinedSymbolNode {\n if (!isUserDefinedSymbolNode(node))\n throw getAssertionError('UserDefinedSymbolNode', node, sourceCodeInfo)\n}\n\nexport function isNormalBuiltinSymbolNode(node: AstNode): node is NormalBuiltinSymbolNode {\n return NodeTypes.NormalBuiltinSymbol === node[0]\n}\n\nexport function isSpecialBuiltinSymbolNode(node: AstNode): node is SpecialBuiltinSymbolNode {\n return NodeTypes.SpecialBuiltinSymbol === node[0]\n}\n\nexport function isNormalExpressionNode(node: AstNode): node is NormalExpressionNode {\n return node[0] === NodeTypes.NormalExpression\n}\nexport function asNormalExpressionNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): NormalExpressionNode {\n assertNormalExpressionNode(node, sourceCodeInfo)\n return node\n}\nexport function assertNormalExpressionNode(\n node: AstNode,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts node is NormalExpressionNode {\n if (!isNormalExpressionNode(node))\n throw getAssertionError('NormalExpressionNode', node, sourceCodeInfo)\n}\n\nexport function isNormalExpressionNodeWithName(node: AstNode): node is NormalExpressionNodeWithName {\n if (!isNormalExpressionNode(node)) {\n return false\n }\n return isSymbolNode(node[1][0])\n}\nexport function asNormalExpressionNodeWithName(\n node: AstNode,\n sourceCodeInfo?: SourceCodeInfo,\n): NormalExpressionNodeWithName {\n assertNormalExpressionNodeWithName(node, sourceCodeInfo)\n return node\n}\nexport function assertNormalExpressionNodeWithName(\n node: AstNode,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts node is NormalExpressionNodeWithName {\n if (!isNormalExpressionNodeWithName(node))\n throw getAssertionError('NormalExpressionNodeWithName', node, sourceCodeInfo)\n}\n\nexport function isExpressionNode(node: AstNode): node is ExpressionNode {\n return isNormalExpressionNode(node)\n || node[0] === NodeTypes.SpecialExpression\n || node[0] === NodeTypes.Number\n || node[0] === NodeTypes.String\n}\nexport function asExpressionNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): ExpressionNode {\n assertExpressionNode(node, sourceCodeInfo)\n return node\n}\nexport function assertExpressionNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): asserts node is ExpressionNode {\n if (!isExpressionNode(node))\n throw getAssertionError('ExpressionNode', node, sourceCodeInfo)\n}\n\nexport function isSpreadNode(node: AstNode): node is SpreadNode {\n return node[0] === NodeTypes.Spread\n}\n","import type { SpecialExpressionNode, SymbolNode } from '../../parser/types'\nimport { assertSymbolNode, isUserDefinedSymbolNode } from '../../typeGuards/astNode'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type DefinedNode = SpecialExpressionNode<[typeof specialExpressionTypes['defined?'], SymbolNode]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'boolean',\n },\n args: {\n symbol: { type: 'any' },\n },\n variants: [\n { argumentNames: ['symbol'] },\n ],\n description: `Returns \\`true\\` if \\`symbol\\` is defined, \\`false\\` otherwise.\n\nBuilt-in symbols are always considered defined. For user-defined symbols, checks if the symbol exists in the current scope.`,\n examples: [\n 'let x = 42; defined?(x)',\n 'defined?(x)',\n 'defined?(+)',\n ],\n}\n\nexport const definedSpecialExpression: BuiltinSpecialExpression<boolean, DefinedNode> = {\n arity: toFixedArity(1),\n docs,\n evaluate: (node, contextStack) => {\n const symbolNode = node[1][1]\n assertSymbolNode(symbolNode)\n if (!isUserDefinedSymbolNode(symbolNode)) {\n return true // If the symbol is not a user defined symbol, it is defined. normal or special builtin\n }\n const lookUpResult = contextStack.lookUp(symbolNode)\n return lookUpResult !== null\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols([node[1][1]], contextStack, builtin, evaluateNode),\n}\n","import type { JsFunction } from '../Lits/Lits'\nimport type { SpecialExpressionType } from '../builtin'\nimport type { Arity } from '../builtin/interface'\nimport type { specialExpressionTypes } from '../builtin/specialExpressionTypes'\nimport type { FunctionType, NodeType, NodeTypes } from '../constants/constants'\nimport type { Context } from '../evaluator/interface'\nimport type { Any, Arr, Coll } from '../interface'\nimport type { ReservedSymbol } from '../tokenizer/reservedNames'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport type { FUNCTION_SYMBOL, REGEXP_SYMBOL } from '../utils/symbols'\n\nexport type EvaluatedFunction = [BindingTarget[], AstNode[], Context]\n\ninterface GenericLitsFunction {\n [FUNCTION_SYMBOL]: true\n sourceCodeInfo?: SourceCodeInfo\n functionType: FunctionType\n arity: Arity\n}\n\nexport interface RegularExpression {\n [REGEXP_SYMBOL]: true\n sourceCodeInfo?: SourceCodeInfo\n s: string\n f: string\n}\n\nexport interface NativeJsFunction extends GenericLitsFunction {\n functionType: 'NativeJsFunction'\n name: string | undefined // name\n nativeFn: JsFunction\n docString: string // documentation string\n}\n\nexport function isJsFunction(fn: unknown): fn is JsFunction {\n return typeof fn === 'object' && fn !== null && 'fn' in fn && typeof (fn as JsFunction).fn === 'function'\n}\n\nexport function assertJsFunction(fn: unknown): asserts fn is JsFunction {\n if (!isJsFunction(fn)) {\n throw new TypeError('Expected a NativeJsFunction')\n }\n}\n\nexport interface NativeJsModule {\n [key: string]: NativeJsFunction | NativeJsModule\n}\n\nexport interface UserDefinedFunction extends GenericLitsFunction {\n functionType: 'UserDefined'\n name: string | undefined // name\n evaluatedfunction: EvaluatedFunction\n docString: string // documentation string\n}\n\nexport interface PartialFunction extends GenericLitsFunction {\n functionType: 'Partial'\n function: FunctionLike\n params: Arr\n placeholders: number[] // indexes of the placeholders\n}\n\nexport interface CompFunction extends GenericLitsFunction {\n functionType: 'Comp'\n params: Arr\n}\n\nexport interface ConstantlyFunction extends GenericLitsFunction {\n functionType: 'Constantly'\n value: Any\n}\n\nexport interface JuxtFunction extends GenericLitsFunction {\n functionType: 'Juxt'\n params: Arr\n}\n\nexport interface ComplementFunction extends GenericLitsFunction {\n functionType: 'Complement'\n function: FunctionLike\n}\n\nexport interface EveryPredFunction extends GenericLitsFunction {\n functionType: 'EveryPred'\n params: Arr\n}\n\nexport interface SomePredFunction extends GenericLitsFunction {\n functionType: 'SomePred'\n params: Arr\n}\n\nexport interface FNullFunction extends GenericLitsFunction {\n functionType: 'Fnull'\n function: FunctionLike\n params: Arr\n}\n\nexport interface NormalBuiltinFunction extends GenericLitsFunction {\n functionType: 'Builtin'\n normalBuiltinSymbolType: number\n name: string\n}\n\nexport interface SpecialBuiltinFunction extends GenericLitsFunction {\n functionType: 'SpecialBuiltin'\n specialBuiltinSymbolType:\n | typeof specialExpressionTypes['&&']\n | typeof specialExpressionTypes['||']\n | typeof specialExpressionTypes['array']\n | typeof specialExpressionTypes['object']\n | typeof specialExpressionTypes['defined?']\n | typeof specialExpressionTypes['recur']\n | typeof specialExpressionTypes['throw']\n | typeof specialExpressionTypes['??']\n}\n\nexport interface ModuleFunction extends GenericLitsFunction {\n functionType: 'Module'\n moduleName: string\n functionName: string\n}\n\nexport type LitsFunction =\n | NativeJsFunction\n | UserDefinedFunction\n | NormalBuiltinFunction\n | SpecialBuiltinFunction\n | ModuleFunction\n | PartialFunction\n | CompFunction\n | ConstantlyFunction\n | JuxtFunction\n | ComplementFunction\n | EveryPredFunction\n | SomePredFunction\n | FNullFunction\n\nexport type LitsFunctionType = LitsFunction['functionType']\n\nexport type FunctionLike = LitsFunction | Coll | number\n\nexport type AstNode<T extends NodeType = NodeType, Payload = unknown> = [T, Payload] | [T, Payload, SourceCodeInfo]\n\nexport type ExpressionNode = NormalExpressionNode | SpecialExpressionNode | NumberNode | StringNode\n\nexport type SpreadNode = AstNode<typeof NodeTypes.Spread, AstNode> // Payload should be array or object depending on context\nexport type NumberNode = AstNode<typeof NodeTypes.Number, number>\nexport type StringNode = AstNode<typeof NodeTypes.String, string>\nexport type UserDefinedSymbolNode = AstNode<typeof NodeTypes.UserDefinedSymbol, string>\nexport type NormalBuiltinSymbolNode = AstNode<typeof NodeTypes.NormalBuiltinSymbol, number>\nexport type SpecialBuiltinSymbolNode = AstNode<typeof NodeTypes.SpecialBuiltinSymbol, SpecialExpressionType>\nexport type SymbolNode = UserDefinedSymbolNode | NormalBuiltinSymbolNode | SpecialBuiltinSymbolNode\nexport type ReservedSymbolNode = AstNode<typeof NodeTypes.ReservedSymbol, ReservedSymbol>\nexport type SpecialExpressionNode<T extends [SpecialExpressionType, ...unknown[]] = [SpecialExpressionType, ...unknown[]]> = AstNode<typeof NodeTypes.SpecialExpression, T> // [name, params]\n\nexport type NormalExpressionNodeWithName = AstNode<typeof NodeTypes.NormalExpression, [NormalBuiltinSymbolNode | UserDefinedSymbolNode, AstNode[]]> // [params, name]\nexport type NormalExpressionNodeExpression = AstNode<typeof NodeTypes.NormalExpression, [AstNode, AstNode[]]> // [name, node as function] node can be string number object or array\nexport type NormalExpressionNode = NormalExpressionNodeWithName | NormalExpressionNodeExpression\nexport const bindingTargetTypes = {\n symbol: 11,\n rest: 12,\n object: 13,\n array: 14,\n} as const\n\nexport type BindingTargetType = typeof bindingTargetTypes[keyof typeof bindingTargetTypes]\n\ntype GenericTarget<T extends BindingTargetType, Payload extends unknown[]> = [T, Payload] | [T, Payload, SourceCodeInfo]\n\nexport type SymbolBindingTarget = GenericTarget<typeof bindingTargetTypes.symbol, [SymbolNode, AstNode | undefined /* default value */]>\nexport type RestBindingTarget = GenericTarget<typeof bindingTargetTypes.rest, [string, AstNode | undefined /* default value */]>\nexport type ObjectBindingTarget = GenericTarget<typeof bindingTargetTypes.object, [Record<string, BindingTarget>, AstNode | undefined /* default value */]>\nexport type ArrayBindingTarget = GenericTarget<typeof bindingTargetTypes.array, [(BindingTarget | null)[], AstNode | undefined /* default value */]>\n\nexport type BindingTarget = SymbolBindingTarget | RestBindingTarget | ObjectBindingTarget | ArrayBindingTarget\n\nexport type BindingNode = AstNode<typeof NodeTypes.Binding, [BindingTarget, AstNode]> // [target, value]\n\ntype AstBody = AstNode[]\nexport interface Ast {\n body: AstBody // body\n hasDebugData: boolean\n}\n","import { LitsError } from '../errors'\nimport type { Any } from '../interface'\nimport { type AstNode, type BindingTarget, type RestBindingTarget, type UserDefinedSymbolNode, bindingTargetTypes } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { assertUnknownRecord } from '../typeGuards'\nimport { assertArray } from '../typeGuards/array'\nimport { asAny, assertAny } from '../typeGuards/lits'\n\nexport function walkDefaults(\n bindingTarget: BindingTarget,\n onDefault: (Node: AstNode) => void,\n): void {\n if (bindingTarget[0] === bindingTargetTypes.object) {\n Object.values(bindingTarget[1][0]).forEach((element) => {\n if (element[1][1]) {\n onDefault(element[1][1])\n }\n walkDefaults(element, onDefault)\n })\n }\n else if (bindingTarget[0] === bindingTargetTypes.array) {\n for (let index = 0; index < bindingTarget[1][0].length; index += 1) {\n const element = bindingTarget[1][0][index] ?? null\n if (element === null) {\n continue\n }\n if (element[1][1]) {\n onDefault(element[1][1])\n }\n walkDefaults(element, onDefault)\n }\n }\n}\n\nexport function evaluateBindingNodeValues(\n target: BindingTarget,\n value: Any,\n evaluate: (Node: AstNode) => Any,\n): Record<string, Any> {\n const sourceCodeInfo = target[2]\n const record: Record<string, Any> = {}\n createRecord(target, value, evaluate, sourceCodeInfo, record)\n return record\n}\n\nfunction createRecord(\n bindingTarget: BindingTarget,\n value: Any,\n evaluate: (Node: AstNode) => Any,\n sourceCodeInfo: SourceCodeInfo | undefined,\n record: Record<string, Any>,\n): void {\n if (bindingTarget[0] === bindingTargetTypes.object) {\n assertUnknownRecord(value, sourceCodeInfo)\n const capturedKeys = new Set<string>()\n let restElement: RestBindingTarget | undefined\n Object.entries(bindingTarget[1][0]).forEach(([key, element]) => {\n if (element[0] === bindingTargetTypes.rest) {\n restElement = element\n return\n }\n capturedKeys.add(key)\n const val = (value[key] !== undefined ? value[key] : element[1][1] && evaluate(element[1][1])) ?? null\n assertAny(val, sourceCodeInfo)\n createRecord(element, val, evaluate, sourceCodeInfo, record)\n })\n if (restElement) {\n const restValues = Object.entries(value)\n .filter(([key]) => !capturedKeys.has(key))\n .reduce((acc: Record<string, Any>, [key, val]) => {\n acc[key] = asAny(val)\n return acc\n }, {})\n\n record[restElement[1][0]] = restValues\n }\n }\n else if (bindingTarget[0] === bindingTargetTypes.array) {\n let restIndex: number | null = null\n assertArray(value, sourceCodeInfo)\n for (let index = 0; index < bindingTarget[1][0].length; index += 1) {\n const element = bindingTarget[1][0][index] ?? null\n if (element === null) {\n continue\n }\n if (element[0] === bindingTargetTypes.rest) {\n restIndex = index\n break\n }\n const val = (value[index] !== undefined ? value[index] : element[1][1] && evaluate(element[1][1])) ?? null\n assertAny(val, sourceCodeInfo)\n createRecord(element, val, evaluate, sourceCodeInfo, record)\n }\n if (restIndex !== null) {\n const restValues = value.slice(restIndex)\n const restElement = bindingTarget[1][0][restIndex]! as RestBindingTarget\n record[restElement[1][0]] = restValues\n }\n }\n else if (bindingTarget[0] === bindingTargetTypes.rest) {\n record[bindingTarget[1][0]] = asAny(value)\n }\n else {\n record[(bindingTarget[1][0] as UserDefinedSymbolNode)[1]] = asAny(value)\n }\n}\n\nexport function getAllBindingTargetNames(bindingTarget: BindingTarget): Record<string, true> {\n const names: Record<string, true> = {}\n getNamesFromBindingTarget(bindingTarget, names)\n return names\n}\n\nfunction getNamesFromBindingTarget(target: BindingTarget | null, names: Record<string, true>): void {\n if (target === null) {\n return\n }\n if (target[0] === bindingTargetTypes.array) {\n for (const element of target[1][0]) {\n getNamesFromBindingTarget(element, names)\n }\n }\n else if (target[0] === bindingTargetTypes.object) {\n for (const element of Object.values(target[1][0])) {\n getNamesFromBindingTarget(element, names)\n }\n }\n else if (target[0] === bindingTargetTypes.rest) {\n if (names[target[1][0]]) {\n throw new LitsError(`Duplicate binding name: ${target[1][0]}`, target[2])\n }\n names[target[1][0]] = true\n }\n else {\n if (names[target[1][0][1]]) {\n throw new LitsError(`Duplicate binding name: ${target[1][0]}`, target[2])\n }\n names[target[1][0][1]] = true\n }\n}\n","import type { Any } from '../../interface'\nimport type { BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport { addToSet } from '../../utils'\nimport { evaluateBindingNodeValues as evaluateBindingTargetValues, getAllBindingTargetNames, walkDefaults } from '../bindingNode'\nimport type { BuiltinSpecialExpression } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type DefNode = SpecialExpressionNode<[typeof specialExpressionTypes['0_def'], BindingNode]> // binding, value\n\nexport const defSpecialExpression: BuiltinSpecialExpression<Any, DefNode> = {\n arity: {},\n evaluate: (node, contextStack, { evaluateNode }) => {\n const bindingNode: BindingNode = node[1][1]\n const target = bindingNode[1][0]\n const value = bindingNode[1][1]\n const bindingValue = evaluateNode(value, contextStack)\n const values = evaluateBindingTargetValues(target, bindingValue, Node => evaluateNode(Node, contextStack))\n contextStack.exportValues(values, target[2])\n return bindingValue\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const bindingNode: BindingNode = node[1][1]\n const target = bindingNode[1][0]\n const value = bindingNode[1][1]\n const bindingResult = getUndefinedSymbols([value], contextStack, builtin, evaluateNode)\n walkDefaults(target, (defaultNode) => {\n addToSet(bindingResult, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode))\n })\n contextStack.addValues(getAllBindingTargetNames(target), target[2])\n return bindingResult\n },\n}\n","import type { Context } from '../../evaluator/interface'\nimport type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type DoNode = SpecialExpressionNode<[typeof specialExpressionTypes['block'], AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['do body end'],\n details: [\n ['body', 'expressions', 'The expressions to evaluate.'],\n ],\n description: 'Evaluates `body`. Resulting value is the value of the last expression.',\n examples: [\n `\ndo\n let a = 1 + 2 + 3 + 4;\n let b = -> $ * ( $ + 1 );\n b(a)\nend`,\n ],\n}\n\nexport const doSpecialExpression: BuiltinSpecialExpression<Any, DoNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const newContext: Context = {}\n\n const newContextStack = contextStack.create(newContext)\n let result: Any = null\n for (const form of node[1][1])\n result = evaluateNode(form, newContextStack)\n\n return result\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n return getUndefinedSymbols(node[1][1], contextStack.create({}), builtin, evaluateNode)\n },\n}\n","import type { ContextStack } from '../../evaluator/ContextStack'\nimport type { Context, EvaluateNode } from '../../evaluator/interface'\nimport type { GetUndefinedSymbols, UndefinedSymbols } from '../../getUndefinedSymbols'\nimport {\n type EvaluatedFunction,\n type LitsFunction,\n type SpecialExpressionNode,\n bindingTargetTypes,\n} from '../../parser/types'\nimport { isAny } from '../../typeGuards/lits'\nimport { addToSet } from '../../utils'\nimport { FUNCTION_SYMBOL } from '../../utils/symbols'\nimport { getAllBindingTargetNames, walkDefaults } from '../bindingNode'\nimport type { Builtin, BuiltinSpecialExpression } from '../interface'\nimport type { Function } from '../utils'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type LambdaNode = SpecialExpressionNode<[typeof specialExpressionTypes['0_lambda'], Function, string]>\n\nexport const lambdaSpecialExpression: BuiltinSpecialExpression<LitsFunction, LambdaNode> = {\n arity: {},\n evaluate: (node, contextStack, { builtin, getUndefinedSymbols, evaluateNode }) => {\n const fn = node[1][1]\n const docString = node[1][2]\n const evaluatedFunction = evaluateFunction(fn, contextStack, builtin, getUndefinedSymbols, evaluateNode)\n\n const min = evaluatedFunction[0].filter(arg => arg[0] !== bindingTargetTypes.rest && arg[1][1] === undefined).length\n const max = evaluatedFunction[0].some(arg => arg[0] === bindingTargetTypes.rest) ? undefined : evaluatedFunction[0].length\n const arity = { min: min > 0 ? min : undefined, max }\n\n const litsFunction: LitsFunction = {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo: node[2],\n functionType: 'UserDefined',\n name: undefined,\n evaluatedfunction: evaluatedFunction,\n arity,\n docString,\n }\n\n return litsFunction\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const fn = node[1][1]\n return getFunctionUnresolvedSymbols(fn, contextStack, getUndefinedSymbols, builtin, evaluateNode)\n },\n\n}\n\nfunction evaluateFunction(\n fn: Function,\n contextStack: ContextStack,\n builtin: Builtin,\n getUndefinedSymbols: GetUndefinedSymbols,\n evaluateNode: EvaluateNode,\n): EvaluatedFunction {\n const functionContext: Context = {}\n\n const context = fn[0].reduce((ctx: Context, arg) => {\n Object.keys(getAllBindingTargetNames(arg)).forEach((name) => {\n ctx[name] = { value: null }\n })\n return ctx\n }, {})\n const undefinedSymbols = getUndefinedSymbols(fn[1], contextStack.new(context), builtin, evaluateNode)\n undefinedSymbols.forEach((name) => {\n const value = contextStack.getValue(name)\n if (isAny(value)) {\n functionContext[name] = { value }\n }\n })\n\n const evaluatedFunction: EvaluatedFunction = [\n fn[0],\n fn[1],\n functionContext,\n ]\n\n return evaluatedFunction\n}\n\nfunction getFunctionUnresolvedSymbols(\n fn: Function,\n contextStack: ContextStack,\n getUndefinedSymbols: GetUndefinedSymbols,\n builtin: Builtin,\n evaluateNode: EvaluateNode,\n): UndefinedSymbols {\n const result = new Set<string>()\n const newContext: Context = { self: { value: null } }\n\n fn[0].forEach((arg) => {\n Object.assign(newContext, getAllBindingTargetNames(arg))\n\n walkDefaults(arg, (defaultNode) => {\n addToSet(result, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode))\n })\n })\n\n const newContextStack = contextStack.create(newContext)\n const overloadResult = getUndefinedSymbols(fn[1], newContextStack, builtin, evaluateNode)\n addToSet(result, overloadResult)\n return result\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type IfNode = SpecialExpressionNode<[typeof specialExpressionTypes['if'], [AstNode, AstNode, AstNode?]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['if test then true-expr else false-expr', 'if test then true-expr'],\n details: [\n ['test', 'expression', 'The condition to test.'],\n ['true-expr', 'expression', 'The expression to evaluate if the test is truthy.'],\n ['false-expr', 'expression', 'The expression to evaluate if the test is falsy.'],\n ],\n description: 'Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is truthy. If $test is falsy `false-expr` is executed, if no `false-expr` exists, `null` is returned.',\n examples: [\n `\nif true then\n write!(\"TRUE\")\nelse\n write!(\"FALSE\")\nend`,\n 'if false then write!(\"TRUE\") else write!(\"FALSE\") end',\n 'if true then write!(\"TRUE\") end',\n 'if false then write!(\"TRUE\") end',\n ],\n}\n\nexport const ifSpecialExpression: BuiltinSpecialExpression<Any, IfNode> = {\n arity: { min: 2, max: 3 },\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const [conditionNode, trueNode, falseNode] = node[1][1]\n if (evaluateNode(conditionNode, contextStack)) {\n return evaluateNode(trueNode, contextStack)\n }\n else if (falseNode) {\n return evaluateNode(falseNode, contextStack)\n }\n return null\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) =>\n getUndefinedSymbols(node[1][1].filter(n => !!n), contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type UnlessNode = SpecialExpressionNode<[typeof specialExpressionTypes['unless'], [AstNode, AstNode, AstNode?]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['unless test then true-expr else false-expr end', 'unless test true-expr end'],\n details: [\n ['test', 'expression', 'The condition to test.'],\n ['true-expr', 'expression', 'The expressions to evaluate if the test is falsy.'],\n ['false-expr', 'expression', 'The expressions to evaluate if the test is truthy.'],\n ],\n description: 'Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is falsy. If $test is truthy `false-expr` is executed, if no `false-expr` exists, `null` is returned.',\n examples: [\n `\nunless true then\n write!(\"TRUE\")\nelse\n write!(\"FALSE\")\nend`,\n 'unless false then write!(\"TRUE\") else write!(\"FALSE\") end',\n 'unless true then write!(\"TRUE\") end',\n 'unless false then write!(\"TRUE\") end',\n ],\n}\n\nexport const unlessSpecialExpression: BuiltinSpecialExpression<Any, UnlessNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const [conditionNode, trueNode, falseNode] = node[1][1]\n if (!evaluateNode(conditionNode, contextStack)) {\n return evaluateNode(trueNode, contextStack)\n }\n else if (falseNode) {\n return evaluateNode(falseNode, contextStack)\n }\n return null\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) =>\n getUndefinedSymbols(node[1][1].filter(n => !!n), contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport { addToSet } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport { evaluateBindingNodeValues, getAllBindingTargetNames, walkDefaults } from '../bindingNode'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type LetNode = SpecialExpressionNode<[typeof specialExpressionTypes['let'], BindingNode]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['let s = value;'],\n details: [\n ['s', 'symbol', 'The name of the variable to bind.'],\n ['value', 'any', 'The value to bind to the variable.'],\n ],\n description: `\n Binds local variables s to \\`value\\`. \\`value\\` can be any expression. The scope of the variables is the body of the let expression.`,\n examples: [`\nlet a = 1 + 2 + 3 + 4;\nlet b = -> $ * ( $ + 1 );\nwrite!(\"a\", a, \"b\", b)`],\n}\n\nexport const letSpecialExpression: BuiltinSpecialExpression<Any, LetNode> = {\n arity: toFixedArity(0),\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const bindingNode = node[1][1]\n const target = bindingNode[1][0]\n const value = bindingNode[1][1]\n const bindingValue = evaluateNode(value, contextStack)\n const values = evaluateBindingNodeValues(target, bindingValue, Node => evaluateNode(Node, contextStack))\n contextStack.addValues(values, target[2])\n return bindingValue\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const bindingNode = node[1][1]\n const target = bindingNode[1][0]\n const value = bindingNode[1][1]\n const bindingResult = getUndefinedSymbols([value], contextStack, builtin, evaluateNode)\n walkDefaults(target, (defaultNode) => {\n addToSet(bindingResult, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode))\n })\n contextStack.addValues(getAllBindingTargetNames(target), target[2])\n return bindingResult\n },\n}\n","import { LitsError, RecurSignal } from '../../errors'\nimport type { Context } from '../../evaluator/interface'\nimport type { Any } from '../../interface'\nimport type { AstNode, BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/lits'\nimport { joinSets } from '../../utils'\nimport { valueToString } from '../../utils/debug/debugTools'\nimport { evaluateBindingNodeValues, getAllBindingTargetNames } from '../bindingNode'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type LoopNode = SpecialExpressionNode<[typeof specialExpressionTypes['loop'], BindingNode[], AstNode]> // bindings, body\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['loop (bindings) -> body'],\n details: [\n ['bindings', 'binding pairs', 'Comma-separated bindings with initial values, e.g. `n = 10, acc = 0`.'],\n ['body', 'expression', 'The expression to evaluate repeatedly. Use `recur` to loop back with new values.'],\n ],\n description: `Creates a loop with initial bindings. Use \\`recur\\` inside the body to jump back to the loop head with new binding values.\n\nIf \\`recur\\` is not called, the loop terminates and returns the value of the body expression.`,\n examples: [\n `loop (n = 10, acc = 0) -> do\n if n == 0 then\n acc\n else\n recur(n - 1, acc + n)\n end\nend`,\n `loop (n = 5, acc = 1) -> do\n if n <= 1 then\n acc\n else\n recur(n - 1, acc * n)\n end\nend`,\n ],\n}\n\nexport const loopSpecialExpression: BuiltinSpecialExpression<Any, LoopNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const bindingNodes = node[1][1]\n const bindingContext: Context = bindingNodes.reduce((result: Context, bindingNode) => {\n const val = evaluateNode(bindingNode[1][1], contextStack.create(result))\n const valueRecord = evaluateBindingNodeValues(bindingNode[1][0], val, Node => evaluateNode(Node, contextStack))\n Object.entries(valueRecord).forEach(([name, value]) => {\n result[name] = { value }\n })\n return result\n }, {})\n const newContextStack = contextStack.create(bindingContext)\n\n const body = node[1][2]\n for (;;) {\n let result: Any = null\n try {\n result = evaluateNode(body, newContextStack)\n }\n catch (error) {\n if (error instanceof RecurSignal) {\n const params = error.params\n if (params.length !== bindingNodes.length) {\n throw new LitsError(\n `recur expected ${bindingNodes.length} parameters, got ${valueToString(params.length)}`,\n node[2],\n )\n }\n bindingNodes.forEach((bindingNode, index) => {\n const valueRecord = evaluateBindingNodeValues(bindingNode[1][0], asAny(params[index]), Node => evaluateNode(Node, contextStack))\n for (const [name, value] of Object.entries(valueRecord)) {\n bindingContext[name]!.value = value\n }\n })\n continue\n }\n throw error\n }\n return result\n }\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const bindingNodes = node[1][1]\n\n const newContext = bindingNodes\n .reduce((context: Context, bindingNode) => {\n const names = getAllBindingTargetNames(bindingNode[1][0])\n\n Object.keys(names).forEach((name) => {\n context[name] = { value: true }\n })\n return context\n }, {})\n\n const bindingValueNodes = bindingNodes.map(bindingNode => bindingNode[1][1])\n const bindingsResult = getUndefinedSymbols(bindingValueNodes, contextStack, builtin, evaluateNode)\n const paramsResult = getUndefinedSymbols([node[1][2]], contextStack.create(newContext), builtin, evaluateNode)\n return joinSets(bindingsResult, paramsResult)\n },\n}\n","import type { GetUndefinedSymbols, UndefinedSymbols } from '../../getUndefinedSymbols'\nimport type { ContextStack } from '../../evaluator/ContextStack'\nimport type { Context, EvaluateNode } from '../../evaluator/interface'\nimport type { Any, Arr } from '../../interface'\nimport type { AstNode, BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport { asNonUndefined } from '../../typeGuards'\nimport { asAny, asColl, isSeq } from '../../typeGuards/lits'\nimport type { Builtin, BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport { evaluateBindingNodeValues, getAllBindingTargetNames } from '../bindingNode'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\nimport { toFixedArity } from '../../utils/arity'\n\nexport type LoopBindingNode = [BindingNode, BindingNode[], AstNode?, AstNode?] // Binding, Let-Bindings, When, While\n\nexport type ForNode = SpecialExpressionNode<[typeof specialExpressionTypes['for'], LoopBindingNode[], AstNode]> // LoopBindings, body\nexport type DoSeqNode = SpecialExpressionNode<[typeof specialExpressionTypes['doseq'], LoopBindingNode[], AstNode]> // LoopBindings, body\n\ntype LoopNode = ForNode | DoSeqNode\n\nfunction addToContext(\n bindings: BindingNode[],\n context: Context,\n contextStack: ContextStack,\n evaluateNode: EvaluateNode,\n) {\n for (const bindingNode of bindings) {\n const [target, bindingValue] = bindingNode[1]\n const val = evaluateNode(bindingValue, contextStack)\n const valueRecord = evaluateBindingNodeValues(target, val, Node => evaluateNode(Node, contextStack))\n Object.entries(valueRecord).forEach(([name, value]) => {\n context[name] = { value }\n })\n }\n}\n\nfunction evaluateLoop(\n returnResult: boolean,\n loopNode: LoopNode,\n contextStack: ContextStack,\n evaluateNode: EvaluateNode,\n) {\n const sourceCodeInfo = loopNode[2]\n const [, loopBindings, body] = loopNode[1]\n\n const result: Arr = []\n\n const bindingIndices = loopBindings.map(() => 0)\n let abort = false\n while (!abort) {\n const context: Context = {}\n const newContextStack = contextStack.create(context)\n let skip = false\n bindingsLoop: for (let bindingIndex = 0; bindingIndex < loopBindings.length; bindingIndex += 1) {\n const [bindingNode, letBindings, whenNode, whileNode] = loopBindings[bindingIndex]!\n const [targetNode, valueNode] = bindingNode[1]\n const coll = asColl(evaluateNode(valueNode, newContextStack), sourceCodeInfo)\n const seq = isSeq(coll) ? coll : Object.entries(coll)\n if (seq.length === 0) {\n skip = true\n abort = true\n break\n }\n const index = asNonUndefined(bindingIndices[bindingIndex], sourceCodeInfo)\n if (index >= seq.length) {\n skip = true\n if (bindingIndex === 0) {\n abort = true\n break\n }\n bindingIndices[bindingIndex] = 0\n bindingIndices[bindingIndex - 1] = asNonUndefined(bindingIndices[bindingIndex - 1], sourceCodeInfo) + 1\n break\n }\n\n const val = asAny(seq[index], sourceCodeInfo)\n const valueRecord = evaluateBindingNodeValues(targetNode, val, Node => evaluateNode(Node, newContextStack))\n Object.entries(valueRecord).forEach(([name, value]) => {\n context[name] = { value }\n })\n if (letBindings) {\n addToContext(\n letBindings,\n context,\n newContextStack,\n evaluateNode,\n )\n }\n if (whenNode && !evaluateNode(whenNode, newContextStack)) {\n bindingIndices[bindingIndex] = asNonUndefined(bindingIndices[bindingIndex], sourceCodeInfo) + 1\n skip = true\n break bindingsLoop\n }\n if (whileNode && !evaluateNode(whileNode, newContextStack)) {\n bindingIndices[bindingIndex] = Number.POSITIVE_INFINITY\n skip = true\n break bindingsLoop\n }\n }\n if (!skip) {\n const value: Any = evaluateNode(body, newContextStack)\n if (returnResult)\n result.push(value)\n\n if (bindingIndices.length > 0)\n bindingIndices[bindingIndices.length - 1]! += 1\n }\n }\n\n return returnResult ? result : null\n}\n\nfunction analyze(\n loopNode: LoopNode,\n contextStack: ContextStack,\n getUndefinedSymbols: GetUndefinedSymbols,\n builtin: Builtin,\n evaluateNode: EvaluateNode,\n): UndefinedSymbols {\n const result = new Set<string>()\n const newContext: Context = {}\n const [, loopBindings, body] = loopNode[1]\n loopBindings.forEach((loopBindingNode) => {\n const [bindingNode, letBindings, whenNode, whileNode] = loopBindingNode\n const [target, value] = bindingNode[1]\n getUndefinedSymbols([value], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n Object.assign(newContext, getAllBindingTargetNames(target))\n if (letBindings) {\n letBindings.forEach((letBindingNode) => {\n const [letTarget, letValue] = letBindingNode[1]\n\n getUndefinedSymbols([letValue], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n Object.assign(newContext, getAllBindingTargetNames(letTarget))\n })\n }\n if (whenNode) {\n getUndefinedSymbols([whenNode], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n }\n if (whileNode) {\n getUndefinedSymbols([whileNode], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n }\n })\n getUndefinedSymbols([body], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n return result\n}\n\nconst forDocs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['for (...binding) -> body'],\n details: [\n ['binding', 'loop-var in collection [...let-binding] [where whereExpr] [while whileExp]', 'A for loop binding'],\n ['loop-var', 'symbol', 'The name of the loop variable.'],\n ['collection', 'any', 'The collection to iterate over.'],\n ['let-binding', 'let binding', 'A let binding to create a local variable.'],\n ['whereExpr', 'expression', 'An expression that must evaluate to truthy for the loop body to be executed.'],\n ['whileExp', 'expression', 'An expression that must evaluate to truthy for the loop to continue.'],\n ['body', 'expressions', 'The expressions to evaluate for each iteration of the loop.'],\n ],\n returns: {\n type: 'any',\n array: true,\n },\n description: 'Iterates over `bindings`, evaluates `body` for each `binding` and returns an `array` of results.',\n examples: [\n `\nfor (i in [1, 2, 3]) -> i * 2\n `,\n `\nfor (\n i in range(10) let ii = i ^ 2 while ii < 40 when ii % 3 == 0,\n j in range(10) when j % 2 == 1\n) -> ii + j\n `,\n ],\n}\n\nexport const forSpecialExpression: BuiltinSpecialExpression<Any, ForNode> = {\n arity: toFixedArity(1),\n docs: forDocs,\n evaluate: (node, contextStack, helpers) => evaluateLoop(true, node, contextStack, helpers.evaluateNode),\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => analyze(node, contextStack, getUndefinedSymbols, builtin, evaluateNode),\n}\n\nconst doseqDocs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['doseq (...binding) -> body'],\n details: [\n ['binding', 'loop-var in collection [...let-binding] [where whereExpr] [while whileExp]', 'A doseq loop binding'],\n ['loop-var', 'symbol', 'The name of the loop variable.'],\n ['collection', 'any', 'The collection to iterate over.'],\n ['let-binding', 'let binding', 'A let binding to create a local variable.'],\n ['whereExpr', 'expression', 'An expression that must evaluate to truthy for the loop body to be executed.'],\n ['whileExp', 'expression', 'An expression that must evaluate to truthy for the loop to continue.'],\n ['body', 'expressions', 'The expressions to evaluate for each iteration of the loop.'],\n ],\n returns: {\n type: 'null',\n },\n description: 'Iterates over `bindings`, evaluates `body` for each `binding` and returns `null`. This is useful for side effects.',\n examples: [\n `\ndoseq (i in [1, 2, 3]) -> write!(i * 2)\n `,\n ],\n}\n\nexport const doseqSpecialExpression: BuiltinSpecialExpression<null, DoSeqNode> = {\n arity: toFixedArity(1),\n docs: doseqDocs,\n evaluate: (node, contextStack, helpers) => {\n evaluateLoop(false, node, contextStack, helpers.evaluateNode)\n return null\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => analyze(node, contextStack, getUndefinedSymbols, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/lits'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type OrNode = SpecialExpressionNode<[typeof specialExpressionTypes['||'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'boolean',\n },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n c: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: `\n Computes logical \\`or\\`. Evaluation of expressions evaluation starts from left.\n As soon as a \\`expression\\` evaluates to a truthy value, the result is returned.\n\n If all expressions evaluate to falsy values, the value of the last expression is returned.`,\n examples: [\n 'false || 1',\n '||(1, 1)',\n '||(3 > 2, \"string\")',\n '||(3 < 2, \"string\")',\n '||(false, false, false, true)',\n '||(1, 2, 3, 4)',\n ],\n}\n\nexport const orSpecialExpression: BuiltinSpecialExpression<Any, OrNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n let value: Any = false\n\n for (const param of node[1][1]) {\n value = evaluateNode(param, contextStack)\n if (value)\n break\n }\n\n return value\n },\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n let value: Any = false\n for (const param of params) {\n value = asAny(param, sourceCodeInfo)\n if (value)\n break\n }\n return value\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { isUserDefinedSymbolNode } from '../../typeGuards/astNode'\nimport { asAny } from '../../typeGuards/lits'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type QqNode = SpecialExpressionNode<[typeof specialExpressionTypes['??'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'any',\n },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n c: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['a'] },\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: `Nullish coalescing operator. Returns the first non-\\`null\\` value.\n\nEvaluation is short-circuited — as soon as a non-\\`null\\` value is found, the remaining expressions are not evaluated.\n\nIf all values are \\`null\\`, returns \\`null\\`.\n\nAlso works with undefined symbols — if a symbol is undefined, it is treated as \\`null\\`.`,\n examples: [\n '1 ?? 2',\n 'null ?? 2',\n '??(null)',\n '??(null, \"default\")',\n '??(1, \"default\")',\n 'false ?? \"default\"',\n '??(null, null, 3)',\n ],\n}\n\nexport const qqSpecialExpression: BuiltinSpecialExpression<Any, QqNode> = {\n arity: { min: 1 },\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n for (const param of node[1][1]) {\n if (isUserDefinedSymbolNode(param) && contextStack.lookUp(param) === null) {\n continue\n }\n const result = evaluateNode(param, contextStack)\n if (result !== null) {\n return result\n }\n }\n return null\n },\n\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n for (const param of params) {\n const value = asAny(param, sourceCodeInfo)\n if (value !== null) {\n return value\n }\n }\n return null\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import { RecurSignal } from '../../errors'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type RecurNode = SpecialExpressionNode<[typeof specialExpressionTypes['recur'], AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['recur(...recur-args)'],\n description: 'Recursevly calls enclosing function or loop with its evaluated `recur-args`.',\n examples: [\n `\nlet foo = (n) -> do\n write!(n);\n if !(zero?(n)) then\n recur(n - 1)\n end\nend;\nfoo(3)`,\n `\n(n -> do\n write!(n);\n if !(zero?(n)) then\n recur(n - 1)\n end\nend)(3)`,\n `\nloop (n = 3) -> do\n write!(n);\n if !(zero?(n)) then\n recur(n - 1)\n end\nend`,\n ],\n}\n\nexport const recurSpecialExpression: BuiltinSpecialExpression<null, RecurNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const params = node[1][1]\n const evaluatedParams = params.map(paramNode => evaluateNode(paramNode, contextStack))\n throw new RecurSignal(evaluatedParams)\n },\n evaluateAsNormalExpression: (params) => {\n throw new RecurSignal(params)\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) =>\n getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import { UserDefinedError } from '../../errors'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asString } from '../../typeGuards/string'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ThrowNode = SpecialExpressionNode<[typeof specialExpressionTypes['throw'], AstNode]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'never',\n },\n args: {\n expr: {\n type: 'any',\n },\n },\n variants: [\n { argumentNames: ['expr'] },\n ],\n description: 'Throws `UserDefinedError` with message set to $expr evaluated. $expr must evaluate to a string.',\n examples: [\n 'try throw(\"You shall not pass!\") catch(error) \"Error: \" ++ error.message end',\n 'try throw(slice(\"You shall not pass!\", 0, 3)) catch(error) \"Error: \" ++ error.message end',\n ],\n}\n\nexport const throwSpecialExpression: BuiltinSpecialExpression<null, ThrowNode> = {\n arity: toFixedArity(1),\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const message = asString(evaluateNode(node[1][1], contextStack), node[2], {\n nonEmpty: true,\n })\n throw new UserDefinedError(message, node[2])\n },\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n const message = asString(params[0], sourceCodeInfo, {\n nonEmpty: true,\n })\n throw new UserDefinedError(message, undefined)\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols([node[1][1]], contextStack, builtin, evaluateNode),\n}\n","import type { Context } from '../../evaluator/interface'\nimport type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode, SymbolNode } from '../../parser/types'\nimport { joinSets } from '../../utils'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type TryNode = SpecialExpressionNode<[typeof specialExpressionTypes['try'], AstNode, SymbolNode | undefined, AstNode]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['try { try-body } catch { catch-body }', 'try { try-body } catch(error) { catch-body }'],\n details: [\n ['try-body', 'expressions', 'The expressions to try.'],\n ['error', 'symbol', 'The error variable to bind.'],\n ['catch-body', 'expression', 'The expressions to evaluate if the try-body throws an error.'],\n ],\n description: 'Executes `try-body`. If that throws, the `catch-body` gets executed. See examples for details.',\n examples: [\n `\ntry\n 2 / 4\ncatch\n \"Oops!\"\nend`,\n `\ntry\n foo()\ncatch(error)\n \"Error: \" ++ error.message\nend`,\n `\ntry\n foo()\ncatch\n 42\nend`,\n ],\n}\n\nexport const trySpecialExpression: BuiltinSpecialExpression<Any, TryNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const [, tryExpression, errorSymbol, catchExpression] = node[1]\n try {\n return evaluateNode(tryExpression, contextStack)\n }\n catch (error) {\n const newContext: Context = errorSymbol\n ? {\n [errorSymbol[1]]: { value: error as Any },\n }\n : {}\n return evaluateNode(catchExpression, contextStack.create(newContext))\n }\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const [, tryExpression, errorSymbol, catchExpression] = node[1]\n const tryResult = getUndefinedSymbols([tryExpression], contextStack, builtin, evaluateNode)\n const newContext: Context = errorSymbol\n ? {\n [errorSymbol[1]]: { value: true },\n }\n : {}\n const catchResult = getUndefinedSymbols([catchExpression], contextStack.create(newContext), builtin, evaluateNode)\n return joinSets(tryResult, catchResult)\n },\n}\n","import { LitsError } from '../../errors'\nimport type { Any, Arr } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { isSpreadNode } from '../../typeGuards/astNode'\nimport { asAny } from '../../typeGuards/lits'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ArrayNode = SpecialExpressionNode<[typeof specialExpressionTypes['array'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'any',\n array: true,\n },\n args: {\n values: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['values'] },\n ],\n description: 'Makes new array from $values.',\n examples: [\n 'array(1, 2, 3)',\n 'array(array(null, false, true))',\n '[]',\n '[1, 2, 3]',\n '[1, 2, ...[3, 4, 5], 6]',\n '[[null, false, true]]',\n '[1, 2, 3][1]',\n ],\n hideOperatorForm: true,\n}\n\nexport const arraySpecialExpression: BuiltinSpecialExpression<Any, ArrayNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const result: Arr = []\n\n for (const param of node[1][1]) {\n if (isSpreadNode(param)) {\n const spreadValue = evaluateNode(param[1], contextStack)\n if (!Array.isArray(spreadValue)) {\n throw new LitsError('Spread value is not an array', param[2])\n }\n result.push(...spreadValue)\n }\n else {\n result.push(evaluateNode(param, contextStack))\n }\n }\n\n return result\n },\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n const result: Arr = []\n\n for (const param of params) {\n result.push(asAny(param, sourceCodeInfo))\n }\n\n return result\n },\n\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import { LitsError } from '../../errors'\nimport type { Any, Obj } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { isUnknownRecord } from '../../typeGuards'\nimport { isSpreadNode } from '../../typeGuards/astNode'\nimport { assertString } from '../../typeGuards/string'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ObjectNode = SpecialExpressionNode<[typeof specialExpressionTypes['object'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'object',\n },\n args: {\n kvps: {\n type: 'any',\n rest: true,\n description: 'key - value pairs, where key is a string',\n },\n },\n variants: [\n { argumentNames: ['kvps'] },\n ],\n description: 'Constructs a new object. Object members are created from the $kvps key-value pairs. Requires an even number of arguments.',\n examples: [\n 'object()',\n `\nlet default = {\n type: \"Person\",\n name: \"John Doe\",\n age: 42\n};\n\n{\n ...default,\n name: \"Lisa\"\n}`,\n 'object(\"x\", 10, \"y\", true, \"z\", \"A string\")',\n '{}',\n '{ a: 1, b: 2 }',\n ],\n hideOperatorForm: true,\n}\n\nexport const objectSpecialExpression: BuiltinSpecialExpression<Any, ObjectNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const result: Obj = {}\n\n const params = node[1][1]\n for (let i = 0; i < params.length; i += 2) {\n const keyNode = params[i]!\n if (isSpreadNode(keyNode)) {\n const spreadObject = evaluateNode(keyNode[1], contextStack)\n if (!isUnknownRecord(spreadObject)) {\n throw new LitsError('Spread value is not an object', keyNode[2])\n }\n Object.assign(result, spreadObject)\n i -= 1\n }\n else {\n const key = evaluateNode(keyNode, contextStack)\n const valueNode = params[i + 1]\n if (valueNode === undefined) {\n throw new LitsError('Missing value for key', keyNode[2])\n }\n const value = evaluateNode(valueNode, contextStack)\n assertString(key, keyNode[2])\n result[key] = value\n }\n }\n return result\n },\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n const result: Obj = {}\n\n for (let i = 0; i < params.length; i += 2) {\n const key = params[i]\n const value = params[i + 1]\n assertString(key, sourceCodeInfo)\n result[key] = value ?? null\n }\n\n return result\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","export const specialExpressionTypes = {\n '??': 0,\n '&&': 1,\n '||': 2,\n 'array': 3,\n 'cond': 4,\n '0_def': 5,\n 'defined?': 6,\n // '0_defn': 7,\n 'block': 7,\n 'doseq': 8,\n '0_lambda': 9,\n 'for': 10,\n // 'function': 10,\n 'if': 11,\n 'let': 12,\n 'loop': 13,\n 'object': 14,\n 'recur': 15,\n 'switch': 16,\n 'throw': 17,\n 'try': 18,\n 'unless': 19,\n} as const\n","import type { Builtin } from './interface'\nimport { allNormalExpressions, normalExpressions } from './normalExpressions'\nimport { andSpecialExpression } from './specialExpressions/and'\nimport { condSpecialExpression } from './specialExpressions/cond'\nimport { switchSpecialExpression } from './specialExpressions/switch'\nimport { definedSpecialExpression } from './specialExpressions/defined'\nimport { defSpecialExpression } from './specialExpressions/def'\nimport { doSpecialExpression } from './specialExpressions/block'\nimport { lambdaSpecialExpression } from './specialExpressions/functions'\nimport { ifSpecialExpression } from './specialExpressions/if'\nimport { unlessSpecialExpression } from './specialExpressions/unless'\nimport { letSpecialExpression } from './specialExpressions/let'\nimport { loopSpecialExpression } from './specialExpressions/loop'\nimport { doseqSpecialExpression, forSpecialExpression } from './specialExpressions/loops'\nimport { orSpecialExpression } from './specialExpressions/or'\nimport { qqSpecialExpression } from './specialExpressions/qq'\nimport { recurSpecialExpression } from './specialExpressions/recur'\nimport { throwSpecialExpression } from './specialExpressions/throw'\nimport { trySpecialExpression } from './specialExpressions/try'\nimport { arraySpecialExpression } from './specialExpressions/array'\nimport { objectSpecialExpression } from './specialExpressions/object'\nimport { specialExpressionTypes } from './specialExpressionTypes'\n\nexport const specialExpressions = [\n qqSpecialExpression,\n andSpecialExpression,\n orSpecialExpression,\n arraySpecialExpression,\n condSpecialExpression,\n defSpecialExpression,\n definedSpecialExpression,\n doSpecialExpression,\n doseqSpecialExpression,\n lambdaSpecialExpression,\n forSpecialExpression,\n ifSpecialExpression,\n letSpecialExpression,\n loopSpecialExpression,\n objectSpecialExpression,\n recurSpecialExpression,\n switchSpecialExpression,\n throwSpecialExpression,\n trySpecialExpression,\n unlessSpecialExpression,\n] as const\n\nexport type SpecialExpressions = typeof specialExpressions\nexport type SpecialExpression = SpecialExpressions[number]\nexport type SpecialExpressionName = keyof typeof specialExpressionTypes\nexport type CommonSpecialExpressionType = [\n | typeof specialExpressionTypes['??']\n | typeof specialExpressionTypes['&&']\n | typeof specialExpressionTypes['cond']\n | typeof specialExpressionTypes['switch']\n | typeof specialExpressionTypes['defined?']\n | typeof specialExpressionTypes['block']\n | typeof specialExpressionTypes['if']\n | typeof specialExpressionTypes['unless']\n | typeof specialExpressionTypes['||']\n | typeof specialExpressionTypes['throw']\n | typeof specialExpressionTypes['array']\n | typeof specialExpressionTypes['object'],\n]\n\nexport type SpecialExpressionType = typeof specialExpressionTypes[SpecialExpressionName]\n\nexport const builtin: Builtin = {\n normalExpressions,\n specialExpressions,\n allNormalExpressions,\n}\n\nexport const normalExpressionKeys = Object.keys(normalExpressions)\nexport const specialExpressionKeys = Object.keys(specialExpressionTypes)\n","import type { Builtin } from '../builtin/interface'\nimport type { DoNode } from '../builtin/specialExpressions/block'\nimport { specialExpressionTypes } from '../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../constants/constants'\nimport { LitsError } from '../errors'\nimport type { ContextStack } from '../evaluator/ContextStack'\nimport type { EvaluateNode } from '../evaluator/interface'\nimport type { Ast, AstNode, NormalExpressionNode, SpecialExpressionNode, SpreadNode, UserDefinedSymbolNode } from '../parser/types'\nimport { isNormalExpressionNodeWithName, isUserDefinedSymbolNode } from '../typeGuards/astNode'\n\nexport type UndefinedSymbols = Set<string>\n\nexport const getUndefinedSymbols: GetUndefinedSymbols = (ast, contextStack, builtin, evaluateNode) => {\n const nodes: AstNode[] = Array.isArray(ast)\n ? ast\n : [[NodeTypes.SpecialExpression, [specialExpressionTypes.block, ast.body]] satisfies DoNode]\n\n const unresolvedSymbols = new Set<string>()\n\n for (const subNode of nodes) {\n findUnresolvedSymbolsInNode(subNode, contextStack, builtin, evaluateNode)\n ?.forEach(symbol => unresolvedSymbols.add(symbol))\n }\n return unresolvedSymbols\n}\n\nexport type GetUndefinedSymbols = (ast: Ast | AstNode[], contextStack: ContextStack, builtin: Builtin, evaluateNode: EvaluateNode) => UndefinedSymbols\n\nfunction findUnresolvedSymbolsInNode(node: AstNode, contextStack: ContextStack, builtin: Builtin, evaluateNode: EvaluateNode): UndefinedSymbols | null {\n const nodeType = node[0]\n switch (nodeType) {\n case NodeTypes.UserDefinedSymbol: {\n const symbolNode = node as UserDefinedSymbolNode\n const lookUpResult = contextStack.lookUp(symbolNode)\n if (lookUpResult === null)\n return new Set([symbolNode[1]])\n\n return null\n }\n case NodeTypes.NormalBuiltinSymbol:\n case NodeTypes.SpecialBuiltinSymbol:\n case NodeTypes.String:\n case NodeTypes.Number:\n case NodeTypes.ReservedSymbol:\n case NodeTypes.Binding:\n return null\n case NodeTypes.NormalExpression: {\n const normalExpressionNode = node as NormalExpressionNode\n const unresolvedSymbols = new Set<string>()\n if (isNormalExpressionNodeWithName(normalExpressionNode)) {\n const [, [symbolNode]] = normalExpressionNode\n if (isUserDefinedSymbolNode(symbolNode)) {\n const lookUpResult = contextStack.lookUp(symbolNode)\n if (lookUpResult === null)\n unresolvedSymbols.add(symbolNode[1])\n }\n }\n else {\n const [, [expressionNode]] = normalExpressionNode\n findUnresolvedSymbolsInNode(expressionNode, contextStack, builtin, evaluateNode)?.forEach(symbol => unresolvedSymbols.add(symbol))\n }\n for (const subNode of normalExpressionNode[1][1]) {\n findUnresolvedSymbolsInNode(subNode, contextStack, builtin, evaluateNode)?.forEach(symbol => unresolvedSymbols.add(symbol))\n }\n return unresolvedSymbols\n }\n case NodeTypes.SpecialExpression: {\n const specialExpressionNode = node as SpecialExpressionNode\n const specialExpressionType = specialExpressionNode[1][0]\n const specialExpression = builtin.specialExpressions[specialExpressionType]\n\n const castedGetUndefinedSymbols = specialExpression.getUndefinedSymbols as Function\n\n return castedGetUndefinedSymbols(specialExpressionNode, contextStack, {\n getUndefinedSymbols,\n builtin,\n evaluateNode,\n }) as UndefinedSymbols\n }\n case NodeTypes.Spread:\n return findUnresolvedSymbolsInNode((node as SpreadNode)[1], contextStack, builtin, evaluateNode)\n\n /* v8 ignore next 2 */\n default:\n throw new LitsError(`Unhandled node type: ${nodeType satisfies never}`, node[2])\n }\n}\n","import type { Any } from '../interface'\n\nconst nonNumberReservedSymbolRecord = {\n true: true,\n false: false,\n null: null,\n do: null,\n else: null,\n case: null,\n each: null,\n in: null,\n when: null,\n while: null,\n catch: null,\n function: null,\n export: null,\n as: null,\n then: null,\n end: null,\n _: null,\n} as const satisfies Record<string, Any>\n\nconst phi = (1 + Math.sqrt(5)) / 2\nexport const numberReservedSymbolRecord = {\n 'E': Math.E,\n '-E': -Math.E,\n 'ε': Math.E,\n '-ε': -Math.E,\n 'PI': Math.PI,\n '-PI': -Math.PI,\n 'π': Math.PI,\n '-π': -Math.PI,\n 'PHI': phi,\n '-PHI': -phi,\n 'φ': phi,\n '-φ': -phi,\n 'POSITIVE_INFINITY': Number.POSITIVE_INFINITY,\n '∞': Number.POSITIVE_INFINITY,\n 'NEGATIVE_INFINITY': Number.NEGATIVE_INFINITY,\n '-∞': Number.NEGATIVE_INFINITY,\n 'MAX_SAFE_INTEGER': Number.MAX_SAFE_INTEGER,\n 'MIN_SAFE_INTEGER': Number.MIN_SAFE_INTEGER,\n 'MAX_VALUE': Number.MAX_VALUE,\n 'MIN_VALUE': Number.MIN_VALUE,\n 'NaN': Number.NaN,\n} as const satisfies Record<string, number>\n\nexport const reservedSymbolRecord = {\n ...nonNumberReservedSymbolRecord,\n ...numberReservedSymbolRecord,\n} as const\n\nexport type ReservedSymbol = keyof typeof reservedSymbolRecord\n\nexport function isReservedSymbol(symbol: string): symbol is keyof typeof reservedSymbolRecord {\n return symbol in reservedSymbolRecord\n}\n\nexport function isNumberReservedSymbol(symbol: string): symbol is keyof typeof numberReservedSymbolRecord {\n return symbol in numberReservedSymbolRecord\n}\n","import { specialExpressions } from '../builtin'\nimport { evaluateBindingNodeValues } from '../builtin/bindingNode'\nimport { allNormalExpressions } from '../builtin/normalExpressions'\nimport { LitsError, RecurSignal } from '../errors'\nimport { arityAcceptsMin, assertNumberOfParams } from '../utils/arity'\nimport type { Any, Arr } from '../interface'\nimport type {\n CompFunction,\n ComplementFunction,\n ConstantlyFunction,\n EveryPredFunction,\n FNullFunction,\n JuxtFunction,\n LitsFunctionType,\n ModuleFunction,\n NativeJsFunction,\n NormalBuiltinFunction,\n PartialFunction,\n SomePredFunction,\n SpecialBuiltinFunction,\n UserDefinedFunction,\n} from '../parser/types'\nimport { bindingTargetTypes } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asNonUndefined, isUnknownRecord } from '../typeGuards'\nimport { asAny, asFunctionLike } from '../typeGuards/lits'\nimport { toAny } from '../utils'\nimport { valueToString } from '../utils/debug/debugTools'\nimport type { ContextStack } from './ContextStack'\nimport type { Context, EvaluateNode, ExecuteFunction } from './interface'\n\ntype FunctionExecutors = Record<LitsFunctionType, (\n fn: any,\n params: Arr,\n sourceCodeInfo: SourceCodeInfo | undefined,\n contextStack: ContextStack,\n helpers: { evaluateNode: EvaluateNode, executeFunction: ExecuteFunction },\n) => Any>\n\nexport const functionExecutors: FunctionExecutors = {\n NativeJsFunction: (fn: NativeJsFunction, params, sourceCodeInfo) => {\n try {\n return toAny(fn.nativeFn.fn(...params))\n }\n catch (error) {\n const message\n = typeof error === 'string'\n ? error\n : isUnknownRecord(error) && typeof error.message === 'string'\n ? error.message\n : '<no message>'\n throw new LitsError(`Native function threw: \"${message}\"`, sourceCodeInfo)\n }\n },\n UserDefined: (fn: UserDefinedFunction, params, sourceCodeInfo, contextStack, { evaluateNode }) => {\n for (;;) {\n if (!arityAcceptsMin(fn.arity, params.length)) {\n throw new LitsError(`Expected ${fn.arity} arguments, got ${params.length}.`, sourceCodeInfo)\n }\n const evaluatedFunction = fn.evaluatedfunction\n const args = evaluatedFunction[0]\n const nbrOfNonRestArgs: number = args.filter(arg => arg[0] !== bindingTargetTypes.rest).length\n\n const newContextStack = contextStack.create(fn.evaluatedfunction[2])\n const newContext: Context = { self: { value: fn } }\n\n const rest: Arr = []\n for (let i = 0; i < params.length; i += 1) {\n if (i < nbrOfNonRestArgs) {\n const param = toAny(params[i])\n const valueRecord = evaluateBindingNodeValues(args[i]!, param, node =>\n evaluateNode(node, newContextStack.create(newContext)))\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n }\n else {\n rest.push(toAny(params[i]))\n }\n }\n\n for (let i = params.length; i < nbrOfNonRestArgs; i++) {\n const arg = args[i]!\n const defaultValue = evaluateNode(arg[1][1]!, contextStack.create(newContext))\n const valueRecord = evaluateBindingNodeValues(arg, defaultValue, node =>\n evaluateNode(node, contextStack.create(newContext)))\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n }\n\n const restArgument = args.find(arg => arg[0] === bindingTargetTypes.rest)\n if (restArgument !== undefined) {\n const valueRecord = evaluateBindingNodeValues(restArgument, rest, node => evaluateNode(node, contextStack.create(newContext)))\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n }\n\n try {\n let result: Any = null\n const newContextStack2 = newContextStack.create(newContext)\n for (const node of evaluatedFunction[1]) {\n result = evaluateNode(node, newContextStack2)\n }\n\n return result\n }\n catch (error) {\n if (error instanceof RecurSignal) {\n params = error.params\n continue\n }\n throw error\n }\n }\n },\n Partial: (fn: PartialFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const actualParams = [...fn.params]\n if (params.length !== fn.placeholders.length) {\n throw new LitsError(`(partial) expects ${fn.placeholders.length} arguments, got ${params.length}.`, sourceCodeInfo)\n }\n const paramsCopy = [...params]\n for (const placeholderIndex of fn.placeholders) {\n actualParams.splice(placeholderIndex, 0, paramsCopy.shift())\n }\n return executeFunction(fn.function, actualParams, contextStack, sourceCodeInfo)\n },\n Comp: (fn: CompFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const { params: f } = fn\n if (f.length === 0) {\n if (params.length !== 1)\n throw new LitsError(`(comp) expects one argument, got ${valueToString(params.length)}.`, sourceCodeInfo)\n\n return asAny(params[0], sourceCodeInfo)\n }\n return asAny(\n f.reduceRight((result: Arr, fun) => {\n return [executeFunction(asFunctionLike(fun, sourceCodeInfo), result, contextStack, sourceCodeInfo)]\n }, params)[0],\n sourceCodeInfo,\n )\n },\n Constantly: (fn: ConstantlyFunction) => {\n return fn.value\n },\n Juxt: (fn: JuxtFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n return fn.params.map(fun => executeFunction(asFunctionLike(fun, sourceCodeInfo), params, contextStack, sourceCodeInfo))\n },\n Complement: (fn: ComplementFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n return !executeFunction(fn.function, params, contextStack, sourceCodeInfo)\n },\n EveryPred: (fn: EveryPredFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n for (const f of fn.params) {\n for (const param of params) {\n const result = executeFunction(asFunctionLike(f, sourceCodeInfo), [param], contextStack, sourceCodeInfo)\n if (!result)\n return false\n }\n }\n return true\n },\n SomePred: (fn: SomePredFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n for (const f of fn.params) {\n for (const param of params) {\n const result = executeFunction(asFunctionLike(f, sourceCodeInfo), [param], contextStack, sourceCodeInfo)\n if (result)\n return true\n }\n }\n return false\n },\n Fnull: (fn: FNullFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const fnulledParams = params.map((param, index) => (param === null ? toAny(fn.params[index]) : param))\n return executeFunction(asFunctionLike(fn.function, sourceCodeInfo), fnulledParams, contextStack, sourceCodeInfo)\n },\n Builtin: (fn: NormalBuiltinFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const normalExpression = asNonUndefined(allNormalExpressions[fn.normalBuiltinSymbolType], sourceCodeInfo)\n return normalExpression.evaluate(params, sourceCodeInfo, contextStack, { executeFunction })\n },\n SpecialBuiltin: (fn: SpecialBuiltinFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const specialExpression = asNonUndefined(specialExpressions[fn.specialBuiltinSymbolType], sourceCodeInfo)\n if (specialExpression.evaluateAsNormalExpression) {\n return specialExpression.evaluateAsNormalExpression(params, sourceCodeInfo, contextStack, { executeFunction })\n }\n else {\n throw new LitsError(`Special builtin function ${fn.specialBuiltinSymbolType} is not supported as normal expression.`, sourceCodeInfo)\n }\n },\n Module: (fn: ModuleFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const module = contextStack.getModule(fn.moduleName)\n if (!module) {\n throw new LitsError(`Module '${fn.moduleName}' not found.`, sourceCodeInfo)\n }\n const expression = module.functions[fn.functionName]\n if (!expression) {\n throw new LitsError(`Function '${fn.functionName}' not found in module '${fn.moduleName}'.`, sourceCodeInfo)\n }\n assertNumberOfParams(expression.arity, params.length, sourceCodeInfo)\n return expression.evaluate(params, sourceCodeInfo, contextStack, { executeFunction })\n },\n}\n","import type { SpecialExpression } from '../builtin'\nimport { builtin } from '../builtin'\nimport { NodeTypes, getNodeTypeName } from '../constants/constants'\nimport { LitsError, UndefinedSymbolError } from '../errors'\nimport { getUndefinedSymbols } from '../getUndefinedSymbols'\nimport type { Any, Arr, Obj } from '../interface'\nimport type {\n Ast,\n AstNode,\n FunctionLike,\n NormalExpressionNode,\n NumberNode,\n PartialFunction,\n ReservedSymbolNode,\n SpecialExpressionNode,\n StringNode,\n SymbolNode,\n} from '../parser/types'\nimport { reservedSymbolRecord } from '../tokenizer/reservedNames'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asNonUndefined } from '../typeGuards'\nimport { annotate } from '../typeGuards/annotatedArrays'\nimport { isNormalBuiltinSymbolNode, isNormalExpressionNodeWithName, isSpreadNode } from '../typeGuards/astNode'\nimport { asFunctionLike, assertSeq, isObj } from '../typeGuards/lits'\nimport { isLitsFunction } from '../typeGuards/litsFunction'\nimport { assertNumber, isNumber } from '../typeGuards/number'\nimport { assertString } from '../typeGuards/string'\nimport { toAny } from '../utils'\nimport { valueToString } from '../utils/debug/debugTools'\nimport { toFixedArity } from '../utils/arity'\nimport { FUNCTION_SYMBOL } from '../utils/symbols'\nimport type { ContextStack } from './ContextStack'\nimport { functionExecutors } from './functionExecutors'\n\nexport function evaluate(ast: Ast, contextStack: ContextStack): Any {\n let result: Any = null\n\n for (const node of ast.body) {\n result = evaluateNode(node, contextStack)\n }\n\n return result\n}\n\nexport function evaluateNode(node: AstNode, contextStack: ContextStack): Any {\n switch (node[0]) {\n case NodeTypes.Number:\n return evaluateNumber(node as NumberNode)\n case NodeTypes.String:\n return evaluateString(node as StringNode)\n case NodeTypes.NormalBuiltinSymbol:\n case NodeTypes.SpecialBuiltinSymbol:\n case NodeTypes.UserDefinedSymbol:\n return contextStack.evaluateSymbol(node as SymbolNode)\n case NodeTypes.ReservedSymbol:\n return evaluateReservedSymbol(node as ReservedSymbolNode)\n case NodeTypes.NormalExpression: {\n const result = evaluateNormalExpression(node as NormalExpressionNode, contextStack)\n if (typeof result === 'number' && Number.isNaN(result)) {\n throw new LitsError('Number is NaN', node[2])\n }\n return annotate(result)\n }\n case NodeTypes.SpecialExpression:\n return annotate(evaluateSpecialExpression(node as SpecialExpressionNode, contextStack))\n /* v8 ignore next 2 */\n default:\n throw new LitsError(`${getNodeTypeName(node[0])}-node cannot be evaluated`, node[2])\n }\n}\n\nfunction evaluateNumber(node: NumberNode): number {\n return node[1]\n}\n\nfunction evaluateString(node: StringNode): string {\n return node[1]\n}\n\nfunction evaluateReservedSymbol(node: ReservedSymbolNode): Any {\n const reservedName = node[1]\n if (!['true', 'false', 'null'].includes(reservedName)) {\n throw new LitsError(`Reserved symbol ${reservedName} cannot be evaluated`, node[2])\n }\n const value = reservedSymbolRecord[reservedName]\n return asNonUndefined(value, node[2])\n}\n\nfunction evaluateNormalExpression(node: NormalExpressionNode, contextStack: ContextStack): Any {\n const sourceCodeInfo = node[2]\n const paramNodes: AstNode[] = node[1][1]\n const params: Arr = []\n const placeholders: number[] = []\n paramNodes.forEach((paramNode, index) => {\n if (isSpreadNode(paramNode)) {\n const spreadValue = evaluateNode(paramNode[1], contextStack)\n if (Array.isArray(spreadValue)) {\n params.push(...spreadValue)\n }\n else {\n throw new LitsError(`Spread operator requires an array, got ${valueToString(paramNode)}`, paramNode[2])\n }\n }\n else if (paramNode[0] === NodeTypes.ReservedSymbol && paramNode[1] === '_') {\n placeholders.push(index)\n }\n else {\n params.push(evaluateNode(paramNode, contextStack))\n }\n })\n if (isNormalExpressionNodeWithName(node)) {\n const nameSymbol = node[1][0]\n if (placeholders.length > 0) {\n const fn = evaluateNode(nameSymbol, contextStack)\n const partialFunction: PartialFunction = {\n [FUNCTION_SYMBOL]: true,\n function: asFunctionLike(fn, sourceCodeInfo),\n functionType: 'Partial',\n params,\n placeholders,\n sourceCodeInfo,\n arity: toFixedArity(placeholders.length),\n }\n return partialFunction\n }\n\n if (isNormalBuiltinSymbolNode(nameSymbol)) {\n const type = nameSymbol[1]\n const normalExpression = builtin.allNormalExpressions[type]!\n return normalExpression.evaluate(params, node[2], contextStack, { executeFunction })\n }\n else {\n const fn = contextStack.getValue(nameSymbol[1])\n if (fn !== undefined) {\n return executeFunction(asFunctionLike(fn, sourceCodeInfo), params, contextStack, sourceCodeInfo)\n }\n throw new UndefinedSymbolError(nameSymbol[1], node[2])\n }\n }\n else {\n const fnNode: AstNode = node[1][0]\n const fn = asFunctionLike(evaluateNode(fnNode, contextStack), sourceCodeInfo)\n if (placeholders.length > 0) {\n const partialFunction: PartialFunction = {\n [FUNCTION_SYMBOL]: true,\n function: fn,\n functionType: 'Partial',\n params,\n placeholders,\n sourceCodeInfo,\n arity: toFixedArity(placeholders.length),\n }\n return partialFunction\n }\n return executeFunction(fn, params, contextStack, sourceCodeInfo)\n }\n}\n\nfunction executeFunction(fn: FunctionLike, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): Any {\n if (isLitsFunction(fn))\n return functionExecutors[fn.functionType](fn, params, sourceCodeInfo, contextStack, { evaluateNode, executeFunction })\n\n if (Array.isArray(fn))\n return evaluateArrayAsFunction(fn, params, sourceCodeInfo)\n\n if (isObj(fn))\n return evalueateObjectAsFunction(fn, params, sourceCodeInfo)\n\n if (typeof fn === 'string')\n return evaluateStringAsFunction(fn, params, sourceCodeInfo)\n\n if (isNumber(fn)) {\n return evaluateNumberAsFunction(fn, params, sourceCodeInfo)\n /* v8 ignore next 4 */\n }\n throw new LitsError('Unexpected function type', sourceCodeInfo)\n}\n\nfunction evaluateSpecialExpression(node: SpecialExpressionNode, contextStack: ContextStack): Any {\n const specialExpressionType = node[1][0]\n const specialExpression: SpecialExpression = asNonUndefined(builtin.specialExpressions[specialExpressionType], node[2])\n const castedEvaluate = specialExpression.evaluate as Function\n\n return castedEvaluate(node, contextStack, { evaluateNode, builtin, getUndefinedSymbols }) as Any\n}\n\nfunction evalueateObjectAsFunction(fn: Obj, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n if (params.length !== 1)\n throw new LitsError('Object as function requires one string parameter.', sourceCodeInfo)\n\n const key = params[0]\n assertString(key, sourceCodeInfo)\n return toAny(fn[key])\n}\n\nfunction evaluateArrayAsFunction(fn: Arr, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n if (params.length !== 1)\n throw new LitsError('Array as function requires one non negative integer parameter.', sourceCodeInfo)\n\n const index = params[0]\n assertNumber(index, sourceCodeInfo, { integer: true, nonNegative: true })\n return toAny(fn[index])\n}\n\nfunction evaluateStringAsFunction(fn: string, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n if (params.length !== 1)\n throw new LitsError('String as function requires one Obj parameter.', sourceCodeInfo)\n\n const param = toAny(params[0])\n if (isObj(param))\n return toAny((param)[fn])\n\n if (isNumber(param, { integer: true }))\n return toAny(fn[param])\n\n throw new LitsError(\n `string as function expects Obj or integer parameter, got ${valueToString(param)}`,\n sourceCodeInfo,\n )\n}\n\nfunction evaluateNumberAsFunction(fn: number, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n assertNumber(fn, sourceCodeInfo, { integer: true })\n if (params.length !== 1)\n throw new LitsError('Number as function requires one Arr parameter.', sourceCodeInfo)\n\n const param = params[0]\n assertSeq(param, sourceCodeInfo)\n return toAny(param[fn])\n}\n"],"names":["getCodeMarker","sourceCodeInfo","position","code","leftPadding","column","rightPadding","length","repeat","Math","max","RecurSignal","Error","params","constructor","super","Object","setPrototypeOf","this","prototype","name","LitsError","shortMessage","err","message","location","line","filePath","getLitsErrorMessage","UserDefinedError","userMessage","UndefinedSymbolError","symbol","symbolName","isLitsError","error","NodeTypes","Number","String","NormalExpression","SpecialExpression","UserDefinedSymbol","NormalBuiltinSymbol","SpecialBuiltinSymbol","ReservedSymbol","Binding","Spread","NodeTypesSet","Set","values","getNodeTypeName","type","keys","find","key","functionTypeSet","FUNCTION_SYMBOL","REGEXP_SYMBOL","isLitsFunction","func","has","isFunctionType","functionType","isNode","value","Array","isArray","isNodeType","valueToString","RegExp","toString","JSON","stringify","getSourceCodeInfo","anyValue","getAssertionError","typeName","asNonUndefined","assertNonUndefined","undefined","isNonUndefined","isUnknownRecord","asLitsFunction","assertLitsFunction","isUserDefinedFunction","asUserDefinedFunction","assertUserDefinedFunction","isNativeJsFunction","asNativeJsFunction","assertNativeJsFunction","isBuiltinFunction","isNumber","options","isNaN","integer","isInteger","finite","isFinite","zero","nonZero","positive","negative","nonPositive","nonNegative","gt","gte","lt","lte","assertNumber","sign","getSignString","numberType","range","getRangeString","filter","x","join","getNumberTypeName","isAny","asAny","assertAny","isSeq","assertSeq","isObj","isRegularExpression","assertObj","isColl","asColl","assertColl","regexp","assertStringOrRegularExpression","isStringOrRegularExpression","asFunctionLike","assertFunctionLike","isFunctionLike","arityAcceptsMin","arity","nbrOfParams","min","assertNumberOfParams","toFixedArity","bitwiseNormalExpression","evaluate","num","count","first","rest","reduce","result","xor","nonEmpty","char","isString","asString","assertString","isStringOrNumber","asStringOrNumber","assertStringOrNumber","collHasKey","coll","getOwnPropertyDescriptor","compare","a","b","deepEqual","epsilon","EPSILON","diff","abs","absA","absB","i","s","f","aKeys","bKeys","toAny","results","symbols","forEach","add","addToSet","target","source","smartTrim","str","minIndent","lines","split","match","shift","pop","indent","acc","lineIndent","Infinity","slice","trimEnd","assertArray","every","v","isStringArray","isCharArray","collectionNormalExpression","fn","contextStack","executeFunction","elem","entries","map","at","colls","obj","objKeys","includes","push","mapObjects","seqs","isStr","len","seq","paramArray","mapped","p","initial","get","defaultValue","copy","assoc","arr","concat","assign","arrayNormalExpression","second","third","from","step","to","flatten","depth","actualDepth","POSITIVE_INFINITY","asNumber","flat","mapcat","windowSize","subArr","sequenceNormalExpression","nth","array","last","index","indexOf","item","assertCharArray","substring","next","reverse","some","sort","comparer","compareValue","defaultComparer","annotatedArrays","vectors","WeakSet","notVectors","matrices","notMatrices","grids","notGrids","annotate","isVector","isMatrix","isGrid","vector","assertNonEmptyVector","assertVector","grid","row","nbrOfCols","matrix","getNumberVectorOrMatrixOperation","hasVector","hasMatrix","param","rows","cold","unaryMathOp","operation","operands","val","j","reduceMathOp","identity","m","mathNormalExpression","inc","firstVector","firstMatrix","binaryMathOp","trunc","floor","sqrt","cbrt","decimals","round","factor","ceil","isEqual","firstAny","miscNormalExpression","isIdentical","currentValue","ms","Date","toISOString","dateTime","valueOf","console","log","boolean","import","importPath","dotIndex","moduleName","module","getModule","expression","functions","functionName","objectNormalExpression","vals","dissoc","newObj","merge","entry","assertStringArray","predicatesNormalExpression","NEGATIVE_INFINITY","table","regexpNormalExpression","sourceArg","flagsArg","flags","e","text","assertRegularExpression","exec","matcher","replace","replaceAll","blankRegexp","stringNormalExpression","number","toLowerCase","toUpperCase","trim","stringList","delimiter","stringOrRegExpValue","limit","test","comp","generateDocString","reference","title","description","variants","args","returns","_isOperator","variant","argumentNames","argName","signature","arg","argStrings","examples","example","typeString","argType","prod","sorted","mid","calcMedian","expressions","normalExpressionReference","docString","getMetaNormalExpression","normalExpressionTypes","normalExpressions","allNormalExpressions","andSpecialExpression","node","evaluateNode","evaluateAsNormalExpression","getUndefinedSymbols","builtin","isSymbolNode","nodeType","asUserDefinedSymbolNode","isUserDefinedSymbolNode","assertUserDefinedSymbolNode","isNormalBuiltinSymbolNode","isSpecialBuiltinSymbolNode","isSpreadNode","definedSpecialExpression","symbolNode","assertSymbolNode","lookUp","bindingTargetTypes","bindingTarget","onDefault","element","walkDefaults","evaluateBindingNodeValues","record","createRecord","restElement","restValues","capturedKeys","restIndex","getAllBindingTargetNames","names","getNamesFromBindingTarget","defSpecialExpression","bindingNode","bindingValue","Node","exportValues","defaultNode","bindingResult","addValues","lambdaSpecialExpression","evaluatedFunction","functionContext","context","ctx","new","undefinedSymbols","evaluateFunction","self","newContext","newContextStack","create","overloadResult","getFunctionUnresolvedSymbols","letSpecialExpression","loopSpecialExpression","bindingNodes","valueRecord","bindingContext","body","bindings","evaluateLoop","returnResult","loopNode","loopBindings","bindingIndices","abort","bindingsLoop","bindingIndex","letBindings","whenNode","whileNode","targetNode","valueNode","skip","addToContext","loopBindingNode","letBindingNode","letTarget","letValue","forSpecialExpression","helpers","analyze","doseqSpecialExpression","orSpecialExpression","qqSpecialExpression","recurSpecialExpression","paramNode","evaluatedParams","throwSpecialExpression","tryExpression","errorSymbol","catchExpression","tryResult","arraySpecialExpression","spreadValue","objectSpecialExpression","keyNode","spreadObject","specialExpressionTypes","block","doseq","for","if","let","loop","object","recur","switch","specialExpressions","form","trueNode","falseNode","conditionNode","n","switchValueNode","cases","switchValue","specialExpressionKeys","ast","nodes","unresolvedSymbols","subNode","findUnresolvedSymbolsInNode","normalExpressionNode","isNormalExpressionNodeWithName","expressionNode","specialExpressionType","specialExpressionNode","castedGetUndefinedSymbols","phi","numberReservedSymbolRecord","E","PI","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","MAX_VALUE","MIN_VALUE","NaN","reservedSymbolRecord","true","false","null","in","when","while","catch","function","export","as","then","end","_","nativeFn","UserDefined","evaluatedfunction","nbrOfNonRestArgs","restArgument","newContextStack2","Partial","actualParams","placeholders","placeholderIndex","splice","paramsCopy","Comp","reduceRight","fun","Constantly","Juxt","Complement","EveryPred","SomePred","Fnull","fnulledParams","Builtin","normalBuiltinSymbolType","specialExpression","specialBuiltinSymbolType","Module","evaluateString","evaluateSymbol","reservedName","evaluateReservedSymbol","paramNodes","nameSymbol","getValue","evaluateNormalExpression","castedEvaluate","evaluateSpecialExpression","functionExecutors","evaluateArrayAsFunction","evalueateObjectAsFunction","evaluateStringAsFunction","evaluateNumberAsFunction","modules","contexts","hostValues","nativeJsFunctions","globalContext","Map","ContextStackImpl","shadowedName","getShadowedBuiltinName","currentContext","contextEntry","hostValue","nativeJsFunction","throw","normalExpression","lookUpResult","normalExpressionKeys","createContextStack","jsFunctions","identifier","identifierParts","scope","part","isJsFunction","TypeError","assertJsFunction","assertNotShadowingBuiltin","globalModuleScope","symbolicOperators","binaryOperators","nonFunctionOperatorSet","isFunctionOperator","operator","binaryOperatorSet","isBinaryOperator","symbolicOperatorSet","isSymbolicOperator","illegalSymbolCharacters","illegalFirstSymbolCharacters","input","escaping","NO_MATCH","decimalNumberRegExp","postNumberRegExp","tokenizeSymbol","endsWith","initialPosition","tokenizers","whitespaceRegExp","symbolMeta","startsWith","tokenizeToken","nextThreeChars","tokenizeString","stringLength","token","baseChar","binaryNumberRegExp","octalNumberRegExp","hexNumberRegExp","nextChar","negate","start","plusPrefix","hasDecimalPoint","hasExponent","threeChars","twoChars","oneChar","lineNbr","getSourceCodeLine","lastLine","getCurrentToken","nbrOfCharacters","tokenizeShebang","tokenizer","asSymbolToken","isSymbolToken","throwUnexpectedToken","assertSymbolToken","isReservedSymbolToken","assertReservedSymbolToken","asReservedSymbolToken","isOperatorToken","operatorName","assertOperatorToken","assertLParenToken","isLParenToken","assertRParenToken","isRParenToken","isLBracketToken","assertLBracketToken","isRBracketToken","assertRBracketToken","isLBraceToken","asLBraceToken","assertLBraceToken","isRBraceToken","isStringToken","expected","expectedValue","actual","actualOutput","tokenStream","removeWhiteSpace","tokens","isSingleLineCommentToken","isShebangToken","isWhitespaceToken","AutoCompleter","originalProgram","originalPosition","prefixProgram","suffixProgram","searchString","suggestions","suggestionIndex","lits","partialProgram","lastToken","tokenize","generateSuggestions","getNextSuggestion","getAutoCompleteSuggestionResult","getNextSuggestionSymbol","getPreviousSuggestion","getPreviousSuggestionSymbol","suggestion","program","getSuggestions","getSearchString","blacklist","startsWithCaseSensitive","generateWithPredicate","startsWithCaseInsensitive","includesCaseSensitive","includesCaseInsensitive","shouldInclude","litsCommands","localeCompare","ParserContext","storedPosition","parseExpression","advance","tryPeek","peek","isAtEnd","peekSourceCodeInfo","currentToken","restorePosition","peekAhead","getPosition","getTokenAt","pos","withSourceCodeInfo","stringToSymbolNode","stringFromQuotedSymbol","normalChar","backslash","singleQuote","normalExpressionNames","specialExpressionNames","getSymbolName","createNamedNormalExpressionNode","fromBinaryOperatorToNode","left","right","parseSymbol","parseBindingTarget","requireDefaultValue","noRest","firstToken","elements","parseOptionalDefaulValue","keyName","keySymbol","isImplicitBlockEnd","ends","assertImplicitBlockEnd","parseForLoopBinding","parseBinding","modifiers","assertInternalLoopBindingDelimiter","letNode","parseLet","existingBoundNames","flatMap","doubleQuote","newline","tab","carriageReturn","backspace","formFeed","parseDo","allowDocString","isDocStringToken","stringNode","parseString","stringToken","parseDocString","parseReservedSymbol","placeholderRegexp","defaults","functionArguments","parseFunctionArguments","parsedDo","parseFunctionCall","nextToken","parseObject","storePosition","lamdaFunction","parseLambdaFunction","startPos","endPos","dollar1","parseShorthandLambdaFunction","asLBracketToken","parseArray","tokenType","parseNumber","endStringPosition","lastIndexOf","regexpString","optionsString","optionsNode","parseRegexpShorthand","symbolToken","createAccessorNode","operand","getPrecedence","operatorSign","precedence","moduleScope","isUnless","condition","thenExpression","parseImplicitBlock","elseExpression","unless","parseIfOrUnless","caseExpression","cond","parseCond","valueExpression","parseSwitch","isDoseq","loopBinding","forLoopBindings","newBoundNames","parseForOrDoseq","parseLoop","try","exportToken","parseExport","isAtExpressionEnd","isA_BinaryOperatorToken","newPrecedece","newPrecedence","operatorSymbol","Cache","cache","firstEntry","lastEntry","_size","maxSize","getContent","size","clear","set","newEntry","nextEntry","dropFirstEntry","astCache","astCacheSize","debug","config","initialCache","cacheEntry","nsList","ns","getRuntimeInfo","run","generateAst","programOrAst","tokenizeParams","createSourceCodeInfo","tokenDescriptor","minify","minifyTokenStream","parse","hasDebugData","transformSymbols","transformer","tokenStram","untokenize","apply","fnParams","fnName","generateApplyFunctionCall","paramsString","cachedAst","getAutoCompleter"],"mappings":"AAEM,SAAUA,EAAcC,GAC5B,IAAKA,EAAeC,WAAaD,EAAeE,KAC9C,MAAO,GAET,MAAMC,EAAcH,EAAeC,SAASG,OAAS,EAC/CC,EAAeL,EAAeE,KAAKI,OAASH,EAAc,EAChE,MAAO,GAAG,IAAII,OAAOC,KAAKC,IAAIN,EAAa,OAAO,IAAII,OAAOC,KAAKC,IAAIJ,EAAc,KACtF,CCQM,MAAOK,UAAoBC,MACxBC,OACP,WAAAC,CAAYD,GACVE,MAAM,kBAAkBF,KACxBG,OAAOC,eAAeC,KAAMP,EAAYQ,WACxCD,KAAKE,KAAO,cACZF,KAAKL,OAASA,CACf,EAGG,MAAOQ,UAAkBT,MACbX,eACAqB,aAChB,WAAAR,CAAYS,EAActB,GACxB,MAAMuB,EAAUD,aAAeX,MAC3BW,EAAIC,QACJ,GAAGD,IAEPR,MA/BJ,SAA6BS,EAAiBvB,GAC5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AI,uBAAAwL,aAAAhP,iBAAAwB,oBAAAuN,eAAA1L,wBAAAH,2BAAA4L,eAAA6U,2BAAA7F"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/utils/debug/getCodeMarker.ts","../src/errors.ts","../src/constants/constants.ts","../src/utils/symbols.ts","../src/utils/debug/debugTools.ts","../src/utils/debug/getSourceCodeInfo.ts","../src/utils/getAssertionError.ts","../src/typeGuards/index.ts","../src/typeGuards/litsFunction.ts","../src/typeGuards/number.ts","../src/typeGuards/lits.ts","../src/utils/arity.ts","../src/builtin/core/bitwise.ts","../src/typeGuards/string.ts","../src/utils/index.ts","../src/typeGuards/array.ts","../src/utils/maybePromise.ts","../src/builtin/core/collection.ts","../src/builtin/core/array.ts","../src/builtin/core/sequence.ts","../src/typeGuards/annotatedArrays.ts","../src/builtin/core/math.ts","../src/builtin/core/misc.ts","../src/builtin/core/object.ts","../src/builtin/core/predicates.ts","../src/builtin/core/regexp.ts","../src/builtin/core/string.ts","../src/builtin/core/functional.ts","../src/utils/docString/generateDocString.ts","../src/builtin/core/meta.ts","../src/builtin/core/vector.ts","../src/builtin/specialExpressions/and.ts","../src/builtin/specialExpressions/cond.ts","../src/builtin/specialExpressions/switch.ts","../src/builtin/normalExpressions/index.ts","../src/typeGuards/astNode.ts","../src/builtin/specialExpressions/defined.ts","../src/parser/types.ts","../src/builtin/bindingNode.ts","../src/builtin/specialExpressions/def.ts","../src/builtin/specialExpressions/block.ts","../src/builtin/specialExpressions/functions.ts","../src/builtin/specialExpressions/if.ts","../src/builtin/specialExpressions/unless.ts","../src/builtin/specialExpressions/let.ts","../src/builtin/specialExpressions/loop.ts","../src/builtin/specialExpressions/loops.ts","../src/builtin/specialExpressions/or.ts","../src/builtin/specialExpressions/qq.ts","../src/builtin/specialExpressions/recur.ts","../src/builtin/specialExpressions/throw.ts","../src/builtin/specialExpressions/try.ts","../src/builtin/specialExpressions/array.ts","../src/builtin/specialExpressions/object.ts","../src/builtin/specialExpressionTypes.ts","../src/builtin/index.ts","../src/getUndefinedSymbols/index.ts","../src/tokenizer/reservedNames.ts","../src/evaluator/functionExecutors.ts","../src/evaluator/index.ts"],"sourcesContent":["import type { SourceCodeInfo } from '../../tokenizer/token'\n\nexport function getCodeMarker(sourceCodeInfo: SourceCodeInfo): string {\n if (!sourceCodeInfo.position || !sourceCodeInfo.code)\n return ''\n\n const leftPadding = sourceCodeInfo.position.column - 1\n const rightPadding = sourceCodeInfo.code.length - leftPadding - 1\n return `${' '.repeat(Math.max(leftPadding, 0))}^${' '.repeat(Math.max(rightPadding, 0))}`\n}\n","import { getCodeMarker } from '../src/utils/debug/getCodeMarker'\nimport type { Arr } from './interface'\nimport type { SourceCodeInfo } from './tokenizer/token'\n\nfunction getLitsErrorMessage(message: string, sourceCodeInfo?: SourceCodeInfo) {\n if (!sourceCodeInfo) {\n return message\n }\n const location = `${sourceCodeInfo.position.line}:${sourceCodeInfo.position.column}`\n const filePathLine = sourceCodeInfo.filePath\n ? `\\n${sourceCodeInfo.filePath}:${location}`\n : `\\nLocation ${location}`\n const codeLine = `\\n${sourceCodeInfo.code}`\n const codeMarker = `\\n${getCodeMarker(sourceCodeInfo)}`\n return `${message}${filePathLine}${codeLine}${codeMarker}`\n}\n\nexport class RecurSignal extends Error {\n public params: Arr\n constructor(params: Arr) {\n super(`recur, params: ${params}`)\n Object.setPrototypeOf(this, RecurSignal.prototype)\n this.name = 'RecurSignal'\n this.params = params\n }\n}\n\nexport class LitsError extends Error {\n public readonly sourceCodeInfo?: SourceCodeInfo\n public readonly shortMessage: string\n constructor(err: unknown, sourceCodeInfo: SourceCodeInfo | undefined) {\n const message = err instanceof Error\n ? err.message\n : `${err}`\n\n super(getLitsErrorMessage(message, sourceCodeInfo))\n this.shortMessage = message\n this.sourceCodeInfo = sourceCodeInfo\n Object.setPrototypeOf(this, LitsError.prototype)\n this.name = 'LitsError'\n }\n\n public getCodeMarker(): string | undefined {\n return this.sourceCodeInfo && getCodeMarker(this.sourceCodeInfo)\n }\n}\n\nexport class UserDefinedError extends LitsError {\n public userMessage: string\n constructor(message: string, sourceCodeInfo?: SourceCodeInfo) {\n super(message, sourceCodeInfo)\n this.userMessage = message\n Object.setPrototypeOf(this, UserDefinedError.prototype)\n this.name = 'UserDefinedError'\n }\n}\n\nexport class AssertionError extends LitsError {\n constructor(message: string | Error, sourceCodeInfo?: SourceCodeInfo) {\n super(message, sourceCodeInfo)\n Object.setPrototypeOf(this, AssertionError.prototype)\n this.name = 'AssertionError'\n }\n}\n\nexport class UndefinedSymbolError extends LitsError {\n public symbol: string\n constructor(symbolName: string, sourceCodeInfo?: SourceCodeInfo) {\n const message = `Undefined symbol '${symbolName}'.`\n super(message, sourceCodeInfo)\n this.symbol = symbolName\n Object.setPrototypeOf(this, UndefinedSymbolError.prototype)\n this.name = 'UndefinedSymbolError'\n }\n}\n\nexport function isLitsError(error: unknown): error is LitsError {\n return error instanceof LitsError\n}\n","export const NodeTypes = {\n Number: 1,\n String: 2,\n NormalExpression: 3,\n SpecialExpression: 4,\n UserDefinedSymbol: 5,\n NormalBuiltinSymbol: 6,\n SpecialBuiltinSymbol: 7,\n ReservedSymbol: 8,\n Binding: 9,\n Spread: 10,\n} as const\n\nconst NodeTypesSet = new Set(Object.values(NodeTypes))\n\nexport type NodeType = typeof NodeTypes[keyof typeof NodeTypes]\n\nexport function getNodeTypeName(type: NodeType): keyof typeof NodeTypes {\n return Object.keys(NodeTypes).find(key => NodeTypes[key as keyof typeof NodeTypes] === type) as keyof typeof NodeTypes\n}\n\n// TODO, is this needed?\nexport function isNodeType(type: unknown): type is NodeType {\n return typeof type === 'number' && NodeTypesSet.has(type as NodeType)\n}\n\nconst functionTypes = [\n 'UserDefined',\n 'Partial',\n 'Comp',\n 'Constantly',\n 'Juxt',\n 'Complement',\n 'EveryPred',\n 'SomePred',\n 'Fnull',\n 'Builtin',\n 'SpecialBuiltin',\n 'NativeJsFunction',\n 'Module',\n] as const\n\nconst functionTypeSet = new Set(functionTypes)\n\nexport type FunctionType = typeof functionTypes[number]\n\nexport function isFunctionType(type: unknown): type is FunctionType {\n return typeof type === 'string' && functionTypeSet.has(type as FunctionType)\n}\n","export const FUNCTION_SYMBOL = '^^fn^^'\nexport const REGEXP_SYMBOL = '^^re^^'\n","import { getNodeTypeName, isFunctionType, isNodeType } from '../../constants/constants'\nimport type { AstNode, LitsFunction } from '../../parser/types'\nimport { FUNCTION_SYMBOL } from '../symbols'\n\nfunction isLitsFunction(func: unknown): func is LitsFunction {\n if (func === null || typeof func !== 'object')\n return false\n\n return FUNCTION_SYMBOL in func && 'functionType' in func && isFunctionType(func.functionType)\n}\n\nfunction isNode(value: unknown): value is AstNode {\n if (!Array.isArray(value) || value.length < 2)\n return false\n return isNodeType(value[0])\n}\n\nexport function valueToString(value: unknown): string {\n if (isLitsFunction(value))\n // eslint-disable-next-line ts/no-unsafe-member-access\n return `<function ${(value as any).name || '\\u03BB'}>`\n\n if (isNode(value))\n return `${getNodeTypeName(value[0])}-node`\n\n if (value === null)\n return 'null'\n\n if (typeof value === 'object' && value instanceof RegExp)\n return `${value}`\n\n if (typeof value === 'object' && value instanceof Error)\n return value.toString()\n\n return JSON.stringify(value)\n}\n","import type { SourceCodeInfo } from '../../tokenizer/token'\n\nexport function getSourceCodeInfo(anyValue: any, sourceCodeInfo: SourceCodeInfo | undefined): SourceCodeInfo | undefined {\n // eslint-disable-next-line ts/no-unsafe-return, ts/no-unsafe-member-access\n return anyValue?.sourceCodeInfo ?? sourceCodeInfo\n}\n","import { LitsError } from '../errors'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from './debug/debugTools'\nimport { getSourceCodeInfo } from './debug/getSourceCodeInfo'\n\nexport function getAssertionError(typeName: string, value: unknown, sourceCodeInfo?: SourceCodeInfo): LitsError {\n return new LitsError(`Expected ${typeName}, got ${valueToString(value)}.`, getSourceCodeInfo(value, sourceCodeInfo))\n}\n","import { LitsError } from '../errors'\nimport type { UnknownRecord } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from '../utils/debug/debugTools'\nimport { getSourceCodeInfo } from '../utils/debug/getSourceCodeInfo'\n\nfunction isNonUndefined<T>(value: T | undefined): value is T {\n return value !== undefined\n}\n\nexport function asNonUndefined<T>(value: T | undefined, sourceCodeInfo?: SourceCodeInfo): T {\n assertNonUndefined(value, sourceCodeInfo)\n return value\n}\n\nexport function assertNonUndefined<T>(value: T | undefined, sourceCodeInfo?: SourceCodeInfo): asserts value is T {\n if (!isNonUndefined(value))\n throw new LitsError('Unexpected undefined', getSourceCodeInfo(value, sourceCodeInfo))\n}\n\nexport function isUnknownRecord(value: unknown): value is Record<string, unknown> {\n return value !== null && typeof value === 'object' && !Array.isArray(value)\n}\n\nexport function assertUnknownRecord(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is UnknownRecord {\n if (!isUnknownRecord(value)) {\n throw new LitsError(\n `Expected ${'UnknownRecord'}, got ${valueToString(value)}.`,\n getSourceCodeInfo(value, sourceCodeInfo),\n )\n }\n}\n\nexport function asUnknownRecord(value: unknown, sourceCodeInfo?: SourceCodeInfo): UnknownRecord {\n assertUnknownRecord(value, sourceCodeInfo)\n return value\n}\n","import type { LitsFunction, NativeJsFunction, NormalBuiltinFunction, UserDefinedFunction } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\nimport { FUNCTION_SYMBOL } from '../utils/symbols'\nimport { isUnknownRecord } from '.'\n\nexport function isLitsFunction(value: unknown): value is LitsFunction {\n if (value === null || typeof value !== 'object')\n return false\n\n return !!(value as LitsFunction)[FUNCTION_SYMBOL]\n}\nexport function asLitsFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): LitsFunction {\n assertLitsFunction(value, sourceCodeInfo)\n return value\n}\nexport function assertLitsFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is LitsFunction {\n if (!isLitsFunction(value))\n throw getAssertionError('LitsFunction', value, sourceCodeInfo)\n}\n\nexport function isUserDefinedFunction(value: unknown): value is UserDefinedFunction {\n return isLitsFunction(value) && value.functionType === 'UserDefined'\n}\nexport function asUserDefinedFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): UserDefinedFunction {\n assertUserDefinedFunction(value, sourceCodeInfo)\n return value\n}\nexport function assertUserDefinedFunction(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is UserDefinedFunction {\n if (!isUserDefinedFunction(value))\n throw getAssertionError('NativeJsFunction', value, sourceCodeInfo)\n}\n\nexport function isNativeJsFunction(value: unknown): value is NativeJsFunction {\n return isLitsFunction(value) && value.functionType === 'NativeJsFunction'\n}\nexport function asNativeJsFunction(value: unknown, sourceCodeInfo?: SourceCodeInfo): NativeJsFunction {\n assertNativeJsFunction(value, sourceCodeInfo)\n return value\n}\nexport function assertNativeJsFunction(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is NativeJsFunction {\n if (!isNativeJsFunction(value))\n throw getAssertionError('NativeJsFunction', value, sourceCodeInfo)\n}\n\nexport function isBuiltinFunction(value: unknown): value is NormalBuiltinFunction {\n return isUnknownRecord(value) && value.functionType === 'Builtin'\n}\n","import { LitsError } from '../errors'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { valueToString } from '../utils/debug/debugTools'\nimport { getSourceCodeInfo } from '../utils/debug/getSourceCodeInfo'\n\ntype SignOptions =\n | {\n positive?: true\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: true\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: true\n nonNegative?: never\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: true\n zero?: never\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: true\n nonZero?: never\n }\n | {\n positive?: never\n negative?: never\n nonPositive?: never\n nonNegative?: never\n zero?: never\n nonZero?: true\n }\n\ntype GtOptions =\n | {\n gt?: number\n gte?: never\n }\n | {\n gt?: never\n gte?: number\n }\n\ntype LtOptions =\n | {\n lt?: number\n lte?: never\n }\n | {\n lt?: never\n lte?: number\n }\n\ntype NumberOptions = {\n integer?: true\n finite?: true\n} & SignOptions &\nGtOptions &\nLtOptions\n\nfunction getRangeString(options: NumberOptions): string {\n const hasUpperAndLowerBound\n = (typeof options.gt === 'number' || typeof options.gte === 'number')\n && (typeof options.lt === 'number' || typeof options.lte === 'number')\n if (hasUpperAndLowerBound) {\n return `${typeof options.gt === 'number' ? `${options.gt} < n ` : `${options.gte} <= n `}${\n typeof options.lt === 'number' ? `< ${options.lt}` : `<= ${options.lte}`\n }`\n }\n else if (typeof options.gt === 'number' || typeof options.gte === 'number') {\n return `${typeof options.gt === 'number' ? `n > ${options.gt}` : `n >= ${options.gte}`}`\n }\n else if (typeof options.lt === 'number' || typeof options.lte === 'number') {\n return `${typeof options.lt === 'number' ? `n < ${options.lt}` : `n <= ${options.lte}`}`\n }\n else { return '' }\n}\n\nfunction getSignString(options: NumberOptions): string {\n return options.positive\n ? 'positive'\n : options.negative\n ? 'negative'\n : options.nonNegative\n ? 'non negative'\n : options.nonPositive\n ? 'non positive'\n : options.nonZero\n ? 'non zero'\n : ''\n}\n\nfunction getNumberTypeName(options: NumberOptions): string {\n if (options.zero)\n return 'zero'\n\n const sign = getSignString(options)\n const numberType = options.integer ? 'integer' : 'number'\n const finite = options.finite ? 'finite' : ''\n const range = getRangeString(options)\n\n return [sign, finite, numberType, range].filter(x => !!x).join(' ')\n}\n\nexport function isNumber(value: unknown, options: NumberOptions = {}): value is number {\n if (typeof value !== 'number')\n return false\n\n if (Number.isNaN(value))\n return false\n\n if (options.integer && !Number.isInteger(value))\n return false\n\n if (options.finite && !Number.isFinite(value))\n return false\n\n if (options.zero && value !== 0)\n return false\n\n if (options.nonZero && value === 0)\n return false\n\n if (options.positive && value <= 0)\n return false\n\n if (options.negative && value >= 0)\n return false\n\n if (options.nonPositive && value > 0)\n return false\n\n if (options.nonNegative && value < 0)\n return false\n\n if (typeof options.gt === 'number' && value <= options.gt)\n return false\n\n if (typeof options.gte === 'number' && value < options.gte)\n return false\n\n if (typeof options.lt === 'number' && value >= options.lt)\n return false\n\n if (typeof options.lte === 'number' && value > options.lte)\n return false\n\n return true\n}\n\nexport function assertNumber(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n options: NumberOptions = {},\n): asserts value is number {\n if (!isNumber(value, options)) {\n throw new LitsError(\n `Expected ${getNumberTypeName(options)}, got ${valueToString(value)}.`,\n getSourceCodeInfo(value, sourceCodeInfo),\n )\n }\n}\n\nexport function asNumber(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: NumberOptions = {},\n): number {\n assertNumber(value, sourceCodeInfo, options)\n return value\n}\n","import type { Any, Coll, Obj, Seq } from '../interface'\nimport type { FunctionLike, RegularExpression } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\nimport { REGEXP_SYMBOL } from '../utils/symbols'\nimport { isLitsFunction } from './litsFunction'\n\nexport function isAny(value: unknown): value is Any {\n // TODO weak test\n return value !== undefined\n}\nexport function asAny(value: unknown, sourceCodeInfo?: SourceCodeInfo): Any {\n assertAny(value, sourceCodeInfo)\n return value\n}\nexport function assertAny(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Any {\n if (!isAny(value))\n throw getAssertionError('not undefined', value, sourceCodeInfo)\n}\n\nexport function isSeq(value: unknown): value is Seq {\n return Array.isArray(value) || typeof value === 'string'\n}\nexport function asSeq(value: unknown, sourceCodeInfo?: SourceCodeInfo): Seq {\n assertSeq(value, sourceCodeInfo)\n return value\n}\nexport function assertSeq(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Seq {\n if (!isSeq(value))\n throw getAssertionError('string or array', value, sourceCodeInfo)\n}\n\nexport function isObj(value: unknown): value is Obj {\n return !(\n value === null\n || typeof value !== 'object'\n || Array.isArray(value)\n || value instanceof RegExp\n || isLitsFunction(value)\n || isRegularExpression(value)\n )\n}\nexport function asObj(value: unknown, sourceCodeInfo?: SourceCodeInfo): Obj {\n assertObj(value, sourceCodeInfo)\n return value\n}\nexport function assertObj(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Obj {\n if (!isObj(value))\n throw getAssertionError('object', value, sourceCodeInfo)\n}\n\nexport function isColl(value: unknown): value is Coll {\n return isSeq(value) || isObj(value)\n}\nexport function asColl(value: unknown, sourceCodeInfo?: SourceCodeInfo): Coll {\n assertColl(value, sourceCodeInfo)\n return value\n}\nexport function assertColl(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is Coll {\n if (!isColl(value))\n throw getAssertionError('string, array or object', value, sourceCodeInfo)\n}\n\nexport function isRegularExpression(regexp: unknown): regexp is RegularExpression {\n if (regexp === null || typeof regexp !== 'object')\n return false\n\n return !!(regexp as RegularExpression)[REGEXP_SYMBOL]\n}\nexport function asRegularExpression(value: unknown, sourceCodeInfo?: SourceCodeInfo): RegularExpression {\n assertRegularExpression(value, sourceCodeInfo)\n return value\n}\nexport function assertRegularExpression(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is RegularExpression {\n if (!isRegularExpression(value))\n throw getAssertionError('RegularExpression', value, sourceCodeInfo)\n}\n\nexport function isStringOrRegularExpression(value: unknown): value is string | RegularExpression {\n return isRegularExpression(value) || typeof value === 'string'\n}\nexport function asStringOrRegularExpression(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): string | RegularExpression {\n assertStringOrRegularExpression(value, sourceCodeInfo)\n return value\n}\nexport function assertStringOrRegularExpression(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is string | RegularExpression {\n if (!isStringOrRegularExpression(value))\n throw getAssertionError('string or RegularExpression', value, sourceCodeInfo)\n}\n\nfunction isFunctionLike(value: unknown): value is FunctionLike {\n if (typeof value === 'number')\n return true\n if (isColl(value))\n return true\n if (isLitsFunction(value))\n return true\n\n return false\n}\nexport function asFunctionLike(value: unknown, sourceCodeInfo?: SourceCodeInfo): FunctionLike {\n assertFunctionLike(value, sourceCodeInfo)\n return value\n}\nexport function assertFunctionLike(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is FunctionLike {\n if (!isFunctionLike(value))\n throw getAssertionError('FunctionLike', value, sourceCodeInfo)\n}\n","import type { Arity } from '../builtin/interface'\nimport { LitsError } from '../errors'\nimport type { FunctionLike } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isColl } from '../typeGuards/lits'\nimport { valueToString } from './debug/debugTools'\n\nexport function arityAccepts(arity: Arity, nbrOfParams: number): boolean {\n const { min, max } = arity\n if (typeof min === 'number' && nbrOfParams < min) {\n return false\n }\n if (typeof max === 'number' && nbrOfParams > max) {\n return false\n }\n return true\n}\n\nexport function arityAcceptsMin(arity: Arity, nbrOfParams: number): boolean {\n const { min } = arity\n if (typeof min === 'number' && nbrOfParams < min) {\n return false\n }\n return true\n}\n\nexport function getCommonArityFromFunctions(params: FunctionLike[]): Arity | null {\n return params.reduce((acc: Arity | null, param): Arity | null => {\n if (acc === null) {\n return null\n }\n const arity: Arity = (typeof param === 'number' || isColl(param)) ? toFixedArity(1) : param.arity\n const { min: aMin, max: aMax } = arity\n const { min: bMin, max: bMax } = acc\n const min = typeof aMin === 'number' && typeof bMin === 'number'\n ? Math.max(aMin, bMin)\n : typeof aMin === 'number' ? aMin : typeof bMin === 'number' ? bMin : undefined\n const max = typeof aMax === 'number' && typeof bMax === 'number'\n ? Math.min(aMax, bMax)\n : typeof aMax === 'number' ? aMax : typeof bMax === 'number' ? bMax : undefined\n\n if (typeof min === 'number' && typeof max === 'number' && min > max) {\n return null\n }\n\n return { min, max }\n }, {})\n}\n\nexport function getArityFromFunction(param: FunctionLike): Arity {\n return (typeof param === 'number' || isColl(param)) ? toFixedArity(1) : param.arity\n}\n\nexport function assertNumberOfParams(arity: Arity, length: number, sourceCodeInfo: SourceCodeInfo | undefined): void {\n const { min, max } = arity\n if (typeof min === 'number' && length < min) {\n throw new LitsError(\n `Wrong number of arguments, expected at least ${min}, got ${valueToString(length)}.`,\n sourceCodeInfo,\n )\n }\n\n if (typeof max === 'number' && length > max) {\n throw new LitsError(\n `Wrong number of arguments, expected at most ${max}, got ${valueToString(length)}.`,\n sourceCodeInfo,\n )\n }\n}\n\nexport function canBeOperator(count: Arity): boolean {\n if (typeof count.max === 'number' && count.max < 2) {\n return false\n }\n\n if (typeof count.min === 'number' && count.min > 2) {\n return false\n }\n\n return true\n}\n\nexport function toFixedArity(arity: number): Arity {\n return { min: arity, max: arity }\n}\n","import { assertNumber } from '../../typeGuards/number'\nimport { toFixedArity } from '../../utils/arity'\nimport type { Argument, BuiltinNormalExpressions } from '../interface'\n\nfunction getOperatorArgs(a: 'integer', b: 'integer'): Record<string, Argument> {\n return { a: { type: a }, b: { type: b } }\n}\n\nexport const bitwiseNormalExpression: BuiltinNormalExpressions = {\n '<<': {\n evaluate: ([num, count], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return num << count\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Shifts $a arithmetically left by $b bit positions.',\n seeAlso: ['>>', '>>>'],\n examples: [\n '1 << 10',\n '<<(1, 10)',\n '<<(-4, 2)',\n ],\n },\n },\n '>>': {\n evaluate: ([num, count], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return num >> count\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Shifts $a arithmetically right by $b bit positions.',\n seeAlso: ['<<', '>>>'],\n examples: [\n '2048 >> 10',\n '>>(2048, 10)',\n '>>>(-16, 2)',\n '>>(4, 10)',\n ],\n },\n },\n '>>>': {\n evaluate: ([num, count], sourceCodeInfo): number => {\n assertNumber(num, sourceCodeInfo, { integer: true })\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return num >>> count\n },\n arity: toFixedArity(2),\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: { ...getOperatorArgs('integer', 'integer') },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Shifts $a arithmetically right by $b bit positions without sign extension.',\n seeAlso: ['<<', '>>'],\n examples: [\n '-16 >>> 2',\n '>>>(2048, 10)',\n '>>>(-16, 2)',\n '>>>(4, 10)',\n '>>>(-1, 10)',\n ],\n },\n },\n '&': {\n evaluate: ([first, ...rest], sourceCodeInfo): number => {\n assertNumber(first, sourceCodeInfo, { integer: true })\n\n return rest.reduce((result: number, value) => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n return result & value\n }, first)\n },\n arity: { min: 2 },\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: {\n ...getOperatorArgs('integer', 'integer'),\n c: { type: 'integer', rest: true },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: 'Returns bitwise `and` of all arguments.',\n seeAlso: ['|', 'xor', 'bitwise.bit-not', 'bitwise.bit-and-not'],\n examples: [\n '0b0011 & 0b0110',\n '&(0b0011, 0b0110)',\n '&(0b0011, 0b0110, 0b1001)',\n ],\n },\n },\n '|': {\n evaluate: ([first, ...rest], sourceCodeInfo): number => {\n assertNumber(first, sourceCodeInfo, { integer: true })\n\n return rest.reduce((result: number, value) => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n return result | value\n }, first)\n },\n arity: { min: 2 },\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: {\n ...getOperatorArgs('integer', 'integer'),\n c: { type: 'integer', rest: true },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: 'Returns bitwise `or` of all arguments.',\n seeAlso: ['&', 'xor', 'bitwise.bit-not', 'bitwise.bit-and-not'],\n examples: [\n '0b0011 | 0b0110',\n '|(0b0011, 0b0110)',\n '|(0b1000, 0b0100, 0b0010)',\n ],\n },\n },\n 'xor': {\n evaluate: ([first, ...rest], sourceCodeInfo): number => {\n assertNumber(first, sourceCodeInfo, { integer: true })\n\n return rest.reduce((result: number, value) => {\n assertNumber(value, sourceCodeInfo, { integer: true })\n return result ^ value\n }, first)\n },\n arity: { min: 2 },\n docs: {\n category: 'bitwise',\n returns: { type: 'integer' },\n args: {\n ...getOperatorArgs('integer', 'integer'),\n c: { type: 'integer', rest: true },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: 'Returns bitwise `xor` of all arguments.',\n seeAlso: ['&', '|', 'bitwise.bit-not', 'bitwise.bit-and-not'],\n examples: [\n '0b0011 xor 0b0110',\n 'xor(0b0011, 0b0110)',\n 'xor(0b11110000, 0b00111100, 0b10101010)',\n ],\n },\n },\n}\n","import type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\n\ntype StringAssertionOptions =\n | {\n nonEmpty?: true\n char?: never\n }\n | {\n nonEmpty?: never\n char?: true\n }\n\nexport function isString(value: unknown, options: StringAssertionOptions = {}): value is string {\n if (typeof value !== 'string')\n return false\n\n if (options.nonEmpty && value.length === 0)\n return false\n\n if (options.char && value.length !== 1)\n return false\n\n return true\n}\n\nexport function assertString(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: StringAssertionOptions = {},\n): asserts value is string {\n if (!isString(value, options)) {\n throw getAssertionError(\n `${options.nonEmpty ? 'non empty string' : options.char ? 'character' : 'string'}`,\n value,\n sourceCodeInfo,\n )\n }\n}\n\nexport function asString(\n value: unknown,\n sourceCodeInfo: SourceCodeInfo | undefined,\n options: StringAssertionOptions = {},\n): string {\n assertString(value, sourceCodeInfo, options)\n return value\n}\n\nexport function isStringOrNumber(value: unknown): value is string | number {\n return typeof value === 'string' || typeof value === 'number'\n}\nexport function asStringOrNumber(value: unknown, sourceCodeInfo?: SourceCodeInfo): string | number {\n assertStringOrNumber(value, sourceCodeInfo)\n return value\n}\nexport function assertStringOrNumber(\n value: unknown,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts value is string | number {\n if (!isStringOrNumber(value))\n throw getAssertionError('string or number', value, sourceCodeInfo)\n}\n","import type { Any, Coll, Obj } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asAny, isColl, isObj, isRegularExpression } from '../typeGuards/lits'\nimport { isNumber } from '../typeGuards/number'\nimport { asString, assertStringOrNumber } from '../typeGuards/string'\nimport { isUnknownRecord } from '../typeGuards'\nimport { LitsError } from '../errors'\n\nexport function collHasKey(coll: unknown, key: string | number): boolean {\n if (!isColl(coll))\n return false\n\n if (typeof coll === 'string' || Array.isArray(coll)) {\n if (!isNumber(key, { integer: true }))\n return false\n\n return key >= 0 && key < coll.length\n }\n return !!Object.getOwnPropertyDescriptor(coll, key)\n}\n\nexport function compare<T extends string | number>(a: T, b: T, sourceCodeInfo: SourceCodeInfo | undefined): number {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n\n if (typeof a === 'string' && typeof b === 'string') {\n return a < b ? -1 : a > b ? 1 : 0\n }\n if (typeof a === 'number' && typeof b === 'number') {\n return Math.sign((a) - (b))\n }\n throw new LitsError(`Cannot compare values of different types: ${typeof a} and ${typeof b}`, sourceCodeInfo)\n}\n\nexport function deepEqual(a: unknown, b: unknown, sourceCodeInfo?: SourceCodeInfo): boolean {\n if (a === b)\n return true\n\n if (typeof a === 'number' && typeof b === 'number')\n return approxEqual(a, b)\n\n if (Array.isArray(a) && Array.isArray(b)) {\n if (a.length !== b.length)\n return false\n\n for (let i = 0; i < a.length; i += 1) {\n if (!deepEqual(asAny(a[i], sourceCodeInfo), asAny(b[i], sourceCodeInfo), sourceCodeInfo))\n return false\n }\n return true\n }\n if (isRegularExpression(a) && isRegularExpression(b))\n return a.s === b.s && a.f === b.f\n\n if (isUnknownRecord(a) && isUnknownRecord(b)) {\n const aKeys = Object.keys(a)\n const bKeys = Object.keys(b)\n if (aKeys.length !== bKeys.length)\n return false\n\n for (let i = 0; i < aKeys.length; i += 1) {\n const key = asString(aKeys[i], sourceCodeInfo)\n if (!deepEqual(a[key], b[key], sourceCodeInfo))\n return false\n }\n return true\n }\n return false\n}\n\nexport function toNonNegativeInteger(num: number): number {\n return Math.max(0, Math.ceil(num))\n}\n\nexport function toAny(value: unknown): Any {\n return (value ?? null) as Any\n}\n\nfunction clone<T>(value: T): T {\n if (isObj(value)) {\n return Object.entries(value).reduce((result: Obj, entry) => {\n const [key, val] = entry\n result[key] = clone(val)\n return result\n }, {}) as T\n }\n if (Array.isArray(value))\n // eslint-disable-next-line ts/no-unsafe-return\n return value.map(item => clone(item)) as unknown as T\n\n return value\n}\n\nexport function cloneColl<T extends Coll>(value: T): T {\n return clone(value)\n}\n\nexport function joinSets<T>(...results: Set<T>[]): Set<T> {\n const result = new Set<T>()\n for (const symbols of results)\n symbols.forEach(symbol => result.add(symbol))\n\n return result\n}\n\nexport function addToSet<T>(target: Set<T>, source: Set<T>): void {\n source.forEach(symbol => target.add(symbol))\n}\n\nexport const EPSILON = 1e-10\n\nexport function approxEqual(a: number, b: number, epsilon: number = EPSILON): boolean {\n if (a === b) {\n return true\n }\n\n const diff = Math.abs(a - b)\n\n if (a === 0 || b === 0 || diff < epsilon) {\n // Use absolute error for values near zero\n return diff < epsilon\n }\n const absA = Math.abs(a)\n const absB = Math.abs(b)\n\n // Use relative error for larger values\n return diff / (absA + absB) < epsilon\n}\n\nexport function approxZero(value: number): boolean {\n return Math.abs(value) < EPSILON\n}\n\nexport function smartTrim(str: string, minIndent = 0): string {\n const lines = str.split('\\n')\n while (lines[0]?.match(/^\\s*$/)) {\n lines.shift() // Remove leading empty lines\n }\n while (lines[lines.length - 1]?.match(/^\\s*$/)) {\n lines.pop() // Remove trailing empty lines\n }\n const indent = lines.reduce((acc, line) => {\n if (line.match(/^\\s*$/))\n return acc // Skip empty lines\n const lineIndent = line.match(/^\\s*/)![0].length\n return Math.min(acc, lineIndent)\n }, Infinity)\n return lines.map(line => ' '.repeat(minIndent) + line.slice(indent)).join('\\n').trimEnd()\n}\n","import type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\n\n// isArray not needed, use Array.isArary\nexport function asArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): unknown[] {\n assertArray(value, sourceCodeInfo)\n return value\n}\nexport function assertArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is unknown[] {\n if (!Array.isArray(value))\n throw getAssertionError('array', value, sourceCodeInfo)\n}\n\nexport function isStringArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every(v => typeof v === 'string')\n}\nexport function asStringArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): string[] {\n assertStringArray(value, sourceCodeInfo)\n return value\n}\nexport function assertStringArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is string[] {\n if (!isStringArray(value))\n throw getAssertionError('array of strings', value, sourceCodeInfo)\n}\n\nexport function isCharArray(value: unknown): value is string[] {\n return Array.isArray(value) && value.every(v => typeof v === 'string' && v.length === 1)\n}\nexport function asCharArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): string[] {\n assertCharArray(value, sourceCodeInfo)\n return value\n}\nexport function assertCharArray(value: unknown, sourceCodeInfo?: SourceCodeInfo): asserts value is string[] {\n if (!isCharArray(value))\n throw getAssertionError('array of strings', value, sourceCodeInfo)\n}\n","/**\n * MaybePromise utilities for transparent async support.\n *\n * The sync path stays zero-overhead — when no async JS functions are involved,\n * everything runs synchronously with only `instanceof Promise` checks as overhead.\n * When an async value is detected, the evaluation chain switches to Promise-based\n * execution for the remainder.\n */\n\nexport type MaybePromise<T> = T | Promise<T>\n\n/**\n * Chain a value that might be a Promise. If the value is sync, calls fn synchronously.\n * If it's a Promise, chains with .then().\n */\nexport function chain<T, U>(value: MaybePromise<T>, fn: (v: T) => MaybePromise<U>): MaybePromise<U> {\n if (value instanceof Promise) {\n return value.then(fn)\n }\n return fn(value)\n}\n\n/**\n * Like Array.map but handles MaybePromise callbacks sequentially.\n * In the sync case, runs as a simple loop. Switches to async only when needed.\n */\nexport function mapSequential<T, U>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<U>,\n): MaybePromise<U[]> {\n const results: U[] = []\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingMap(result, results, arr, fn, i)\n }\n results.push(result)\n }\n return results\n}\n\nasync function chainRemainingMap<T, U>(\n currentPromise: Promise<U>,\n results: U[],\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<U>,\n startIndex: number,\n): Promise<U[]> {\n results.push(await currentPromise)\n for (let i = startIndex + 1; i < arr.length; i++) {\n results.push(await fn(arr[i]!, i))\n }\n return results\n}\n\n/**\n * Like Array.reduce but handles MaybePromise callbacks sequentially.\n * In the sync case, runs as a simple loop. Switches to async only when needed.\n */\nexport function reduceSequential<T, U>(\n arr: readonly T[],\n fn: (acc: U, elem: T, index: number) => MaybePromise<U>,\n initial: U,\n): MaybePromise<U> {\n let result: U = initial\n for (let i = 0; i < arr.length; i++) {\n const next = fn(result, arr[i]!, i)\n if (next instanceof Promise) {\n return chainRemainingReduce(next, arr, fn, i)\n }\n result = next\n }\n return result\n}\n\nasync function chainRemainingReduce<T, U>(\n currentPromise: Promise<U>,\n arr: readonly T[],\n fn: (acc: U, elem: T, index: number) => MaybePromise<U>,\n startIndex: number,\n): Promise<U> {\n let result = await currentPromise\n for (let i = startIndex + 1; i < arr.length; i++) {\n result = await fn(result, arr[i]!, i)\n }\n return result\n}\n\n/**\n * Like Array.forEach but handles MaybePromise callbacks sequentially.\n * In the sync case, runs as a simple loop. Switches to async only when needed.\n */\nexport function forEachSequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<void>,\n): MaybePromise<void> {\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingForEach(result, arr, fn, i)\n }\n }\n}\n\nasync function chainRemainingForEach<T>(\n currentPromise: Promise<void>,\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<void>,\n startIndex: number,\n): Promise<void> {\n await currentPromise\n for (let i = startIndex + 1; i < arr.length; i++) {\n await fn(arr[i]!, i)\n }\n}\n\n/**\n * Try/catch that handles MaybePromise values correctly.\n * If tryFn returns a Promise, catches both sync throws and Promise rejections.\n */\nexport function tryCatch<T>(\n tryFn: () => MaybePromise<T>,\n catchFn: (error: unknown) => MaybePromise<T>,\n): MaybePromise<T> {\n try {\n const result = tryFn()\n if (result instanceof Promise) {\n return result.catch(catchFn)\n }\n return result\n }\n catch (error) {\n return catchFn(error)\n }\n}\n\n/**\n * Like Array.some but handles MaybePromise callbacks sequentially.\n * Returns the first truthy MaybePromise result, or false.\n */\nexport function someSequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n): MaybePromise<boolean> {\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingSome(result, arr, fn, i)\n }\n if (result)\n return true\n }\n return false\n}\n\nasync function chainRemainingSome<T>(\n currentPromise: Promise<unknown>,\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n startIndex: number,\n): Promise<boolean> {\n if (await currentPromise)\n return true\n for (let i = startIndex + 1; i < arr.length; i++) {\n if (await fn(arr[i]!, i))\n return true\n }\n return false\n}\n\n/**\n * Like Array.every but handles MaybePromise callbacks sequentially.\n * Returns false as soon as a falsy result is found.\n */\nexport function everySequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n): MaybePromise<boolean> {\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingEvery(result, arr, fn, i)\n }\n if (!result)\n return false\n }\n return true\n}\n\nasync function chainRemainingEvery<T>(\n currentPromise: Promise<unknown>,\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n startIndex: number,\n): Promise<boolean> {\n if (!await currentPromise)\n return false\n for (let i = startIndex + 1; i < arr.length; i++) {\n if (!await fn(arr[i]!, i))\n return false\n }\n return true\n}\n\n/**\n * Like Array.filter but handles MaybePromise callbacks sequentially.\n * Returns the filtered array.\n */\nexport function filterSequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n): MaybePromise<T[]> {\n const results: T[] = []\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingFilter(result, results, arr, fn, i)\n }\n if (result)\n results.push(arr[i]!)\n }\n return results\n}\n\nasync function chainRemainingFilter<T>(\n currentPromise: Promise<unknown>,\n results: T[],\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n startIndex: number,\n): Promise<T[]> {\n if (await currentPromise)\n results.push(arr[startIndex]!)\n for (let i = startIndex + 1; i < arr.length; i++) {\n if (await fn(arr[i]!, i))\n results.push(arr[i]!)\n }\n return results\n}\n\n/**\n * Like Array.findIndex but handles MaybePromise callbacks sequentially.\n * Returns -1 if no element matches.\n */\nexport function findIndexSequential<T>(\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n): MaybePromise<number> {\n for (let i = 0; i < arr.length; i++) {\n const result = fn(arr[i]!, i)\n if (result instanceof Promise) {\n return chainRemainingFindIndex(result, arr, fn, i)\n }\n if (result)\n return i\n }\n return -1\n}\n\nasync function chainRemainingFindIndex<T>(\n currentPromise: Promise<unknown>,\n arr: readonly T[],\n fn: (elem: T, index: number) => MaybePromise<unknown>,\n startIndex: number,\n): Promise<number> {\n if (await currentPromise)\n return startIndex\n for (let i = startIndex + 1; i < arr.length; i++) {\n if (await fn(arr[i]!, i))\n return i\n }\n return -1\n}\n","import type { ContextStack } from '../../evaluator/ContextStack'\nimport type { ExecuteFunction } from '../../evaluator/interface'\nimport type { Any, Arr, Coll, Obj, Seq } from '../../interface'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { collHasKey, deepEqual, toAny } from '../../utils'\nimport { asAny, asFunctionLike, assertAny, assertColl, assertFunctionLike, assertObj, assertSeq, isObj, isSeq } from '../../typeGuards/lits'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { assertNumber, isNumber } from '../../typeGuards/number'\nimport { assertString, assertStringOrNumber, isString, isStringOrNumber } from '../../typeGuards/string'\nimport type { FunctionLike } from '../../parser/types'\nimport { LitsError } from '../../errors'\nimport { toFixedArity } from '../../utils/arity'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain, mapSequential, reduceSequential } from '../../utils/maybePromise'\n\nfunction mapObjects({\n colls,\n contextStack,\n executeFunction,\n fn,\n sourceCodeInfo,\n}: {\n colls: unknown[]\n fn: FunctionLike\n sourceCodeInfo: SourceCodeInfo | undefined\n contextStack: ContextStack\n executeFunction: ExecuteFunction\n}): MaybePromise<Obj> {\n assertObj(colls[0], sourceCodeInfo)\n const keys = Object.keys(colls[0])\n const params: Record<string, unknown[]> = {}\n colls.forEach((obj) => {\n assertObj(obj, sourceCodeInfo)\n const objKeys = Object.keys(obj)\n if (objKeys.length !== keys.length) {\n throw new LitsError(`All objects must have the same keys. Expected: ${keys.join(', ')}. Found: ${objKeys.join(', ')}`, sourceCodeInfo)\n }\n if (!objKeys.every(key => keys.includes(key))) {\n throw new LitsError(`All objects must have the same keys. Expected: ${keys.join(', ')}. Found: ${objKeys.join(', ')}`, sourceCodeInfo)\n }\n Object.entries(obj).forEach(([key, value]) => {\n if (!params[key])\n params[key] = []\n params[key].push(value)\n })\n })\n\n const initialObj: Obj = {}\n return reduceSequential(keys, (result: Obj, key) => {\n return chain(\n executeFunction(fn, params[key]!, contextStack, sourceCodeInfo),\n (value) => {\n result[key] = value\n return result\n },\n )\n }, initialObj)\n}\n\nfunction get(coll: Coll, key: string | number): Any | undefined {\n if (isObj(coll)) {\n if (typeof key === 'string' && collHasKey(coll, key))\n return toAny(coll[key])\n }\n else {\n if (isNumber(key, { nonNegative: true, integer: true }) && key >= 0 && key < coll.length)\n return toAny(coll[key])\n }\n return undefined\n}\n\nfunction assoc(coll: Coll, key: string | number, value: Any, sourceCodeInfo?: SourceCodeInfo) {\n assertColl(coll, sourceCodeInfo)\n assertStringOrNumber(key, sourceCodeInfo)\n if (Array.isArray(coll) || typeof coll === 'string') {\n assertNumber(key, sourceCodeInfo, { integer: true })\n assertNumber(key, sourceCodeInfo, { gte: 0 })\n assertNumber(key, sourceCodeInfo, { lte: coll.length })\n if (typeof coll === 'string') {\n assertString(value, sourceCodeInfo, { char: true })\n return `${coll.slice(0, key)}${value}${coll.slice(key + 1)}`\n }\n const copy = [...coll]\n copy[key] = value\n return copy\n }\n assertString(key, sourceCodeInfo)\n const copy = { ...coll }\n copy[key] = value\n return copy\n}\n\nexport const collectionNormalExpression: BuiltinNormalExpressions = {\n 'filter': {\n evaluate: ([coll, fn]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Coll> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n if (Array.isArray(coll)) {\n return reduceSequential(coll, (result: Arr, elem) => {\n return chain(executeFunction(fn, [elem], contextStack, sourceCodeInfo), (keep) => {\n if (keep)\n result.push(elem)\n return result\n })\n }, [] as Arr)\n }\n if (isString(coll)) {\n const chars = coll.split('')\n return chain(\n reduceSequential(chars, (result: string[], elem) => {\n return chain(executeFunction(fn, [elem], contextStack, sourceCodeInfo), (keep) => {\n if (keep)\n result.push(elem)\n return result\n })\n }, [] as string[]),\n filtered => filtered.join(''),\n )\n }\n const entries = Object.entries(coll)\n const initialObj: Obj = {}\n return reduceSequential(entries, (result: Obj, [key, value]) => {\n return chain(executeFunction(fn, [value], contextStack, sourceCodeInfo), (keep) => {\n if (keep)\n result[key] = value\n return result\n })\n }, initialObj)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n coll: { type: 'collection' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['coll', 'fun'] }],\n description: 'Creates a new collection with all elements that pass the test implemented by $fun.',\n seeAlso: ['collection.filteri', 'map', 'sequence.remove'],\n examples: [\n `\nfilter(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)`,\n `\nfilter(\n [5, 10, 15, 20],\n -> $ > 10\n)`,\n `\nfilter(\n { a: 1, b: 2 },\n odd?\n)`,\n ],\n },\n },\n 'map': {\n evaluate: (params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const fn = asFunctionLike(params.at(-1), sourceCodeInfo)\n\n if (isObj(params[0])) {\n return mapObjects({\n colls: params.slice(0, -1),\n fn,\n sourceCodeInfo,\n contextStack,\n executeFunction,\n })\n }\n\n const seqs = params.slice(0, -1) as Seq[]\n assertSeq(seqs[0], sourceCodeInfo)\n\n const isStr = typeof seqs[0] === 'string'\n let len = seqs[0].length\n seqs.slice(1).forEach((seq) => {\n if (isStr) {\n assertString(seq, sourceCodeInfo)\n }\n else {\n assertArray(seq, sourceCodeInfo)\n }\n len = Math.min(len, seq.length)\n })\n\n const paramArray: unknown[][] = []\n for (let i = 0; i < len; i++) {\n paramArray.push(seqs.map(seq => seq[i]))\n }\n\n const mapped = mapSequential(paramArray, p => executeFunction(fn, p, contextStack, sourceCodeInfo))\n\n if (!isStr) {\n return mapped\n }\n return chain(mapped, (resolvedMapped) => {\n resolvedMapped.forEach(char => assertString(char, sourceCodeInfo))\n return resolvedMapped.join('')\n })\n },\n arity: { min: 2 },\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n colls: { type: 'collection', rest: true, description: 'At least one.' },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['colls', 'fun'] }],\n description: 'Creates a new collection populated with the results of calling $fun on every element in $colls.',\n seeAlso: ['collection.mapi', 'filter', 'reduce', 'mapcat', 'grid.map', 'grid.mapi'],\n examples: [\n '[1, 2, 3] map -',\n '[1, 2, 3] map -> -($)',\n 'map([\"Albert\", \"Mojir\", 42], str)',\n 'map([1, 2, 3], inc)',\n 'map([1, 2, 3], [1, 10, 100], *)',\n 'map({ a: 1, b: 2 }, inc)',\n 'map({ a: 1, b: 2 }, { a: 10, b: 20 }, +)',\n ],\n },\n },\n 'reduce': {\n evaluate: ([coll, fn, initial], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertColl(coll, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n assertAny(initial, sourceCodeInfo)\n\n if (typeof coll === 'string') {\n assertString(initial, sourceCodeInfo)\n if (coll.length === 0)\n return initial\n\n return reduceSequential(coll.split(''), (result: Any, elem) => {\n return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo)\n }, initial)\n }\n else if (Array.isArray(coll)) {\n if (coll.length === 0)\n return initial\n\n return reduceSequential(coll, (result: Any, elem) => {\n return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo)\n }, initial)\n }\n else {\n if (Object.keys(coll).length === 0)\n return initial\n\n return reduceSequential(Object.entries(coll), (result: Any, [, elem]) => {\n return executeFunction(fn, [result, elem], contextStack, sourceCodeInfo)\n }, initial)\n }\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'any' },\n args: {\n fun: { type: 'function' },\n coll: { type: 'collection' },\n initial: { type: 'any' },\n },\n variants: [{ argumentNames: ['coll', 'fun', 'initial'] }],\n description: 'Runs $fun function on each element of the $coll, passing in the return value from the calculation on the preceding element. The final result of running the reducer across all elements of the $coll is a single value.',\n seeAlso: ['collection.reduce-right', 'collection.reducei', 'collection.reductions', 'map', 'grid.reduce', 'grid.reducei'],\n examples: [\n 'reduce([1, 2, 3], +, 0)',\n 'reduce([], +, 0)',\n 'reduce({ a: 1, b: 2 }, +, 0)',\n `\nreduce(\n [1, 2, 3, 4, 5, 6, 7, 8, 9],\n (result, value) -> result + (even?(value) ? value : 0),\n 0)`,\n ],\n },\n },\n 'get': {\n evaluate: (params, sourceCodeInfo) => {\n const [coll, key] = params\n const defaultValue = toAny(params[2])\n assertStringOrNumber(key, sourceCodeInfo)\n if (coll === null)\n return defaultValue\n\n assertColl(coll, sourceCodeInfo)\n const result = get(coll, key)\n return result === undefined ? defaultValue : result\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'collection',\n returns: { type: 'any' },\n args: {\n 'a': { type: 'collection' },\n 'b': { type: ['string', 'integer'] },\n 'not-found': { type: 'any', description: 'Default value to return if $b is not found.' },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'not-found'] },\n ],\n description: 'Returns value in $a mapped at $b.',\n seeAlso: ['collection.get-in', 'contains?', 'find', 'nth'],\n examples: [\n '[1, 2, 3] get 1',\n '{ a: 1 } get \"a\"',\n '\"Albert\" get \"3\"',\n `\nget(\n [1, 2, 3],\n 1, // Optional comma after last argument\n)`,\n `\nget(\n [],\n 1\n)`,\n `\nget(\n [],\n 1,\n \"default\"\n)`,\n `\nget(\n { a: 1 },\n \"a\"\n)`,\n `\nget(\n { a: 1 },\n \"b\"\n)`,\n `\nget(\n { a: 1 },\n \"b\",\n \"default\"\n)`,\n `\nget(\n null,\n \"a\"\n)`,\n `\nget(\n null,\n \"b\",\n \"default\"\n)`,\n ],\n },\n },\n 'count': {\n evaluate: ([coll], sourceCodeInfo): number => {\n if (coll === null)\n return 0\n\n if (typeof coll === 'string')\n return coll.length\n\n assertColl(coll, sourceCodeInfo)\n if (Array.isArray(coll))\n return coll.length\n\n return Object.keys(coll).length\n },\n arity: toFixedArity(1),\n docs: {\n category: 'collection',\n returns: { type: 'number' },\n args: {\n coll: { type: ['collection', 'null'] },\n },\n variants: [{ argumentNames: ['coll'] }],\n description: 'Returns number of elements in $coll.',\n seeAlso: ['empty?'],\n examples: [\n 'count([1, 2, 3])',\n 'count([])',\n 'count({ a: 1 })',\n 'count(\"\")',\n 'count(\"Albert\")',\n 'count(null)',\n ],\n },\n },\n 'contains?': {\n evaluate: ([coll, key], sourceCodeInfo): boolean => {\n if (coll === null)\n return false\n\n assertColl(coll, sourceCodeInfo)\n if (isString(coll)) {\n assertString(key, sourceCodeInfo)\n return coll.includes(key)\n }\n if (isSeq(coll)) {\n assertAny(key, sourceCodeInfo)\n return !!coll.find(elem => deepEqual(asAny(elem), key, sourceCodeInfo))\n }\n assertString(key, sourceCodeInfo)\n return key in coll\n },\n arity: toFixedArity(2),\n docs: {\n category: 'collection',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['collection', 'null'] },\n b: { type: ['string', 'integer'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns `true` if $a contains $b, otherwise returns `false`. For strings, it checks if substring is included.',\n seeAlso: ['get', 'find', 'index-of'],\n examples: [\n '[1, 2, 3] contains? 1',\n 'null contains? 1',\n '{ a: 1, b: 2 } contains? \"a\"',\n `\ncontains?(\n [],\n 1\n)`,\n `\ncontains?(\n [1],\n 1\n)`,\n `\ncontains?(\n [1, 2, 3],\n 1\n)`,\n `\ncontains?(\n {},\n \"a\"\n)`,\n `\ncontains?(\n { a: 1, b: 2 },\n \"a\"\n)`,\n ],\n },\n },\n 'assoc': {\n evaluate: ([coll, key, value], sourceCodeInfo): Coll => {\n assertColl(coll, sourceCodeInfo)\n assertStringOrNumber(key, sourceCodeInfo)\n assertAny(value, sourceCodeInfo)\n return assoc(coll, key, value, sourceCodeInfo)\n },\n arity: toFixedArity(3),\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n coll: { type: 'collection' },\n key: { type: ['string', 'number'] },\n value: { type: 'any' },\n kvs: { type: 'any', description: 'Key-value pairs to associate.', rest: true },\n },\n variants: [\n { argumentNames: ['coll', 'key', 'value'] },\n { argumentNames: ['coll', 'key', 'value', 'kvs'] },\n ],\n description: `\nAdd or replace the value of element $key to $value in $coll. Repeated for all key-value pairs in $kvs.\nIf $coll is an 'array', $key must be \\`number\\` satisfying \\`0 <=\\` $key \\`<= length\\`.`,\n seeAlso: ['collection.assoc-in', 'dissoc', 'merge', 'collection.update'],\n examples: [\n `\nassoc(\n [1, 2, 3],\n 1,\n \"Two\"\n)`,\n `\nassoc(\n [1, 2, 3],\n 3,\n \"Four\"\n)`,\n `\nassoc(\n { a: 1, b: 2 },\n \"a\",\n \"One\")`,\n `\nassoc(\n { a: 1, b: 2 },\n \"c\",\n \"Three\")`,\n `\nassoc(\n \"Albert\",\n 6,\n \"a\")`,\n ],\n },\n },\n '++': {\n evaluate: (params, sourceCodeInfo): Any => {\n if (!isNumber(params[0])) {\n assertColl(params[0], sourceCodeInfo)\n }\n if (Array.isArray(params[0])) {\n return params.reduce((result: Arr, arr) => {\n assertArray(arr, sourceCodeInfo)\n return result.concat(arr)\n }, [])\n }\n else if (isStringOrNumber(params[0])) {\n return params.reduce((result: string, s) => {\n assertStringOrNumber(s, sourceCodeInfo)\n return `${result}${s}`\n }, '')\n }\n else {\n return params.reduce((result: Obj, obj) => {\n assertObj(obj, sourceCodeInfo)\n return Object.assign(result, obj)\n }, {})\n }\n },\n arity: { min: 1 },\n docs: {\n category: 'collection',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'collection' },\n colls: { type: 'collection', rest: true },\n },\n variants: [\n { argumentNames: ['a'] },\n { argumentNames: ['a', 'colls'] },\n ],\n description: 'Concatenates collections into one collection.',\n seeAlso: ['mapcat', 'str', 'join', 'push', 'sequence.unshift'],\n examples: [\n '\"Albert\" ++ \" \" ++ \"Mojir\"',\n '\"Albert\" ++ \"Mojir\"',\n\n '++(\"Albert\", \"-\", \"Mojir\")',\n '++(\"Albert\")',\n\n '++(\"A\", \"l\", \"b\", \"e\", \"r\", \"t\")',\n '++([1, 2], [3, 4])',\n '++([], [3, 4])',\n '++([1, 2], [])',\n '++([1, 2], [3, 4], [5, 6])',\n '++([])',\n '++({ a: 1, b: 2 }, { b: 1, c: 2 })',\n '++({}, { a: 1 })',\n ],\n },\n },\n}\n","import type { Arr } from '../../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { asNumber, assertNumber } from '../../typeGuards/number'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { assertFunctionLike } from '../../typeGuards/lits'\nimport { toFixedArity } from '../../utils/arity'\nimport { chain, mapSequential } from '../../utils/maybePromise'\n\nexport const arrayNormalExpression: BuiltinNormalExpressions = {\n 'range': {\n evaluate: (params, sourceCodeInfo): Arr => {\n const [first, second, third] = params\n let from: number\n let to: number\n let step: number\n assertNumber(first, sourceCodeInfo, { finite: true })\n\n if (params.length === 1) {\n from = 0\n to = first\n step = to >= 0 ? 1 : -1\n }\n else if (params.length === 2) {\n assertNumber(second, sourceCodeInfo, { finite: true })\n from = first\n to = second\n step = to >= from ? 1 : -1\n }\n else {\n assertNumber(second, sourceCodeInfo, { finite: true })\n assertNumber(third, sourceCodeInfo, { finite: true })\n from = first\n to = second\n step = third\n if (to > from)\n assertNumber(step, sourceCodeInfo, { positive: true })\n else if (to < from)\n assertNumber(step, sourceCodeInfo, { negative: true })\n else\n assertNumber(step, sourceCodeInfo, { nonZero: true })\n }\n\n const result: number[] = []\n\n for (let i = from; step < 0 ? i > to : i < to; i += step)\n result.push(i)\n\n return result\n },\n arity: { min: 1, max: 3 },\n docs: {\n category: 'array',\n returns: { type: 'number', array: true },\n args: {\n a: { type: 'number' },\n b: { type: 'number' },\n step: { type: 'number' },\n },\n variants: [\n { argumentNames: ['b'] },\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'step'] },\n ],\n description: `$range creates an array with a range of numbers from $a to $b (exclusive), by $step.\n\n$a defaults to 0.\n$step defaults to 1.`,\n seeAlso: ['repeat', 'vector.linspace'],\n examples: [\n 'range(4)',\n 'range(1, 4)',\n '1 range 10',\n 'range(0.4, 4.9)',\n `\nrange(\n 0.25, // start value\n 1, // end value (exclusive)\n 0.25, // step value\n)`,\n ],\n },\n },\n\n 'repeat': {\n evaluate: ([value, count], sourceCodeInfo): Arr => {\n assertNumber(count, sourceCodeInfo, { integer: true, nonNegative: true })\n const result: Arr = []\n for (let i = 0; i < count; i += 1)\n result.push(value)\n\n return result\n },\n arity: toFixedArity(2),\n docs: {\n category: 'array',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'any' },\n b: { type: 'integer' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns an array with $a repeated $b times.',\n seeAlso: ['range', 'vector.ones', 'vector.zeros', 'vector.fill', 'vector.generate', 'string.string-repeat'],\n examples: [\n 'repeat(10, 3)',\n 'repeat(10, 0)',\n '\"Albert\" repeat 5',\n ],\n },\n },\n\n 'flatten': {\n evaluate: ([seq, depth], sourceCodeInfo): Arr => {\n assertArray(seq, sourceCodeInfo)\n\n const actualDepth = depth === undefined || depth === Number.POSITIVE_INFINITY\n ? Number.POSITIVE_INFINITY\n : asNumber(depth, sourceCodeInfo, { integer: true, nonNegative: true })\n\n return seq.flat(actualDepth)\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'array',\n returns: { type: 'any', array: true },\n args: {\n x: { type: ['array', 'any'], description: 'If $x is not an array, `[ ]` is returned.' },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'Takes a nested array $x and flattens it.',\n seeAlso: ['mapcat'],\n examples: [\n 'flatten([1, 2, [3, 4], 5])',\n `\nlet foo = \"bar\";\nflatten([\n 1,\n \" 2 A \",\n [foo, [4, [\"ABC\"]]],\n 6,\n])`,\n ],\n hideOperatorForm: true,\n },\n },\n 'mapcat': {\n evaluate: ([arr, fn], sourceCodeInfo, contextStack, { executeFunction }) => {\n assertArray(arr, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n return chain(\n mapSequential(arr, elem => executeFunction(fn, [elem], contextStack, sourceCodeInfo)),\n mapped => mapped.flat(1),\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'array',\n returns: { type: 'collection' },\n args: {\n a: { type: 'collection' },\n b: { type: 'function' },\n colls: { type: 'collection', array: true },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['colls', 'fun'] }],\n description: 'Returns the result of applying concat to the result of applying map to $fun and $colls.',\n seeAlso: ['flatten', 'map', '++'],\n examples: [\n '[[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]] mapcat reverse',\n 'mapcat([[3, 2, 1, 0], [6, 5, 4], [9, 8, 7]], reverse)',\n '[[3, 2, 1, 0,], [6, 5, 4,], [9, 8, 7]] mapcat reverse',\n `\nlet foo = (n) -> do\n [n - 1, n, n + 1]\nend;\n[1, 2, 3] mapcat foo`,\n `\nmapcat(\n [[1, 2], [2, 2], [2, 3]],\n -> $ filter odd?\n)`,\n ],\n },\n },\n 'moving-fn': {\n evaluate: ([arr, windowSize, fn], sourceCodeInfo, contextStack, { executeFunction }) => {\n assertArray(arr, sourceCodeInfo)\n assertNumber(windowSize, sourceCodeInfo, { integer: true, lte: arr.length })\n assertFunctionLike(fn, sourceCodeInfo)\n\n const windows: Arr[] = []\n for (let i = 0; i <= arr.length - windowSize; i++) {\n windows.push(arr.slice(i, i + windowSize))\n }\n return mapSequential(windows, window => executeFunction(fn, [window], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(3),\n docs: {\n category: 'array',\n returns: { type: 'array' },\n args: {\n arr: { type: 'array' },\n windowSize: { type: 'number', description: 'The size of the moving window.' },\n fn: { type: 'function' },\n },\n variants: [{ argumentNames: ['arr', 'windowSize', 'fn'] }],\n description: 'Returns the result of applying $fn to each moving window of size $windowSize in $arr.',\n seeAlso: ['running-fn', 'vector.moving-mean'],\n examples: [\n 'moving-fn([1, 2, 3], 2, sum)',\n 'moving-fn([1, 2, 3], 1, sum)',\n 'moving-fn([1, 2, 3], 3, sum)',\n ],\n },\n },\n 'running-fn': {\n evaluate: ([arr, fn], sourceCodeInfo, contextStack, { executeFunction }) => {\n assertArray(arr, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n const subArrays: Arr[] = []\n for (let i = 0; i < arr.length; i += 1) {\n subArrays.push(arr.slice(0, i + 1))\n }\n return mapSequential(subArrays, subArr => executeFunction(fn, [subArr], contextStack, sourceCodeInfo))\n },\n arity: toFixedArity(2),\n docs: {\n category: 'array',\n returns: { type: 'array' },\n args: {\n a: { type: 'array' },\n b: { type: 'function' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns the result of applying $b to each element of $a.',\n seeAlso: ['moving-fn', 'vector.running-mean'],\n examples: [\n 'running-fn([1, 2, 3], sum)',\n 'running-fn([1, 2, 3], max)',\n 'running-fn([1, 2, 3], min)',\n ],\n },\n },\n}\n","import type { Any, Arr, Seq } from '../../interface'\nimport { assertCharArray } from '../../typeGuards/array'\nimport { asAny, assertAny, assertFunctionLike, assertSeq } from '../../typeGuards/lits'\nimport { assertNumber } from '../../typeGuards/number'\nimport { assertString, assertStringOrNumber } from '../../typeGuards/string'\nimport { compare, deepEqual, toAny } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain, reduceSequential } from '../../utils/maybePromise'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const sequenceNormalExpression: BuiltinNormalExpressions = {\n 'nth': {\n evaluate: (params, sourceCodeInfo): Any => {\n const [seq, i] = params\n const defaultValue = toAny(params[2])\n\n assertNumber(i, sourceCodeInfo, { integer: true })\n\n if (seq === null)\n return defaultValue\n\n assertSeq(seq, sourceCodeInfo)\n if (i >= 0 && i < seq.length) {\n const result = toAny(seq[i])\n return result\n }\n else {\n return defaultValue\n }\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: {\n 'a': { type: 'sequence' },\n 'b': { type: 'integer' },\n 'seq': { type: ['sequence', 'null'] },\n 'n': { type: 'integer' },\n 'not-found': { type: 'any' },\n },\n variants: [\n { argumentNames: ['seq', 'n'] },\n { argumentNames: ['seq', 'n', 'not-found'] },\n ],\n description: 'Accesses element $n of $seq. Accessing out-of-bounds indices returns $not-found, if present, else `null`.',\n seeAlso: ['first', 'second', 'last', 'get', 'slice'],\n examples: [\n '[1, 2, 3] nth 1',\n '\"A string\" nth 3',\n 'nth([1, 2, 3], 1)',\n 'nth([1, 2, 3], 3)',\n 'nth([1, 2, 3], -1)',\n 'nth([1, 2, 3], 3, 99)',\n 'nth(\"A string\", 1)',\n 'nth(\"A string\", 3)',\n 'nth(\"A string\", -3)',\n 'nth(\"A string\", 30, \"X\")',\n 'nth(null, 1)',\n 'nth(null, 1, \"Default value\")',\n ],\n },\n },\n 'first': {\n evaluate: ([array], sourceCodeInfo): Any => {\n if (array === null)\n return null\n\n assertSeq(array, sourceCodeInfo)\n const result = toAny(array[0])\n\n return result\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns the first element of $seq. If $seq is empty or `null`, `null` is returned.',\n seeAlso: ['second', 'last', 'nth', 'rest', 'next'],\n examples: [\n 'first([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'first([])',\n 'first(null)',\n ],\n },\n },\n 'last': {\n evaluate: ([array], sourceCodeInfo): Any => {\n if (array === null)\n return null\n\n assertSeq(array, sourceCodeInfo)\n const result = toAny(array.at(-1))\n\n return result\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns the last element of $seq. If $seq is empty, `null` is returned.',\n seeAlso: ['first', 'second', 'nth', 'pop'],\n examples: [\n 'last([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'last([1, 2])',\n 'last([1])',\n 'last([])',\n 'last(null)',\n ],\n },\n },\n 'pop': {\n evaluate: ([seq], sourceCodeInfo): Seq => {\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n return seq.substring(0, seq.length - 1)\n }\n\n return seq.slice(0, seq.length - 1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'], rest: true },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns a copy of $seq with last element removed. If $seq is empty `null` is returned.',\n seeAlso: ['push', 'sequence.shift', 'last'],\n examples: [\n 'pop([1, 2, 3])',\n 'pop([])',\n ],\n },\n },\n 'index-of': {\n evaluate: ([seq, value], sourceCodeInfo): number | null => {\n assertAny(value, sourceCodeInfo)\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n assertString(value, sourceCodeInfo)\n const index = seq.indexOf(value)\n return index !== -1 ? index : null\n }\n else {\n const index = seq.findIndex(item => deepEqual(asAny(item, sourceCodeInfo), value), sourceCodeInfo)\n return index !== -1 ? index : null\n }\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: ['number', 'null'] },\n args: {\n a: { type: 'sequence' },\n b: { type: 'any' },\n seq: { type: ['sequence', 'null'] },\n x: { type: 'any' },\n },\n variants: [{ argumentNames: ['seq', 'x'] }],\n description: 'Returns the index of $x in $seq. If element is not present in $seq `null` is returned.',\n seeAlso: ['sequence.last-index-of', 'sequence.position', 'contains?'],\n examples: [\n '[[1], [2], [1], [2]] index-of [1]',\n 'index-of([\"Albert\", \"Mojir\", 160, [1, 2]], \"Mojir\")',\n 'index-of([5, 10, 15, 20], 15)',\n 'index-of([5, 10, 15, 20], 1)',\n 'index-of(null, 1)',\n ],\n },\n },\n 'push': {\n evaluate: ([seq, ...values], sourceCodeInfo): Seq => {\n assertSeq(seq, sourceCodeInfo)\n if (typeof seq === 'string') {\n assertCharArray(values, sourceCodeInfo)\n return [seq, ...values].join('')\n }\n else {\n return [...seq, ...values]\n }\n },\n arity: { min: 2 },\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'any' },\n seq: { type: 'sequence' },\n values: { type: 'any', rest: true, description: 'At least one.' },\n },\n variants: [{ argumentNames: ['seq', 'values'] }],\n description: 'Returns copy of $seq with $values added to the end of it.',\n seeAlso: ['sequence.unshift', 'pop', '++'],\n examples: [\n '[1, 2, 3] push 4',\n '\"Albert\" push \"!\"',\n 'push([1, 2, 3], 4)',\n 'push([1, 2, 3], 4, 5, 6)',\n `\nlet l = [1, 2, 3];\npush(l, 4);\nl`,\n ],\n },\n },\n 'rest': {\n evaluate: ([seq], sourceCodeInfo): Arr | string => {\n assertSeq(seq, sourceCodeInfo)\n if (Array.isArray(seq)) {\n if (seq.length <= 1)\n return []\n\n return seq.slice(1)\n }\n return seq.substring(1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'] },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n description: `If $seq is an array, returns a new array with all but the first element from $seq.\nIf $seq has less than two elements, an empty array is returned.\nFor string $seq returns all but the first characters in $seq.`,\n seeAlso: ['next', 'first', 'sequence.shift'],\n examples: [\n 'rest([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'rest([\"Albert\"])',\n 'rest([])',\n 'rest(\"Albert\")',\n 'rest(\"A\",)',\n 'rest(\"\")',\n ],\n },\n },\n 'next': {\n evaluate: ([seq], sourceCodeInfo): Arr | string | null => {\n assertSeq(seq, sourceCodeInfo)\n if (Array.isArray(seq)) {\n if (seq.length <= 1)\n return null\n\n return seq.slice(1)\n }\n if (seq.length <= 1)\n return null\n\n return seq.substring(1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'] },\n args: { seq: { type: 'sequence' } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'If $seq is an array, returns a new array with all but the first element from $seq. If $seq has less than two elements, `null` is returned. For string $seq returns all but the first characters in $seq. If length of string $seq is less than two, `null` is returned.',\n seeAlso: ['rest', 'first'],\n examples: [\n 'next([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'next([\"Albert\"])',\n 'next([])',\n 'next(\"Albert\")',\n 'next(\"A\",)',\n 'next(\"\")',\n ],\n },\n },\n 'reverse': {\n evaluate: ([seq], sourceCodeInfo): Any => {\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n if (Array.isArray(seq)) {\n return [...seq].reverse()\n }\n\n return seq.split('').reverse().join('')\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: ['sequence', 'null'] },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'If $seq is an array, creates a new array with the elements from $seq in reversed order. If $seq is a string, returns new reversed string.',\n seeAlso: ['sort'],\n examples: [\n 'reverse([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'reverse([])',\n 'reverse(\"Albert\")',\n 'reverse(null)',\n ],\n },\n },\n 'second': {\n evaluate: ([seq], sourceCodeInfo): Any => {\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n return toAny(seq[1])\n },\n arity: toFixedArity(1),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: { seq: { type: ['sequence', 'null'] } },\n variants: [{ argumentNames: ['seq'] }],\n description: 'Returns the second element of $seq. If $seq has less than two elements or is `null`, `null` is returned.',\n seeAlso: ['first', 'last', 'nth'],\n examples: [\n 'second([\"Albert\", \"Mojir\", 160, [1, 2]])',\n 'second([1])',\n 'second([])',\n 'second(null)',\n ],\n },\n },\n 'slice': {\n evaluate: (params, sourceCodeInfo): Any => {\n const [seq, from, to] = params\n assertSeq(seq, sourceCodeInfo)\n assertNumber(from, sourceCodeInfo, { integer: true })\n\n if (params.length === 2) {\n if (Array.isArray(seq)) {\n return seq.slice(from)\n }\n return seq.slice(from)\n }\n\n assertNumber(to, sourceCodeInfo, { integer: true })\n if (Array.isArray(seq)) {\n return seq.slice(from, to)\n }\n return seq.slice(from, to)\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'sequence',\n returns: { type: 'sequence' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'integer' },\n seq: { type: 'sequence', rest: true },\n start: { type: 'integer', description: 'Defaults to `0`.' },\n stop: { type: 'integer', description: 'Defaults lenght of sequence + 1.' },\n },\n variants: [\n { argumentNames: ['seq'] },\n { argumentNames: ['seq', 'start'] },\n { argumentNames: ['seq', 'start', 'stop'] },\n ],\n description: 'Returns a copy of a portion of $seq from index $start (inclusive) to $stop (exclusive).',\n seeAlso: ['sequence.take', 'sequence.drop', 'sequence.splice', 'nth'],\n examples: [\n '[1, 2, 3, 4, 5] slice 2',\n 'slice([1, 2, 3, 4, 5], 2, 4)',\n 'slice([1, 2, 3, 4, 5], 2)',\n ],\n },\n },\n 'some': {\n evaluate: ([seq, fn]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertFunctionLike(fn, sourceCodeInfo)\n if (seq === null)\n return null\n\n assertSeq(seq, sourceCodeInfo)\n\n if (seq.length === 0)\n return null\n\n const items = typeof seq === 'string' ? seq.split('') : seq\n return reduceSequential(\n items,\n (found: Any, elem) => {\n if (found !== null)\n return found\n return chain(executeFunction(fn, [elem], contextStack, sourceCodeInfo), (result) => {\n return result ? toAny(elem) : null\n })\n },\n null as Any,\n )\n },\n arity: toFixedArity(2),\n docs: {\n category: 'sequence',\n returns: { type: 'any' },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: ['sequence', 'null'] },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['seq', 'fun'] }],\n description: 'Returns the first element that passes the test implemented by $fun. I no element was found, `null` is returned.',\n seeAlso: ['sequence.position', 'collection.any?', 'find'],\n examples: [\n `\nsome(\n [\"Albert\", \"Mojir\", 160, [1, 2]],\n string?\n)`,\n `\nsome(\n [5, 10, 15, 20],\n -> $ > 10\n)`,\n `\nsome(\n [1, 2, 3, 4],\n -> $ > 10\n)`,\n `\nsome(\n [],\n -> $ > 10\n)`,\n `\nsome(\n null,\n -> $ > 10\n)`,\n ],\n },\n },\n 'sort': {\n evaluate: (params: Arr, sourceCodeInfo, _contextStack, { executeFunction: _executeFunction }): Seq => {\n const [seq] = params\n const defaultComparer = params.length === 1\n const comparer = defaultComparer ? null : params[1]\n assertSeq(seq, sourceCodeInfo)\n\n if (typeof seq === 'string') {\n const result = seq.split('')\n if (defaultComparer) {\n result.sort((a, b) => compare(a, b, sourceCodeInfo))\n }\n else {\n assertFunctionLike(comparer, sourceCodeInfo)\n // Note: sort comparator must be synchronous — async comparators would need a different approach\n result.sort((a, b) => {\n const compareValue = _executeFunction(comparer, [a, b], _contextStack, sourceCodeInfo)\n if (compareValue instanceof Promise) {\n throw new TypeError('Async functions cannot be used as sort comparators')\n }\n assertNumber(compareValue, sourceCodeInfo, { finite: true })\n return compareValue\n })\n }\n return result.join('')\n }\n\n const result = [...seq]\n if (defaultComparer) {\n result.sort((a, b) => {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n return compare(a, b, sourceCodeInfo)\n })\n }\n else {\n result.sort((a, b) => {\n assertFunctionLike(comparer, sourceCodeInfo)\n // Note: sort comparator must be synchronous\n const compareValue = _executeFunction(comparer, [a, b], _contextStack, sourceCodeInfo)\n if (compareValue instanceof Promise) {\n throw new TypeError('Async functions cannot be used as sort comparators')\n }\n assertNumber(compareValue, sourceCodeInfo, { finite: true })\n return compareValue\n })\n }\n return result\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'sequence',\n returns: { type: 'any', rest: true },\n args: {\n a: { type: 'sequence' },\n b: { type: 'function' },\n seq: { type: 'sequence' },\n fun: { type: 'function' },\n },\n variants: [\n { argumentNames: ['seq'] },\n { argumentNames: ['seq', 'fun'] },\n ],\n description: 'Returns a new sequence with the elements from $seq sorted according to $fun. If no $fun is supplied, builtin `compare` will be used.',\n seeAlso: ['sequence.sort-by', 'compare', 'reverse', 'vector.sort-indices'],\n examples: [\n '[3, 1, 2] sort (a, b) -> b - a',\n 'sort([3, 1, 2])',\n `\nsort(\n [3, 1, 2],\n (a, b) -> cond case a < b then -1 case a > b then 1 case true then -1 end\n)`,\n `\nsort(\n [3, 1, 2],\n (a, b) -> cond case a > b then -1 case a < b then 1 case true then -1 end\n)`,\n ],\n },\n },\n}\n","import { LitsError } from '../errors'\nimport type { Any } from '../interface'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { isNumber } from './number'\n\nconst annotatedArrays = new WeakSet<unknown[]>()\nconst vectors = new WeakSet<unknown[]>()\nconst notVectors = new WeakSet<unknown[]>()\nconst matrices = new WeakSet<unknown[]>()\nconst notMatrices = new WeakSet<unknown[]>()\nconst grids = new WeakSet<unknown[]>()\nconst notGrids = new WeakSet<unknown[]>()\n\nexport function annotate<T>(value: T): T {\n if (!Array.isArray(value)) {\n return value\n }\n if (annotatedArrays.has(value)) {\n return value\n }\n isVector(value)\n if (!isMatrix(value)) {\n isGrid(value)\n }\n\n return value\n}\nexport function isVector(vector: unknown): vector is number[] {\n if (!Array.isArray(vector)) {\n return false\n }\n\n if (vectors.has(vector)) {\n return true\n }\n if (notVectors.has(vector)) {\n return false\n }\n\n if (vector.every(elem => isNumber(elem))) {\n annotatedArrays.add(vector)\n vectors.add(vector)\n return true\n }\n notVectors.add(vector)\n return false\n}\n\nexport function assertVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is number[] {\n if (!isVector(vector)) {\n throw new LitsError(`Expected a vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function is2dVector(vector: unknown): vector is [number, number] {\n if (!isVector(vector)) {\n return false\n }\n return vector.length === 2\n}\nexport function assert2dVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is [number, number] {\n if (!is2dVector(vector)) {\n throw new LitsError(`Expected a 2d vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function is3dVector(vector: unknown): vector is [number, number, number] {\n if (!isVector(vector)) {\n return false\n }\n return vector.length === 3\n}\nexport function assert3dVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is [number, number, number] {\n if (!is3dVector(vector)) {\n throw new LitsError(`Expected a 3d vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function assertNonEmptyVector(vector: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts vector is number[] {\n assertVector(vector, sourceCodeInfo)\n if (vector.length === 0) {\n throw new LitsError(`Expected a non empty vector, but got ${vector}`, sourceCodeInfo)\n }\n}\n\nexport function isGrid(grid: unknown): grid is unknown[][] {\n if (!Array.isArray(grid)) {\n return false\n }\n if (grids.has(grid)) {\n return true\n }\n if (notGrids.has(grid)) {\n return false\n }\n if (grid.length === 0) {\n notGrids.add(grid)\n return false\n }\n if (!Array.isArray(grid[0])) {\n notGrids.add(grid)\n return false\n }\n const nbrOfCols = grid[0].length\n for (const row of grid.slice(1)) {\n if (!Array.isArray(row)) {\n notGrids.add(grid)\n return false\n }\n if (row.length !== nbrOfCols) {\n notGrids.add(grid)\n return false\n }\n }\n annotatedArrays.add(grid)\n grids.add(grid)\n return true\n}\n\nexport function assertGrid(grid: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts grid is Any[][] {\n if (!isGrid(grid)) {\n throw new LitsError(`Expected a grid, but got ${grid}`, sourceCodeInfo)\n }\n}\n\nexport function isMatrix(matrix: unknown): matrix is number[][] {\n if (!Array.isArray(matrix)) {\n return false\n }\n if (matrices.has(matrix)) {\n return true\n }\n if (notMatrices.has(matrix)) {\n return false\n }\n if (matrix.length === 0) {\n notMatrices.add(matrix)\n return false\n }\n if (!Array.isArray(matrix[0]) || matrix[0].length === 0) {\n notMatrices.add(matrix)\n return false\n }\n const nbrOfCols = matrix[0].length\n for (const row of matrix) {\n if (!Array.isArray(row) || row.length !== nbrOfCols || row.some(cell => !isNumber(cell))) {\n notMatrices.add(matrix)\n return false\n }\n }\n annotatedArrays.add(matrix)\n grids.add(matrix)\n matrices.add(matrix)\n return true\n}\n\nexport function assertMatrix(matrix: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts matrix is number[][] {\n if (!isMatrix(matrix)) {\n throw new LitsError(`Expected a matrix, but got ${matrix}`, sourceCodeInfo)\n }\n}\n\nexport function assertSquareMatrix(matrix: unknown, sourceCodeInfo: SourceCodeInfo | undefined): asserts matrix is number[][] {\n if (!isMatrix(matrix)) {\n throw new LitsError(`Expected a matrix, but got ${matrix}`, sourceCodeInfo)\n }\n if (matrix.length !== matrix[0]!.length) {\n throw new LitsError(`Expected square matrix, but got ${matrix.length} and ${matrix[0]!.length}`, sourceCodeInfo)\n }\n}\n\nexport function isSquareMatrix(matrix: unknown): matrix is number[][] {\n if (!isMatrix(matrix)) {\n return false\n }\n if (matrix.length !== matrix[0]!.length) {\n return false\n }\n return true\n}\n","import { LitsError } from '../../errors'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { assertNonEmptyVector, isMatrix, isVector } from '../../typeGuards/annotatedArrays'\nimport { assertNumber, isNumber } from '../../typeGuards/number'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\ntype NumberVectorOrMatrix = number | number[] | number[][]\n\nfunction getNumberVectorOrMatrixOperation(\n params: unknown[],\n sourceCodeInfo: SourceCodeInfo | undefined,\n):\n | ['number', number[]]\n | ['vector', number[][]]\n | ['matrix', number[][][]] {\n let hasVector: boolean = false\n let hasMatrix: boolean = false\n for (const param of params) {\n if (isVector(param)) {\n hasVector = true\n }\n else if (isMatrix(param)) {\n hasMatrix = true\n }\n else if (!isNumber(param)) {\n throw new LitsError(`Invalid parameter type: ${typeof param}`, sourceCodeInfo)\n }\n }\n if (hasMatrix) {\n if (hasVector) {\n throw new LitsError('Cannot mix vector and matrix types', sourceCodeInfo)\n }\n let rows: number | null = null\n let cold: number | null = null\n for (const param of params) {\n if (isMatrix(param)) {\n if (rows === null) {\n rows = param.length\n cold = param[0]!.length\n }\n else {\n if (param.length !== rows || param[0]!.length !== cold) {\n throw new LitsError('Matrix dimensions do not match', sourceCodeInfo)\n }\n }\n }\n }\n const matrices = params.map((param) => {\n if (isMatrix(param)) {\n return param\n }\n return Array.from({ length: rows as number }, () => Array.from({ length: cold as number }, () => param as number))\n })\n return ['matrix', matrices]\n }\n if (hasVector) {\n let length: number | null = null\n for (const param of params) {\n if (isVector(param)) {\n if (length === null) {\n length = param.length\n }\n else {\n if (param.length !== length) {\n throw new LitsError('Vector lengths do not match', sourceCodeInfo)\n }\n }\n }\n }\n const vectors = params.map((param) => {\n if (isVector(param)) {\n return param\n }\n return Array.from({ length: length as number }, () => param as number)\n })\n\n return ['vector', vectors]\n }\n return ['number', params as number[]]\n}\n\nfunction unaryMathOp(\n fn: (val: number) => number,\n): (params: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) => NumberVectorOrMatrix {\n return (params, sourceCodeInfo) => {\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n if (operation === 'number') {\n return fn(operands[0]!)\n }\n else if (operation === 'vector') {\n return operands[0]!.map(val => fn(val))\n }\n else {\n return operands[0]!.map(row => row.map(val => fn(val)))\n }\n }\n}\n\nfunction binaryMathOp(\n fn: (a: number, b: number) => number,\n): (params: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) => NumberVectorOrMatrix {\n return (params, sourceCodeInfo) => {\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n if (operation === 'number') {\n return fn(operands[0]!, operands[1]!)\n }\n else if (operation === 'vector') {\n return operands[0]!.map((val, i) => fn(val, operands[1]![i]!))\n }\n else {\n return operands[0]!.map((row, i) => row.map((val, j) => fn(val, operands[1]![i]![j]!)))\n }\n }\n}\n\nfunction reduceMathOp(\n identity: number,\n fn: (a: number, b: number) => number,\n): (params: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) => NumberVectorOrMatrix {\n return (params, sourceCodeInfo) => {\n if (params.length === 0)\n return identity\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n if (operation === 'number') {\n return operands.reduce((a, b) => fn(a, b), identity)\n }\n else if (operation === 'vector') {\n const [first, ...rest] = operands\n return rest.reduce((acc, v) => acc.map((val, i) => fn(val, v[i]!)), first!)\n }\n else {\n const [first, ...rest] = operands\n return rest.reduce((acc, m) => acc.map((row, i) => row.map((val, j) => fn(val, m[i]![j]!))), first!)\n }\n }\n}\n\nexport const mathNormalExpression: BuiltinNormalExpressions = {\n 'inc': {\n evaluate: unaryMathOp(val => val + 1),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: 'number' },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `inc` function increments its argument by 1, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it increases each element by 1 while preserving the original structure.',\n seeAlso: ['dec', '+'],\n examples: [\n 'inc(0)',\n 'inc(1)',\n 'inc(100.1)',\n 'inc([1, 2, 3])',\n 'inc([[1, 2], [3, 4]])',\n ],\n },\n },\n 'dec': {\n evaluate: unaryMathOp(val => val - 1),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `dec` function decrements its argument by 1, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it decreases each element by 1 while preserving the original structure.',\n seeAlso: ['inc', '-'],\n examples: [\n 'dec(0)',\n 'dec(1)',\n 'dec(100.1)',\n 'dec([1, 2, 3])',\n 'dec([[1, 2], [3, 4]])',\n ],\n },\n },\n '+': {\n evaluate: reduceMathOp(0, (a, b) => a + b),\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n description: 'The `+` function performs addition of numbers and element-wise addition of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it adds the scalar to each element of the collection.',\n seeAlso: ['-', '*', '/', 'inc'],\n examples: [\n '1 + 2',\n '1 + 20 + 30',\n '+(1, 2, 3, 4)',\n '+()',\n '+(1)',\n '[1, 2, 3] + 2',\n '[1, 2, 3] + [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] + [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] + 2',\n ],\n },\n },\n '*': {\n evaluate: reduceMathOp(1, (a, b) => a * b),\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n description: 'The `*` function performs multiplication of `numbers` and element-wise multiplication of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it multiplies each element of the collection by the scalar.',\n seeAlso: ['/', '+', '-', '^'],\n examples: [\n '6 * 7',\n '-1 * 4',\n '*(4, 7)',\n '*(1, 2, 3, 4, 5)',\n '*()',\n '*(8)',\n '[1, 2, 3] * 2',\n '[1, 2, 3] * [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] * [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] * 2',\n ],\n },\n },\n '/': {\n evaluate: (params, sourceCodeInfo): NumberVectorOrMatrix => {\n if (params.length === 0) {\n return 1\n }\n\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n\n if (operation === 'number') {\n const [first, ...rest] = operands\n if (rest.length === 0) {\n return 1 / first!\n }\n return rest.reduce((result, param) => {\n return result / param\n }, first!)\n }\n else if (operation === 'vector') {\n const firstVector = operands[0]!\n const restVectors = operands.slice(1)\n return restVectors.reduce((acc, vector) => acc.map((val, i) => val / vector[i]!), firstVector)\n }\n else {\n const firstMatrix = operands[0]!\n const restMatrices = operands.slice(1)\n return restMatrices.reduce((acc, matrix) => acc.map((row, i) => row.map((val, j) => val / matrix[i]![j]!)), firstMatrix)\n }\n },\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n description: 'The `/` function performs division of `numbers` and element-wise division of `vectors` and `matrices` of compatible dimensions, returning the same type as its inputs. When used with mixed types, it divides each element of the collection by the scalar.',\n seeAlso: ['*', '+', '-', 'quot', 'mod', '%'],\n examples: [\n '12 / 100',\n '-1 / 4',\n '/(7, 4)',\n '/(1, 2, 4, 8)',\n '/()',\n '/(8)',\n '[1, 2, 3] / 2',\n '[1, 2, 3] / [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] / [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] / 2',\n ],\n },\n },\n '-': {\n evaluate: (params, sourceCodeInfo): NumberVectorOrMatrix => {\n if (params.length === 0) {\n return 0\n }\n\n const [operation, operands] = getNumberVectorOrMatrixOperation(params, sourceCodeInfo)\n\n if (operation === 'number') {\n const [first, ...rest] = operands\n if (rest.length === 0)\n return -first!\n\n return rest.reduce((result, param) => {\n return result - param\n }, first!)\n }\n else if (operation === 'vector') {\n const firstVector = operands[0]!\n const restVectors = operands.slice(1)\n return restVectors.reduce((acc, vector) => acc.map((val, i) => val - vector[i]!), firstVector)\n }\n else {\n const firstMatrix = operands[0]!\n const restMatrices = operands.slice(1)\n return restMatrices.reduce((acc, matrix) => acc.map((row, i) => row.map((val, j) => val - matrix[i]![j]!)), firstMatrix)\n }\n },\n arity: {},\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n xs: { type: ['number', 'vector', 'matrix'], rest: true },\n },\n variants: [{ argumentNames: ['xs'] }],\n description: 'Computes difference between first value and sum of the rest. When called with only one argument, it does negation.',\n seeAlso: ['+', '*', '/', 'dec', 'abs'],\n examples: [\n '50 - 8',\n '1 - 1 - 1',\n '-()',\n '-(4, 2)',\n '-(4, 3, 2, 1,)',\n '[1, 2, 3] - 2',\n '[1, 2, 3] - [4, 5, 6]',\n '[[1, 2, 3], [4, 5, 6]] - [[7, 8, 9], [10, 11, 12]]',\n '[[1, 2, 3], [4, 5, 6]] - 2',\n ],\n },\n },\n 'quot': {\n evaluate: binaryMathOp((a, b) => Math.trunc(a / b)),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'The `quot` function performs integer division truncated toward zero, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies integer division between each element of the collection and the scalar.',\n seeAlso: ['mod', '%', '/', 'trunc'],\n examples: [\n 'quot(5, 3)',\n 'quot(5.2, 3.1)',\n 'quot(-5, 3)',\n '5 quot -3',\n '-5 quot -3',\n 'quot(5, 0)',\n 'quot(0, 5)',\n '[1, 2, 3] quot 2',\n '2 quot [1, 2, 3]',\n 'quot([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]',\n 'quot([[1, 2, 3], [4, 5, 6]], 2)',\n '[[1, 2, 3], [4, 5, 6]] quot [[7, 8, 9], [10, 11, 12]]',\n ],\n },\n },\n 'mod': {\n evaluate: binaryMathOp((a, b) => a - b * Math.floor(a / b)),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'The `mod` function computes the modulo of division with the same sign as the divisor, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the modulo operation between each element of the collection and the scalar.',\n seeAlso: ['%', 'quot', '/'],\n examples: [\n 'mod(5, 3)',\n 'mod(5.2, 3.1)',\n 'mod(-5, 3)',\n '5 mod -3',\n '-5 mod -3',\n '[1, 2, 3] mod 2',\n '2 mod [1, 2, 3]',\n 'mod([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] mod [[7, 8, 9], [10, 11, 12]]',\n 'mod([[1, 2, 3], [4, 5, 6]], 2)',\n ],\n },\n },\n '%': {\n evaluate: binaryMathOp((a, b) => a % b),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'The `%` function computes the remainder of division with the same sign as the dividend, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the remainder operation between each element of the collection and the scalar.',\n seeAlso: ['mod', 'quot', '/'],\n examples: [\n '5 % 3',\n '5.2 % 3.1',\n '-5 % 3',\n '%(5, -3)',\n '%(-5, -3)',\n '[1, 2, 3] % 2',\n '2 % [1, 2, 3]',\n '%([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] % [[7, 8, 9], [10, 11, 12]]',\n '%([[1, 2, 3], [4, 5, 6]], 2)',\n ],\n },\n },\n 'sqrt': {\n evaluate: unaryMathOp(val => Math.sqrt(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `sqrt` function calculates the square root of `numbers` and computes element-wise square roots of `vectors` and `matrices`. When applied to collections, it returns the square root of each element while preserving the original structure.',\n seeAlso: ['cbrt', '^'],\n examples: [\n 'sqrt(0)',\n 'sqrt(9)',\n 'sqrt(2)',\n 'sqrt(0)',\n 'sqrt(9)',\n 'sqrt(2)',\n 'sqrt([1, 4, 9])',\n 'sqrt([[1, 4], [9, 16]])',\n ],\n },\n },\n 'cbrt': {\n evaluate: unaryMathOp(val => Math.cbrt(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `cbrt` function calculates the cube root of `numbers` and computes element-wise cube roots of `vectors` and `matrices`. When applied to collections, it returns the cube root of each element while preserving the original structure.',\n seeAlso: ['sqrt', '^'],\n examples: [\n 'cbrt(0)',\n 'cbrt(27)',\n 'cbrt(2)',\n 'cbrt(1)',\n 'cbrt(0)',\n 'cbrt(27)',\n 'cbrt(2)',\n 'cbrt(1)',\n 'cbrt([1, 8, 27])',\n 'cbrt([[1, 8], [27, 64]])',\n ],\n },\n },\n '^': {\n evaluate: binaryMathOp((a, b) => a ** b),\n arity: toFixedArity(2),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'The ^ function computes exponentiation, raising the first argument to the power of the second, working on `numbers` and element-wise on `vectors` and `matrices` of compatible dimensions. When used with mixed types, it applies the power operation between each element of the collection and the scalar.',\n seeAlso: ['sqrt', 'cbrt', '*', 'math.ln'],\n examples: [\n '2 ^ 3',\n '2 ^ 0',\n '2 ^ -3',\n '^(-2, 3)',\n '^(-2, -3)',\n '[1, 2, 3] ^ 2',\n '2 ^ [1, 2, 3]',\n '^([1, 2, 3], [4, 5, 6])',\n '[[1, 2, 3], [4, 5, 6]] ^ [[7, 8, 9], [10, 11, 12]]',\n '^([[1, 2, 3], [4, 5, 6]], 2)',\n ],\n },\n },\n 'round': {\n evaluate: ([value, decimals], sourceCodeInfo): NumberVectorOrMatrix => {\n const [operation, operands] = getNumberVectorOrMatrixOperation([value], sourceCodeInfo)\n if (operation === 'number') {\n if (decimals === undefined || decimals === 0) {\n return Math.round(operands[0]!)\n }\n else {\n assertNumber(decimals, sourceCodeInfo, { integer: true, positive: true })\n const factor = 10 ** decimals\n return Math.round(operands[0]! * factor) / factor\n }\n }\n else if (operation === 'vector') {\n const vector = operands[0]!\n if (decimals === undefined || decimals === 0) {\n return vector.map(val => Math.round(val))\n }\n else {\n assertNumber(decimals, sourceCodeInfo, { integer: true, positive: true })\n const factor = 10 ** decimals\n return vector.map(val => Math.round(val * factor) / factor)\n }\n }\n else {\n const matrix = operands[0]!\n if (decimals === undefined || decimals === 0) {\n return matrix.map(row => row.map(val => Math.round(val)))\n }\n else {\n assertNumber(decimals, sourceCodeInfo, { integer: true, positive: true })\n const factor = 10 ** decimals\n return matrix.map(row => row.map(val => Math.round(val * factor) / factor))\n }\n }\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n a: { type: ['number', 'vector', 'matrix'] },\n b: { type: 'integer' },\n },\n variants: [\n { argumentNames: ['a'] },\n { argumentNames: ['a', 'b'] },\n ],\n description: 'The `round` function rounds a `number` to the nearest `integer` or to a specified number of `decimal` places, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it rounds each element while preserving the original structure.',\n seeAlso: ['floor', 'ceil', 'trunc'],\n examples: [\n 'round(2)',\n 'round(2.49)',\n 'round(2.5)',\n 'round(-2.49)',\n 'round(-2.5)',\n 'round(-2.501)',\n 'round(1.23456789, 4)',\n '1.123456789 round 2',\n 'round([1.23456789, 2.3456789], 1)',\n '[1.23456789, 2.3456789] round 4',\n '[[1.23456789, 2.3456789], [3.456789, 4.56789]] round 4',\n 'round([[1.23456789, 2.3456789], [3.456789, 4.56789]], 2)',\n ],\n },\n },\n 'trunc': {\n evaluate: unaryMathOp(val => Math.trunc(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['integer', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `trunc` function truncates `numbers` toward zero (removing decimal portions without rounding), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it truncates each element while preserving the original structure.',\n seeAlso: ['round', 'floor', 'ceil', 'quot'],\n examples: [\n 'trunc(2)',\n 'trunc(2.49)',\n 'trunc(2.5)',\n 'trunc(-2.49)',\n 'trunc(-2.5)',\n 'trunc(-2.501)',\n 'trunc([1.23456789, 2.3456789])',\n 'trunc([[1.23456789, 2.3456789], [3.456789, 4.56789]])',\n ],\n },\n },\n 'floor': {\n evaluate: unaryMathOp(val => Math.floor(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['integer', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `floor` function returns the largest `integer` less than or equal to a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the floor of each element while preserving the original structure.',\n seeAlso: ['ceil', 'round', 'trunc'],\n examples: [\n 'floor(2)',\n 'floor(2.49)',\n 'floor(2.5)',\n 'floor(-2.49)',\n 'floor(-2.5)',\n 'floor(-2.501)',\n 'floor([1.23456789, 2.3456789])',\n 'floor([[1.23456789, 2.3456789], [3.456789, 4.56789]])',\n ],\n },\n },\n 'ceil': {\n evaluate: unaryMathOp(val => Math.ceil(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['integer', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `ceil` function returns the smallest `integer` greater than or equal to a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the ceiling of each element while preserving the original structure.',\n seeAlso: ['floor', 'round', 'trunc'],\n examples: [\n 'ceil(2)',\n 'ceil(2.49)',\n 'ceil(2.5)',\n 'ceil(-2.49)',\n 'ceil(-2.5)',\n 'ceil(-2.501)',\n 'ceil([1.23456789, 2.3456789])',\n 'ceil([[1.23456789, 2.3456789], [3.456789, 4.56789]])',\n ],\n },\n },\n 'min': {\n evaluate: (params, sourceCodeInfo): number => {\n if (params.length === 1 && isVector(params[0])) {\n const vector = params[0]\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((m, val) => Math.min(m, val), Infinity)\n }\n const [first, ...rest] = params\n assertNumber(first, sourceCodeInfo)\n return rest.reduce((m: number, value) => {\n assertNumber(value, sourceCodeInfo)\n return Math.min(m, value)\n }, first)\n },\n arity: { min: 1 },\n docs: {\n category: 'math',\n returns: { type: 'number' },\n args: {\n a: { type: 'number' },\n b: { type: 'number' },\n xs: { type: 'number', rest: true },\n vector: { type: 'vector' },\n },\n variants: [\n { argumentNames: ['xs'] },\n { argumentNames: ['vector'] },\n ],\n description: 'Returns the smallest value. Accepts either multiple numbers or a single vector of numbers.',\n seeAlso: ['max', 'vector.span', 'vector.min-index'],\n examples: [\n '2 min 3',\n 'min(2, 0, 1)',\n 'min(2, -1, 1)',\n 'min([2, 0, -1])',\n '12 min 14',\n ],\n },\n },\n 'max': {\n evaluate: (params, sourceCodeInfo): number => {\n if (params.length === 1 && isVector(params[0])) {\n const vector = params[0]\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((m, val) => Math.max(m, val), -Infinity)\n }\n const [first, ...rest] = params\n assertNumber(first, sourceCodeInfo)\n return rest.reduce((m: number, value) => {\n assertNumber(value, sourceCodeInfo)\n return Math.max(m, value)\n }, first)\n },\n arity: { min: 1 },\n docs: {\n category: 'math',\n returns: { type: 'number' },\n args: {\n a: { type: 'number' },\n b: { type: 'number' },\n xs: { type: 'number', rest: true },\n vector: { type: 'vector' },\n },\n variants: [\n { argumentNames: ['xs'] },\n { argumentNames: ['vector'] },\n ],\n description: 'Returns the largest value. Accepts either multiple numbers or a single vector of numbers.',\n seeAlso: ['min', 'vector.span', 'vector.max-index'],\n examples: [\n '2 max 3',\n 'max(2, 0, 1)',\n 'max(2, -1, 1)',\n 'max([2, 0, -1])',\n '4 max 2',\n ],\n },\n },\n 'abs': {\n evaluate: unaryMathOp(val => Math.abs(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The abs function returns the absolute value (magnitude) of a `number`, working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the absolute value of each element while preserving the original structure.',\n seeAlso: ['sign', '-'],\n examples: [\n 'abs(-2.3)',\n 'abs(0)',\n 'abs(2.5)',\n 'abs([1, -2, 3])',\n 'abs([[1, -2], [3, -4]])',\n ],\n },\n },\n 'sign': {\n evaluate: unaryMathOp(val => Math.sign(val)),\n arity: toFixedArity(1),\n docs: {\n category: 'math',\n returns: { type: ['number', 'vector', 'matrix'] },\n args: {\n x: { type: ['number', 'vector', 'matrix'] },\n },\n variants: [{ argumentNames: ['x'] }],\n description: 'The `sign` function returns the `sign` of a `number` (-1 for negative, 0 for zero, 1 for positive), working on `numbers` and element-wise on `vectors` and `matrices`. When applied to collections, it returns the sign of each element while preserving the original structure.',\n seeAlso: ['abs'],\n examples: [\n 'sign(-2.3)',\n 'sign(-0)',\n 'sign(0)',\n 'sign(12312)',\n 'sign([1, -2, 3])',\n 'sign([[1, -2], [3, -4]])',\n ],\n },\n },\n}\n","import { LitsError } from '../../errors'\nimport type { Any } from '../../interface'\nimport type { ModuleFunction } from '../../parser/types'\nimport type { SourceCodeInfo } from '../../tokenizer/token'\nimport { asAny, assertAny } from '../../typeGuards/lits'\nimport { assertNumber } from '../../typeGuards/number'\nimport { asStringOrNumber, assertString, assertStringOrNumber } from '../../typeGuards/string'\nimport { compare, deepEqual } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport { FUNCTION_SYMBOL } from '../../utils/symbols'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nfunction isEqual([first, ...rest]: unknown[], sourceCodeInfo: SourceCodeInfo | undefined) {\n const firstAny = asAny(first, sourceCodeInfo)\n for (const param of rest) {\n if (!deepEqual(firstAny, asAny(param, sourceCodeInfo), sourceCodeInfo))\n return false\n }\n return true\n}\n\nfunction isIdentical([first, ...rest]: unknown[]) {\n for (const param of rest) {\n if (param !== first)\n return false\n }\n return true\n}\n\nexport const miscNormalExpression: BuiltinNormalExpressions = {\n '==': {\n evaluate: (params, sourceCodeInfo): boolean => {\n return isEqual(params, sourceCodeInfo)\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n x: { type: 'any' },\n ys: { type: 'any', rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if all `values` are structaul equal to each other, otherwise result is `false`.',\n seeAlso: ['≠', 'identical?'],\n examples: [\n '1 == 1',\n '[1, 2] == [1, 2]',\n `\n{\n a: 1,\n b: 2,\n} == {\n b: 2,\n a: 1,\n}`,\n '==(1, 1)',\n '==(1.01, 1)',\n '==(\"1\", 1)',\n '==(\"2\", \"2\", \"2\", \"2\")',\n '==(2, 2, 1, 2)',\n '==([1, 2], [1, 2])',\n '==({ a: 1, b: 2 }, { b: 2, a: 1 })',\n ],\n },\n },\n '≠': {\n evaluate: (params, sourceCodeInfo): boolean => {\n return !isEqual(params, sourceCodeInfo)\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n x: { type: 'any' },\n ys: { type: 'any', rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if all `values` are not equal to each other, otherwise result is `false`. `(≠ a b c)` is same as `(! (== a b c))`.',\n seeAlso: ['==', 'identical?'],\n examples: [\n '1 ≠ 2',\n '3 ≠ 3',\n '≠(3)',\n '≠(3, 3, 2)',\n '≠(\"3\", \"2\", \"1\", \"0\",)',\n '≠(0, -0)',\n ],\n },\n },\n 'identical?': {\n evaluate: (params): boolean => {\n return isIdentical(params)\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns true if $a and $b are referential equal.',\n seeAlso: ['==', '≠'],\n examples: [\n 'identical?({ a: 10, b: 20 }, { b: 20, a: 10 })',\n 'identical?([1, true, null], [1, true, null])',\n 'identical?(0.3, 0.1 + 0.2)',\n ],\n },\n },\n '>': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) <= 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in decreasing order, `false` otherwise.',\n seeAlso: ['<', '>=', '<=', 'compare'],\n examples: [\n '>(1, 0)',\n '>(1.01, 1)',\n '>(1, 1)',\n '>(4, 3, 2, 1)',\n '>(3, 2, 2, 1)',\n ],\n },\n },\n\n '<': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) >= 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in increasing order, `false` otherwise.',\n seeAlso: ['>', '>=', '<=', 'compare'],\n examples: [\n '<(0, 1)',\n '<(1, 1.01)',\n '<(1, 1)',\n '<(1, 2, 2, 3)',\n '<(\"a\", \"b\")',\n ],\n },\n },\n '>=': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) < 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in non increasing order, `false` otherwise.',\n seeAlso: ['>', '<', '<=', 'compare'],\n examples: [\n '1 >= 1',\n '0 >= 1',\n '>=(1, 0)',\n '>=(1.01, 1)',\n '>=(1, 1)',\n '>=(4, 3, 2, 1)',\n '>=(3, 2, 2, 1)',\n ],\n },\n },\n '<=': {\n evaluate: ([first, ...rest], sourceCodeInfo): boolean => {\n let currentValue = asStringOrNumber(first)\n for (const param of rest) {\n if (compare(currentValue, asStringOrNumber(param), sourceCodeInfo) > 0)\n return false\n\n currentValue = asStringOrNumber(param)\n }\n return true\n },\n arity: { min: 1 },\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n x: { type: ['number', 'string'] },\n ys: { type: ['number', 'string'], rest: true },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'ys'] },\n ],\n description: 'Returns `true` if $x and $ys are in non decreasing order, `false` otherwise.',\n seeAlso: ['>', '<', '>=', 'compare'],\n examples: [\n '1 <= 1',\n '<=(0, 1)',\n '<=(1, 1.01)',\n '<=(1, 1)',\n '<=(1, 2, 3, 4)',\n '<=(1, 2, 2, 3)',\n ],\n },\n },\n '!': {\n evaluate: ([first]): boolean => !first,\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Computes logical negation. Note that any other $x than `false`, `0`, `null` and `\\'\\'` is truthy.',\n seeAlso: ['boolean'],\n examples: [\n '!(3)',\n '!(true)',\n '!(\"A string\")',\n '!(0)',\n '!(false)',\n '!(null)',\n '!(\"\")',\n ],\n },\n },\n 'epoch->iso-date': {\n evaluate: ([ms], sourceCodeInfo): string => {\n assertNumber(ms, sourceCodeInfo)\n return new Date(ms).toISOString()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'string' },\n args: { ms: { type: 'number' } },\n variants: [{ argumentNames: ['ms'] }],\n description: 'Returns IOS date time string from `ms` (milliseconds elapsed since the UNIX epoch).',\n seeAlso: ['iso-date->epoch'],\n examples: [\n 'epoch->iso-date(1649756230899)',\n 'epoch->iso-date(0)',\n ],\n },\n },\n 'iso-date->epoch': {\n evaluate: ([dateTime], sourceCodeInfo): number => {\n assertString(dateTime, sourceCodeInfo)\n const ms = new Date(dateTime).valueOf()\n assertNumber(ms, sourceCodeInfo, { finite: true })\n return ms\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'number' },\n args: { iso: { type: 'string' } },\n variants: [{ argumentNames: ['iso'] }],\n description: 'Returns milliseconds elapsed since the UNIX epoch to `iso`.',\n seeAlso: ['epoch->iso-date'],\n examples: [\n 'iso-date->epoch(\"2022-04-12T09:37:10.899Z\")',\n 'iso-date->epoch(\"1980-01-01\")',\n ],\n },\n },\n 'write!': {\n evaluate: (params, sourceCodeInfo): Any => {\n // eslint-disable-next-line no-console\n console.log(...params)\n\n if (params.length > 0)\n return asAny(params[params.length - 1], sourceCodeInfo)\n\n return null\n },\n arity: {},\n docs: {\n category: 'misc',\n returns: { type: 'any' },\n args: { values: { type: 'any', rest: true } },\n variants: [{ argumentNames: ['values'] }],\n description: 'It logs the $values and then returns the last argument. If called with no arguments `null` is returned.',\n examples: [\n 'write!(\"A string\")',\n 'write!(100, \"items\")',\n 'write!(object(\"a\", 10))',\n 'write!([\"a\", \"b\", \"c\"])',\n 'write!(#\"^start\")',\n 'write!(null, true, false)',\n ],\n hideOperatorForm: true,\n },\n },\n 'boolean': {\n evaluate: ([value]): boolean => {\n return !!value\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Coerces $x to boolean.',\n seeAlso: ['!', 'boolean?', 'true?', 'false?'],\n examples: [\n 'boolean(0)',\n 'boolean(1)',\n 'boolean(null)',\n 'boolean(\"Albert\")',\n ],\n },\n },\n 'compare': {\n evaluate: ([a, b], sourceCodeInfo): number => {\n assertStringOrNumber(a, sourceCodeInfo)\n assertStringOrNumber(b, sourceCodeInfo)\n return compare(a, b, sourceCodeInfo)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'misc',\n returns: { type: 'number' },\n args: {\n a: { type: ['number', 'string'] },\n b: { type: ['number', 'string'] },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Compares two values. Returns `-1` if $a < $b, `1` if $a > $b and `0` if $a and $b have the same sort order.',\n seeAlso: ['<', '>', '<=', '>=', 'sort', 'sequence.sort-by'],\n examples: [\n 'compare(0, 1)',\n 'compare(0, 0)',\n 'compare(1, 0)',\n 'compare(\"Albert\", \"Mojir\")',\n ],\n },\n },\n 'json-parse': {\n evaluate: ([first], sourceCodeInfo): Any => {\n assertString(first, sourceCodeInfo)\n // eslint-disable-next-line ts/no-unsafe-return\n return JSON.parse(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'any' },\n args: { x: { type: 'string' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `JSON.parse(`$x`)`.',\n seeAlso: ['json-stringify'],\n examples: [\n 'json-parse(\"[1, 2, 3]\")',\n ],\n },\n },\n 'json-stringify': {\n evaluate: ([first, second], sourceCodeInfo): string => {\n assertAny(first, sourceCodeInfo)\n if (second === undefined)\n return JSON.stringify(first)\n\n assertNumber(second, sourceCodeInfo)\n return JSON.stringify(first, null, second)\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'misc',\n returns: { type: 'string' },\n args: {\n x: { type: 'any' },\n indent: { type: 'integer', description: 'Number of spaces to use for indentation.' },\n },\n variants: [\n { argumentNames: ['x'] },\n { argumentNames: ['x', 'indent'] },\n ],\n description: 'Returns `JSON.stringify(`$x`)`. If second argument is provided, returns `JSON.stringify(`$x`, null, `$indent`)`.',\n seeAlso: ['json-parse'],\n examples: [\n 'json-stringify([1, 2, 3])',\n 'json-stringify({ a: { b: 10 }}, 2)',\n ],\n hideOperatorForm: true,\n },\n },\n 'import': {\n evaluate: ([importPath], sourceCodeInfo, contextStack): ModuleFunction | Record<string, ModuleFunction> => {\n assertString(importPath, sourceCodeInfo)\n\n // Check if importing a specific function (e.g., \"grid.row\")\n const dotIndex = importPath.indexOf('.')\n if (dotIndex !== -1) {\n const moduleName = importPath.substring(0, dotIndex)\n const functionName = importPath.substring(dotIndex + 1)\n\n const module = contextStack.getModule(moduleName)\n if (!module) {\n throw new LitsError(`Unknown module: '${moduleName}'`, sourceCodeInfo)\n }\n\n const expression = module.functions[functionName]\n\n if (!expression) {\n throw new LitsError(`Function '${functionName}' not found in module '${moduleName}'`, sourceCodeInfo)\n }\n\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Module',\n moduleName,\n functionName,\n arity: expression.arity,\n }\n }\n\n // Import entire module\n const moduleName = importPath\n const module = contextStack.getModule(moduleName)\n if (!module) {\n throw new LitsError(`Unknown module: '${moduleName}'`, sourceCodeInfo)\n }\n\n // Create an object where each key is a function name and value is a ModuleFunction\n const result: Record<string, ModuleFunction> = {}\n for (const [functionName, expression] of Object.entries(module.functions)) {\n result[functionName] = {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Module',\n moduleName,\n functionName,\n arity: expression.arity,\n }\n }\n return result\n },\n arity: toFixedArity(1),\n docs: {\n category: 'misc',\n returns: { type: 'any' },\n args: {\n path: {\n type: 'string',\n description: 'The module path to import. Can be a module name (e.g., \"vector\", \"grid\") or a fully qualified function name (e.g., \"vector.mean\", \"grid.row\").',\n },\n },\n variants: [{ argumentNames: ['path'] }],\n description: 'Imports module functions. Use a module name (e.g., \"vector\") to import all functions as an object, or a fully qualified name (e.g., \"vector.mean\") to import a single function directly.',\n examples: [\n 'let v = import(\"vector\"); v.mean([1, 2, 3, 4])',\n 'let v-sum = import(\"vector.sum\"); v-sum([1, 2, 3])',\n 'let g = import(\"grid\"); g.row([[1, 2], [3, 4]], 0)',\n ],\n },\n },\n}\n","import type { Any, Arr, Obj } from '../../interface'\nimport { assertArray, assertStringArray } from '../../typeGuards/array'\nimport { assertFunctionLike, assertObj } from '../../typeGuards/lits'\nimport { asString, assertString } from '../../typeGuards/string'\nimport { collHasKey, toAny } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain, reduceSequential } from '../../utils/maybePromise'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const objectNormalExpression: BuiltinNormalExpressions = {\n 'keys': {\n evaluate: ([obj], sourceCodeInfo): string[] => {\n assertObj(obj, sourceCodeInfo)\n return Object.keys(obj)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'object',\n returns: { type: 'any', array: true },\n args: { obj: { type: 'object' } },\n variants: [{ argumentNames: ['obj'] }],\n description: 'Returns array of all keys in $obj.',\n seeAlso: ['vals', 'entries', 'zipmap', 'select-keys'],\n examples: [\n 'keys({})',\n 'keys({ x: 10, y: true, z: \"A string\" })',\n 'keys(object(\"x\", 10, \"y\", true, \"z\", \"A string\"))',\n ],\n },\n },\n\n 'vals': {\n evaluate: ([obj], sourceCodeInfo): Arr => {\n assertObj(obj, sourceCodeInfo)\n return Object.values(obj)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'object',\n returns: { type: 'any', array: true },\n args: { obj: { type: 'object' } },\n variants: [{ argumentNames: ['obj'] }],\n description: 'Returns array of all values in $obj.',\n seeAlso: ['keys', 'entries', 'zipmap'],\n examples: [\n 'vals({})',\n 'vals({ x: 10, y: true, z: \"A string\" })',\n 'vals(object(\"x\", 10, \"y\", true, \"z\", \"A string\"))',\n ],\n },\n },\n\n 'entries': {\n evaluate: ([obj], sourceCodeInfo): Array<[string, unknown]> => {\n assertObj(obj, sourceCodeInfo)\n return Object.entries(obj)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'object',\n returns: { type: 'array' },\n args: { obj: { type: 'object' } },\n variants: [{ argumentNames: ['obj'] }],\n description: 'Returns nested array of all key - value pairs in $obj.',\n seeAlso: ['keys', 'vals', 'zipmap', 'find'],\n examples: [\n 'entries({})',\n 'entries({ x: 10, y: true, z: \"A string\" })',\n 'entries(object(\"x\", 10, \"y\", true, \"z\", \"A string\"))',\n ],\n },\n },\n\n 'find': {\n evaluate: ([obj, key], sourceCodeInfo): [string, unknown] | null => {\n assertObj(obj, sourceCodeInfo)\n assertString(key, sourceCodeInfo)\n if (collHasKey(obj, key))\n return [key, obj[key]]\n\n return null\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: ['array', 'null'] },\n args: {\n a: { type: 'object' },\n b: { type: 'string' },\n obj: { type: 'object' },\n key: { type: 'string' },\n },\n variants: [{ argumentNames: ['obj', 'key'] }],\n description: 'Returns entry (key-value pair) for $key, or `null` if $key not present in $obj.',\n seeAlso: ['get', 'contains?', 'entries', 'sequence.position', 'some'],\n examples: [\n '{ a: 1, \"b\": 2 } find \"a\"',\n 'find(object(\"a\", 1, \"b\", 2), \"b\")',\n 'find(object(\"a\", 1, \"b\", 2), \"c\")',\n ],\n },\n },\n\n 'dissoc': {\n evaluate: ([obj, key], sourceCodeInfo): Any => {\n assertObj(obj, sourceCodeInfo)\n assertString(key, sourceCodeInfo)\n const newObj = { ...obj }\n delete newObj[key]\n return newObj\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'object' },\n b: { type: 'string' },\n obj: { type: 'object' },\n key: { type: 'string' },\n },\n variants: [{ argumentNames: ['obj', 'key'] }],\n description: 'Return shallow copy of $obj with $key deleted.',\n seeAlso: ['assoc', 'select-keys'],\n examples: [\n '{ x: 10, y: 20 } dissoc \"y\"',\n 'dissoc({ x: 10, y: 20 }, \"x\")',\n 'dissoc({ x: 10 }, \"y\")',\n `\nlet o = { a: 5 };\ndissoc(o, \"a\");\no`,\n ],\n },\n },\n\n 'merge': {\n evaluate: (params, sourceCodeInfo): Any => {\n if (params.length === 0)\n return null\n\n const [first, ...rest] = params\n assertObj(first, sourceCodeInfo)\n\n return rest.reduce(\n (result: Obj, obj) => {\n assertObj(obj, sourceCodeInfo)\n return { ...result, ...obj }\n },\n { ...first },\n )\n },\n arity: { min: 0 },\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'object' },\n b: { type: 'object' },\n objs: { type: 'object', rest: true },\n },\n variants: [{ argumentNames: ['objs'] }],\n description: `Returns a new object created by merging together all arguments.\n\nIf two keys appears in more than one object the value from the last object is used.\nIf no arguments are provided \\`null\\` is returned.`,\n seeAlso: ['merge-with', 'assoc'],\n examples: [\n '{ x: 10 } merge { y: 20 }',\n 'merge(object(\"x\", 10), object(\"y\", 20))',\n 'merge(object(\"x\", 10), object(\"x\", 15, \"y\", 20))',\n ],\n },\n },\n\n 'merge-with': {\n evaluate: (params: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n const first = params[0]\n const fn = params.at(-1)\n const rest = params.slice(1, -1)\n\n assertObj(first, sourceCodeInfo)\n assertFunctionLike(fn, sourceCodeInfo)\n\n return reduceSequential(\n rest,\n (result: Obj, obj) => {\n assertObj(obj, sourceCodeInfo)\n const entries = Object.entries(obj)\n return chain(\n reduceSequential(\n entries,\n (res: Obj, entry) => {\n const key = asString(entry[0], sourceCodeInfo)\n const val = toAny(entry[1])\n if (collHasKey(res, key)) {\n return chain(executeFunction(fn, [res[key], val], contextStack, sourceCodeInfo), (merged) => {\n res[key] = merged\n return res\n })\n }\n else {\n res[key] = val\n return res\n }\n },\n result,\n ),\n r => r,\n )\n },\n { ...first } satisfies Obj,\n )\n },\n arity: { min: 2 },\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n objs: { type: 'object', rest: true },\n fun: { type: 'function' },\n },\n variants: [{ argumentNames: ['objs', 'fun'] }],\n description: `\nReturns a new object created by merging together all arguments.\nIf two keys appears in more than one object $fun is used to calculate the new value.\n\nIf no arguments are provided \\`null\\` is returned.`,\n seeAlso: ['merge'],\n examples: [\n 'merge-with(object(\"x\", 10), object(\"y\", 20), +)',\n 'merge-with(object(\"x\", 10), object(\"x\", 15, \"y\", 20), +)',\n 'merge-with({ x: 10 }, { x: 20 }, { x: 30 }, { x: 40 }, -)',\n ],\n hideOperatorForm: true,\n },\n },\n\n 'zipmap': {\n evaluate: ([keys, values], sourceCodeInfo): Any => {\n assertStringArray(keys, sourceCodeInfo)\n assertArray(values, sourceCodeInfo)\n\n const length = Math.min(keys.length, values.length)\n\n const result: Obj = {}\n\n for (let i = 0; i < length; i += 1) {\n const key = asString(keys[i], sourceCodeInfo)\n result[key] = toAny(values[i])\n }\n return result\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'array' },\n b: { type: 'array' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns a new object created by mapping $a to $b.',\n seeAlso: ['entries', 'keys', 'vals', 'sequence.interleave'],\n examples: [\n '[\"a\", \"b\", \"c\"] zipmap [1, 2, 3]',\n 'zipmap([\"a\", \"b\", \"c\"], [10, null, [1, 2, 3]])',\n 'zipmap([\"a\", \"b\", \"c\"], [1])',\n 'zipmap([], [10, null, [1, 2, 3]])',\n ],\n },\n },\n\n 'select-keys': {\n evaluate: ([obj, keys], sourceCodeInfo): Any => {\n assertStringArray(keys, sourceCodeInfo)\n assertObj(obj, sourceCodeInfo)\n\n return keys.reduce((result: Obj, key) => {\n if (collHasKey(obj, key))\n result[key] = toAny(obj[key])\n\n return result\n }, {})\n },\n arity: toFixedArity(2),\n docs: {\n category: 'object',\n returns: { type: 'object' },\n args: {\n a: { type: 'object' },\n b: { type: 'array' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Returns an object containing only those entries in $a whose key is in $b.',\n seeAlso: ['dissoc', 'keys'],\n examples: [\n '{ a: 1, b: 2, c: 3 } select-keys [\"a\", \"b\"]',\n 'select-keys({ a: 1, b: 2, c: 3 }, [\"a\", \"b\"])',\n 'select-keys({ a: 1 }, [\"a\", \"b\"])',\n ],\n },\n },\n}\n","import { isLitsFunction } from '../../typeGuards/litsFunction'\nimport { assertColl, isColl, isObj, isRegularExpression, isSeq } from '../../typeGuards/lits'\nimport { assertNumber, isNumber } from '../../typeGuards/number'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { isGrid, isMatrix, isVector } from '../../typeGuards/annotatedArrays'\nimport { EPSILON } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\n\nexport const predicatesNormalExpression: BuiltinNormalExpressions = {\n 'function?': {\n evaluate: ([first]): boolean => isLitsFunction(first),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a function, otherwise `false`.',\n seeAlso: ['string?', 'number?', 'boolean?', 'null?', 'array?', 'object?', 'regexp?'],\n examples: [\n 'function?(+)',\n 'function?(/)',\n 'function?((x, y) -> x + y)',\n 'function?(false)',\n 'function?(\"false\")',\n 'function?([1, 2, 3])',\n ],\n },\n },\n\n 'string?': {\n evaluate: ([first]): boolean => typeof first === 'string',\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a string, otherwise `false`.',\n seeAlso: ['blank?', 'number?', 'boolean?', 'null?', 'array?', 'object?', 'regexp?', 'function?', 'collection?', 'sequence?'],\n examples: [\n 'string?(\"\")',\n 'string?(\"A string\")',\n 'string?(true ? \"A string\" : false)',\n 'string?(false)',\n 'string?([1, 2, 3])',\n 'string?(100)',\n ],\n },\n },\n\n 'number?': {\n evaluate: ([first]): boolean => typeof first === 'number',\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a number, otherwise `false`.',\n seeAlso: ['integer?', 'zero?', 'pos?', 'neg?', 'finite?', 'number', 'string?', 'boolean?', 'null?', 'function?'],\n examples: [\n 'number?(0)',\n 'number?(2)',\n 'number?(-0.12)',\n 'number?(false)',\n 'number?([1, 2, 3])',\n 'number?(\"A string\")',\n ],\n },\n },\n\n 'integer?': {\n evaluate: ([first]): boolean => typeof first === 'number' && isNumber(first, { integer: true }),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is an integer, otherwise `false`.',\n seeAlso: ['number?', 'number', 'even?', 'odd?'],\n examples: [\n 'integer?(0)',\n 'integer?(-12)',\n 'integer?(42)',\n 'integer?(10.1)',\n 'integer?((x, y) -> x + y)',\n 'integer?(false)',\n 'integer?(\"false\")',\n 'integer?([1, 2, 3])',\n ],\n },\n },\n\n 'boolean?': {\n evaluate: ([first]): boolean => typeof first === 'boolean',\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a `boolean`, otherwise `false`.',\n seeAlso: ['true?', 'false?', 'boolean', 'string?', 'number?', 'null?', 'function?'],\n examples: [\n 'boolean?(true)',\n 'boolean?(false)',\n 'boolean?([1, 2, 3])',\n 'boolean?(0)',\n 'boolean?(\"A string\")',\n ],\n },\n },\n\n 'null?': {\n evaluate: ([first]): boolean => first === null || first === undefined,\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `null`, otherwise `false`.',\n seeAlso: ['empty?', 'not-empty?', 'string?', 'number?', 'boolean?', 'function?'],\n examples: [\n 'null?(null)',\n 'null?(false)',\n 'null?([1, 2, 3])',\n 'null?(0)',\n 'null?(\"A string\")',\n ],\n },\n },\n\n 'zero?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo, { finite: true })\n return Math.abs(value) < EPSILON\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `0`, otherwise `false`.',\n seeAlso: ['pos?', 'neg?', 'even?', 'number?'],\n examples: [\n 'zero?(0)',\n 'zero?(-0.0)',\n 'zero?(1)',\n 'zero?(0.1)',\n ],\n },\n },\n\n 'pos?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return first > 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is greater than `0`, otherwise `false`.',\n seeAlso: ['neg?', 'zero?', 'number?'],\n examples: [\n 'pos?(0)',\n 'pos?(-0.0)',\n 'pos?(1)',\n 'pos?(-0.1)',\n ],\n },\n },\n\n 'neg?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return first < 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is less than `0`, otherwise `false`.',\n seeAlso: ['pos?', 'zero?', 'number?'],\n examples: [\n 'neg?(0)',\n 'neg?(-0.0)',\n 'neg?(1)',\n 'neg?(-0.1)',\n ],\n },\n },\n\n 'even?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return first % 2 === 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is even, otherwise `false`.',\n seeAlso: ['odd?', 'integer?', 'zero?'],\n examples: [\n 'even?(0)',\n 'even?(-0.0)',\n 'even?(-1)',\n 'even?(2.1)',\n ],\n },\n },\n\n 'odd?': {\n evaluate: ([first], sourceCodeInfo): boolean => {\n assertNumber(first, sourceCodeInfo, { finite: true })\n return isNumber(first, { integer: true }) && first % 2 !== 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is odd, otherwise `false`.',\n seeAlso: ['even?', 'integer?'],\n examples: [\n 'odd?(1.0)',\n 'odd?(1.001)',\n 'odd?(-1)',\n 'odd?(2.1)',\n ],\n },\n },\n\n 'array?': {\n evaluate: ([first]): boolean => {\n return Array.isArray(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is an array, otherwise `false`.',\n seeAlso: ['sequence?', 'collection?', 'object?', 'string?', 'vector?', 'matrix?', 'grid?', 'function?'],\n examples: [\n 'array?([])',\n 'array?([1, 2, 3])',\n 'array?(object(\"a\", 10))',\n 'array?(42)',\n 'array?(10.1)',\n 'array?((x, y) -> x + y)',\n ],\n },\n },\n\n 'collection?': {\n evaluate: ([first]): boolean => {\n return isColl(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a collection i.e. an array, an object or a string, otherwise `false`.',\n seeAlso: ['sequence?', 'array?', 'object?', 'string?'],\n examples: [\n 'collection?([])',\n 'collection?([1, 2, 3])',\n 'collection?(object(\"a\", 10))',\n 'collection?(\"Albert\")',\n 'collection?(42)',\n 'collection?(10.1)',\n 'collection?((x, y) -> x + y)',\n ],\n },\n },\n\n 'sequence?': {\n evaluate: ([first]): boolean => {\n return isSeq(first)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a sequence i.e. an array or a string, otherwise `false`.',\n seeAlso: ['collection?', 'array?', 'string?'],\n examples: [\n 'sequence?([])',\n 'sequence?([1, 2, 3])',\n 'sequence?(object(\"a\", 10))',\n 'sequence?(\"Albert\")',\n 'sequence?(42)',\n 'sequence?(10.1)',\n 'sequence?((x, y) -> x + y)',\n ],\n },\n },\n\n 'object?': {\n evaluate: ([first]): boolean => isObj(first),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is an object, otherwise `false`.',\n seeAlso: ['collection?', 'array?', 'string?', 'function?'],\n examples: [\n 'object?(object(\"a\", 10))',\n 'object?(42)',\n 'object?(10.1)',\n 'object?((x, y) -> x + y)',\n 'object?(#\"^start\")',\n 'object?(\"false\")',\n 'object?([1, 2, 3])',\n ],\n },\n },\n\n 'regexp?': {\n evaluate: ([value]): boolean => isRegularExpression(value),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is a regexp, otherwise `false`.',\n seeAlso: ['regexp', 'match', 'string?', 'function?'],\n examples: [\n 'regexp?(regexp(\"^start\"))',\n 'regexp?(#\"^start\")',\n 'regexp?(-12)',\n 'regexp?({})',\n 'regexp?(10.1)',\n 'regexp?((x, y) -> x + y)',\n 'regexp?(false)',\n 'regexp?(\"false\")',\n 'regexp?([1, 2, 3])',\n ],\n },\n },\n\n 'finite?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo)\n return Number.isFinite(value)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is finite, otherwise `false`.',\n seeAlso: ['positive-infinity?', 'negative-infinity?', 'number?'],\n examples: [\n 'finite?(1.0)',\n 'finite?(1 / 0)',\n 'finite?(-1 / 0)',\n ],\n },\n },\n\n 'positive-infinity?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo)\n return value === Number.POSITIVE_INFINITY\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x equals positive infinity, otherwise `false`.',\n seeAlso: ['negative-infinity?', 'finite?'],\n examples: [\n 'positive-infinity?(1.0)',\n 'positive-infinity?(1 / 0)',\n 'positive-infinity?(-1 / 0)',\n ],\n },\n },\n\n 'negative-infinity?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n assertNumber(value, sourceCodeInfo)\n return value === Number.NEGATIVE_INFINITY\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'number' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x equals negative infinity, otherwise `false`.',\n seeAlso: ['positive-infinity?', 'finite?'],\n examples: [\n 'negative-infinity?(1.0)',\n 'negative-infinity?(1 / 0)',\n 'negative-infinity?(-1 / 0)',\n ],\n },\n },\n\n 'true?': {\n evaluate: ([value]): boolean => {\n return value === true\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `true`, otherwise `false`.',\n seeAlso: ['false?', 'boolean?', 'boolean'],\n examples: [\n 'true?(false)',\n 'true?(true)',\n 'true?(1)',\n 'true?(0)',\n ],\n },\n },\n\n 'false?': {\n evaluate: ([value]): boolean => {\n return value === false\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is `true`, otherwise `false`.',\n seeAlso: ['true?', 'boolean?', 'boolean'],\n examples: [\n 'false?(false)',\n 'false?(true)',\n 'false?(1)',\n 'false?(0)',\n ],\n },\n },\n\n 'empty?': {\n evaluate: ([coll], sourceCodeInfo): boolean => {\n if (coll === null)\n return true\n\n assertColl(coll, sourceCodeInfo)\n if (typeof coll === 'string')\n return coll.length === 0\n\n if (Array.isArray(coll))\n return coll.length === 0\n\n return Object.keys(coll).length === 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: ['collection', 'string', 'null'] } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `true` if $x is empty or `null`, otherwise `false`.',\n seeAlso: ['not-empty?', 'collection.not-empty', 'null?', 'blank?', 'count'],\n examples: [\n 'empty?([])',\n 'empty?([1, 2, 3])',\n 'empty?({})',\n 'empty?({ a: 2 })',\n 'empty?(\"\")',\n 'empty?(\"Albert\")',\n 'empty?(null)',\n ],\n },\n },\n 'not-empty?': {\n evaluate: ([coll], sourceCodeInfo): boolean => {\n if (coll === null)\n return false\n\n assertColl(coll, sourceCodeInfo)\n if (typeof coll === 'string')\n return coll.length > 0\n\n if (Array.isArray(coll))\n return coll.length > 0\n\n return Object.keys(coll).length > 0\n },\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n returns: { type: 'boolean' },\n args: { x: { type: ['collection', 'string', 'null'] } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns `false` if $x is empty or `null`, otherwise `true`.',\n seeAlso: ['empty?', 'collection.not-empty', 'null?'],\n examples: [\n 'not-empty?([])',\n 'not-empty?([1, 2, 3])',\n 'not-empty?({})',\n 'not-empty?({ a: 2 })',\n 'not-empty?(\"\")',\n 'not-empty?(\"Albert\")',\n 'not-empty?(null)',\n ],\n },\n },\n 'vector?': {\n evaluate: ([vector]): boolean => isVector(vector),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n description: 'Checks if a value is a `vector`. A `vector` is an array of `numbers`.',\n seeAlso: ['matrix?', 'grid?', 'array?'],\n returns: { type: 'boolean' },\n args: { value: { type: 'any', description: 'The value to check.' } },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'vector?(1)',\n 'vector?([1, 2, 3])',\n 'vector?([1, 2, \"3\"])',\n ],\n },\n },\n 'matrix?': {\n evaluate: ([matrix]): boolean => isMatrix(matrix),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n description: 'Checks if a value is a `matrix`. A `matrix` is an array of arrays of `numbers`.',\n seeAlso: ['vector?', 'grid?', 'array?'],\n returns: { type: 'boolean' },\n args: { value: { type: 'any', description: 'The value to check.' } },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'matrix?(1)',\n 'matrix?([1, 2, 3])',\n 'matrix?([[1, 2], [3, 4]])',\n 'matrix?([[1, 2], [3, \"4\"]])',\n 'matrix?([[1, 2], [3]])',\n ],\n },\n },\n 'grid?': {\n evaluate: ([table]): boolean => isGrid(table),\n arity: toFixedArity(1),\n docs: {\n category: 'predicate',\n description: 'Checks if a `value` is a `grid`. A `grid` is an `array` of `arrays` where all inner `arrays` have the same length.',\n seeAlso: ['vector?', 'matrix?', 'array?'],\n returns: { type: 'boolean' },\n args: { value: { type: 'any', description: 'The value to check.' } },\n variants: [{ argumentNames: ['value'] }],\n examples: [\n 'grid?(\"1\")',\n 'grid?([\"1\", 2, 3])',\n 'grid?([[\"1\", 2], [3, 4]])',\n 'grid?([[\"1\", 2], [3, \"4\"]])',\n 'grid?([[\"1\", 2], [3]])',\n ],\n },\n },\n\n}\n","import { LitsError } from '../../errors'\nimport type { RegularExpression } from '../../parser/types'\nimport { assertRegularExpression, assertStringOrRegularExpression, isRegularExpression } from '../../typeGuards/lits'\nimport { assertString, isString } from '../../typeGuards/string'\nimport { toFixedArity } from '../../utils/arity'\nimport { REGEXP_SYMBOL } from '../../utils/symbols'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nexport const regexpNormalExpression: BuiltinNormalExpressions = {\n 'regexp': {\n evaluate: ([sourceArg, flagsArg], sourceCodeInfo): RegularExpression => {\n assertString(sourceArg, sourceCodeInfo)\n const source = sourceArg || '(?:)'\n const flags = typeof flagsArg === 'string' ? flagsArg : ''\n\n try {\n // eslint-disable-next-line no-new\n new RegExp(source, flags) // Throws if invalid regexp\n }\n catch (e) {\n throw new LitsError(`Invalid regular expression: ${source} ${flags}`, sourceCodeInfo)\n }\n return {\n [REGEXP_SYMBOL]: true,\n sourceCodeInfo,\n s: source,\n f: flags,\n }\n },\n arity: { min: 1, max: 2 },\n docs: {\n category: 'regular-expression',\n returns: { type: 'regexp' },\n args: {\n pattern: { type: 'string' },\n flags: { type: 'string', description: 'Optional flags for the regular expression. Possible values are the same as Javascript RegExp takes.' },\n },\n variants: [\n { argumentNames: ['pattern'] },\n { argumentNames: ['pattern', 'flags'] },\n ],\n description: 'Creates a RegExp from $pattern and $flags.',\n examples: [\n 'regexp(\"^\\\\s*(.*)$\")',\n '#\"^\\\\s*(.*)$\"',\n 'regexp(\"albert\", \"ig\")',\n '#\"albert\"ig',\n ],\n seeAlso: ['-short-regexp', 'match', 'replace', 'replace-all', 'regexp?'],\n hideOperatorForm: true,\n },\n },\n 'match': {\n evaluate: ([text, regexp], sourceCodeInfo): string[] | null => {\n assertRegularExpression(regexp, sourceCodeInfo)\n if (!isString(text))\n return null\n\n const regExp = new RegExp(regexp.s, regexp.f)\n const match = regExp.exec(text)\n if (match)\n return [...match]\n\n return null\n },\n arity: toFixedArity(2),\n docs: {\n category: 'regular-expression',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'regexp' },\n b: { type: 'string' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: `Matches $b against regular expression $a.\nIf $b is a string and matches the regular expression, a \\`match\\`-array is returned, otherwise \\`null\\` is returned.`,\n seeAlso: ['regexp', 'replace', 'replace-all', '-short-regexp', 'regexp?'],\n examples: [\n 'match(\" A string\", regexp(\"^\\\\\\\\s*(.*)$\"))',\n 'match(\" A string\", #\"^\\\\s*(.*)$\")',\n 'match(\"My name is Albert\", #\"albert\"i)',\n 'match(\"My name is Ben\", #\"albert\"i)',\n 'match(null, #\"albert\"i)',\n 'match(1, #\"albert\"i)',\n 'match({}, #\"albert\"i)',\n ],\n },\n },\n 'replace': {\n evaluate: ([str, regexp, value], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n assertStringOrRegularExpression(regexp, sourceCodeInfo)\n assertString(value, sourceCodeInfo)\n\n const matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, `${regexp.f}`) : regexp\n return str.replace(matcher, value)\n },\n arity: toFixedArity(3),\n docs: {\n category: 'regular-expression',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'string' },\n b: { type: ['regexp', 'string'] },\n x: { type: 'string' },\n },\n variants: [{ argumentNames: ['a', 'b', 'x'] }],\n description: 'Returns a new string with first match of regular expression $b replaced by $x.',\n seeAlso: ['replace-all', 'regexp', 'match', '-short-regexp'],\n examples: [\n 'replace(\"Duck duck\", \"u\", \"i\")',\n 'replace(\"Duck duck\", #\"u\", \"i\")',\n 'replace(\"abcABC\", regexp(\"a\", \"i\"), \"-\")',\n 'replace(\"abcABC\", regexp(\"a\", \"gi\"), \"-\")',\n 'replace(\"abcABC\", #\"a\"i, \"-\")',\n 'replace(\"abcABC\", #\"a\"gi, \"-\")',\n ],\n },\n },\n 'replace-all': {\n evaluate: ([str, regexp, value], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n assertStringOrRegularExpression(regexp, sourceCodeInfo)\n assertString(value, sourceCodeInfo)\n const matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, `${regexp.f.includes('g') ? regexp.f : `${regexp.f}g`}`) : regexp\n return str.replaceAll(matcher, value)\n },\n arity: toFixedArity(3),\n docs: {\n category: 'regular-expression',\n returns: { type: 'any', array: true },\n args: {\n a: { type: 'string' },\n b: { type: ['regexp', 'string'] },\n x: { type: 'string' },\n },\n variants: [{ argumentNames: ['a', 'b', 'x'] }],\n description: 'Returns a new string with all matches of regular expression $b replaced by $x.',\n seeAlso: ['replace', 'regexp', 'match', '-short-regexp'],\n examples: [\n 'replace-all(\"Duck duck\", \"u\", \"i\")',\n 'replace-all(\"Duck duck\", regexp(\"u\"), \"i\")',\n 'replace-all(\"abcABC\", regexp(\"a\", \"i\"), \"-\")',\n 'replace-all(\"abcABC\", regexp(\"a\", \"gi\"), \"-\")',\n 'replace-all(\"abcABC\", #\"a\"i, \"-\")',\n 'replace-all(\"abcABC\", #\"a\"gi, \"-\")',\n ],\n },\n },\n}\n","import { LitsError } from '../../errors'\nimport type { Arr } from '../../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { assertStringOrRegularExpression, isObj } from '../../typeGuards/lits'\nimport { assertNumber } from '../../typeGuards/number'\nimport { assertString, assertStringOrNumber } from '../../typeGuards/string'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nconst blankRegexp = /^\\s*$/\nexport const stringNormalExpression: BuiltinNormalExpressions = {\n 'str': {\n evaluate: (params: Arr) => {\n return params.reduce((result: string, param) => {\n const paramStr\n = param === undefined || param === null\n ? ''\n : isObj(param)\n ? JSON.stringify(param)\n : Array.isArray(param)\n ? JSON.stringify(param)\n : `${param}`\n return result + paramStr\n }, '')\n },\n arity: {},\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { values: { type: 'any', rest: true } },\n variants: [{ argumentNames: ['values'] }],\n description: 'Concatenats $values into one string. If `value` equals `null` empty string is returned.',\n seeAlso: ['++', 'join', 'string.template', 'string.string-repeat', 'number'],\n examples: [\n 'str(\"A string\", \", and another string\", \" ...and more\")',\n 'str(\"Just one string\")',\n 'str()',\n 'str(0, false, true, null, #\"^kalle\", [1, 2, 3], {a: \"a\"})',\n ],\n hideOperatorForm: true,\n },\n },\n\n 'number': {\n evaluate: ([str], sourceCodeInfo): number => {\n assertString(str, sourceCodeInfo)\n const number = Number(str)\n if (Number.isNaN(number))\n throw new LitsError(`Could not convert '${str}' to a number.`, sourceCodeInfo)\n\n return number\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'number' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Parses $s to a number.',\n seeAlso: ['str', 'number?', 'integer?'],\n examples: [\n 'number(\"10\")',\n 'number(\"010\")',\n 'number(\"-1.01\")',\n ],\n },\n },\n\n 'lower-case': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.toLowerCase()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns $s converted to lower case.',\n seeAlso: ['upper-case', 'string.capitalize'],\n examples: [\n 'lower-case(\"Albert\")',\n 'lower-case(\"\")',\n ],\n },\n },\n\n 'upper-case': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.toUpperCase()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns $s converted to upper case.',\n seeAlso: ['lower-case', 'string.capitalize'],\n examples: [\n 'upper-case(\"Albert\")',\n 'upper-case(\"\")',\n ],\n },\n },\n\n 'trim': {\n evaluate: ([str], sourceCodeInfo): string => {\n assertString(str, sourceCodeInfo)\n return str.trim()\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: { s: { type: 'string' } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns a new string with leading and trailing whitespaces removed.',\n seeAlso: ['string.trim-left', 'string.trim-right', 'blank?'],\n examples: [\n 'trim(\" Albert \")',\n 'trim(\" \")',\n 'trim(\"\")',\n ],\n },\n },\n\n 'join': {\n evaluate: ([stringList, delimiter], sourceCodeInfo): string => {\n assertArray(stringList, sourceCodeInfo)\n stringList.forEach(str => assertStringOrNumber(str, sourceCodeInfo))\n assertString(delimiter, sourceCodeInfo)\n return stringList.join(delimiter)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: {\n a: { type: 'array' },\n b: { type: 'string' },\n arr: { type: 'array' },\n delimiter: { type: 'string' },\n },\n variants: [{ argumentNames: ['arr', 'delimiter'] }],\n description: 'Returns a new string by concatenating all of the elements in $arr, separated by $delimiter.',\n seeAlso: ['split', 'str', '++', 'sequence.interpose'],\n examples: [\n 'map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str) join \", \"',\n '([0, 1, 2, 3, 4, 5, 6, 7, 8, 9] map str) join \", \"',\n 'join([\"Albert\", 10], \", \")',\n 'join([\"Albert\", \"Mojir\"], \" \")',\n 'join(map([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], str), \", \")',\n ],\n },\n },\n\n 'split': {\n evaluate: ([str, stringOrRegExpValue, limit], sourceCodeInfo): string[] => {\n assertString(str, sourceCodeInfo)\n assertStringOrRegularExpression(stringOrRegExpValue, sourceCodeInfo)\n if (limit !== undefined)\n assertNumber(limit, sourceCodeInfo, { integer: true, nonNegative: true })\n\n const delimiter\n = typeof stringOrRegExpValue === 'string'\n ? stringOrRegExpValue\n : new RegExp(stringOrRegExpValue.s, stringOrRegExpValue.f)\n return str.split(delimiter, limit)\n },\n arity: { min: 2, max: 3 },\n docs: {\n category: 'string',\n returns: { type: 'string' },\n args: {\n a: { type: 'string' },\n b: { type: 'string' },\n s: { type: 'string' },\n delimiter: { type: 'string' },\n limit: { type: 'integer' },\n },\n variants: [\n { argumentNames: ['s', 'delimiter'] },\n { argumentNames: ['s', 'delimiter', 'limit'] },\n ],\n description: 'Divides $s into an array of substrings. The division is done by searching for `delimiter`. If `limit` as provided, at most `limit` number of substrings are returned.',\n seeAlso: ['join', 'string.split-lines'],\n examples: [\n '\"Albert Mojir\" split \" \"',\n 'split(\"Albert Mojir\", \" \")',\n 'split(\"abcdefghijklmnopqrstuvw\", #\"[aoueiy]\")',\n 'split(\"0123456789\", \"\")',\n 'split(\"0123456789\", \"\", 5) map number',\n ],\n },\n },\n 'blank?': {\n evaluate: ([value], sourceCodeInfo): boolean => {\n if (value === null) {\n return true\n }\n assertString(value, sourceCodeInfo)\n return blankRegexp.test(value)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'string',\n returns: { type: 'boolean' },\n args: { s: { type: ['string', 'null'] } },\n variants: [{ argumentNames: ['s'] }],\n description: 'Returns true if $s is null or only contains whitespace characters.',\n seeAlso: ['trim', 'empty?', 'string?'],\n examples: [\n 'blank?(\"\")',\n 'blank?(null)',\n 'blank?(\"\\n\")',\n 'blank?(\" \")',\n 'blank?(\".\")',\n ],\n },\n },\n}\n","import type { Any, Arr } from '../../interface'\nimport type {\n CompFunction,\n ConstantlyFunction,\n FunctionLike,\n} from '../../parser/types'\nimport { toAny } from '../../utils'\nimport { getArityFromFunction, toFixedArity } from '../../utils/arity'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { FUNCTION_SYMBOL } from '../../utils/symbols'\nimport type { BuiltinNormalExpressions } from '../interface'\nimport { assertArray } from '../../typeGuards/array'\nimport { assertFunctionLike } from '../../typeGuards/lits'\n\nexport const functionalNormalExpression: BuiltinNormalExpressions = {\n '|>': {\n evaluate: ([value, func], sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertFunctionLike(func, sourceCodeInfo)\n return executeFunction(func, [value], contextStack, sourceCodeInfo)\n },\n arity: toFixedArity(2),\n docs: {\n category: 'functional',\n returns: { type: 'any' },\n args: {\n a: { type: 'any' },\n b: { type: 'function' },\n },\n variants: [{ argumentNames: ['a', 'b'] }],\n description: 'Takes a value $a and a function $b, and returns the result of applying $b to $a.',\n seeAlso: ['apply', 'comp'],\n examples: [\n `\n1 |> inc |> inc`,\n `range(10)\n |> map(_, -> $ ^ 2) // [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]\n |> filter(_, odd?) // [1, 9, 25, 49, 81]\n |> reduce(_, +, 0) // 165\n |> sqrt // 12.84523257866513\n |> round(_, 2)`,\n ],\n },\n },\n 'apply': {\n evaluate: ([func, ...params]: Arr, sourceCodeInfo, contextStack, { executeFunction }): MaybePromise<Any> => {\n assertFunctionLike(func, sourceCodeInfo)\n const paramsLength = params.length\n const last = params[paramsLength - 1]\n assertArray(last, sourceCodeInfo)\n const applyArray = [...params.slice(0, -1), ...last]\n return executeFunction(func, applyArray, contextStack, sourceCodeInfo)\n },\n arity: { min: 2 },\n docs: {\n category: 'functional',\n returns: { type: 'any' },\n args: {\n a: { type: 'function' },\n b: { type: 'array' },\n fun: { type: 'function' },\n args: { type: 'array' },\n },\n variants: [{ argumentNames: ['fun', 'args'] }],\n description: 'Call supplied function $fun with specified arguments $args.',\n seeAlso: ['|>'],\n examples: [\n `\napply(+, [1, 2, 3])`,\n `\napply(\n (x, y) -> sqrt(x ^ 2 + y ^ 2),\n [3, 4]\n)`,\n `\n(x, y) -> sqrt(x ^ 2 + y ^ 2) apply [3, 4]`,\n ],\n },\n },\n\n 'identity': {\n evaluate: ([value]): Any => {\n return toAny(value)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'functional',\n returns: { type: 'any' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns $x.',\n seeAlso: ['constantly', 'functional.fnull'],\n examples: ['identity(1)', 'identity(\"Albert\")', 'identity({ a: 1 })', 'identity(null)'],\n },\n },\n\n 'comp': {\n evaluate: (params, sourceCodeInfo): CompFunction => {\n params.forEach(param => assertFunctionLike(param, sourceCodeInfo))\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Comp',\n params,\n arity: params.length > 0 ? getArityFromFunction(params.at(-1) as FunctionLike) : { min: 1, max: 1 },\n }\n },\n arity: {},\n docs: {\n category: 'functional',\n returns: { type: 'function' },\n args: {\n a: { type: 'function' },\n b: { type: 'function' },\n fns: { type: 'function', rest: true },\n },\n variants: [{ argumentNames: ['fns'] }],\n description: `Takes a variable number of functions and returns a function that is the composition of those.\n\n The returned function takes a variable number of arguments,\n applies the rightmost function to the args,\n the next function (right-to-left) to the result, etc.`,\n seeAlso: ['|>', 'functional.juxt', 'functional.complement'],\n examples: [\n `\nlet negative-quotient = comp(-, /);\nnegative-quotient(9, 3)`,\n `\nlet x = { bar: { foo: 42 } };\ncomp(\"foo\", \"bar\")(x)`,\n ],\n },\n },\n\n 'constantly': {\n evaluate: ([value], sourceCodeInfo): ConstantlyFunction => {\n return {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo,\n functionType: 'Constantly',\n value: toAny(value),\n arity: {},\n }\n },\n arity: toFixedArity(1),\n docs: {\n category: 'functional',\n returns: { type: 'function' },\n args: { x: { type: 'any' } },\n variants: [{ argumentNames: ['x'] }],\n description: 'Returns a function that takes any number of arguments and always returns $x.',\n seeAlso: ['identity', 'functional.fnull'],\n examples: [\n `\nlet always-true = constantly(true);\nalways-true(9, 3)`,\n ],\n },\n },\n\n}\n","import { smartTrim } from '..'\nimport type { Argument, FunctionReference, TypedValue } from '../../../reference'\n\nexport function generateDocString(reference: FunctionReference): string {\n return smartTrim(`\n ${reference.title}\n\n ${reference.description\n .replace(/`(.+?)`/g, '$1')\n .replace(/\\$(\\w+)/g, '$1')\n .replace(/\\*\\*\\*(.+)\\*\\*\\*/g, '$1')\n .replace(/\\*\\*(.+)\\*\\*/g, '$1')\n }\n\n Signature:\n ${signature(reference).join('\\n ')}\n\n Arguments:\n ${argStrings(reference).join('\\n ')}\n\n Examples:\n${reference.examples.map(example => smartTrim(example, 4)).join('\\n\\n')}`)\n}\n\nfunction signature({ title, variants, args, returns, _isOperator }: FunctionReference): string[] {\n const functionForms = variants.map((variant) => {\n const form = ` ${title}(${variant.argumentNames.map((argName) => {\n let result = ''\n const arg = args[argName]!\n if (arg.rest) {\n result += '...'\n }\n result += argName\n return result\n }).join(', ')})`\n\n return `${form} -> ${type(returns)}`\n })\n\n const operatorForm = _isOperator ? ['', 'Operator:', ` a ${title} b -> ${type(returns)}`] : []\n\n return [\n ...functionForms,\n ...operatorForm,\n ]\n}\n\nfunction type(arg: Argument | TypedValue) {\n const argType = arg.type\n const types = Array.isArray(argType) ? argType : [argType]\n const typeString = types.join(' | ')\n return arg.array || arg.rest ? `Array<${typeString}>` : typeString\n}\n\nfunction argStrings(reference: FunctionReference): string[] {\n return Object.entries(reference.args).map(([argName, arg]) => `${argName}: ${type(arg)}`)\n}\n","import type { FunctionReference } from '../../../reference'\nimport { assertNonUndefined } from '../../typeGuards'\nimport { assertFunctionLike } from '../../typeGuards/lits'\nimport { isLitsFunction } from '../../typeGuards/litsFunction'\nimport { toFixedArity } from '../../utils/arity'\nimport { generateDocString } from '../../utils/docString/generateDocString'\nimport type { Arity, BuiltinNormalExpressions } from '../interface'\n\nexport function getMetaNormalExpression(normalExpressionReference: Record<string, FunctionReference>): BuiltinNormalExpressions {\n return {\n doc: {\n evaluate: ([fn], sourceCodeInfo): string => {\n assertNonUndefined(normalExpressionReference)\n assertFunctionLike(fn, sourceCodeInfo)\n if (!isLitsFunction(fn)) {\n return ''\n }\n if (fn.functionType === 'Builtin') {\n const reference = normalExpressionReference[fn.name]\n return reference ? generateDocString(reference) : ''\n }\n if (fn.functionType === 'UserDefined' || fn.functionType === 'NativeJsFunction') {\n return fn.docString\n }\n return ''\n },\n arity: toFixedArity(1),\n docs: {\n category: 'meta',\n returns: { type: 'string' },\n args: { fun: { type: 'function' } },\n variants: [{ argumentNames: ['fun'] }],\n description: 'Returns documentation string of the $fun.',\n seeAlso: ['arity'],\n examples: [\n 'doc(+)',\n `\nlet add = (x, y) -> do\n \"\"\"\n Adds two numbers.\n Args:\n x: First number.\n y: Second number.\n Returns:\n Sum of x and y.\n \"\"\"\n x + y;\nend;\n\ndoc(add)`,\n ],\n },\n },\n arity: {\n evaluate: ([fn], sourceCodeInfo): Arity => {\n assertFunctionLike(fn, sourceCodeInfo)\n return isLitsFunction(fn) ? fn.arity : toFixedArity(1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'meta',\n returns: { type: 'object' },\n args: { fun: { type: 'function' } },\n variants: [{ argumentNames: ['fun'] }],\n description: 'Returns arity of the $fun. The arity is an object with the properties: `min` and `max`. If the function has fixed arity, `min` and `max` are equal to the number of required parameters. If no restrictions apply, empty object is returned.',\n seeAlso: ['doc'],\n examples: [\n 'arity(+)',\n 'arity(defined?)',\n `\nlet add = (x, y = 0) -> do\n x + y;\nend;\n\narity(add)`,\n `\nlet foo = (k, ...x) -> do\n k + x;\nend;\n arity(foo)`,\n ],\n },\n },\n }\n}\n","import { assertNonEmptyVector, assertVector } from '../../typeGuards/annotatedArrays'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinNormalExpressions } from '../interface'\n\nfunction calcMedian(vector: number[]): number {\n const sorted = [...vector].sort((a, b) => a - b)\n const mid = Math.floor(sorted.length / 2)\n return sorted.length % 2 === 0\n ? (sorted[mid - 1]! + sorted[mid]!) / 2\n : sorted[mid]!\n}\n\nexport const vectorNormalExpression: BuiltinNormalExpressions = {\n sum: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc + val, 0)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to sum.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the **sum** of all elements in the `vector`. Returns `0` for an empty vector.',\n seeAlso: ['prod', 'mean', 'median', 'vector.sum'],\n examples: [\n 'sum([1, 2, 3, 4, 5])',\n 'sum([1, -2, 3])',\n 'sum([])',\n ],\n },\n },\n\n prod: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc * val, 1)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to multiply.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the **product** of all elements in the `vector`. Returns `1` for an empty vector.',\n seeAlso: ['sum', 'mean', 'median', 'vector.prod'],\n examples: [\n 'prod([1, 2, 3, 4, 5])',\n 'prod([1, -2, 3])',\n 'prod([])',\n ],\n },\n },\n\n mean: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return vector.reduce((acc, val) => acc + val, 0) / vector.length\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to calculate the mean of.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the arithmetic **mean** of all elements in the `vector`. Throws for an empty vector.',\n seeAlso: ['median', 'sum', 'prod', 'vector.mean'],\n examples: [\n 'mean([1, 2, 3, 4, 5])',\n 'mean([1, -2, 3])',\n ],\n },\n },\n\n median: {\n evaluate: ([vector], sourceCodeInfo): number => {\n assertNonEmptyVector(vector, sourceCodeInfo)\n return calcMedian(vector)\n },\n arity: toFixedArity(1),\n docs: {\n category: 'vector',\n returns: { type: 'number' },\n args: {\n vector: { type: 'vector', description: 'The vector to calculate the median of.' },\n },\n variants: [{ argumentNames: ['vector'] }],\n description: 'Returns the **median** of all elements in the `vector`. For even-length vectors, returns the average of the two middle values. Throws for an empty vector.',\n seeAlso: ['mean', 'sum', 'prod', 'vector.median'],\n examples: [\n 'median([1, 2, 3, 4, 5])',\n 'median([1, 2, 3, 4])',\n 'median([3, 1, 4, 1, 5])',\n ],\n },\n },\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/lits'\nimport { reduceSequential } from '../../utils/maybePromise'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type AndNode = SpecialExpressionNode<[typeof specialExpressionTypes['&&'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'any',\n },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n c: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: `\nComputes logical \\`and\\`. Evaluation of expressions starts from left.\nAs soon as an \\`expression\\` evaluates to a falsy value, the result is returned.\n\nIf all expressions evaluate to truthy values, the value of the last expression is returned.`,\n examples: [\n 'true && 1',\n '&&(1, 1)',\n '&&(3 > 2, \"string\")',\n '&&(3 < 2, \"string\")',\n '&&(true, true, true, true)',\n '&&(true, true, 0, true)',\n ],\n}\n\nexport const andSpecialExpression: BuiltinSpecialExpression<Any, AndNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n return reduceSequential(\n node[1][1],\n (acc, param) => {\n if (!acc)\n return acc\n return evaluateNode(param, contextStack)\n },\n true as Any,\n )\n },\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n let value: Any = true\n for (const param of params) {\n value = asAny(param, sourceCodeInfo)\n if (!value)\n break\n }\n return value\n },\n\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain } from '../../utils/maybePromise'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type CondNode = SpecialExpressionNode<[typeof specialExpressionTypes['cond'], [AstNode, AstNode][]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['cond cond-branch cond-branch ... end'],\n details: [\n ['cond-branch', 'case test then body', 'A branch of the cond expression.'],\n ['test', 'expression', 'The condition to test.'],\n ['body', 'expressions', 'The expressions to evaluate if the test is truthy.'],\n ],\n description: 'Used for branching. `cond-branches` are tested sequentially from the top. If no branch is tested truthy, `null` is returned.',\n examples: [\n `\ncond\n case false then write!(\"FALSE\")\n case true then write!(\"TRUE\")\nend`,\n `\ncond\n case false then write!(\"FALSE\")\n case null then write!(\"null\")\nend ?? write!(\"TRUE\")`,\n `\ncond\n case false then write!(\"FALSE\")\n case null then write!(\"null\")\nend ?? write!(\"TRUE\")`,\n ],\n}\n\nexport const condSpecialExpression: BuiltinSpecialExpression<Any, CondNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const params = node[1][1]\n function processCase(index: number): MaybePromise<Any> {\n if (index >= params.length)\n return null\n const [test, form] = params[index]!\n return chain(evaluateNode(test, contextStack), (value) => {\n if (!value)\n return processCase(index + 1)\n return evaluateNode(form, contextStack)\n })\n }\n return processCase(0)\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1].flat(), contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain } from '../../utils/maybePromise'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type SwitchNode = SpecialExpressionNode<[typeof specialExpressionTypes['switch'], AstNode, [AstNode, AstNode][]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['switch value switch-branch switch-branch ... end'],\n details: [\n ['value', 'any', 'The value to test.'],\n ['switch-branch', 'case test then body', 'A branch of the switch expression.'],\n ['test', 'expression', 'The condition to test.'],\n ['body', 'expressions', 'The expressions to evaluate if the test is truthy.'],\n ],\n description: 'Used for branching. `switch-branches` are tested sequentially from the top against `value`. If no branch is tested truthy, `null` is returned.',\n examples: [\n `\nswitch 1\n case 1 then write!(\"One\")\n case 2 then write!(\"Two\")\nend`,\n `\nswitch 2\n case 1 then write!(\"One\")\n case 2 then write!(\"Two\")\nend`,\n `\nswitch 3\n case 1 then write!(\"One\")\n case 2 then write!(\"Two\")\nend`,\n ],\n}\n\nexport const switchSpecialExpression: BuiltinSpecialExpression<Any, SwitchNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const [, switchValueNode, cases] = node[1]\n return chain(evaluateNode(switchValueNode, contextStack), (switchValue) => {\n function processCase(index: number): MaybePromise<Any> {\n if (index >= cases.length)\n return null\n const [test, form] = cases[index]!\n return chain(evaluateNode(test, contextStack), (value) => {\n if (value === switchValue) {\n return evaluateNode(form, contextStack)\n }\n return processCase(index + 1)\n })\n }\n return processCase(0)\n })\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols([node[1][1], ...node[1][2].flat()], contextStack, builtin, evaluateNode),\n}\n","import type { BuiltinNormalExpression, BuiltinNormalExpressions } from '../interface'\nimport type { Any } from '../../interface'\nimport type { FunctionReference } from '../../../reference'\nimport type { CoreNormalExpressionName } from '../../../reference/api'\n\n// Core categories - always available\nimport { bitwiseNormalExpression } from '../core/bitwise'\nimport { collectionNormalExpression } from '../core/collection'\nimport { arrayNormalExpression } from '../core/array'\nimport { sequenceNormalExpression } from '../core/sequence'\nimport { mathNormalExpression } from '../core/math'\nimport { miscNormalExpression } from '../core/misc'\nimport { objectNormalExpression } from '../core/object'\nimport { predicatesNormalExpression } from '../core/predicates'\nimport { regexpNormalExpression } from '../core/regexp'\nimport { stringNormalExpression } from '../core/string'\nimport { functionalNormalExpression } from '../core/functional'\nimport { getMetaNormalExpression } from '../core/meta'\nimport { vectorNormalExpression } from '../core/vector'\n\nconst normalExpressionReference: Record<string, FunctionReference> = {}\n\nexport function setNormalExpressionReference(reference: Record<CoreNormalExpressionName, FunctionReference>) {\n Object.assign(normalExpressionReference, reference)\n}\n\nconst expressions: BuiltinNormalExpressions = {\n // Core categories\n ...bitwiseNormalExpression,\n ...collectionNormalExpression,\n ...arrayNormalExpression,\n ...sequenceNormalExpression,\n ...mathNormalExpression,\n ...getMetaNormalExpression(normalExpressionReference),\n ...miscNormalExpression,\n ...objectNormalExpression,\n ...predicatesNormalExpression,\n ...regexpNormalExpression,\n ...stringNormalExpression,\n ...functionalNormalExpression,\n ...vectorNormalExpression,\n}\n\nObject.entries(expressions).forEach(([name, expression]) => {\n expression.name = name\n})\n\nexport const normalExpressions: BuiltinNormalExpressions = {\n ...expressions,\n}\n\nexport const normalExpressionTypes: Record<string, number> = {}\nexport const allNormalExpressions: BuiltinNormalExpression<Any>[] = []\n\nObject.entries(normalExpressions).forEach(([key, value], index) => {\n normalExpressionTypes[key] = index\n allNormalExpressions.push(value)\n})\n","import { NodeTypes } from '../constants/constants'\nimport type {\n AstNode,\n ExpressionNode,\n NormalBuiltinSymbolNode,\n NormalExpressionNode,\n NormalExpressionNodeWithName,\n SpecialBuiltinSymbolNode,\n SpreadNode,\n SymbolNode,\n UserDefinedSymbolNode,\n} from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { getAssertionError } from '../utils/getAssertionError'\n\nexport function isSymbolNode(node: AstNode): node is SymbolNode {\n const nodeType = node[0]\n return NodeTypes.UserDefinedSymbol === nodeType\n || NodeTypes.NormalBuiltinSymbol === nodeType\n || NodeTypes.SpecialBuiltinSymbol === nodeType\n}\nexport function asSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): SymbolNode {\n assertSymbolNode(node, sourceCodeInfo)\n return node\n}\nexport function assertSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): asserts node is SymbolNode {\n if (!isSymbolNode(node))\n throw getAssertionError('SymbolNode', node, sourceCodeInfo)\n}\n\nexport function isUserDefinedSymbolNode(node: AstNode): node is UserDefinedSymbolNode {\n return NodeTypes.UserDefinedSymbol === node[0]\n}\nexport function asUserDefinedSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): UserDefinedSymbolNode {\n assertUserDefinedSymbolNode(node, sourceCodeInfo)\n return node\n}\nfunction assertUserDefinedSymbolNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): asserts node is UserDefinedSymbolNode {\n if (!isUserDefinedSymbolNode(node))\n throw getAssertionError('UserDefinedSymbolNode', node, sourceCodeInfo)\n}\n\nexport function isNormalBuiltinSymbolNode(node: AstNode): node is NormalBuiltinSymbolNode {\n return NodeTypes.NormalBuiltinSymbol === node[0]\n}\n\nexport function isSpecialBuiltinSymbolNode(node: AstNode): node is SpecialBuiltinSymbolNode {\n return NodeTypes.SpecialBuiltinSymbol === node[0]\n}\n\nexport function isNormalExpressionNode(node: AstNode): node is NormalExpressionNode {\n return node[0] === NodeTypes.NormalExpression\n}\nexport function asNormalExpressionNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): NormalExpressionNode {\n assertNormalExpressionNode(node, sourceCodeInfo)\n return node\n}\nexport function assertNormalExpressionNode(\n node: AstNode,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts node is NormalExpressionNode {\n if (!isNormalExpressionNode(node))\n throw getAssertionError('NormalExpressionNode', node, sourceCodeInfo)\n}\n\nexport function isNormalExpressionNodeWithName(node: AstNode): node is NormalExpressionNodeWithName {\n if (!isNormalExpressionNode(node)) {\n return false\n }\n return isSymbolNode(node[1][0])\n}\nexport function asNormalExpressionNodeWithName(\n node: AstNode,\n sourceCodeInfo?: SourceCodeInfo,\n): NormalExpressionNodeWithName {\n assertNormalExpressionNodeWithName(node, sourceCodeInfo)\n return node\n}\nexport function assertNormalExpressionNodeWithName(\n node: AstNode,\n sourceCodeInfo?: SourceCodeInfo,\n): asserts node is NormalExpressionNodeWithName {\n if (!isNormalExpressionNodeWithName(node))\n throw getAssertionError('NormalExpressionNodeWithName', node, sourceCodeInfo)\n}\n\nexport function isExpressionNode(node: AstNode): node is ExpressionNode {\n return isNormalExpressionNode(node)\n || node[0] === NodeTypes.SpecialExpression\n || node[0] === NodeTypes.Number\n || node[0] === NodeTypes.String\n}\nexport function asExpressionNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): ExpressionNode {\n assertExpressionNode(node, sourceCodeInfo)\n return node\n}\nexport function assertExpressionNode(node: AstNode, sourceCodeInfo?: SourceCodeInfo): asserts node is ExpressionNode {\n if (!isExpressionNode(node))\n throw getAssertionError('ExpressionNode', node, sourceCodeInfo)\n}\n\nexport function isSpreadNode(node: AstNode): node is SpreadNode {\n return node[0] === NodeTypes.Spread\n}\n","import type { SpecialExpressionNode, SymbolNode } from '../../parser/types'\nimport { assertSymbolNode, isUserDefinedSymbolNode } from '../../typeGuards/astNode'\nimport { toFixedArity } from '../../utils/arity'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type DefinedNode = SpecialExpressionNode<[typeof specialExpressionTypes['defined?'], SymbolNode]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'boolean',\n },\n args: {\n symbol: { type: 'any' },\n },\n variants: [\n { argumentNames: ['symbol'] },\n ],\n description: `Returns \\`true\\` if \\`symbol\\` is defined, \\`false\\` otherwise.\n\nBuilt-in symbols are always considered defined. For user-defined symbols, checks if the symbol exists in the current scope.`,\n examples: [\n 'let x = 42; defined?(x)',\n 'defined?(x)',\n 'defined?(+)',\n ],\n}\n\nexport const definedSpecialExpression: BuiltinSpecialExpression<boolean, DefinedNode> = {\n arity: toFixedArity(1),\n docs,\n evaluate: (node, contextStack) => {\n const symbolNode = node[1][1]\n assertSymbolNode(symbolNode)\n if (!isUserDefinedSymbolNode(symbolNode)) {\n return true // If the symbol is not a user defined symbol, it is defined. normal or special builtin\n }\n const lookUpResult = contextStack.lookUp(symbolNode)\n return lookUpResult !== null\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols([node[1][1]], contextStack, builtin, evaluateNode),\n}\n","import type { JsFunction } from '../Lits/Lits'\nimport type { SpecialExpressionType } from '../builtin'\nimport type { Arity } from '../builtin/interface'\nimport type { specialExpressionTypes } from '../builtin/specialExpressionTypes'\nimport type { FunctionType, NodeType, NodeTypes } from '../constants/constants'\nimport type { Context } from '../evaluator/interface'\nimport type { Any, Arr, Coll } from '../interface'\nimport type { ReservedSymbol } from '../tokenizer/reservedNames'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport type { FUNCTION_SYMBOL, REGEXP_SYMBOL } from '../utils/symbols'\n\nexport type EvaluatedFunction = [BindingTarget[], AstNode[], Context]\n\ninterface GenericLitsFunction {\n [FUNCTION_SYMBOL]: true\n sourceCodeInfo?: SourceCodeInfo\n functionType: FunctionType\n arity: Arity\n}\n\nexport interface RegularExpression {\n [REGEXP_SYMBOL]: true\n sourceCodeInfo?: SourceCodeInfo\n s: string\n f: string\n}\n\nexport interface NativeJsFunction extends GenericLitsFunction {\n functionType: 'NativeJsFunction'\n name: string | undefined // name\n nativeFn: JsFunction\n docString: string // documentation string\n}\n\nexport function isJsFunction(fn: unknown): fn is JsFunction {\n return typeof fn === 'object' && fn !== null && 'fn' in fn && typeof (fn as JsFunction).fn === 'function'\n}\n\nexport function assertJsFunction(fn: unknown): asserts fn is JsFunction {\n if (!isJsFunction(fn)) {\n throw new TypeError('Expected a NativeJsFunction')\n }\n}\n\nexport interface NativeJsModule {\n [key: string]: NativeJsFunction | NativeJsModule\n}\n\nexport interface UserDefinedFunction extends GenericLitsFunction {\n functionType: 'UserDefined'\n name: string | undefined // name\n evaluatedfunction: EvaluatedFunction\n docString: string // documentation string\n}\n\nexport interface PartialFunction extends GenericLitsFunction {\n functionType: 'Partial'\n function: FunctionLike\n params: Arr\n placeholders: number[] // indexes of the placeholders\n}\n\nexport interface CompFunction extends GenericLitsFunction {\n functionType: 'Comp'\n params: Arr\n}\n\nexport interface ConstantlyFunction extends GenericLitsFunction {\n functionType: 'Constantly'\n value: Any\n}\n\nexport interface JuxtFunction extends GenericLitsFunction {\n functionType: 'Juxt'\n params: Arr\n}\n\nexport interface ComplementFunction extends GenericLitsFunction {\n functionType: 'Complement'\n function: FunctionLike\n}\n\nexport interface EveryPredFunction extends GenericLitsFunction {\n functionType: 'EveryPred'\n params: Arr\n}\n\nexport interface SomePredFunction extends GenericLitsFunction {\n functionType: 'SomePred'\n params: Arr\n}\n\nexport interface FNullFunction extends GenericLitsFunction {\n functionType: 'Fnull'\n function: FunctionLike\n params: Arr\n}\n\nexport interface NormalBuiltinFunction extends GenericLitsFunction {\n functionType: 'Builtin'\n normalBuiltinSymbolType: number\n name: string\n}\n\nexport interface SpecialBuiltinFunction extends GenericLitsFunction {\n functionType: 'SpecialBuiltin'\n specialBuiltinSymbolType:\n | typeof specialExpressionTypes['&&']\n | typeof specialExpressionTypes['||']\n | typeof specialExpressionTypes['array']\n | typeof specialExpressionTypes['object']\n | typeof specialExpressionTypes['defined?']\n | typeof specialExpressionTypes['recur']\n | typeof specialExpressionTypes['throw']\n | typeof specialExpressionTypes['??']\n}\n\nexport interface ModuleFunction extends GenericLitsFunction {\n functionType: 'Module'\n moduleName: string\n functionName: string\n}\n\nexport type LitsFunction =\n | NativeJsFunction\n | UserDefinedFunction\n | NormalBuiltinFunction\n | SpecialBuiltinFunction\n | ModuleFunction\n | PartialFunction\n | CompFunction\n | ConstantlyFunction\n | JuxtFunction\n | ComplementFunction\n | EveryPredFunction\n | SomePredFunction\n | FNullFunction\n\nexport type LitsFunctionType = LitsFunction['functionType']\n\nexport type FunctionLike = LitsFunction | Coll | number\n\nexport type AstNode<T extends NodeType = NodeType, Payload = unknown> = [T, Payload] | [T, Payload, SourceCodeInfo]\n\nexport type ExpressionNode = NormalExpressionNode | SpecialExpressionNode | NumberNode | StringNode\n\nexport type SpreadNode = AstNode<typeof NodeTypes.Spread, AstNode> // Payload should be array or object depending on context\nexport type NumberNode = AstNode<typeof NodeTypes.Number, number>\nexport type StringNode = AstNode<typeof NodeTypes.String, string>\nexport type UserDefinedSymbolNode = AstNode<typeof NodeTypes.UserDefinedSymbol, string>\nexport type NormalBuiltinSymbolNode = AstNode<typeof NodeTypes.NormalBuiltinSymbol, number>\nexport type SpecialBuiltinSymbolNode = AstNode<typeof NodeTypes.SpecialBuiltinSymbol, SpecialExpressionType>\nexport type SymbolNode = UserDefinedSymbolNode | NormalBuiltinSymbolNode | SpecialBuiltinSymbolNode\nexport type ReservedSymbolNode = AstNode<typeof NodeTypes.ReservedSymbol, ReservedSymbol>\nexport type SpecialExpressionNode<T extends [SpecialExpressionType, ...unknown[]] = [SpecialExpressionType, ...unknown[]]> = AstNode<typeof NodeTypes.SpecialExpression, T> // [name, params]\n\nexport type NormalExpressionNodeWithName = AstNode<typeof NodeTypes.NormalExpression, [NormalBuiltinSymbolNode | UserDefinedSymbolNode, AstNode[]]> // [params, name]\nexport type NormalExpressionNodeExpression = AstNode<typeof NodeTypes.NormalExpression, [AstNode, AstNode[]]> // [name, node as function] node can be string number object or array\nexport type NormalExpressionNode = NormalExpressionNodeWithName | NormalExpressionNodeExpression\nexport const bindingTargetTypes = {\n symbol: 11,\n rest: 12,\n object: 13,\n array: 14,\n} as const\n\nexport type BindingTargetType = typeof bindingTargetTypes[keyof typeof bindingTargetTypes]\n\ntype GenericTarget<T extends BindingTargetType, Payload extends unknown[]> = [T, Payload] | [T, Payload, SourceCodeInfo]\n\nexport type SymbolBindingTarget = GenericTarget<typeof bindingTargetTypes.symbol, [SymbolNode, AstNode | undefined /* default value */]>\nexport type RestBindingTarget = GenericTarget<typeof bindingTargetTypes.rest, [string, AstNode | undefined /* default value */]>\nexport type ObjectBindingTarget = GenericTarget<typeof bindingTargetTypes.object, [Record<string, BindingTarget>, AstNode | undefined /* default value */]>\nexport type ArrayBindingTarget = GenericTarget<typeof bindingTargetTypes.array, [(BindingTarget | null)[], AstNode | undefined /* default value */]>\n\nexport type BindingTarget = SymbolBindingTarget | RestBindingTarget | ObjectBindingTarget | ArrayBindingTarget\n\nexport type BindingNode = AstNode<typeof NodeTypes.Binding, [BindingTarget, AstNode]> // [target, value]\n\ntype AstBody = AstNode[]\nexport interface Ast {\n body: AstBody // body\n hasDebugData: boolean\n}\n","import { LitsError } from '../errors'\nimport type { Any } from '../interface'\nimport { type AstNode, type BindingTarget, type RestBindingTarget, type UserDefinedSymbolNode, bindingTargetTypes } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { assertUnknownRecord } from '../typeGuards'\nimport { assertArray } from '../typeGuards/array'\nimport { asAny, assertAny } from '../typeGuards/lits'\nimport type { MaybePromise } from '../utils/maybePromise'\nimport { chain, forEachSequential } from '../utils/maybePromise'\n\nexport function walkDefaults(\n bindingTarget: BindingTarget,\n onDefault: (Node: AstNode) => void,\n): void {\n if (bindingTarget[0] === bindingTargetTypes.object) {\n Object.values(bindingTarget[1][0]).forEach((element) => {\n if (element[1][1]) {\n onDefault(element[1][1])\n }\n walkDefaults(element, onDefault)\n })\n }\n else if (bindingTarget[0] === bindingTargetTypes.array) {\n for (let index = 0; index < bindingTarget[1][0].length; index += 1) {\n const element = bindingTarget[1][0][index] ?? null\n if (element === null) {\n continue\n }\n if (element[1][1]) {\n onDefault(element[1][1])\n }\n walkDefaults(element, onDefault)\n }\n }\n}\n\nexport function evaluateBindingNodeValues(\n target: BindingTarget,\n value: Any,\n evaluate: (Node: AstNode) => MaybePromise<Any>,\n): MaybePromise<Record<string, Any>> {\n const sourceCodeInfo = target[2]\n const record: Record<string, Any> = {}\n return chain(createRecord(target, value, evaluate, sourceCodeInfo, record), () => record)\n}\n\nfunction createRecord(\n bindingTarget: BindingTarget,\n value: Any,\n evaluate: (Node: AstNode) => MaybePromise<Any>,\n sourceCodeInfo: SourceCodeInfo | undefined,\n record: Record<string, Any>,\n): MaybePromise<void> {\n if (bindingTarget[0] === bindingTargetTypes.object) {\n assertUnknownRecord(value, sourceCodeInfo)\n const capturedKeys = new Set<string>()\n let restElement: RestBindingTarget | undefined\n const entries = Object.entries(bindingTarget[1][0])\n\n return chain(\n forEachSequential(entries, ([key, element]) => {\n if (element[0] === bindingTargetTypes.rest) {\n restElement = element\n return\n }\n capturedKeys.add(key)\n const existingVal = value[key]\n const maybeVal: MaybePromise<Any> = existingVal !== undefined\n ? existingVal as Any\n : element[1][1]\n ? evaluate(element[1][1])\n : null\n return chain(maybeVal, (resolvedVal) => {\n const val = resolvedVal ?? null\n assertAny(val, sourceCodeInfo)\n return createRecord(element, val, evaluate, sourceCodeInfo, record)\n })\n }),\n () => {\n if (restElement) {\n const restValues = Object.entries(value)\n .filter(([key]) => !capturedKeys.has(key))\n .reduce((acc: Record<string, Any>, [key, val]) => {\n acc[key] = asAny(val)\n return acc\n }, {})\n\n record[restElement[1][0]] = restValues\n }\n },\n )\n }\n else if (bindingTarget[0] === bindingTargetTypes.array) {\n let restIndex: number | null = null\n assertArray(value, sourceCodeInfo)\n\n const elements: Array<{ element: BindingTarget, index: number }> = []\n for (let index = 0; index < bindingTarget[1][0].length; index += 1) {\n const element = bindingTarget[1][0][index] ?? null\n if (element === null) {\n continue\n }\n if (element[0] === bindingTargetTypes.rest) {\n restIndex = index\n break\n }\n elements.push({ element, index })\n }\n\n return chain(\n forEachSequential(elements, ({ element, index }) => {\n const existingVal = value[index]\n const maybeVal: MaybePromise<Any> = existingVal !== undefined\n ? existingVal as Any\n : element[1][1]\n ? evaluate(element[1][1])\n : null\n return chain(maybeVal, (resolvedVal) => {\n const val = resolvedVal ?? null\n assertAny(val, sourceCodeInfo)\n return createRecord(element, val, evaluate, sourceCodeInfo, record)\n })\n }),\n () => {\n if (restIndex !== null) {\n const restValues = value.slice(restIndex)\n const restElement = bindingTarget[1][0][restIndex]! as RestBindingTarget\n record[restElement[1][0]] = restValues\n }\n },\n )\n }\n else if (bindingTarget[0] === bindingTargetTypes.rest) {\n record[bindingTarget[1][0]] = asAny(value)\n }\n else {\n record[(bindingTarget[1][0] as UserDefinedSymbolNode)[1]] = asAny(value)\n }\n}\n\nexport function getAllBindingTargetNames(bindingTarget: BindingTarget): Record<string, true> {\n const names: Record<string, true> = {}\n getNamesFromBindingTarget(bindingTarget, names)\n return names\n}\n\nfunction getNamesFromBindingTarget(target: BindingTarget | null, names: Record<string, true>): void {\n if (target === null) {\n return\n }\n if (target[0] === bindingTargetTypes.array) {\n for (const element of target[1][0]) {\n getNamesFromBindingTarget(element, names)\n }\n }\n else if (target[0] === bindingTargetTypes.object) {\n for (const element of Object.values(target[1][0])) {\n getNamesFromBindingTarget(element, names)\n }\n }\n else if (target[0] === bindingTargetTypes.rest) {\n if (names[target[1][0]]) {\n throw new LitsError(`Duplicate binding name: ${target[1][0]}`, target[2])\n }\n names[target[1][0]] = true\n }\n else {\n if (names[target[1][0][1]]) {\n throw new LitsError(`Duplicate binding name: ${target[1][0]}`, target[2])\n }\n names[target[1][0][1]] = true\n }\n}\n","import type { Any } from '../../interface'\nimport type { BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport { addToSet } from '../../utils'\nimport { chain } from '../../utils/maybePromise'\nimport { evaluateBindingNodeValues as evaluateBindingTargetValues, getAllBindingTargetNames, walkDefaults } from '../bindingNode'\nimport type { BuiltinSpecialExpression } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type DefNode = SpecialExpressionNode<[typeof specialExpressionTypes['0_def'], BindingNode]> // binding, value\n\nexport const defSpecialExpression: BuiltinSpecialExpression<Any, DefNode> = {\n arity: {},\n evaluate: (node, contextStack, { evaluateNode }) => {\n const bindingNode: BindingNode = node[1][1]\n const target = bindingNode[1][0]\n const value = bindingNode[1][1]\n return chain(evaluateNode(value, contextStack), (bindingValue) => {\n return chain(evaluateBindingTargetValues(target, bindingValue, Node => evaluateNode(Node, contextStack)), (values) => {\n contextStack.exportValues(values, target[2])\n return bindingValue\n })\n })\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const bindingNode: BindingNode = node[1][1]\n const target = bindingNode[1][0]\n const value = bindingNode[1][1]\n const bindingResult = getUndefinedSymbols([value], contextStack, builtin, evaluateNode)\n walkDefaults(target, (defaultNode) => {\n addToSet(bindingResult, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode))\n })\n contextStack.addValues(getAllBindingTargetNames(target), target[2])\n return bindingResult\n },\n}\n","import type { Context } from '../../evaluator/interface'\nimport type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { reduceSequential } from '../../utils/maybePromise'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type DoNode = SpecialExpressionNode<[typeof specialExpressionTypes['block'], AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['do body end'],\n details: [\n ['body', 'expressions', 'The expressions to evaluate.'],\n ],\n description: 'Evaluates `body`. Resulting value is the value of the last expression.',\n examples: [\n `\ndo\n let a = 1 + 2 + 3 + 4;\n let b = -> $ * ( $ + 1 );\n b(a)\nend`,\n ],\n}\n\nexport const doSpecialExpression: BuiltinSpecialExpression<Any, DoNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const newContext: Context = {}\n\n const newContextStack = contextStack.create(newContext)\n return reduceSequential(\n node[1][1],\n (_acc, form) => evaluateNode(form, newContextStack),\n null as Any,\n )\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n return getUndefinedSymbols(node[1][1], contextStack.create({}), builtin, evaluateNode)\n },\n}\n","import type { ContextStack } from '../../evaluator/ContextStack'\nimport type { Context, EvaluateNode } from '../../evaluator/interface'\nimport type { GetUndefinedSymbols, UndefinedSymbols } from '../../getUndefinedSymbols'\nimport {\n type EvaluatedFunction,\n type LitsFunction,\n type SpecialExpressionNode,\n bindingTargetTypes,\n} from '../../parser/types'\nimport { isAny } from '../../typeGuards/lits'\nimport { addToSet } from '../../utils'\nimport { FUNCTION_SYMBOL } from '../../utils/symbols'\nimport { getAllBindingTargetNames, walkDefaults } from '../bindingNode'\nimport type { Builtin, BuiltinSpecialExpression } from '../interface'\nimport type { Function } from '../utils'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type LambdaNode = SpecialExpressionNode<[typeof specialExpressionTypes['0_lambda'], Function, string]>\n\nexport const lambdaSpecialExpression: BuiltinSpecialExpression<LitsFunction, LambdaNode> = {\n arity: {},\n evaluate: (node, contextStack, { builtin, getUndefinedSymbols, evaluateNode }) => {\n const fn = node[1][1]\n const docString = node[1][2]\n const evaluatedFunction = evaluateFunction(fn, contextStack, builtin, getUndefinedSymbols, evaluateNode)\n\n const min = evaluatedFunction[0].filter(arg => arg[0] !== bindingTargetTypes.rest && arg[1][1] === undefined).length\n const max = evaluatedFunction[0].some(arg => arg[0] === bindingTargetTypes.rest) ? undefined : evaluatedFunction[0].length\n const arity = { min: min > 0 ? min : undefined, max }\n\n const litsFunction: LitsFunction = {\n [FUNCTION_SYMBOL]: true,\n sourceCodeInfo: node[2],\n functionType: 'UserDefined',\n name: undefined,\n evaluatedfunction: evaluatedFunction,\n arity,\n docString,\n }\n\n return litsFunction\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const fn = node[1][1]\n return getFunctionUnresolvedSymbols(fn, contextStack, getUndefinedSymbols, builtin, evaluateNode)\n },\n\n}\n\nfunction evaluateFunction(\n fn: Function,\n contextStack: ContextStack,\n builtin: Builtin,\n getUndefinedSymbols: GetUndefinedSymbols,\n evaluateNode: EvaluateNode,\n): EvaluatedFunction {\n const functionContext: Context = {}\n\n const context = fn[0].reduce((ctx: Context, arg) => {\n Object.keys(getAllBindingTargetNames(arg)).forEach((name) => {\n ctx[name] = { value: null }\n })\n return ctx\n }, {})\n const undefinedSymbols = getUndefinedSymbols(fn[1], contextStack.new(context), builtin, evaluateNode)\n undefinedSymbols.forEach((name) => {\n const value = contextStack.getValue(name)\n if (isAny(value)) {\n functionContext[name] = { value }\n }\n })\n\n const evaluatedFunction: EvaluatedFunction = [\n fn[0],\n fn[1],\n functionContext,\n ]\n\n return evaluatedFunction\n}\n\nfunction getFunctionUnresolvedSymbols(\n fn: Function,\n contextStack: ContextStack,\n getUndefinedSymbols: GetUndefinedSymbols,\n builtin: Builtin,\n evaluateNode: EvaluateNode,\n): UndefinedSymbols {\n const result = new Set<string>()\n const newContext: Context = { self: { value: null } }\n\n fn[0].forEach((arg) => {\n Object.assign(newContext, getAllBindingTargetNames(arg))\n\n walkDefaults(arg, (defaultNode) => {\n addToSet(result, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode))\n })\n })\n\n const newContextStack = contextStack.create(newContext)\n const overloadResult = getUndefinedSymbols(fn[1], newContextStack, builtin, evaluateNode)\n addToSet(result, overloadResult)\n return result\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { chain } from '../../utils/maybePromise'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type IfNode = SpecialExpressionNode<[typeof specialExpressionTypes['if'], [AstNode, AstNode, AstNode?]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['if test then true-expr else false-expr', 'if test then true-expr'],\n details: [\n ['test', 'expression', 'The condition to test.'],\n ['true-expr', 'expression', 'The expression to evaluate if the test is truthy.'],\n ['false-expr', 'expression', 'The expression to evaluate if the test is falsy.'],\n ],\n description: 'Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is truthy. If $test is falsy `false-expr` is executed, if no `false-expr` exists, `null` is returned.',\n examples: [\n `\nif true then\n write!(\"TRUE\")\nelse\n write!(\"FALSE\")\nend`,\n 'if false then write!(\"TRUE\") else write!(\"FALSE\") end',\n 'if true then write!(\"TRUE\") end',\n 'if false then write!(\"TRUE\") end',\n ],\n}\n\nexport const ifSpecialExpression: BuiltinSpecialExpression<Any, IfNode> = {\n arity: { min: 2, max: 3 },\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const [conditionNode, trueNode, falseNode] = node[1][1]\n return chain(evaluateNode(conditionNode, contextStack), (condition) => {\n if (condition) {\n return evaluateNode(trueNode, contextStack)\n }\n else if (falseNode) {\n return evaluateNode(falseNode, contextStack)\n }\n return null\n })\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) =>\n getUndefinedSymbols(node[1][1].filter(n => !!n), contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { chain } from '../../utils/maybePromise'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type UnlessNode = SpecialExpressionNode<[typeof specialExpressionTypes['unless'], [AstNode, AstNode, AstNode?]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['unless test then true-expr else false-expr end', 'unless test true-expr end'],\n details: [\n ['test', 'expression', 'The condition to test.'],\n ['true-expr', 'expression', 'The expressions to evaluate if the test is falsy.'],\n ['false-expr', 'expression', 'The expressions to evaluate if the test is truthy.'],\n ],\n description: 'Either `true-expr` or `false-expr` branch is taken. `true-expr` is selected when $test is falsy. If $test is truthy `false-expr` is executed, if no `false-expr` exists, `null` is returned.',\n examples: [\n `\nunless true then\n write!(\"TRUE\")\nelse\n write!(\"FALSE\")\nend`,\n 'unless false then write!(\"TRUE\") else write!(\"FALSE\") end',\n 'unless true then write!(\"TRUE\") end',\n 'unless false then write!(\"TRUE\") end',\n ],\n}\n\nexport const unlessSpecialExpression: BuiltinSpecialExpression<Any, UnlessNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const [conditionNode, trueNode, falseNode] = node[1][1]\n return chain(evaluateNode(conditionNode, contextStack), (condition) => {\n if (!condition) {\n return evaluateNode(trueNode, contextStack)\n }\n else if (falseNode) {\n return evaluateNode(falseNode, contextStack)\n }\n return null\n })\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) =>\n getUndefinedSymbols(node[1][1].filter(n => !!n), contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport { addToSet } from '../../utils'\nimport { toFixedArity } from '../../utils/arity'\nimport { chain } from '../../utils/maybePromise'\nimport { evaluateBindingNodeValues, getAllBindingTargetNames, walkDefaults } from '../bindingNode'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type LetNode = SpecialExpressionNode<[typeof specialExpressionTypes['let'], BindingNode]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['let s = value;'],\n details: [\n ['s', 'symbol', 'The name of the variable to bind.'],\n ['value', 'any', 'The value to bind to the variable.'],\n ],\n description: `\n Binds local variables s to \\`value\\`. \\`value\\` can be any expression. The scope of the variables is the body of the let expression.`,\n examples: [`\nlet a = 1 + 2 + 3 + 4;\nlet b = -> $ * ( $ + 1 );\nwrite!(\"a\", a, \"b\", b)`],\n}\n\nexport const letSpecialExpression: BuiltinSpecialExpression<Any, LetNode> = {\n arity: toFixedArity(0),\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const bindingNode = node[1][1]\n const target = bindingNode[1][0]\n const value = bindingNode[1][1]\n return chain(evaluateNode(value, contextStack), (bindingValue) => {\n return chain(evaluateBindingNodeValues(target, bindingValue, Node => evaluateNode(Node, contextStack)), (values) => {\n contextStack.addValues(values, target[2])\n return bindingValue\n })\n })\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const bindingNode = node[1][1]\n const target = bindingNode[1][0]\n const value = bindingNode[1][1]\n const bindingResult = getUndefinedSymbols([value], contextStack, builtin, evaluateNode)\n walkDefaults(target, (defaultNode) => {\n addToSet(bindingResult, getUndefinedSymbols([defaultNode], contextStack, builtin, evaluateNode))\n })\n contextStack.addValues(getAllBindingTargetNames(target), target[2])\n return bindingResult\n },\n}\n","import { LitsError, RecurSignal } from '../../errors'\nimport type { Context } from '../../evaluator/interface'\nimport type { Any } from '../../interface'\nimport type { AstNode, BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/lits'\nimport { joinSets } from '../../utils'\nimport { valueToString } from '../../utils/debug/debugTools'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain, forEachSequential, reduceSequential, tryCatch } from '../../utils/maybePromise'\nimport { evaluateBindingNodeValues, getAllBindingTargetNames } from '../bindingNode'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type LoopNode = SpecialExpressionNode<[typeof specialExpressionTypes['loop'], BindingNode[], AstNode]> // bindings, body\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['loop (bindings) -> body'],\n details: [\n ['bindings', 'binding pairs', 'Comma-separated bindings with initial values, e.g. `n = 10, acc = 0`.'],\n ['body', 'expression', 'The expression to evaluate repeatedly. Use `recur` to loop back with new values.'],\n ],\n description: `Creates a loop with initial bindings. Use \\`recur\\` inside the body to jump back to the loop head with new binding values.\n\nIf \\`recur\\` is not called, the loop terminates and returns the value of the body expression.`,\n examples: [\n `loop (n = 10, acc = 0) -> do\n if n == 0 then\n acc\n else\n recur(n - 1, acc + n)\n end\nend`,\n `loop (n = 5, acc = 1) -> do\n if n <= 1 then\n acc\n else\n recur(n - 1, acc * n)\n end\nend`,\n ],\n}\n\nexport const loopSpecialExpression: BuiltinSpecialExpression<Any, LoopNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const bindingNodes = node[1][1]\n\n // Set up initial binding context sequentially (bindings may depend on each other)\n const initialContext: Context = {}\n const setupBindings = reduceSequential(\n bindingNodes,\n (result: Context, bindingNode) => {\n return chain(evaluateNode(bindingNode[1][1], contextStack.create(result)), (val) => {\n return chain(evaluateBindingNodeValues(bindingNode[1][0], val, Node => evaluateNode(Node, contextStack)), (valueRecord) => {\n Object.entries(valueRecord).forEach(([name, value]) => {\n result[name] = { value }\n })\n return result\n })\n })\n },\n initialContext,\n )\n\n return chain(setupBindings, (bindingContext) => {\n const newContextStack = contextStack.create(bindingContext)\n const body = node[1][2]\n\n function rebindAndIterate(params: unknown[]): MaybePromise<Any> {\n if (params.length !== bindingNodes.length) {\n throw new LitsError(\n `recur expected ${bindingNodes.length} parameters, got ${valueToString(params.length)}`,\n node[2],\n )\n }\n return chain(\n forEachSequential(bindingNodes, (bindingNode, index) => {\n return chain(evaluateBindingNodeValues(bindingNode[1][0], asAny(params[index]), Node => evaluateNode(Node, contextStack)), (valueRecord) => {\n for (const [name, value] of Object.entries(valueRecord)) {\n bindingContext[name]!.value = value\n }\n })\n }),\n () => iterate(),\n )\n }\n\n function iterate(): MaybePromise<Any> {\n return tryCatch(\n () => evaluateNode(body, newContextStack),\n (error) => {\n if (error instanceof RecurSignal) {\n return rebindAndIterate(error.params)\n }\n throw error\n },\n )\n }\n\n // Use sync for(;;) loop for the sync case to avoid stack overflow\n for (;;) {\n try {\n const result = evaluateNode(body, newContextStack)\n if (result instanceof Promise) {\n // Async path: handle recur via promise chain\n return result.catch((error: unknown) => {\n if (error instanceof RecurSignal) {\n return rebindAndIterate(error.params)\n }\n throw error\n })\n }\n return result\n }\n catch (error) {\n if (error instanceof RecurSignal) {\n const params = error.params\n if (params.length !== bindingNodes.length) {\n throw new LitsError(\n `recur expected ${bindingNodes.length} parameters, got ${valueToString(params.length)}`,\n node[2],\n )\n }\n // rebindAndIterate returns MaybePromise — if any binding default is async,\n // we must switch to the async iterate path\n for (let index = 0; index < bindingNodes.length; index += 1) {\n const bindingNode = bindingNodes[index]!\n const valueRecord = evaluateBindingNodeValues(bindingNode[1][0], asAny(params[index]), Node => evaluateNode(Node, contextStack))\n if (valueRecord instanceof Promise) {\n // Switch to fully async path\n return valueRecord.then((resolved) => {\n for (const [name, value] of Object.entries(resolved)) {\n bindingContext[name]!.value = value\n }\n // Handle remaining bindings then iterate\n return chain(\n forEachSequential(bindingNodes.slice(index + 1), (bn, subIndex) => {\n return chain(evaluateBindingNodeValues(bn[1][0], asAny(params[index + 1 + subIndex]), Node => evaluateNode(Node, contextStack)), (vr) => {\n for (const [name, value] of Object.entries(vr)) {\n bindingContext[name]!.value = value\n }\n })\n }),\n () => iterate(),\n )\n })\n }\n for (const [name, value] of Object.entries(valueRecord)) {\n bindingContext[name]!.value = value\n }\n }\n continue\n }\n throw error\n }\n }\n })\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const bindingNodes = node[1][1]\n\n const newContext = bindingNodes\n .reduce((context: Context, bindingNode) => {\n const names = getAllBindingTargetNames(bindingNode[1][0])\n\n Object.keys(names).forEach((name) => {\n context[name] = { value: true }\n })\n return context\n }, {})\n\n const bindingValueNodes = bindingNodes.map(bindingNode => bindingNode[1][1])\n const bindingsResult = getUndefinedSymbols(bindingValueNodes, contextStack, builtin, evaluateNode)\n const paramsResult = getUndefinedSymbols([node[1][2]], contextStack.create(newContext), builtin, evaluateNode)\n return joinSets(bindingsResult, paramsResult)\n },\n}\n","import type { GetUndefinedSymbols, UndefinedSymbols } from '../../getUndefinedSymbols'\nimport type { ContextStack } from '../../evaluator/ContextStack'\nimport type { Context, EvaluateNode } from '../../evaluator/interface'\nimport type { Any, Arr } from '../../interface'\nimport type { AstNode, BindingNode, SpecialExpressionNode } from '../../parser/types'\nimport { asNonUndefined } from '../../typeGuards'\nimport { asAny, asColl, isSeq } from '../../typeGuards/lits'\nimport type { Builtin, BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport { evaluateBindingNodeValues, getAllBindingTargetNames } from '../bindingNode'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\nimport { toFixedArity } from '../../utils/arity'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain } from '../../utils/maybePromise'\n\nexport type LoopBindingNode = [BindingNode, BindingNode[], AstNode?, AstNode?] // Binding, Let-Bindings, When, While\n\nexport type ForNode = SpecialExpressionNode<[typeof specialExpressionTypes['for'], LoopBindingNode[], AstNode]> // LoopBindings, body\nexport type DoSeqNode = SpecialExpressionNode<[typeof specialExpressionTypes['doseq'], LoopBindingNode[], AstNode]> // LoopBindings, body\n\ntype LoopNode = ForNode | DoSeqNode\n\nfunction addToContext(\n bindings: BindingNode[],\n context: Context,\n contextStack: ContextStack,\n evaluateNode: EvaluateNode,\n): MaybePromise<void> {\n let bindingChain: MaybePromise<void> = undefined as unknown as void\n for (const bindingNode of bindings) {\n bindingChain = chain(bindingChain, () => {\n const [target, bindingValue] = bindingNode[1]\n return chain(evaluateNode(bindingValue, contextStack), (val) => {\n return chain(evaluateBindingNodeValues(target, val, Node => evaluateNode(Node, contextStack)), (valueRecord) => {\n Object.entries(valueRecord).forEach(([name, value]) => {\n context[name] = { value }\n })\n })\n })\n })\n }\n return bindingChain\n}\n\nfunction evaluateLoop(\n returnResult: boolean,\n loopNode: LoopNode,\n contextStack: ContextStack,\n evaluateNode: EvaluateNode,\n): MaybePromise<Any> {\n const sourceCodeInfo = loopNode[2]\n const [, loopBindings, body] = loopNode[1]\n\n const result: Arr = []\n\n const bindingIndices = loopBindings.map(() => 0)\n\n function processIteration(): MaybePromise<Any> {\n const context: Context = {}\n const newContextStack = contextStack.create(context)\n\n function processBinding(bindingIndex: number): MaybePromise<'skip' | 'abort' | 'continue'> {\n if (bindingIndex >= loopBindings.length)\n return 'continue'\n\n const [bindingNode, letBindings, whenNode, whileNode] = loopBindings[bindingIndex]!\n const [targetNode, valueNode] = bindingNode[1]\n\n return chain(evaluateNode(valueNode, newContextStack), (rawColl) => {\n const coll = asColl(rawColl, sourceCodeInfo)\n const seq = isSeq(coll) ? coll : Object.entries(coll)\n\n if (seq.length === 0) {\n return 'abort'\n }\n\n const index = asNonUndefined(bindingIndices[bindingIndex], sourceCodeInfo)\n if (index >= seq.length) {\n if (bindingIndex === 0) {\n return 'abort'\n }\n bindingIndices[bindingIndex] = 0\n bindingIndices[bindingIndex - 1] = asNonUndefined(bindingIndices[bindingIndex - 1], sourceCodeInfo) + 1\n return 'skip'\n }\n\n const val = asAny(seq[index], sourceCodeInfo)\n return chain(evaluateBindingNodeValues(targetNode, val, Node => evaluateNode(Node, newContextStack)), (valueRecord) => {\n Object.entries(valueRecord).forEach(([name, value]) => {\n context[name] = { value }\n })\n\n return chain(\n letBindings.length > 0\n ? addToContext(letBindings, context, newContextStack, evaluateNode)\n : undefined as unknown as void,\n () => {\n if (whenNode) {\n return chain(evaluateNode(whenNode, newContextStack), (whenResult) => {\n if (!whenResult) {\n bindingIndices[bindingIndex] = asNonUndefined(bindingIndices[bindingIndex], sourceCodeInfo) + 1\n return 'skip' as const\n }\n if (whileNode) {\n return chain(evaluateNode(whileNode, newContextStack), (whileResult) => {\n if (!whileResult) {\n bindingIndices[bindingIndex] = Number.POSITIVE_INFINITY\n return 'skip' as const\n }\n return processBinding(bindingIndex + 1)\n })\n }\n return processBinding(bindingIndex + 1)\n })\n }\n if (whileNode) {\n return chain(evaluateNode(whileNode, newContextStack), (whileResult) => {\n if (!whileResult) {\n bindingIndices[bindingIndex] = Number.POSITIVE_INFINITY\n return 'skip' as const\n }\n return processBinding(bindingIndex + 1)\n })\n }\n return processBinding(bindingIndex + 1)\n },\n )\n })\n })\n }\n\n return chain(processBinding(0), (status) => {\n if (status === 'abort') {\n return returnResult ? result : null\n }\n if (status === 'skip') {\n return processIteration()\n }\n // status === 'continue'\n return chain(evaluateNode(body, newContextStack), (value) => {\n if (returnResult)\n result.push(value)\n\n if (bindingIndices.length > 0)\n bindingIndices[bindingIndices.length - 1]! += 1\n\n return processIteration()\n })\n })\n }\n\n return processIteration()\n}\n\nfunction analyze(\n loopNode: LoopNode,\n contextStack: ContextStack,\n getUndefinedSymbols: GetUndefinedSymbols,\n builtin: Builtin,\n evaluateNode: EvaluateNode,\n): UndefinedSymbols {\n const result = new Set<string>()\n const newContext: Context = {}\n const [, loopBindings, body] = loopNode[1]\n loopBindings.forEach((loopBindingNode) => {\n const [bindingNode, letBindings, whenNode, whileNode] = loopBindingNode\n const [target, value] = bindingNode[1]\n getUndefinedSymbols([value], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n Object.assign(newContext, getAllBindingTargetNames(target))\n if (letBindings) {\n letBindings.forEach((letBindingNode) => {\n const [letTarget, letValue] = letBindingNode[1]\n\n getUndefinedSymbols([letValue], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n Object.assign(newContext, getAllBindingTargetNames(letTarget))\n })\n }\n if (whenNode) {\n getUndefinedSymbols([whenNode], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n }\n if (whileNode) {\n getUndefinedSymbols([whileNode], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n }\n })\n getUndefinedSymbols([body], contextStack.create(newContext), builtin, evaluateNode).forEach(symbol =>\n result.add(symbol),\n )\n return result\n}\n\nconst forDocs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['for (...binding) -> body'],\n details: [\n ['binding', 'loop-var in collection [...let-binding] [where whereExpr] [while whileExp]', 'A for loop binding'],\n ['loop-var', 'symbol', 'The name of the loop variable.'],\n ['collection', 'any', 'The collection to iterate over.'],\n ['let-binding', 'let binding', 'A let binding to create a local variable.'],\n ['whereExpr', 'expression', 'An expression that must evaluate to truthy for the loop body to be executed.'],\n ['whileExp', 'expression', 'An expression that must evaluate to truthy for the loop to continue.'],\n ['body', 'expressions', 'The expressions to evaluate for each iteration of the loop.'],\n ],\n returns: {\n type: 'any',\n array: true,\n },\n description: 'Iterates over `bindings`, evaluates `body` for each `binding` and returns an `array` of results.',\n examples: [\n `\nfor (i in [1, 2, 3]) -> i * 2\n `,\n `\nfor (\n i in range(10) let ii = i ^ 2 while ii < 40 when ii % 3 == 0,\n j in range(10) when j % 2 == 1\n) -> ii + j\n `,\n ],\n}\n\nexport const forSpecialExpression: BuiltinSpecialExpression<Any, ForNode> = {\n arity: toFixedArity(1),\n docs: forDocs,\n evaluate: (node, contextStack, helpers) => evaluateLoop(true, node, contextStack, helpers.evaluateNode),\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => analyze(node, contextStack, getUndefinedSymbols, builtin, evaluateNode),\n}\n\nconst doseqDocs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['doseq (...binding) -> body'],\n details: [\n ['binding', 'loop-var in collection [...let-binding] [where whereExpr] [while whileExp]', 'A doseq loop binding'],\n ['loop-var', 'symbol', 'The name of the loop variable.'],\n ['collection', 'any', 'The collection to iterate over.'],\n ['let-binding', 'let binding', 'A let binding to create a local variable.'],\n ['whereExpr', 'expression', 'An expression that must evaluate to truthy for the loop body to be executed.'],\n ['whileExp', 'expression', 'An expression that must evaluate to truthy for the loop to continue.'],\n ['body', 'expressions', 'The expressions to evaluate for each iteration of the loop.'],\n ],\n returns: {\n type: 'null',\n },\n description: 'Iterates over `bindings`, evaluates `body` for each `binding` and returns `null`. This is useful for side effects.',\n examples: [\n `\ndoseq (i in [1, 2, 3]) -> write!(i * 2)\n `,\n ],\n}\n\nexport const doseqSpecialExpression: BuiltinSpecialExpression<null, DoSeqNode> = {\n arity: toFixedArity(1),\n docs: doseqDocs,\n evaluate: (node, contextStack, helpers) => {\n return chain(evaluateLoop(false, node, contextStack, helpers.evaluateNode), () => null)\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => analyze(node, contextStack, getUndefinedSymbols, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asAny } from '../../typeGuards/lits'\nimport { reduceSequential } from '../../utils/maybePromise'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type OrNode = SpecialExpressionNode<[typeof specialExpressionTypes['||'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'boolean',\n },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n c: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: `\n Computes logical \\`or\\`. Evaluation of expressions evaluation starts from left.\n As soon as a \\`expression\\` evaluates to a truthy value, the result is returned.\n\n If all expressions evaluate to falsy values, the value of the last expression is returned.`,\n examples: [\n 'false || 1',\n '||(1, 1)',\n '||(3 > 2, \"string\")',\n '||(3 < 2, \"string\")',\n '||(false, false, false, true)',\n '||(1, 2, 3, 4)',\n ],\n}\n\nexport const orSpecialExpression: BuiltinSpecialExpression<Any, OrNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n return reduceSequential(\n node[1][1],\n (acc, param) => {\n if (acc)\n return acc\n return evaluateNode(param, contextStack)\n },\n false as Any,\n )\n },\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n let value: Any = false\n for (const param of params) {\n value = asAny(param, sourceCodeInfo)\n if (value)\n break\n }\n return value\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { isUserDefinedSymbolNode } from '../../typeGuards/astNode'\nimport { asAny } from '../../typeGuards/lits'\nimport { chain, reduceSequential } from '../../utils/maybePromise'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type QqNode = SpecialExpressionNode<[typeof specialExpressionTypes['??'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'any',\n },\n args: {\n a: { type: 'any' },\n b: { type: 'any' },\n c: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['a'] },\n { argumentNames: ['a', 'b'] },\n { argumentNames: ['a', 'b', 'c'] },\n ],\n description: `Nullish coalescing operator. Returns the first non-\\`null\\` value.\n\nEvaluation is short-circuited — as soon as a non-\\`null\\` value is found, the remaining expressions are not evaluated.\n\nIf all values are \\`null\\`, returns \\`null\\`.\n\nAlso works with undefined symbols — if a symbol is undefined, it is treated as \\`null\\`.`,\n examples: [\n '1 ?? 2',\n 'null ?? 2',\n '??(null)',\n '??(null, \"default\")',\n '??(1, \"default\")',\n 'false ?? \"default\"',\n '??(null, null, 3)',\n ],\n}\n\nexport const qqSpecialExpression: BuiltinSpecialExpression<Any, QqNode> = {\n arity: { min: 1 },\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n // Use a sentinel to know we haven't found a non-null value yet\n const SENTINEL = Symbol('qq-sentinel')\n type SentinelOrAny = Any | typeof SENTINEL\n return chain(\n reduceSequential(\n node[1][1],\n (acc: SentinelOrAny, param) => {\n if (acc !== SENTINEL)\n return acc\n if (isUserDefinedSymbolNode(param) && contextStack.lookUp(param) === null) {\n return SENTINEL\n }\n return chain(evaluateNode(param, contextStack), (result) => {\n if (result !== null) {\n return result\n }\n return SENTINEL\n })\n },\n SENTINEL as SentinelOrAny,\n ),\n result => result === SENTINEL ? null : result as Any,\n )\n },\n\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n for (const param of params) {\n const value = asAny(param, sourceCodeInfo)\n if (value !== null) {\n return value\n }\n }\n return null\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import { RecurSignal } from '../../errors'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { chain, mapSequential } from '../../utils/maybePromise'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type RecurNode = SpecialExpressionNode<[typeof specialExpressionTypes['recur'], AstNode[]]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['recur(...recur-args)'],\n description: 'Recursevly calls enclosing function or loop with its evaluated `recur-args`.',\n examples: [\n `\nlet foo = (n) -> do\n write!(n);\n if !(zero?(n)) then\n recur(n - 1)\n end\nend;\nfoo(3)`,\n `\n(n -> do\n write!(n);\n if !(zero?(n)) then\n recur(n - 1)\n end\nend)(3)`,\n `\nloop (n = 3) -> do\n write!(n);\n if !(zero?(n)) then\n recur(n - 1)\n end\nend`,\n ],\n}\n\nexport const recurSpecialExpression: BuiltinSpecialExpression<null, RecurNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const params = node[1][1]\n return chain(\n mapSequential(params, paramNode => evaluateNode(paramNode, contextStack)),\n (evaluatedParams) => {\n throw new RecurSignal(evaluatedParams)\n },\n )\n },\n evaluateAsNormalExpression: (params) => {\n throw new RecurSignal(params)\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) =>\n getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import { UserDefinedError } from '../../errors'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { asString } from '../../typeGuards/string'\nimport { toFixedArity } from '../../utils/arity'\nimport { chain } from '../../utils/maybePromise'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ThrowNode = SpecialExpressionNode<[typeof specialExpressionTypes['throw'], AstNode]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'never',\n },\n args: {\n expr: {\n type: 'any',\n },\n },\n variants: [\n { argumentNames: ['expr'] },\n ],\n description: 'Throws `UserDefinedError` with message set to $expr evaluated. $expr must evaluate to a string.',\n examples: [\n 'try throw(\"You shall not pass!\") catch(error) \"Error: \" ++ error.message end',\n 'try throw(slice(\"You shall not pass!\", 0, 3)) catch(error) \"Error: \" ++ error.message end',\n ],\n}\n\nexport const throwSpecialExpression: BuiltinSpecialExpression<null, ThrowNode> = {\n arity: toFixedArity(1),\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n return chain(evaluateNode(node[1][1], contextStack), (result) => {\n const message = asString(result, node[2], {\n nonEmpty: true,\n })\n throw new UserDefinedError(message, node[2])\n })\n },\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n const message = asString(params[0], sourceCodeInfo, {\n nonEmpty: true,\n })\n throw new UserDefinedError(message, undefined)\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols([node[1][1]], contextStack, builtin, evaluateNode),\n}\n","import type { Context } from '../../evaluator/interface'\nimport type { Any } from '../../interface'\nimport type { AstNode, SpecialExpressionNode, SymbolNode } from '../../parser/types'\nimport { joinSets } from '../../utils'\nimport { tryCatch } from '../../utils/maybePromise'\nimport type { BuiltinSpecialExpression, CustomDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type TryNode = SpecialExpressionNode<[typeof specialExpressionTypes['try'], AstNode, SymbolNode | undefined, AstNode]>\n\nconst docs: CustomDocs = {\n category: 'special-expression',\n customVariants: ['try { try-body } catch { catch-body }', 'try { try-body } catch(error) { catch-body }'],\n details: [\n ['try-body', 'expressions', 'The expressions to try.'],\n ['error', 'symbol', 'The error variable to bind.'],\n ['catch-body', 'expression', 'The expressions to evaluate if the try-body throws an error.'],\n ],\n description: 'Executes `try-body`. If that throws, the `catch-body` gets executed. See examples for details.',\n examples: [\n `\ntry\n 2 / 4\ncatch\n \"Oops!\"\nend`,\n `\ntry\n foo()\ncatch(error)\n \"Error: \" ++ error.message\nend`,\n `\ntry\n foo()\ncatch\n 42\nend`,\n ],\n}\n\nexport const trySpecialExpression: BuiltinSpecialExpression<Any, TryNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const [, tryExpression, errorSymbol, catchExpression] = node[1]\n return tryCatch(\n () => evaluateNode(tryExpression, contextStack),\n (error) => {\n const newContext: Context = errorSymbol\n ? {\n [errorSymbol[1]]: { value: error as Any },\n }\n : {}\n return evaluateNode(catchExpression, contextStack.create(newContext))\n },\n )\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => {\n const [, tryExpression, errorSymbol, catchExpression] = node[1]\n const tryResult = getUndefinedSymbols([tryExpression], contextStack, builtin, evaluateNode)\n const newContext: Context = errorSymbol\n ? {\n [errorSymbol[1]]: { value: true },\n }\n : {}\n const catchResult = getUndefinedSymbols([catchExpression], contextStack.create(newContext), builtin, evaluateNode)\n return joinSets(tryResult, catchResult)\n },\n}\n","import { LitsError } from '../../errors'\nimport type { Any, Arr } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { isSpreadNode } from '../../typeGuards/astNode'\nimport { asAny } from '../../typeGuards/lits'\nimport { chain, forEachSequential } from '../../utils/maybePromise'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ArrayNode = SpecialExpressionNode<[typeof specialExpressionTypes['array'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'any',\n array: true,\n },\n args: {\n values: {\n type: 'any',\n rest: true,\n },\n },\n variants: [\n { argumentNames: ['values'] },\n ],\n description: 'Makes new array from $values.',\n examples: [\n 'array(1, 2, 3)',\n 'array(array(null, false, true))',\n '[]',\n '[1, 2, 3]',\n '[1, 2, ...[3, 4, 5], 6]',\n '[[null, false, true]]',\n '[1, 2, 3][1]',\n ],\n hideOperatorForm: true,\n}\n\nexport const arraySpecialExpression: BuiltinSpecialExpression<Any, ArrayNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const result: Arr = []\n\n return chain(\n forEachSequential(node[1][1], (param) => {\n if (isSpreadNode(param)) {\n return chain(evaluateNode(param[1], contextStack), (spreadValue) => {\n if (!Array.isArray(spreadValue)) {\n throw new LitsError('Spread value is not an array', param[2])\n }\n result.push(...spreadValue)\n })\n }\n else {\n return chain(evaluateNode(param, contextStack), (value) => {\n result.push(value)\n })\n }\n }),\n () => result,\n )\n },\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n const result: Arr = []\n\n for (const param of params) {\n result.push(asAny(param, sourceCodeInfo))\n }\n\n return result\n },\n\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","import { LitsError } from '../../errors'\nimport type { Any, Obj } from '../../interface'\nimport type { AstNode, SpecialExpressionNode } from '../../parser/types'\nimport { isUnknownRecord } from '../../typeGuards'\nimport { isSpreadNode } from '../../typeGuards/astNode'\nimport { assertString } from '../../typeGuards/string'\nimport type { MaybePromise } from '../../utils/maybePromise'\nimport { chain } from '../../utils/maybePromise'\nimport type { BuiltinSpecialExpression, FunctionDocs } from '../interface'\nimport type { specialExpressionTypes } from '../specialExpressionTypes'\n\nexport type ObjectNode = SpecialExpressionNode<[typeof specialExpressionTypes['object'], AstNode[]]>\n\nconst docs: FunctionDocs = {\n category: 'special-expression',\n returns: {\n type: 'object',\n },\n args: {\n kvps: {\n type: 'any',\n rest: true,\n description: 'key - value pairs, where key is a string',\n },\n },\n variants: [\n { argumentNames: ['kvps'] },\n ],\n description: 'Constructs a new object. Object members are created from the $kvps key-value pairs. Requires an even number of arguments.',\n examples: [\n 'object()',\n `\nlet default = {\n type: \"Person\",\n name: \"John Doe\",\n age: 42\n};\n\n{\n ...default,\n name: \"Lisa\"\n}`,\n 'object(\"x\", 10, \"y\", true, \"z\", \"A string\")',\n '{}',\n '{ a: 1, b: 2 }',\n ],\n hideOperatorForm: true,\n}\n\nexport const objectSpecialExpression: BuiltinSpecialExpression<Any, ObjectNode> = {\n arity: {},\n docs,\n evaluate: (node, contextStack, { evaluateNode }) => {\n const result: Obj = {}\n const params = node[1][1]\n\n function processEntry(i: number): MaybePromise<Obj> {\n if (i >= params.length)\n return result\n const keyNode = params[i]!\n if (isSpreadNode(keyNode)) {\n return chain(evaluateNode(keyNode[1], contextStack), (spreadObject) => {\n if (!isUnknownRecord(spreadObject)) {\n throw new LitsError('Spread value is not an object', keyNode[2])\n }\n Object.assign(result, spreadObject)\n return processEntry(i + 1)\n })\n }\n else {\n const valueNode = params[i + 1]\n if (valueNode === undefined) {\n throw new LitsError('Missing value for key', keyNode[2])\n }\n return chain(evaluateNode(keyNode, contextStack), (key) => {\n return chain(evaluateNode(valueNode, contextStack), (value) => {\n assertString(key, keyNode[2])\n result[key] = value\n return processEntry(i + 2)\n })\n })\n }\n }\n\n return processEntry(0)\n },\n evaluateAsNormalExpression: (params, sourceCodeInfo) => {\n const result: Obj = {}\n\n for (let i = 0; i < params.length; i += 2) {\n const key = params[i]\n const value = params[i + 1]\n assertString(key, sourceCodeInfo)\n result[key] = value ?? null\n }\n\n return result\n },\n getUndefinedSymbols: (node, contextStack, { getUndefinedSymbols, builtin, evaluateNode }) => getUndefinedSymbols(node[1][1], contextStack, builtin, evaluateNode),\n}\n","export const specialExpressionTypes = {\n '??': 0,\n '&&': 1,\n '||': 2,\n 'array': 3,\n 'cond': 4,\n '0_def': 5,\n 'defined?': 6,\n // '0_defn': 7,\n 'block': 7,\n 'doseq': 8,\n '0_lambda': 9,\n 'for': 10,\n // 'function': 10,\n 'if': 11,\n 'let': 12,\n 'loop': 13,\n 'object': 14,\n 'recur': 15,\n 'switch': 16,\n 'throw': 17,\n 'try': 18,\n 'unless': 19,\n} as const\n","import type { Builtin } from './interface'\nimport { allNormalExpressions, normalExpressions } from './normalExpressions'\nimport { andSpecialExpression } from './specialExpressions/and'\nimport { condSpecialExpression } from './specialExpressions/cond'\nimport { switchSpecialExpression } from './specialExpressions/switch'\nimport { definedSpecialExpression } from './specialExpressions/defined'\nimport { defSpecialExpression } from './specialExpressions/def'\nimport { doSpecialExpression } from './specialExpressions/block'\nimport { lambdaSpecialExpression } from './specialExpressions/functions'\nimport { ifSpecialExpression } from './specialExpressions/if'\nimport { unlessSpecialExpression } from './specialExpressions/unless'\nimport { letSpecialExpression } from './specialExpressions/let'\nimport { loopSpecialExpression } from './specialExpressions/loop'\nimport { doseqSpecialExpression, forSpecialExpression } from './specialExpressions/loops'\nimport { orSpecialExpression } from './specialExpressions/or'\nimport { qqSpecialExpression } from './specialExpressions/qq'\nimport { recurSpecialExpression } from './specialExpressions/recur'\nimport { throwSpecialExpression } from './specialExpressions/throw'\nimport { trySpecialExpression } from './specialExpressions/try'\nimport { arraySpecialExpression } from './specialExpressions/array'\nimport { objectSpecialExpression } from './specialExpressions/object'\nimport { specialExpressionTypes } from './specialExpressionTypes'\n\nexport const specialExpressions = [\n qqSpecialExpression,\n andSpecialExpression,\n orSpecialExpression,\n arraySpecialExpression,\n condSpecialExpression,\n defSpecialExpression,\n definedSpecialExpression,\n doSpecialExpression,\n doseqSpecialExpression,\n lambdaSpecialExpression,\n forSpecialExpression,\n ifSpecialExpression,\n letSpecialExpression,\n loopSpecialExpression,\n objectSpecialExpression,\n recurSpecialExpression,\n switchSpecialExpression,\n throwSpecialExpression,\n trySpecialExpression,\n unlessSpecialExpression,\n] as const\n\nexport type SpecialExpressions = typeof specialExpressions\nexport type SpecialExpression = SpecialExpressions[number]\nexport type SpecialExpressionName = keyof typeof specialExpressionTypes\nexport type CommonSpecialExpressionType = [\n | typeof specialExpressionTypes['??']\n | typeof specialExpressionTypes['&&']\n | typeof specialExpressionTypes['cond']\n | typeof specialExpressionTypes['switch']\n | typeof specialExpressionTypes['defined?']\n | typeof specialExpressionTypes['block']\n | typeof specialExpressionTypes['if']\n | typeof specialExpressionTypes['unless']\n | typeof specialExpressionTypes['||']\n | typeof specialExpressionTypes['throw']\n | typeof specialExpressionTypes['array']\n | typeof specialExpressionTypes['object'],\n]\n\nexport type SpecialExpressionType = typeof specialExpressionTypes[SpecialExpressionName]\n\nexport const builtin: Builtin = {\n normalExpressions,\n specialExpressions,\n allNormalExpressions,\n}\n\nexport const normalExpressionKeys = Object.keys(normalExpressions)\nexport const specialExpressionKeys = Object.keys(specialExpressionTypes)\n","import type { Builtin } from '../builtin/interface'\nimport type { DoNode } from '../builtin/specialExpressions/block'\nimport { specialExpressionTypes } from '../builtin/specialExpressionTypes'\nimport { NodeTypes } from '../constants/constants'\nimport { LitsError } from '../errors'\nimport type { ContextStack } from '../evaluator/ContextStack'\nimport type { EvaluateNode } from '../evaluator/interface'\nimport type { Ast, AstNode, NormalExpressionNode, SpecialExpressionNode, SpreadNode, UserDefinedSymbolNode } from '../parser/types'\nimport { isNormalExpressionNodeWithName, isUserDefinedSymbolNode } from '../typeGuards/astNode'\n\nexport type UndefinedSymbols = Set<string>\n\nexport const getUndefinedSymbols: GetUndefinedSymbols = (ast, contextStack, builtin, evaluateNode) => {\n const nodes: AstNode[] = Array.isArray(ast)\n ? ast\n : [[NodeTypes.SpecialExpression, [specialExpressionTypes.block, ast.body]] satisfies DoNode]\n\n const unresolvedSymbols = new Set<string>()\n\n for (const subNode of nodes) {\n findUnresolvedSymbolsInNode(subNode, contextStack, builtin, evaluateNode)\n ?.forEach(symbol => unresolvedSymbols.add(symbol))\n }\n return unresolvedSymbols\n}\n\nexport type GetUndefinedSymbols = (ast: Ast | AstNode[], contextStack: ContextStack, builtin: Builtin, evaluateNode: EvaluateNode) => UndefinedSymbols\n\nfunction findUnresolvedSymbolsInNode(node: AstNode, contextStack: ContextStack, builtin: Builtin, evaluateNode: EvaluateNode): UndefinedSymbols | null {\n const nodeType = node[0]\n switch (nodeType) {\n case NodeTypes.UserDefinedSymbol: {\n const symbolNode = node as UserDefinedSymbolNode\n const lookUpResult = contextStack.lookUp(symbolNode)\n if (lookUpResult === null)\n return new Set([symbolNode[1]])\n\n return null\n }\n case NodeTypes.NormalBuiltinSymbol:\n case NodeTypes.SpecialBuiltinSymbol:\n case NodeTypes.String:\n case NodeTypes.Number:\n case NodeTypes.ReservedSymbol:\n case NodeTypes.Binding:\n return null\n case NodeTypes.NormalExpression: {\n const normalExpressionNode = node as NormalExpressionNode\n const unresolvedSymbols = new Set<string>()\n if (isNormalExpressionNodeWithName(normalExpressionNode)) {\n const [, [symbolNode]] = normalExpressionNode\n if (isUserDefinedSymbolNode(symbolNode)) {\n const lookUpResult = contextStack.lookUp(symbolNode)\n if (lookUpResult === null)\n unresolvedSymbols.add(symbolNode[1])\n }\n }\n else {\n const [, [expressionNode]] = normalExpressionNode\n findUnresolvedSymbolsInNode(expressionNode, contextStack, builtin, evaluateNode)?.forEach(symbol => unresolvedSymbols.add(symbol))\n }\n for (const subNode of normalExpressionNode[1][1]) {\n findUnresolvedSymbolsInNode(subNode, contextStack, builtin, evaluateNode)?.forEach(symbol => unresolvedSymbols.add(symbol))\n }\n return unresolvedSymbols\n }\n case NodeTypes.SpecialExpression: {\n const specialExpressionNode = node as SpecialExpressionNode\n const specialExpressionType = specialExpressionNode[1][0]\n const specialExpression = builtin.specialExpressions[specialExpressionType]\n\n const castedGetUndefinedSymbols = specialExpression.getUndefinedSymbols as Function\n\n return castedGetUndefinedSymbols(specialExpressionNode, contextStack, {\n getUndefinedSymbols,\n builtin,\n evaluateNode,\n }) as UndefinedSymbols\n }\n case NodeTypes.Spread:\n return findUnresolvedSymbolsInNode((node as SpreadNode)[1], contextStack, builtin, evaluateNode)\n\n /* v8 ignore next 2 */\n default:\n throw new LitsError(`Unhandled node type: ${nodeType satisfies never}`, node[2])\n }\n}\n","import type { Any } from '../interface'\n\nconst nonNumberReservedSymbolRecord = {\n true: true,\n false: false,\n null: null,\n do: null,\n else: null,\n case: null,\n each: null,\n in: null,\n when: null,\n while: null,\n catch: null,\n function: null,\n export: null,\n as: null,\n then: null,\n end: null,\n _: null,\n} as const satisfies Record<string, Any>\n\nconst phi = (1 + Math.sqrt(5)) / 2\nexport const numberReservedSymbolRecord = {\n 'E': Math.E,\n '-E': -Math.E,\n 'ε': Math.E,\n '-ε': -Math.E,\n 'PI': Math.PI,\n '-PI': -Math.PI,\n 'π': Math.PI,\n '-π': -Math.PI,\n 'PHI': phi,\n '-PHI': -phi,\n 'φ': phi,\n '-φ': -phi,\n 'POSITIVE_INFINITY': Number.POSITIVE_INFINITY,\n '∞': Number.POSITIVE_INFINITY,\n 'NEGATIVE_INFINITY': Number.NEGATIVE_INFINITY,\n '-∞': Number.NEGATIVE_INFINITY,\n 'MAX_SAFE_INTEGER': Number.MAX_SAFE_INTEGER,\n 'MIN_SAFE_INTEGER': Number.MIN_SAFE_INTEGER,\n 'MAX_VALUE': Number.MAX_VALUE,\n 'MIN_VALUE': Number.MIN_VALUE,\n 'NaN': Number.NaN,\n} as const satisfies Record<string, number>\n\nexport const reservedSymbolRecord = {\n ...nonNumberReservedSymbolRecord,\n ...numberReservedSymbolRecord,\n} as const\n\nexport type ReservedSymbol = keyof typeof reservedSymbolRecord\n\nexport function isReservedSymbol(symbol: string): symbol is keyof typeof reservedSymbolRecord {\n return symbol in reservedSymbolRecord\n}\n\nexport function isNumberReservedSymbol(symbol: string): symbol is keyof typeof numberReservedSymbolRecord {\n return symbol in numberReservedSymbolRecord\n}\n","import { specialExpressions } from '../builtin'\nimport { evaluateBindingNodeValues } from '../builtin/bindingNode'\nimport { allNormalExpressions } from '../builtin/normalExpressions'\nimport { LitsError, RecurSignal } from '../errors'\nimport { arityAcceptsMin, assertNumberOfParams } from '../utils/arity'\nimport type { Any, Arr } from '../interface'\nimport type {\n CompFunction,\n ComplementFunction,\n ConstantlyFunction,\n EveryPredFunction,\n FNullFunction,\n JuxtFunction,\n LitsFunctionType,\n ModuleFunction,\n NativeJsFunction,\n NormalBuiltinFunction,\n PartialFunction,\n SomePredFunction,\n SpecialBuiltinFunction,\n UserDefinedFunction,\n} from '../parser/types'\nimport { bindingTargetTypes } from '../parser/types'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asNonUndefined, isUnknownRecord } from '../typeGuards'\nimport { asAny, asFunctionLike } from '../typeGuards/lits'\nimport { toAny } from '../utils'\nimport { valueToString } from '../utils/debug/debugTools'\nimport type { MaybePromise } from '../utils/maybePromise'\nimport { chain, mapSequential, reduceSequential } from '../utils/maybePromise'\nimport type { ContextStack } from './ContextStack'\nimport type { Context, EvaluateNode, ExecuteFunction } from './interface'\n\ntype FunctionExecutors = Record<LitsFunctionType, (\n fn: any,\n params: Arr,\n sourceCodeInfo: SourceCodeInfo | undefined,\n contextStack: ContextStack,\n helpers: { evaluateNode: EvaluateNode, executeFunction: ExecuteFunction },\n) => MaybePromise<Any>>\n\nexport const functionExecutors: FunctionExecutors = {\n NativeJsFunction: (fn: NativeJsFunction, params, sourceCodeInfo) => {\n try {\n const result = fn.nativeFn.fn(...params)\n // If the native function returns a Promise, await it transparently\n if (result instanceof Promise) {\n return result.then(\n resolved => toAny(resolved),\n (error: unknown) => {\n const message\n = typeof error === 'string'\n ? error\n : isUnknownRecord(error) && typeof error.message === 'string'\n ? error.message\n : '<no message>'\n throw new LitsError(`Native function threw: \"${message}\"`, sourceCodeInfo)\n },\n )\n }\n return toAny(result)\n }\n catch (error) {\n const message\n = typeof error === 'string'\n ? error\n : isUnknownRecord(error) && typeof error.message === 'string'\n ? error.message\n : '<no message>'\n throw new LitsError(`Native function threw: \"${message}\"`, sourceCodeInfo)\n }\n },\n UserDefined: (fn: UserDefinedFunction, params, sourceCodeInfo, contextStack, { evaluateNode }) => {\n function setupAndExecute(currentParams: Arr): MaybePromise<Any> {\n if (!arityAcceptsMin(fn.arity, currentParams.length)) {\n throw new LitsError(`Expected ${fn.arity} arguments, got ${currentParams.length}.`, sourceCodeInfo)\n }\n const evaluatedFunction = fn.evaluatedfunction\n const args = evaluatedFunction[0]\n const nbrOfNonRestArgs: number = args.filter(arg => arg[0] !== bindingTargetTypes.rest).length\n\n const newContextStack = contextStack.create(fn.evaluatedfunction[2])\n const newContext: Context = { self: { value: fn } }\n\n const rest: Arr = []\n\n // Process non-rest params sequentially since binding evaluation may be async\n let paramSetup: MaybePromise<void> = undefined as unknown as void\n for (let i = 0; i < currentParams.length; i += 1) {\n if (i < nbrOfNonRestArgs) {\n const paramIndex = i\n paramSetup = chain(paramSetup, () => {\n const param = toAny(currentParams[paramIndex])\n return chain(evaluateBindingNodeValues(args[paramIndex]!, param, node =>\n evaluateNode(node, newContextStack.create(newContext))), (valueRecord) => {\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n })\n })\n }\n else {\n rest.push(toAny(currentParams[i]))\n }\n }\n\n // Handle default values for optional params — chain sequentially since they may be async\n let defaultSetup: MaybePromise<void> = undefined as unknown as void\n for (let i = currentParams.length; i < nbrOfNonRestArgs; i++) {\n const argIndex = i\n defaultSetup = chain(defaultSetup, () => {\n const arg = args[argIndex]!\n return chain(evaluateNode(arg[1][1]!, contextStack.create(newContext)), (defaultValue) => {\n return chain(evaluateBindingNodeValues(arg, defaultValue, node =>\n evaluateNode(node, contextStack.create(newContext))), (valueRecord) => {\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n })\n })\n })\n }\n\n return chain(paramSetup, () => chain(defaultSetup, () => {\n const restArgument = args.find(arg => arg[0] === bindingTargetTypes.rest)\n const restSetup: MaybePromise<void> = restArgument !== undefined\n ? chain(evaluateBindingNodeValues(restArgument, rest, node =>\n evaluateNode(node, contextStack.create(newContext))), (valueRecord) => {\n Object.entries(valueRecord).forEach(([key, value]) => {\n newContext[key] = { value }\n })\n })\n : undefined as unknown as void\n\n return chain(restSetup, () => {\n // Evaluate body nodes sequentially\n const newContextStack2 = newContextStack.create(newContext)\n const bodyResult = reduceSequential(\n evaluatedFunction[1],\n (_acc, node) => evaluateNode(node, newContextStack2),\n null as Any,\n )\n\n // Handle RecurSignal for async body results\n if (bodyResult instanceof Promise) {\n return bodyResult.catch((error: unknown) => {\n if (error instanceof RecurSignal) {\n return setupAndExecute(error.params)\n }\n throw error\n })\n }\n\n return bodyResult\n })\n }))\n }\n\n // Sync recur loop: use for(;;) to avoid stack overflow for sync tail recursion\n for (;;) {\n try {\n const result = setupAndExecute(params)\n // If result is async, the RecurSignal handling is inside the Promise chain\n return result\n }\n catch (error) {\n if (error instanceof RecurSignal) {\n params = error.params\n continue\n }\n throw error\n }\n }\n },\n Partial: (fn: PartialFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const actualParams = [...fn.params]\n if (params.length !== fn.placeholders.length) {\n throw new LitsError(`(partial) expects ${fn.placeholders.length} arguments, got ${params.length}.`, sourceCodeInfo)\n }\n const paramsCopy = [...params]\n for (const placeholderIndex of fn.placeholders) {\n actualParams.splice(placeholderIndex, 0, paramsCopy.shift())\n }\n return executeFunction(fn.function, actualParams, contextStack, sourceCodeInfo)\n },\n Comp: (fn: CompFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const { params: f } = fn\n if (f.length === 0) {\n if (params.length !== 1)\n throw new LitsError(`(comp) expects one argument, got ${valueToString(params.length)}.`, sourceCodeInfo)\n\n return asAny(params[0], sourceCodeInfo)\n }\n // reduceRight with MaybePromise: each step wraps result in array, passes to next function\n let result: MaybePromise<Arr> = params\n for (let i = f.length - 1; i >= 0; i--) {\n const fun = f[i]!\n result = chain(result, (currentParams) => {\n return chain(\n executeFunction(asFunctionLike(fun, sourceCodeInfo), currentParams, contextStack, sourceCodeInfo),\n r => [r],\n )\n })\n }\n return chain(result, finalArr => asAny(finalArr[0], sourceCodeInfo))\n },\n Constantly: (fn: ConstantlyFunction) => {\n return fn.value\n },\n Juxt: (fn: JuxtFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n return mapSequential(fn.params, fun =>\n executeFunction(asFunctionLike(fun, sourceCodeInfo), params, contextStack, sourceCodeInfo))\n },\n Complement: (fn: ComplementFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n return chain(\n executeFunction(fn.function, params, contextStack, sourceCodeInfo),\n result => !result,\n )\n },\n EveryPred: (fn: EveryPredFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n // Flatten to sequential checks: for each predicate, for each param\n const checks: Array<() => MaybePromise<Any>> = []\n for (const f of fn.params) {\n for (const param of params) {\n checks.push(() => executeFunction(asFunctionLike(f, sourceCodeInfo), [param], contextStack, sourceCodeInfo))\n }\n }\n return reduceSequential(\n checks,\n (acc, check) => {\n if (!acc)\n return false\n return chain(check(), result => !!result)\n },\n true as Any,\n )\n },\n SomePred: (fn: SomePredFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const checks: Array<() => MaybePromise<Any>> = []\n for (const f of fn.params) {\n for (const param of params) {\n checks.push(() => executeFunction(asFunctionLike(f, sourceCodeInfo), [param], contextStack, sourceCodeInfo))\n }\n }\n return reduceSequential(\n checks,\n (acc, check) => {\n if (acc)\n return true\n return chain(check(), result => !!result)\n },\n false as Any,\n )\n },\n Fnull: (fn: FNullFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const fnulledParams = params.map((param, index) => (param === null ? toAny(fn.params[index]) : param))\n return executeFunction(asFunctionLike(fn.function, sourceCodeInfo), fnulledParams, contextStack, sourceCodeInfo)\n },\n Builtin: (fn: NormalBuiltinFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const normalExpression = asNonUndefined(allNormalExpressions[fn.normalBuiltinSymbolType], sourceCodeInfo)\n return normalExpression.evaluate(params, sourceCodeInfo, contextStack, { executeFunction })\n },\n SpecialBuiltin: (fn: SpecialBuiltinFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const specialExpression = asNonUndefined(specialExpressions[fn.specialBuiltinSymbolType], sourceCodeInfo)\n if (specialExpression.evaluateAsNormalExpression) {\n return specialExpression.evaluateAsNormalExpression(params, sourceCodeInfo, contextStack, { executeFunction })\n }\n else {\n throw new LitsError(`Special builtin function ${fn.specialBuiltinSymbolType} is not supported as normal expression.`, sourceCodeInfo)\n }\n },\n Module: (fn: ModuleFunction, params, sourceCodeInfo, contextStack, { executeFunction }) => {\n const module = contextStack.getModule(fn.moduleName)\n if (!module) {\n throw new LitsError(`Module '${fn.moduleName}' not found.`, sourceCodeInfo)\n }\n const expression = module.functions[fn.functionName]\n if (!expression) {\n throw new LitsError(`Function '${fn.functionName}' not found in module '${fn.moduleName}'.`, sourceCodeInfo)\n }\n assertNumberOfParams(expression.arity, params.length, sourceCodeInfo)\n return expression.evaluate(params, sourceCodeInfo, contextStack, { executeFunction })\n },\n}\n","import type { SpecialExpression } from '../builtin'\nimport { builtin } from '../builtin'\nimport { NodeTypes, getNodeTypeName } from '../constants/constants'\nimport { LitsError, UndefinedSymbolError } from '../errors'\nimport { getUndefinedSymbols } from '../getUndefinedSymbols'\nimport type { Any, Arr, Obj } from '../interface'\nimport type {\n Ast,\n AstNode,\n FunctionLike,\n NormalExpressionNode,\n NumberNode,\n PartialFunction,\n ReservedSymbolNode,\n SpecialExpressionNode,\n StringNode,\n SymbolNode,\n} from '../parser/types'\nimport { reservedSymbolRecord } from '../tokenizer/reservedNames'\nimport type { SourceCodeInfo } from '../tokenizer/token'\nimport { asNonUndefined } from '../typeGuards'\nimport { annotate } from '../typeGuards/annotatedArrays'\nimport { isNormalBuiltinSymbolNode, isNormalExpressionNodeWithName, isSpreadNode } from '../typeGuards/astNode'\nimport { asFunctionLike, assertSeq, isObj } from '../typeGuards/lits'\nimport { isLitsFunction } from '../typeGuards/litsFunction'\nimport { assertNumber, isNumber } from '../typeGuards/number'\nimport { assertString } from '../typeGuards/string'\nimport { toAny } from '../utils'\nimport { valueToString } from '../utils/debug/debugTools'\nimport { toFixedArity } from '../utils/arity'\nimport type { MaybePromise } from '../utils/maybePromise'\nimport { chain, forEachSequential, reduceSequential } from '../utils/maybePromise'\nimport { FUNCTION_SYMBOL } from '../utils/symbols'\nimport type { ContextStack } from './ContextStack'\nimport { functionExecutors } from './functionExecutors'\n\nexport function evaluate(ast: Ast, contextStack: ContextStack): MaybePromise<Any> {\n return reduceSequential(\n ast.body,\n (_acc, node) => evaluateNode(node, contextStack),\n null as Any,\n )\n}\n\nexport function evaluateNode(node: AstNode, contextStack: ContextStack): MaybePromise<Any> {\n switch (node[0]) {\n case NodeTypes.Number:\n return evaluateNumber(node as NumberNode)\n case NodeTypes.String:\n return evaluateString(node as StringNode)\n case NodeTypes.NormalBuiltinSymbol:\n case NodeTypes.SpecialBuiltinSymbol:\n case NodeTypes.UserDefinedSymbol:\n return contextStack.evaluateSymbol(node as SymbolNode)\n case NodeTypes.ReservedSymbol:\n return evaluateReservedSymbol(node as ReservedSymbolNode)\n case NodeTypes.NormalExpression: {\n const result = evaluateNormalExpression(node as NormalExpressionNode, contextStack)\n return chain(result, (resolved) => {\n if (typeof resolved === 'number' && Number.isNaN(resolved)) {\n throw new LitsError('Number is NaN', node[2])\n }\n return annotate(resolved)\n })\n }\n case NodeTypes.SpecialExpression:\n return chain(\n evaluateSpecialExpression(node as SpecialExpressionNode, contextStack),\n resolved => annotate(resolved),\n )\n /* v8 ignore next 2 */\n default:\n throw new LitsError(`${getNodeTypeName(node[0])}-node cannot be evaluated`, node[2])\n }\n}\n\nfunction evaluateNumber(node: NumberNode): number {\n return node[1]\n}\n\nfunction evaluateString(node: StringNode): string {\n return node[1]\n}\n\nfunction evaluateReservedSymbol(node: ReservedSymbolNode): Any {\n const reservedName = node[1]\n if (!['true', 'false', 'null'].includes(reservedName)) {\n throw new LitsError(`Reserved symbol ${reservedName} cannot be evaluated`, node[2])\n }\n const value = reservedSymbolRecord[reservedName]\n return asNonUndefined(value, node[2])\n}\n\nfunction evaluateParams(\n paramNodes: AstNode[],\n contextStack: ContextStack,\n): MaybePromise<{ params: Arr, placeholders: number[] }> {\n const params: Arr = []\n const placeholders: number[] = []\n\n const result = forEachSequential(paramNodes, (paramNode, index) => {\n if (isSpreadNode(paramNode)) {\n return chain(evaluateNode(paramNode[1], contextStack), (spreadValue) => {\n if (Array.isArray(spreadValue)) {\n params.push(...spreadValue)\n }\n else {\n throw new LitsError(`Spread operator requires an array, got ${valueToString(paramNode)}`, paramNode[2])\n }\n })\n }\n else if (paramNode[0] === NodeTypes.ReservedSymbol && paramNode[1] === '_') {\n placeholders.push(index)\n }\n else {\n return chain(evaluateNode(paramNode, contextStack), (value) => {\n params.push(value)\n })\n }\n })\n\n return chain(result, () => ({ params, placeholders }))\n}\n\nfunction evaluateNormalExpression(node: NormalExpressionNode, contextStack: ContextStack): MaybePromise<Any> {\n const sourceCodeInfo = node[2]\n\n return chain(evaluateParams(node[1][1], contextStack), ({ params, placeholders }) => {\n if (isNormalExpressionNodeWithName(node)) {\n const nameSymbol = node[1][0]\n if (placeholders.length > 0) {\n const fn = evaluateNode(nameSymbol, contextStack)\n return chain(fn, (resolvedFn) => {\n const partialFunction: PartialFunction = {\n [FUNCTION_SYMBOL]: true,\n function: asFunctionLike(resolvedFn, sourceCodeInfo),\n functionType: 'Partial',\n params,\n placeholders,\n sourceCodeInfo,\n arity: toFixedArity(placeholders.length),\n }\n return partialFunction\n })\n }\n\n if (isNormalBuiltinSymbolNode(nameSymbol)) {\n const type = nameSymbol[1]\n const normalExpression = builtin.allNormalExpressions[type]!\n return normalExpression.evaluate(params, node[2], contextStack, { executeFunction })\n }\n else {\n const fn = contextStack.getValue(nameSymbol[1])\n if (fn !== undefined) {\n return executeFunction(asFunctionLike(fn, sourceCodeInfo), params, contextStack, sourceCodeInfo)\n }\n throw new UndefinedSymbolError(nameSymbol[1], node[2])\n }\n }\n else {\n const fnNode: AstNode = node[1][0]\n return chain(evaluateNode(fnNode, contextStack), (resolvedFn) => {\n const fn = asFunctionLike(resolvedFn, sourceCodeInfo)\n if (placeholders.length > 0) {\n const partialFunction: PartialFunction = {\n [FUNCTION_SYMBOL]: true,\n function: fn,\n functionType: 'Partial',\n params,\n placeholders,\n sourceCodeInfo,\n arity: toFixedArity(placeholders.length),\n }\n return partialFunction\n }\n return executeFunction(fn, params, contextStack, sourceCodeInfo)\n })\n }\n })\n}\n\nfunction executeFunction(fn: FunctionLike, params: Arr, contextStack: ContextStack, sourceCodeInfo?: SourceCodeInfo): MaybePromise<Any> {\n if (isLitsFunction(fn))\n return functionExecutors[fn.functionType](fn, params, sourceCodeInfo, contextStack, { evaluateNode, executeFunction })\n\n if (Array.isArray(fn))\n return evaluateArrayAsFunction(fn, params, sourceCodeInfo)\n\n if (isObj(fn))\n return evalueateObjectAsFunction(fn, params, sourceCodeInfo)\n\n if (typeof fn === 'string')\n return evaluateStringAsFunction(fn, params, sourceCodeInfo)\n\n if (isNumber(fn)) {\n return evaluateNumberAsFunction(fn, params, sourceCodeInfo)\n /* v8 ignore next 4 */\n }\n throw new LitsError('Unexpected function type', sourceCodeInfo)\n}\n\nfunction evaluateSpecialExpression(node: SpecialExpressionNode, contextStack: ContextStack): MaybePromise<Any> {\n const specialExpressionType = node[1][0]\n const specialExpression: SpecialExpression = asNonUndefined(builtin.specialExpressions[specialExpressionType], node[2])\n const castedEvaluate = specialExpression.evaluate as Function\n\n return castedEvaluate(node, contextStack, { evaluateNode, builtin, getUndefinedSymbols }) as MaybePromise<Any>\n}\n\nfunction evalueateObjectAsFunction(fn: Obj, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n if (params.length !== 1)\n throw new LitsError('Object as function requires one string parameter.', sourceCodeInfo)\n\n const key = params[0]\n assertString(key, sourceCodeInfo)\n return toAny(fn[key])\n}\n\nfunction evaluateArrayAsFunction(fn: Arr, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n if (params.length !== 1)\n throw new LitsError('Array as function requires one non negative integer parameter.', sourceCodeInfo)\n\n const index = params[0]\n assertNumber(index, sourceCodeInfo, { integer: true, nonNegative: true })\n return toAny(fn[index])\n}\n\nfunction evaluateStringAsFunction(fn: string, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n if (params.length !== 1)\n throw new LitsError('String as function requires one Obj parameter.', sourceCodeInfo)\n\n const param = toAny(params[0])\n if (isObj(param))\n return toAny((param)[fn])\n\n if (isNumber(param, { integer: true }))\n return toAny(fn[param])\n\n throw new LitsError(\n `string as function expects Obj or integer parameter, got ${valueToString(param)}`,\n sourceCodeInfo,\n )\n}\n\nfunction evaluateNumberAsFunction(fn: number, params: Arr, sourceCodeInfo?: SourceCodeInfo): Any {\n assertNumber(fn, sourceCodeInfo, { integer: true })\n if (params.length !== 1)\n throw new LitsError('Number as function requires one Arr parameter.', sourceCodeInfo)\n\n const param = params[0]\n assertSeq(param, sourceCodeInfo)\n return toAny(param[fn])\n}\n"],"names":["getCodeMarker","sourceCodeInfo","position","code","leftPadding","column","rightPadding","length","repeat","Math","max","RecurSignal","Error","params","constructor","super","Object","setPrototypeOf","this","prototype","name","LitsError","shortMessage","err","message","location","line","filePath","getLitsErrorMessage","UserDefinedError","userMessage","UndefinedSymbolError","symbol","symbolName","isLitsError","error","NodeTypes","Number","String","NormalExpression","SpecialExpression","UserDefinedSymbol","NormalBuiltinSymbol","SpecialBuiltinSymbol","ReservedSymbol","Binding","Spread","NodeTypesSet","Set","values","getNodeTypeName","type","keys","find","key","functionTypeSet","FUNCTION_SYMBOL","REGEXP_SYMBOL","isLitsFunction","func","has","isFunctionType","functionType","isNode","value","Array","isArray","isNodeType","valueToString","RegExp","toString","JSON","stringify","getSourceCodeInfo","anyValue","getAssertionError","typeName","asNonUndefined","assertNonUndefined","undefined","isNonUndefined","isUnknownRecord","asLitsFunction","assertLitsFunction","isUserDefinedFunction","asUserDefinedFunction","assertUserDefinedFunction","isNativeJsFunction","asNativeJsFunction","assertNativeJsFunction","isBuiltinFunction","isNumber","options","isNaN","integer","isInteger","finite","isFinite","zero","nonZero","positive","negative","nonPositive","nonNegative","gt","gte","lt","lte","assertNumber","sign","getSignString","numberType","range","getRangeString","filter","x","join","getNumberTypeName","isAny","asAny","assertAny","isSeq","assertSeq","isObj","isRegularExpression","assertObj","isColl","assertColl","regexp","assertStringOrRegularExpression","isStringOrRegularExpression","asFunctionLike","assertFunctionLike","isFunctionLike","assertNumberOfParams","arity","min","toFixedArity","bitwiseNormalExpression","evaluate","num","count","first","rest","reduce","result","xor","nonEmpty","char","isString","asString","assertString","isStringOrNumber","asStringOrNumber","assertStringOrNumber","collHasKey","coll","getOwnPropertyDescriptor","compare","a","b","deepEqual","epsilon","EPSILON","diff","abs","absA","absB","i","s","f","aKeys","bKeys","toAny","results","symbols","forEach","add","addToSet","target","source","smartTrim","str","minIndent","lines","split","match","shift","pop","indent","acc","lineIndent","Infinity","slice","trimEnd","assertArray","every","v","isStringArray","isCharArray","fn","Promise","then","mapSequential","arr","chainRemainingMap","push","async","currentPromise","startIndex","reduceSequential","initial","next","chainRemainingReduce","chainRemainingForEach","tryCatch","tryFn","catchFn","catch","collectionNormalExpression","elem","chain","executeFunction","contextStack","keep","filtered","entries","map","at","colls","obj","objKeys","includes","mapObjects","seqs","isStr","len","seq","paramArray","mapped","p","resolvedMapped","get","defaultValue","assoc","copy","concat","assign","arrayNormalExpression","second","third","from","step","to","flatten","depth","actualDepth","POSITIVE_INFINITY","asNumber","flat","mapcat","windowSize","windows","window","subArrays","subArr","sequenceNormalExpression","nth","array","index","indexOf","findIndex","item","assertCharArray","substring","reverse","some","found","comparer","defaultComparer","sort","compareValue","_executeFunction","_contextStack","TypeError","annotatedArrays","vectors","WeakSet","notVectors","matrices","notMatrices","grids","notGrids","annotate","vector","assertVector","isVector","assertNonEmptyVector","grid","nbrOfCols","row","isMatrix","matrix","cell","getNumberVectorOrMatrixOperation","hasMatrix","param","hasVector","rows","cold","operation","operands","val","j","reduceMathOp","identity","m","mathNormalExpression","inc","unaryMathOp","dec","firstVector","firstMatrix","quot","binaryMathOp","trunc","mod","floor","sqrt","cbrt","round","decimals","factor","ceil","isEqual","firstAny","miscNormalExpression","isIdentical","currentValue","ms","Date","toISOString","dateTime","valueOf","console","log","boolean","parse","importPath","dotIndex","moduleName","functionName","getModule","module","expression","functions","dissoc","newObj","merge","res","entry","merged","zipmap","assertStringArray","NEGATIVE_INFINITY","table","isGrid","regexpNormalExpression","sourceArg","flagsArg","flags","e","text","assertRegularExpression","exec","replace","matcher","replaceAll","blankRegexp","stringNormalExpression","number","toLowerCase","toUpperCase","trim","stringList","delimiter","stringOrRegExpValue","limit","test","functionalNormalExpression","last","comp","reference","title","description","variants","args","returns","_isOperator","functionForms","variant","argumentNames","argName","operatorForm","signature","arg","examples","example","argType","typeString","sum","median","sorted","mid","calcMedian","expressions","normalExpressionReference","doc","generateDocString","docString","vectorNormalExpression","normalExpressions","allNormalExpressions","andSpecialExpression","node","evaluateNode","evaluateAsNormalExpression","getUndefinedSymbols","builtin","condSpecialExpression","processCase","form","switchSpecialExpression","switchValueNode","cases","switchValue","isSymbolNode","nodeType","isUserDefinedSymbolNode","asUserDefinedSymbolNode","assertUserDefinedSymbolNode","isNormalBuiltinSymbolNode","isSpecialBuiltinSymbolNode","isNormalExpressionNodeWithName","isNormalExpressionNode","definedSpecialExpression","symbolNode","assertSymbolNode","lookUp","bindingTargetTypes","walkDefaults","bindingTarget","onDefault","element","createRecord","record","capturedKeys","restElement","forEachSequential","existingVal","resolvedVal","restValues","restIndex","getAllBindingTargetNames","names","getNamesFromBindingTarget","defSpecialExpression","bindingNode","bindingValue","evaluateBindingNodeValues","Node","exportValues","bindingResult","defaultNode","addValues","newContextStack","create","_acc","lambdaSpecialExpression","evaluatedFunction","functionContext","context","ctx","new","undefinedSymbols","evaluateFunction","self","newContext","overloadResult","getFunctionUnresolvedSymbols","ifSpecialExpression","trueNode","falseNode","conditionNode","condition","n","unlessSpecialExpression","letSpecialExpression","loopSpecialExpression","setupBindings","bindingNodes","valueRecord","bindingContext","body","iterate","rebindAndIterate","resolved","bn","subIndex","vr","returnResult","loopNode","loopBindings","bindingIndices","processIteration","processBinding","bindingIndex","letBindings","whenNode","whileNode","targetNode","valueNode","rawColl","asColl","bindingChain","bindings","addToContext","whenResult","whileResult","status","analyze","loopBindingNode","letBindingNode","letTarget","letValue","helpers","evaluateLoop","doseqSpecialExpression","SENTINEL","Symbol","recurSpecialExpression","paramNode","evaluatedParams","throwSpecialExpression","trySpecialExpression","tryExpression","errorSymbol","catchExpression","tryResult","arraySpecialExpression","isSpreadNode","spreadValue","processEntry","keyNode","spreadObject","specialExpressionTypes","cond","block","doseq","for","throw","try","unless","specialExpressions","qqSpecialExpression","orSpecialExpression","doSpecialExpression","normalExpressionKeys","specialExpressionKeys","ast","nodes","subNode","unresolvedSymbols","findUnresolvedSymbolsInNode","normalExpressionNode","expressionNode","specialExpressionNode","specialExpressionType","castedGetUndefinedSymbols","phi","numberReservedSymbolRecord","E","PI","PHI","MAX_SAFE_INTEGER","MIN_SAFE_INTEGER","MAX_VALUE","MIN_VALUE","NaN","reservedSymbolRecord","true","false","null","do","in","when","while","function","export","as","end","_","NativeJsFunction","nativeFn","UserDefined","nbrOfParams","arityAcceptsMin","currentParams","evaluatedfunction","nbrOfNonRestArgs","paramSetup","defaultSetup","paramIndex","argIndex","restSetup","restArgument","newContextStack2","bodyResult","setupAndExecute","placeholders","paramsCopy","placeholderIndex","actualParams","splice","Comp","fun","r","finalArr","Constantly","Juxt","Complement","checks","check","SomePred","Fnull","fnulledParams","Builtin","normalBuiltinSymbolType","SpecialBuiltin","specialBuiltinSymbolType","specialExpression","evaluateString","evaluateSymbol","reservedName","evaluateReservedSymbol","paramNodes","evaluateParams","nameSymbol","resolvedFn","getValue","evaluateNormalExpression","castedEvaluate","evaluateSpecialExpression","evaluateArrayAsFunction","evalueateObjectAsFunction","evaluateNumberAsFunction","contexts","globalContext","nativeJsFunctions","modules","hostValues","Map","ContextStackImpl","shadowedName","getShadowedBuiltinName","currentContext","contextEntry","nativeJsFunction","hostValue","object","recur","normalExpression","lookUpResult","createContextStack","jsFunctions","identifier","identifierParts","scope","part","isJsFunction","assertJsFunction","assertNotShadowingBuiltin","globalModuleScope","symbolicOperators","nonFunctionOperatorSet","isFunctionOperator","operator","binaryOperatorSet","binaryOperators","isBinaryOperator","symbolicOperatorSet","illegalFirstSymbolCharacters","illegalSymbolCharacterSet","illegalSymbolCharacters","illegalFirstSymbolCharacterSet","whitespaceRegExp","escaping","input","decimalNumberRegExp","octalNumberRegExp","binaryNumberRegExp","postNumberRegExp","tokenizeSymbol","initialPosition","endsWith","NO_MATCH","symbolMeta","startsWith","tokenizeToken","nextThreeChars","token","stringLength","baseChar","hexNumberRegExp","nextChar","negate","start","plusPrefix","hasDecimalPoint","hasExponent","isSymbolicOperator","twoChars","createSourceCodeInfo","lastLine","lineNbr","getSourceCodeLine","getCurrentToken","tokenizeShebang","nbrOfCharacters","tokenizer","tokenizers","asSymbolToken","throwUnexpectedToken","assertReservedSymbolToken","isReservedSymbolToken","isOperatorToken","operatorName","assertOperatorToken","isLParenToken","assertLParenToken","isRParenToken","asLBracketToken","isLBracketToken","assertLBracketToken","isRBracketToken","assertRBracketToken","isLBraceToken","assertLBraceToken","isRBraceToken","isStringToken","isA_BinaryOperatorToken","expected","expectedValue","actual","actualOutput","minifyTokenStream","tokens","isSingleLineCommentToken","isMultiLineCommentToken","isShebangToken","removeWhiteSpace","isWhitespaceToken","tokenStream","litsCommands","AutoCompleter","originalProgram","originalPosition","prefixProgram","suffixProgram","searchString","suggestions","suggestionIndex","lits","partialProgram","lastToken","tokenize","getNextSuggestion","getAutoCompleteSuggestionResult","getNextSuggestionSymbol","getPreviousSuggestion","getPreviousSuggestionSymbol","suggestion","program","getSuggestions","getSearchString","generateSuggestions","blacklist","startsWithCaseSensitive","generateWithPredicate","startsWithCaseInsensitive","includesCaseSensitive","includesCaseInsensitive","shouldInclude","localeCompare","ParserContext","storedPosition","parseExpression","advance","tryPeek","peek","isAtEnd","peekSourceCodeInfo","currentToken","storePosition","getTokenAt","pos","withSourceCodeInfo","stringToSymbolNode","normalExpressionTypes","stringFromQuotedSymbol","backslash","singleQuote","specialExpressionNames","getSymbolName","createNamedNormalExpressionNode","isAtExpressionEnd","fromBinaryOperatorToNode","left","right","isSymbolToken","parseBindingTarget","requireDefaultValue","noRest","firstToken","parseOptionalDefaulValue","parseSymbol","elements","keySymbol","keyName","parseLet","let","parseImplicitBlock","ends","isImplicitBlockEnd","assertImplicitBlockEnd","parseForLoopBinding","parseBinding","modifiers","assertInternalLoopBindingDelimiter","letNode","existingBoundNames","flatMap","symbolsString","parseString","doubleQuote","newline","tab","carriageReturn","backspace","formFeed","normalChar","allowDocString","isDocStringToken","stringToken","stringNode","asReservedSymbolToken","isNumberReservedSymbol","placeholderRegexp","peekAhead","functionArguments","defaults","parsedDo","parseDo","nextToken","parseObject","asLBraceToken","parseOperand","operand","lamdaFunction","parseLambdaFunction","restorePosition","startPos","getPosition","endPos","dollar1","parseShorthandLambdaFunction","parseArray","tokenType","numberString","parseNumber","parseReservedSymbol","endStringPosition","optionsString","regexpString","optionsNode","parseRegexpShorthand","parseOperandPart","symbolToken","createAccessorNode","parseFunctionCall","getPrecedence","operatorSign","precedence","moduleScope","isUnless","elseExpression","thenExpression","if","parseIfOrUnless","caseExpression","parseCond","valueExpression","switch","parseSwitch","isDoseq","forLoopBindings","loopBinding","newBoundNames","assertRParenToken","parseForOrDoseq","loop","parseLoop","parseTry","exportToken","parseExport","newPrecedece","newPrecedence","operatorSymbol","Cache","cache","firstEntry","lastEntry","_size","maxSize","getContent","size","clear","set","newEntry","nextEntry","dropFirstEntry","Lits","astCache","astCacheSize","debug","config","initialCache","cacheEntry","nsList","ns","getRuntimeInfo","run","generateAst","programOrAst","apply","fnParams","tokenizeParams","hasDebugData","tokenDescriptor","transformSymbols","transformer","tokenStram","transformSymbolTokens","untokenize","fnName","generateApplyFunctionCall","paramsString","cachedAst","getAutoCompleter"],"mappings":"AAEM,SAAUA,EAAcC,GAC5B,IAAKA,EAAeC,WAAaD,EAAeE,KAC9C,MAAO,GAET,MAAMC,EAAcH,EAAeC,SAASG,OAAS,EAC/CC,EAAeL,EAAeE,KAAKI,OAASH,EAAc,EAChE,MAAO,GAAG,IAAII,OAAOC,KAAKC,IAAIN,EAAa,OAAO,IAAII,OAAOC,KAAKC,IAAIJ,EAAc,KACtF,CCQM,MAAOK,UAAoBC,MACxBC,OACP,WAAAC,CAAYD,GACVE,MAAM,kBAAkBF,KACxBG,OAAOC,eAAeC,KAAMP,EAAYQ,WACxCD,KAAKE,KAAO,cACZF,KAAKL,OAASA,CACf,EAGG,MAAOQ,UAAkBT,MACbX,eACAq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