@mojir/lits 2.0.16 → 2.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/cli/cli.js +667 -380
  2. package/dist/cli/reference/api.d.ts +5 -5
  3. package/dist/cli/src/builtin/index.d.ts +0 -2
  4. package/dist/cli/src/builtin/specialExpressions/functions.d.ts +0 -5
  5. package/dist/cli/src/parser/AlgebraicParser.d.ts +6 -6
  6. package/dist/cli/src/parser/commonTokenParsers.d.ts +2 -1
  7. package/dist/cli/src/tokenizer/algebraic/algebraicReservedNames.d.ts +16 -4
  8. package/dist/cli/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
  9. package/dist/cli/src/tokenizer/algebraic/algebraicTokens.d.ts +2 -2
  10. package/dist/cli/src/tokenizer/common/commonTokenizers.d.ts +3 -2
  11. package/dist/cli/src/tokenizer/common/commonTokens.d.ts +6 -2
  12. package/dist/cli/src/tokenizer/polish/polishTokenizers.d.ts +2 -3
  13. package/dist/cli/src/tokenizer/polish/polishTokens.d.ts +4 -8
  14. package/dist/cli/src/tokenizer/tokens.d.ts +2 -2
  15. package/dist/index.esm.js +663 -378
  16. package/dist/index.esm.js.map +1 -1
  17. package/dist/index.js +663 -378
  18. package/dist/index.js.map +1 -1
  19. package/dist/lits.iife.js +663 -378
  20. package/dist/lits.iife.js.map +1 -1
  21. package/dist/reference/api.d.ts +5 -5
  22. package/dist/src/builtin/index.d.ts +0 -2
  23. package/dist/src/builtin/specialExpressions/functions.d.ts +0 -5
  24. package/dist/src/parser/AlgebraicParser.d.ts +6 -6
  25. package/dist/src/parser/commonTokenParsers.d.ts +2 -1
  26. package/dist/src/tokenizer/algebraic/algebraicReservedNames.d.ts +16 -4
  27. package/dist/src/tokenizer/algebraic/algebraicTokenizers.d.ts +1 -1
  28. package/dist/src/tokenizer/algebraic/algebraicTokens.d.ts +2 -2
  29. package/dist/src/tokenizer/common/commonTokenizers.d.ts +3 -2
  30. package/dist/src/tokenizer/common/commonTokens.d.ts +6 -2
  31. package/dist/src/tokenizer/polish/polishTokenizers.d.ts +2 -3
  32. package/dist/src/tokenizer/polish/polishTokens.d.ts +4 -8
  33. package/dist/src/tokenizer/tokens.d.ts +2 -2
  34. package/dist/testFramework.esm.js +361 -271
  35. package/dist/testFramework.esm.js.map +1 -1
  36. package/dist/testFramework.js +361 -271
  37. package/dist/testFramework.js.map +1 -1
  38. package/package.json +1 -1
  39. package/dist/cli/src/builtin/specialExpressions/defs.d.ts +0 -5
  40. package/dist/src/builtin/specialExpressions/defs.d.ts +0 -5
package/dist/cli/cli.js CHANGED
@@ -92,7 +92,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
92
92
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
93
93
  };
94
94
 
95
- var version = "2.0.16";
95
+ var version = "2.0.17";
96
96
 
97
97
  var AstNodeType;
98
98
  (function (AstNodeType) {
@@ -288,6 +288,7 @@ var commonSimpleTokenTypes = [
288
288
  ];
289
289
  var commomValueTokenTypes = [
290
290
  'String',
291
+ 'RegexpShorthand',
291
292
  ];
292
293
  function isLParenToken(token) {
293
294
  return (token === null || token === void 0 ? void 0 : token[0]) === 'LParen';
@@ -361,6 +362,18 @@ function asStringToken(token) {
361
362
  assertStringToken(token);
362
363
  return token;
363
364
  }
365
+ function isRegexpShorthandToken(token) {
366
+ return (token === null || token === void 0 ? void 0 : token[0]) === 'RegexpShorthand';
367
+ }
368
+ function assertRegexpShorthandToken(token) {
369
+ if (!isRegexpShorthandToken(token)) {
370
+ throwUnexpectedToken('RegexpShorthand', undefined, token);
371
+ }
372
+ }
373
+ function asRegexpShorthandToken(token) {
374
+ assertRegexpShorthandToken(token);
375
+ return token;
376
+ }
364
377
  function isAlgebraicNotationToken(token) {
365
378
  return (token === null || token === void 0 ? void 0 : token[0]) === 'AlgNotation';
366
379
  }
@@ -431,24 +444,22 @@ var symbolicOperators = __spreadArray(__spreadArray(__spreadArray([], __read(sym
431
444
  var nonFunctionOperators = [
432
445
  '??',
433
446
  '&&',
447
+ '||',
434
448
  'comment',
435
449
  'cond',
450
+ 'def',
436
451
  'defined?',
437
- 'if',
438
- 'unless',
439
- '||',
452
+ 'defn',
440
453
  'do',
441
- 'throw',
442
- 'let',
443
- 'def',
444
- 'defs',
454
+ 'doseq',
445
455
  'fn',
446
- 'defn',
447
- 'defns',
448
- 'try',
449
- 'recur',
456
+ 'if',
457
+ 'let',
450
458
  'loop',
451
- 'doseq',
459
+ 'recur',
460
+ 'throw',
461
+ 'try',
462
+ 'unless',
452
463
  'while',
453
464
  ];
454
465
  var nonFunctionOperatorSet = new Set(nonFunctionOperators);
@@ -519,9 +530,10 @@ function isA_OperatorToken(token, operatorName) {
519
530
  }
520
531
  function assertA_OperatorToken(token, operatorName) {
521
532
  if (!isA_OperatorToken(token, operatorName)) {
522
- {
533
+ if (operatorName) {
523
534
  throw new LitsError("Unexpected token: ".concat(token, ", expected operator ").concat(operatorName), undefined);
524
535
  }
536
+ throwUnexpectedToken('A_Operator', operatorName, token);
525
537
  }
526
538
  }
527
539
  function isA_WhitespaceToken(token) {
@@ -544,7 +556,6 @@ var polishOnlyValueTokenTypes = [
544
556
  'P_StringShorthand',
545
557
  'P_Symbol',
546
558
  'P_ReservedSymbol',
547
- 'P_RegexpShorthand',
548
559
  'P_CollectionAccessor',
549
560
  'P_Comment',
550
561
  'P_Whitespace',
@@ -582,18 +593,6 @@ function isP_ReservedSymbolToken(token) {
582
593
  function isP_ModifierToken(token) {
583
594
  return (token === null || token === void 0 ? void 0 : token[0]) === 'P_Modifier';
584
595
  }
585
- function isP_RegexpShorthandToken(token) {
586
- return (token === null || token === void 0 ? void 0 : token[0]) === 'P_RegexpShorthand';
587
- }
588
- function assertP_RegexpShorthandToken(token) {
589
- if (!isP_RegexpShorthandToken(token)) {
590
- throwUnexpectedToken('P_RegexpShorthand', undefined, token);
591
- }
592
- }
593
- function asP_RegexpShorthandToken(token) {
594
- assertP_RegexpShorthandToken(token);
595
- return token;
596
- }
597
596
  function isP_FnShorthandToken(token) {
598
597
  return (token === null || token === void 0 ? void 0 : token[0]) === 'P_FnShorthand';
599
598
  }
@@ -774,11 +773,6 @@ var specialExpressionCommentRemovers = {
774
773
  removeOptions.removeCommenNodesFromArray(node.p);
775
774
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
776
775
  },
777
- 'defns': function (_node, _removeOptions) { },
778
- 'defs': function (node, removeOptions) {
779
- removeOptions.removeCommenNodesFromArray(node.p);
780
- node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
781
- },
782
776
  'do': function (node, removeOptions) {
783
777
  removeOptions.removeCommenNodesFromArray(node.p);
784
778
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
@@ -1946,7 +1940,7 @@ var arrayNormalExpression = {
1946
1940
  };
1947
1941
 
1948
1942
  var sequenceNormalExpression = {
1949
- nth: {
1943
+ 'nth': {
1950
1944
  evaluate: function (params, sourceCodeInfo) {
1951
1945
  var _a = __read(params, 2), seq = _a[0], i = _a[1];
1952
1946
  var defaultValue = toAny(params[2]);
@@ -1958,7 +1952,7 @@ var sequenceNormalExpression = {
1958
1952
  },
1959
1953
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
1960
1954
  },
1961
- filter: {
1955
+ 'filter': {
1962
1956
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
1963
1957
  var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
1964
1958
  var executeFunction = _b.executeFunction;
@@ -1973,7 +1967,7 @@ var sequenceNormalExpression = {
1973
1967
  },
1974
1968
  validate: function (node) { return assertNumberOfParams(2, node); },
1975
1969
  },
1976
- first: {
1970
+ 'first': {
1977
1971
  evaluate: function (_a, sourceCodeInfo) {
1978
1972
  var _b = __read(_a, 1), array = _b[0];
1979
1973
  if (array === null)
@@ -1983,7 +1977,7 @@ var sequenceNormalExpression = {
1983
1977
  },
1984
1978
  validate: function (node) { return assertNumberOfParams(1, node); },
1985
1979
  },
1986
- last: {
1980
+ 'last': {
1987
1981
  evaluate: function (_a, sourceCodeInfo) {
1988
1982
  var _b = __read(_a, 1), array = _b[0];
1989
1983
  if (array === null)
@@ -1993,7 +1987,7 @@ var sequenceNormalExpression = {
1993
1987
  },
1994
1988
  validate: function (node) { return assertNumberOfParams(1, node); },
1995
1989
  },
1996
- map: {
1990
+ 'map': {
1997
1991
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
1998
1992
  var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
1999
1993
  var executeFunction = _b.executeFunction;
@@ -2015,7 +2009,7 @@ var sequenceNormalExpression = {
2015
2009
  },
2016
2010
  validate: function (node) { return assertNumberOfParams(2, node); },
2017
2011
  },
2018
- pop: {
2012
+ 'pop': {
2019
2013
  evaluate: function (_a, sourceCodeInfo) {
2020
2014
  var _b = __read(_a, 1), seq = _b[0];
2021
2015
  assertSeq(seq, sourceCodeInfo);
@@ -2026,7 +2020,7 @@ var sequenceNormalExpression = {
2026
2020
  },
2027
2021
  validate: function (node) { return assertNumberOfParams(1, node); },
2028
2022
  },
2029
- position: {
2023
+ 'position': {
2030
2024
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2031
2025
  var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2032
2026
  var executeFunction = _b.executeFunction;
@@ -2045,7 +2039,7 @@ var sequenceNormalExpression = {
2045
2039
  },
2046
2040
  validate: function (node) { return assertNumberOfParams(2, node); },
2047
2041
  },
2048
- index_of: {
2042
+ 'index_of': {
2049
2043
  evaluate: function (_a, sourceCodeInfo) {
2050
2044
  var _b = __read(_a, 2), seq = _b[0], value = _b[1];
2051
2045
  assertAny(value, sourceCodeInfo);
@@ -2064,7 +2058,26 @@ var sequenceNormalExpression = {
2064
2058
  },
2065
2059
  validate: function (node) { return assertNumberOfParams(2, node); },
2066
2060
  },
2067
- push: {
2061
+ 'last_index_of': {
2062
+ evaluate: function (_a, sourceCodeInfo) {
2063
+ var _b = __read(_a, 2), seq = _b[0], value = _b[1];
2064
+ assertAny(value, sourceCodeInfo);
2065
+ if (seq === null)
2066
+ return null;
2067
+ assertSeq(seq, sourceCodeInfo);
2068
+ if (typeof seq === 'string') {
2069
+ assertString(value, sourceCodeInfo);
2070
+ var index = seq.lastIndexOf(value);
2071
+ return index !== -1 ? index : null;
2072
+ }
2073
+ else {
2074
+ var index = seq.lastIndexOf(value);
2075
+ return index !== -1 ? index : null;
2076
+ }
2077
+ },
2078
+ validate: function (node) { return assertNumberOfParams(2, node); },
2079
+ },
2080
+ 'push': {
2068
2081
  evaluate: function (_a, sourceCodeInfo) {
2069
2082
  var _b = __read(_a), seq = _b[0], values = _b.slice(1);
2070
2083
  assertSeq(seq, sourceCodeInfo);
@@ -2078,7 +2091,7 @@ var sequenceNormalExpression = {
2078
2091
  },
2079
2092
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
2080
2093
  },
2081
- reductions: {
2094
+ 'reductions': {
2082
2095
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2083
2096
  var executeFunction = _a.executeFunction;
2084
2097
  var _b = __read(params, 2), seq = _b[0], fn = _b[1];
@@ -2139,7 +2152,7 @@ var sequenceNormalExpression = {
2139
2152
  },
2140
2153
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2141
2154
  },
2142
- reduce: {
2155
+ 'reduce': {
2143
2156
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2144
2157
  var executeFunction = _a.executeFunction;
2145
2158
  var _b = __read(params, 2), seq = _b[0], fn = _b[1];
@@ -2186,7 +2199,7 @@ var sequenceNormalExpression = {
2186
2199
  },
2187
2200
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2188
2201
  },
2189
- reduce_right: {
2202
+ 'reduce_right': {
2190
2203
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2191
2204
  var executeFunction = _a.executeFunction;
2192
2205
  var _b = __read(params, 2), seq = _b[0], fn = _b[1];
@@ -2234,7 +2247,7 @@ var sequenceNormalExpression = {
2234
2247
  },
2235
2248
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2236
2249
  },
2237
- rest: {
2250
+ 'rest': {
2238
2251
  evaluate: function (_a, sourceCodeInfo) {
2239
2252
  var _b = __read(_a, 1), seq = _b[0];
2240
2253
  assertSeq(seq, sourceCodeInfo);
@@ -2247,7 +2260,7 @@ var sequenceNormalExpression = {
2247
2260
  },
2248
2261
  validate: function (node) { return assertNumberOfParams(1, node); },
2249
2262
  },
2250
- nthrest: {
2263
+ 'nthrest': {
2251
2264
  evaluate: function (_a, sourceCodeInfo) {
2252
2265
  var _b = __read(_a, 2), seq = _b[0], count = _b[1];
2253
2266
  assertSeq(seq, sourceCodeInfo);
@@ -2259,7 +2272,7 @@ var sequenceNormalExpression = {
2259
2272
  },
2260
2273
  validate: function (node) { return assertNumberOfParams(2, node); },
2261
2274
  },
2262
- next: {
2275
+ 'next': {
2263
2276
  evaluate: function (_a, sourceCodeInfo) {
2264
2277
  var _b = __read(_a, 1), seq = _b[0];
2265
2278
  assertSeq(seq, sourceCodeInfo);
@@ -2274,7 +2287,7 @@ var sequenceNormalExpression = {
2274
2287
  },
2275
2288
  validate: function (node) { return assertNumberOfParams(1, node); },
2276
2289
  },
2277
- nthnext: {
2290
+ 'nthnext': {
2278
2291
  evaluate: function (_a, sourceCodeInfo) {
2279
2292
  var _b = __read(_a, 2), seq = _b[0], count = _b[1];
2280
2293
  assertSeq(seq, sourceCodeInfo);
@@ -2288,7 +2301,7 @@ var sequenceNormalExpression = {
2288
2301
  },
2289
2302
  validate: function (node) { return assertNumberOfParams(2, node); },
2290
2303
  },
2291
- reverse: {
2304
+ 'reverse': {
2292
2305
  evaluate: function (_a, sourceCodeInfo) {
2293
2306
  var _b = __read(_a, 1), seq = _b[0];
2294
2307
  if (seq === null)
@@ -2300,7 +2313,7 @@ var sequenceNormalExpression = {
2300
2313
  },
2301
2314
  validate: function (node) { return assertNumberOfParams(1, node); },
2302
2315
  },
2303
- second: {
2316
+ 'second': {
2304
2317
  evaluate: function (_a, sourceCodeInfo) {
2305
2318
  var _b = __read(_a, 1), seq = _b[0];
2306
2319
  if (seq === null)
@@ -2310,7 +2323,7 @@ var sequenceNormalExpression = {
2310
2323
  },
2311
2324
  validate: function (node) { return assertNumberOfParams(1, node); },
2312
2325
  },
2313
- shift: {
2326
+ 'shift': {
2314
2327
  evaluate: function (_a, sourceCodeInfo) {
2315
2328
  var _b = __read(_a, 1), seq = _b[0];
2316
2329
  assertSeq(seq, sourceCodeInfo);
@@ -2322,7 +2335,7 @@ var sequenceNormalExpression = {
2322
2335
  },
2323
2336
  validate: function (node) { return assertNumberOfParams(1, node); },
2324
2337
  },
2325
- slice: {
2338
+ 'slice': {
2326
2339
  evaluate: function (params, sourceCodeInfo) {
2327
2340
  var _a = __read(params, 3), seq = _a[0], from = _a[1], to = _a[2];
2328
2341
  assertSeq(seq, sourceCodeInfo);
@@ -2336,7 +2349,7 @@ var sequenceNormalExpression = {
2336
2349
  },
2337
2350
  validate: function (node) { return assertNumberOfParams({ min: 1, max: 3 }, node); },
2338
2351
  },
2339
- some: {
2352
+ 'some': {
2340
2353
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2341
2354
  var _c;
2342
2355
  var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
@@ -2353,7 +2366,7 @@ var sequenceNormalExpression = {
2353
2366
  },
2354
2367
  validate: function (node) { return assertNumberOfParams(2, node); },
2355
2368
  },
2356
- sort: {
2369
+ 'sort': {
2357
2370
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2358
2371
  var executeFunction = _a.executeFunction;
2359
2372
  var _b = __read(params, 1), seq = _b[0];
@@ -2391,7 +2404,7 @@ var sequenceNormalExpression = {
2391
2404
  },
2392
2405
  validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
2393
2406
  },
2394
- sort_by: {
2407
+ 'sort_by': {
2395
2408
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2396
2409
  var executeFunction = _a.executeFunction;
2397
2410
  var _b = __read(params, 2), seq = _b[0], keyfn = _b[1];
@@ -2442,7 +2455,7 @@ var sequenceNormalExpression = {
2442
2455
  },
2443
2456
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2444
2457
  },
2445
- take: {
2458
+ 'take': {
2446
2459
  evaluate: function (_a, sourceCodeInfo) {
2447
2460
  var _b = __read(_a, 2), input = _b[0], n = _b[1];
2448
2461
  assertNumber(n, sourceCodeInfo);
@@ -2452,7 +2465,7 @@ var sequenceNormalExpression = {
2452
2465
  },
2453
2466
  validate: function (node) { return assertNumberOfParams(2, node); },
2454
2467
  },
2455
- take_last: {
2468
+ 'take_last': {
2456
2469
  evaluate: function (_a, sourceCodeInfo) {
2457
2470
  var _b = __read(_a, 2), array = _b[0], n = _b[1];
2458
2471
  assertSeq(array, sourceCodeInfo);
@@ -2463,7 +2476,7 @@ var sequenceNormalExpression = {
2463
2476
  },
2464
2477
  validate: function (node) { return assertNumberOfParams(2, node); },
2465
2478
  },
2466
- take_while: {
2479
+ 'take_while': {
2467
2480
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2468
2481
  var e_1, _c;
2469
2482
  var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
@@ -2491,7 +2504,7 @@ var sequenceNormalExpression = {
2491
2504
  },
2492
2505
  validate: function (node) { return assertNumberOfParams(2, node); },
2493
2506
  },
2494
- drop: {
2507
+ 'drop': {
2495
2508
  evaluate: function (_a, sourceCodeInfo) {
2496
2509
  var _b = __read(_a, 2), input = _b[0], n = _b[1];
2497
2510
  assertNumber(n, sourceCodeInfo);
@@ -2501,7 +2514,7 @@ var sequenceNormalExpression = {
2501
2514
  },
2502
2515
  validate: function (node) { return assertNumberOfParams(2, node); },
2503
2516
  },
2504
- drop_last: {
2517
+ 'drop_last': {
2505
2518
  evaluate: function (_a, sourceCodeInfo) {
2506
2519
  var _b = __read(_a, 2), array = _b[0], n = _b[1];
2507
2520
  assertSeq(array, sourceCodeInfo);
@@ -2512,7 +2525,7 @@ var sequenceNormalExpression = {
2512
2525
  },
2513
2526
  validate: function (node) { return assertNumberOfParams(2, node); },
2514
2527
  },
2515
- drop_while: {
2528
+ 'drop_while': {
2516
2529
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2517
2530
  var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2518
2531
  var executeFunction = _b.executeFunction;
@@ -2528,7 +2541,7 @@ var sequenceNormalExpression = {
2528
2541
  },
2529
2542
  validate: function (node) { return assertNumberOfParams(2, node); },
2530
2543
  },
2531
- unshift: {
2544
+ 'unshift': {
2532
2545
  evaluate: function (_a, sourceCodeInfo) {
2533
2546
  var _b = __read(_a), seq = _b[0], values = _b.slice(1);
2534
2547
  assertSeq(seq, sourceCodeInfo);
@@ -2542,7 +2555,7 @@ var sequenceNormalExpression = {
2542
2555
  },
2543
2556
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
2544
2557
  },
2545
- distinct: {
2558
+ 'distinct': {
2546
2559
  evaluate: function (_a, sourceCodeInfo) {
2547
2560
  var _b = __read(_a, 1), input = _b[0];
2548
2561
  assertSeq(input, sourceCodeInfo);
@@ -2552,9 +2565,9 @@ var sequenceNormalExpression = {
2552
2565
  },
2553
2566
  validate: function (node) { return assertNumberOfParams(1, node); },
2554
2567
  },
2555
- remove: {
2568
+ 'remove': {
2556
2569
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2557
- var _c = __read(_a, 2), fn = _c[0], input = _c[1];
2570
+ var _c = __read(_a, 2), input = _c[0], fn = _c[1];
2558
2571
  var executeFunction = _b.executeFunction;
2559
2572
  assertLitsFunction(fn, sourceCodeInfo);
2560
2573
  assertSeq(input, sourceCodeInfo);
@@ -2567,9 +2580,9 @@ var sequenceNormalExpression = {
2567
2580
  },
2568
2581
  validate: function (node) { return assertNumberOfParams(2, node); },
2569
2582
  },
2570
- remove_at: {
2583
+ 'remove_at': {
2571
2584
  evaluate: function (_a, sourceCodeInfo) {
2572
- var _b = __read(_a, 2), index = _b[0], input = _b[1];
2585
+ var _b = __read(_a, 2), input = _b[0], index = _b[1];
2573
2586
  assertNumber(index, sourceCodeInfo);
2574
2587
  assertSeq(input, sourceCodeInfo);
2575
2588
  var intIndex = Math.ceil(index);
@@ -2584,9 +2597,9 @@ var sequenceNormalExpression = {
2584
2597
  },
2585
2598
  validate: function (node) { return assertNumberOfParams(2, node); },
2586
2599
  },
2587
- split_at: {
2600
+ 'split_at': {
2588
2601
  evaluate: function (_a, sourceCodeInfo) {
2589
- var _b = __read(_a, 2), pos = _b[0], seq = _b[1];
2602
+ var _b = __read(_a, 2), seq = _b[0], pos = _b[1];
2590
2603
  assertNumber(pos, sourceCodeInfo, { finite: true });
2591
2604
  var intPos = toNonNegativeInteger(pos);
2592
2605
  assertSeq(seq, sourceCodeInfo);
@@ -2594,9 +2607,9 @@ var sequenceNormalExpression = {
2594
2607
  },
2595
2608
  validate: function (node) { return assertNumberOfParams(2, node); },
2596
2609
  },
2597
- split_with: {
2610
+ 'split_with': {
2598
2611
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2599
- var _c = __read(_a, 2), fn = _c[0], seq = _c[1];
2612
+ var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2600
2613
  var executeFunction = _b.executeFunction;
2601
2614
  assertLitsFunction(fn, sourceCodeInfo);
2602
2615
  assertSeq(seq, sourceCodeInfo);
@@ -2609,7 +2622,7 @@ var sequenceNormalExpression = {
2609
2622
  },
2610
2623
  validate: function (node) { return assertNumberOfParams(2, node); },
2611
2624
  },
2612
- frequencies: {
2625
+ 'frequencies': {
2613
2626
  evaluate: function (_a, sourceCodeInfo) {
2614
2627
  var _b = __read(_a, 1), seq = _b[0];
2615
2628
  assertSeq(seq, sourceCodeInfo);
@@ -2625,9 +2638,9 @@ var sequenceNormalExpression = {
2625
2638
  },
2626
2639
  validate: function (node) { return assertNumberOfParams(1, node); },
2627
2640
  },
2628
- group_by: {
2641
+ 'group_by': {
2629
2642
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2630
- var _c = __read(_a, 2), fn = _c[0], seq = _c[1];
2643
+ var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2631
2644
  var executeFunction = _b.executeFunction;
2632
2645
  assertAny(fn, sourceCodeInfo);
2633
2646
  assertSeq(seq, sourceCodeInfo);
@@ -2643,34 +2656,30 @@ var sequenceNormalExpression = {
2643
2656
  },
2644
2657
  validate: function (node) { return assertNumberOfParams(2, node); },
2645
2658
  },
2646
- partition: {
2659
+ 'partition': {
2647
2660
  evaluate: function (params, sourceCodeInfo) {
2648
- var len = params.length;
2649
- var n = toNonNegativeInteger(asNumber(params[0], sourceCodeInfo));
2650
- var seq = len === 2
2651
- ? asSeq(params[1], sourceCodeInfo)
2652
- : len === 3
2653
- ? asSeq(params[2], sourceCodeInfo)
2654
- : asSeq(params[3], sourceCodeInfo);
2655
- var step = len >= 3 ? toNonNegativeInteger(asNumber(params[1], sourceCodeInfo)) : n;
2656
- var pad = len === 4 ? (params[2] === null ? [] : asArray(params[2], sourceCodeInfo)) : undefined;
2661
+ var seq = asSeq(params[0], sourceCodeInfo);
2662
+ var n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo));
2663
+ var step = params.length >= 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n;
2664
+ var pad = params.length === 4
2665
+ ? params[3] === null ? [] : asArray(params[3], sourceCodeInfo)
2666
+ : undefined;
2657
2667
  return partition(n, step, seq, pad, sourceCodeInfo);
2658
2668
  },
2659
2669
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 4 }, node); },
2660
2670
  },
2661
- partition_all: {
2671
+ 'partition_all': {
2662
2672
  evaluate: function (params, sourceCodeInfo) {
2663
- var len = params.length;
2664
- var n = toNonNegativeInteger(asNumber(params[0], sourceCodeInfo));
2665
- var seq = len === 2 ? asSeq(params[1], sourceCodeInfo) : asSeq(params[2], sourceCodeInfo);
2666
- var step = len >= 3 ? toNonNegativeInteger(asNumber(params[1], sourceCodeInfo)) : n;
2673
+ var seq = asSeq(params[0], sourceCodeInfo);
2674
+ var n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo));
2675
+ var step = params.length === 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n;
2667
2676
  return partition(n, step, seq, [], sourceCodeInfo);
2668
2677
  },
2669
2678
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2670
2679
  },
2671
- partition_by: {
2680
+ 'partition_by': {
2672
2681
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2673
- var _c = __read(_a, 2), fn = _c[0], seq = _c[1];
2682
+ var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2674
2683
  var executeFunction = _b.executeFunction;
2675
2684
  assertLitsFunction(fn, sourceCodeInfo);
2676
2685
  assertSeq(seq, sourceCodeInfo);
@@ -2687,7 +2696,88 @@ var sequenceNormalExpression = {
2687
2696
  }, []);
2688
2697
  return isStringSeq ? result.map(function (elem) { return elem.join(''); }) : result;
2689
2698
  },
2690
- validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2699
+ validate: function (node) { return assertNumberOfParams(2, node); },
2700
+ },
2701
+ 'ends_with?': {
2702
+ evaluate: function (_a, sourceCodeInfo) {
2703
+ var _b = __read(_a, 2), str = _b[0], search = _b[1];
2704
+ assertSeq(str, sourceCodeInfo);
2705
+ if (typeof str === 'string') {
2706
+ assertString(search, sourceCodeInfo);
2707
+ return str.endsWith(search);
2708
+ }
2709
+ return str.at(-1) === search;
2710
+ },
2711
+ validate: function (node) { return assertNumberOfParams(2, node); },
2712
+ },
2713
+ 'starts_with?': {
2714
+ evaluate: function (_a, sourceCodeInfo) {
2715
+ var _b = __read(_a, 2), str = _b[0], search = _b[1];
2716
+ assertSeq(str, sourceCodeInfo);
2717
+ if (typeof str === 'string') {
2718
+ assertString(search, sourceCodeInfo);
2719
+ return str.startsWith(search);
2720
+ }
2721
+ return str[0] === search;
2722
+ },
2723
+ validate: function (node) { return assertNumberOfParams(2, node); },
2724
+ },
2725
+ 'interleave': {
2726
+ evaluate: function (_a, sourceCodeInfo) {
2727
+ var e_2, _b;
2728
+ var _c = __read(_a), seqs = _c.slice(0);
2729
+ var isStringSeq = typeof seqs[0] === 'string';
2730
+ var seqsArr = isStringSeq
2731
+ ? seqs.map(function (seq) {
2732
+ assertString(seq, sourceCodeInfo);
2733
+ if (typeof seq === 'string')
2734
+ return seq.split('');
2735
+ return seq;
2736
+ })
2737
+ : seqs.map(function (seq) {
2738
+ assertArray(seq, sourceCodeInfo);
2739
+ return seq;
2740
+ });
2741
+ var maxLength = Math.min.apply(Math, __spreadArray([], __read(seqsArr.map(function (seq) { return seq.length; })), false));
2742
+ var result = [];
2743
+ for (var i = 0; i < maxLength; i += 1) {
2744
+ try {
2745
+ for (var seqsArr_1 = (e_2 = void 0, __values(seqsArr)), seqsArr_1_1 = seqsArr_1.next(); !seqsArr_1_1.done; seqsArr_1_1 = seqsArr_1.next()) {
2746
+ var seq = seqsArr_1_1.value;
2747
+ if (i < seq.length)
2748
+ result.push(seq[i]);
2749
+ }
2750
+ }
2751
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2752
+ finally {
2753
+ try {
2754
+ if (seqsArr_1_1 && !seqsArr_1_1.done && (_b = seqsArr_1.return)) _b.call(seqsArr_1);
2755
+ }
2756
+ finally { if (e_2) throw e_2.error; }
2757
+ }
2758
+ }
2759
+ return isStringSeq ? result.join('') : result;
2760
+ },
2761
+ validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
2762
+ },
2763
+ 'interpose': {
2764
+ evaluate: function (_a, sourceCodeInfo) {
2765
+ var _b = __read(_a, 2), seq = _b[0], separator = _b[1];
2766
+ assertSeq(seq, sourceCodeInfo);
2767
+ if (typeof seq === 'string') {
2768
+ assertString(separator, sourceCodeInfo);
2769
+ return seq.split('').join(separator);
2770
+ }
2771
+ if (seq.length === 0)
2772
+ return [];
2773
+ var result = [];
2774
+ for (var i = 0; i < seq.length - 1; i += 1) {
2775
+ result.push(seq[i], separator);
2776
+ }
2777
+ result.push(seq[seq.length - 1]);
2778
+ return result;
2779
+ },
2780
+ validate: function (node) { return assertNumberOfParams(2, node); },
2691
2781
  },
2692
2782
  };
2693
2783
  function partition(n, step, seq, pad, sourceCodeInfo) {
@@ -3850,7 +3940,7 @@ var regexpNormalExpression = {
3850
3940
  },
3851
3941
  match: {
3852
3942
  evaluate: function (_a, sourceCodeInfo) {
3853
- var _b = __read(_a, 2), regexp = _b[0], text = _b[1];
3943
+ var _b = __read(_a, 2), text = _b[0], regexp = _b[1];
3854
3944
  assertRegularExpression(regexp, sourceCodeInfo);
3855
3945
  if (!isString(text))
3856
3946
  return null;
@@ -3866,15 +3956,27 @@ var regexpNormalExpression = {
3866
3956
  evaluate: function (_a, sourceCodeInfo) {
3867
3957
  var _b = __read(_a, 3), str = _b[0], regexp = _b[1], value = _b[2];
3868
3958
  assertString(str, sourceCodeInfo);
3869
- assertRegularExpression(regexp, sourceCodeInfo);
3959
+ assertStringOrRegularExpression(regexp, sourceCodeInfo);
3870
3960
  assertString(value, sourceCodeInfo);
3871
- var regExp = new RegExp(regexp.s, regexp.f);
3872
- return str.replace(regExp, value);
3961
+ var matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, "".concat(regexp.f)) : regexp;
3962
+ return str.replace(matcher, value);
3963
+ },
3964
+ validate: function (node) { return assertNumberOfParams(3, node); },
3965
+ },
3966
+ replace_all: {
3967
+ evaluate: function (_a, sourceCodeInfo) {
3968
+ var _b = __read(_a, 3), str = _b[0], regexp = _b[1], value = _b[2];
3969
+ assertString(str, sourceCodeInfo);
3970
+ assertStringOrRegularExpression(regexp, sourceCodeInfo);
3971
+ assertString(value, sourceCodeInfo);
3972
+ var matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, "".concat(regexp.f.includes('g') ? regexp.f : "".concat(regexp.f, "g"))) : regexp;
3973
+ return str.replaceAll(matcher, value);
3873
3974
  },
3874
3975
  validate: function (node) { return assertNumberOfParams(3, node); },
3875
3976
  },
3876
3977
  };
3877
3978
 
3979
+ var blankRegexp = /^\s*$/;
3878
3980
  var stringNormalExpression = {
3879
3981
  'subs': {
3880
3982
  evaluate: function (_a, sourceCodeInfo) {
@@ -4032,6 +4134,14 @@ var stringNormalExpression = {
4032
4134
  },
4033
4135
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
4034
4136
  },
4137
+ 'split_lines': {
4138
+ evaluate: function (_a, sourceCodeInfo) {
4139
+ var _b = __read(_a, 1), str = _b[0];
4140
+ assertString(str, sourceCodeInfo);
4141
+ return str.split((/\r\n|\n|\r/)).filter(function (line) { return line !== ''; });
4142
+ },
4143
+ validate: function (node) { return assertNumberOfParams(1, node); },
4144
+ },
4035
4145
  'pad_left': {
4036
4146
  evaluate: function (_a, sourceCodeInfo) {
4037
4147
  var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
@@ -4135,6 +4245,25 @@ var stringNormalExpression = {
4135
4245
  },
4136
4246
  validate: function (node) { return assertNumberOfParams(1, node); },
4137
4247
  },
4248
+ 'blank?': {
4249
+ evaluate: function (_a, sourceCodeInfo) {
4250
+ var _b = __read(_a, 1), value = _b[0];
4251
+ if (value === null) {
4252
+ return true;
4253
+ }
4254
+ assertString(value, sourceCodeInfo);
4255
+ return blankRegexp.test(value);
4256
+ },
4257
+ validate: function (node) { return assertNumberOfParams(1, node); },
4258
+ },
4259
+ 'capitalize': {
4260
+ evaluate: function (_a, sourceCodeInfo) {
4261
+ var _b = __read(_a, 1), str = _b[0];
4262
+ assertString(str, sourceCodeInfo);
4263
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
4264
+ },
4265
+ validate: function (node) { return assertNumberOfParams(1, node); },
4266
+ },
4138
4267
  };
4139
4268
  var doubleDollarRegexp = /\$\$/g;
4140
4269
  function applyPlaceholders(templateString, placeholders, sourceCodeInfo) {
@@ -4480,44 +4609,6 @@ var defSpecialExpression = {
4480
4609
  },
4481
4610
  };
4482
4611
 
4483
- var defsSpecialExpression = {
4484
- polishParse: function (tokenStream, parseState, firstToken, _a) {
4485
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
4486
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
4487
- assertRParenToken(tokenStream.tokens[parseState.position++]);
4488
- var node = {
4489
- t: AstNodeType.SpecialExpression,
4490
- n: 'defs',
4491
- p: params,
4492
- token: getTokenDebugData(firstToken) && firstToken,
4493
- };
4494
- return node;
4495
- },
4496
- validateParameterCount: function (node) { return assertNumberOfParams(2, node); },
4497
- evaluate: function (node, contextStack, _a) {
4498
- var _b, _c;
4499
- var evaluateAstNode = _a.evaluateAstNode, builtin = _a.builtin;
4500
- var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
4501
- var name = evaluateAstNode(node.p[0], contextStack);
4502
- assertString(name, sourceCodeInfo);
4503
- assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
4504
- contextStack.exportValue(name, evaluateAstNode(node.p[1], contextStack));
4505
- return null;
4506
- },
4507
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
4508
- var _b;
4509
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
4510
- var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
4511
- var subNode = node.p[1];
4512
- var result = findUnresolvedIdentifiers([subNode], contextStack, builtin);
4513
- var name = evaluateAstNode(node.p[0], contextStack);
4514
- assertString(name, sourceCodeInfo);
4515
- assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
4516
- contextStack.exportValue(name, true);
4517
- return result;
4518
- },
4519
- };
4520
-
4521
4612
  var doSpecialExpression = {
4522
4613
  polishParse: getCommonPolishSpecialExpressionParser('do'),
4523
4614
  validateParameterCount: function () { return undefined; },
@@ -4597,7 +4688,7 @@ var defnSpecialExpression = {
4597
4688
  var _b;
4598
4689
  var _c, _d;
4599
4690
  var builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
4600
- var name = getFunctionName('defn', node, contextStack, evaluateAstNode);
4691
+ var name = node.f.v;
4601
4692
  assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
4602
4693
  var evaluatedFunctionOverloades = evaluateFunctionOverloades(node, contextStack, evaluateAstNode);
4603
4694
  var litsFunction = (_b = {},
@@ -4618,53 +4709,6 @@ var defnSpecialExpression = {
4618
4709
  return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
4619
4710
  },
4620
4711
  };
4621
- var defnsSpecialExpression = {
4622
- polishParse: function (tokenStream, parseState, firstToken, parsers) {
4623
- var parseToken = parsers.parseToken;
4624
- var functionName = parseToken(tokenStream, parseState);
4625
- var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
4626
- assertRParenToken(tokenStream.tokens[parseState.position++]);
4627
- var node = {
4628
- t: AstNodeType.SpecialExpression,
4629
- n: 'defns',
4630
- p: [],
4631
- f: functionName,
4632
- o: functionOverloades,
4633
- token: getTokenDebugData(firstToken) && firstToken,
4634
- };
4635
- return node;
4636
- },
4637
- validateParameterCount: function () { return undefined; },
4638
- evaluate: function (node, contextStack, _a) {
4639
- var _b;
4640
- var _c, _d;
4641
- var builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
4642
- var name = getFunctionName('defns', node, contextStack, evaluateAstNode);
4643
- assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
4644
- var evaluatedFunctionOverloades = evaluateFunctionOverloades(node, contextStack, evaluateAstNode);
4645
- var litsFunction = (_b = {},
4646
- _b[FUNCTION_SYMBOL] = true,
4647
- _b.sourceCodeInfo = (_d = getTokenDebugData(node.token)) === null || _d === void 0 ? void 0 : _d.sourceCodeInfo,
4648
- _b.t = FunctionType.UserDefined,
4649
- _b.n = name,
4650
- _b.o = evaluatedFunctionOverloades,
4651
- _b);
4652
- contextStack.exportValue(name, litsFunction);
4653
- return null;
4654
- },
4655
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
4656
- var _b;
4657
- var _c;
4658
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
4659
- var sourceCodeInfo = (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo;
4660
- var name = evaluateAstNode(asAstNode(node.f, sourceCodeInfo), contextStack);
4661
- assertString(name, sourceCodeInfo);
4662
- assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
4663
- contextStack.exportValue(name, true);
4664
- var newContext = (_b = {}, _b[name] = { value: true }, _b);
4665
- return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
4666
- },
4667
- };
4668
4712
  var fnSpecialExpression = {
4669
4713
  polishParse: function (tokenStream, parseState, firstToken, parsers) {
4670
4714
  var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
@@ -4698,14 +4742,6 @@ var fnSpecialExpression = {
4698
4742
  return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin);
4699
4743
  },
4700
4744
  };
4701
- function getFunctionName(expressionName, node, contextStack, evaluateAstNode) {
4702
- var _a;
4703
- var sourceCodeInfo = (_a = getTokenDebugData(node.token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo;
4704
- if (expressionName === 'defn')
4705
- return (node.f).v;
4706
- var name = evaluateAstNode(node.f, contextStack);
4707
- return asString(name, sourceCodeInfo);
4708
- }
4709
4745
  function evaluateFunctionOverloades(node, contextStack, evaluateAstNode) {
4710
4746
  var e_1, _a, e_2, _b;
4711
4747
  var evaluatedFunctionOverloades = [];
@@ -5483,8 +5519,6 @@ var specialExpressions = {
5483
5519
  'switch': switchSpecialExpression,
5484
5520
  'def': defSpecialExpression,
5485
5521
  'defn': defnSpecialExpression,
5486
- 'defns': defnsSpecialExpression,
5487
- 'defs': defsSpecialExpression,
5488
5522
  'do': doSpecialExpression,
5489
5523
  'doseq': doseqSpecialExpression,
5490
5524
  'for': forSpecialExpression,
@@ -5546,7 +5580,6 @@ var ContextStackImpl = /** @class */ (function () {
5546
5580
  if (normalExpressionKeys.includes(name)) {
5547
5581
  throw new Error("Cannot shadow builtin function \"".concat(name, "\""));
5548
5582
  }
5549
- this.addValue(name, value);
5550
5583
  this.globalContext[name] = { value: value };
5551
5584
  };
5552
5585
  ContextStackImpl.prototype.addValue = function (name, value) {
@@ -6210,6 +6243,33 @@ function parseString(tokenStream, parseState) {
6210
6243
  token: getTokenDebugData(tkn) && tkn,
6211
6244
  };
6212
6245
  }
6246
+ function parseRegexpShorthand(tokenStream, parseState) {
6247
+ var tkn = asRegexpShorthandToken(tokenStream.tokens[parseState.position++]);
6248
+ var endStringPosition = tkn[1].lastIndexOf('"');
6249
+ var regexpString = tkn[1].substring(2, endStringPosition);
6250
+ var optionsString = tkn[1].substring(endStringPosition + 1);
6251
+ var stringNode = {
6252
+ t: AstNodeType.String,
6253
+ v: regexpString,
6254
+ p: [],
6255
+ n: undefined,
6256
+ token: getTokenDebugData(tkn) && tkn,
6257
+ };
6258
+ var optionsNode = {
6259
+ t: AstNodeType.String,
6260
+ v: optionsString,
6261
+ p: [],
6262
+ n: undefined,
6263
+ token: getTokenDebugData(tkn) && tkn,
6264
+ };
6265
+ var node = {
6266
+ t: AstNodeType.NormalExpression,
6267
+ n: 'regexp',
6268
+ p: [stringNode, optionsNode],
6269
+ token: getTokenDebugData(tkn) && tkn,
6270
+ };
6271
+ return node;
6272
+ }
6213
6273
 
6214
6274
  var exponentiationPrecedence = 10;
6215
6275
  var binaryFunctionalOperatorPrecedence = 1;
@@ -6351,6 +6411,12 @@ var AlgebraicParser = /** @class */ (function () {
6351
6411
  this.tokenStream = tokenStream;
6352
6412
  this.parseState = parseState;
6353
6413
  }
6414
+ AlgebraicParser.prototype.peek = function () {
6415
+ return this.tokenStream.tokens[this.parseState.position];
6416
+ };
6417
+ AlgebraicParser.prototype.peekAhead = function (count) {
6418
+ return this.tokenStream.tokens[this.parseState.position + count];
6419
+ };
6354
6420
  AlgebraicParser.prototype.advance = function () {
6355
6421
  this.parseState.position += 1;
6356
6422
  };
@@ -6372,10 +6438,6 @@ var AlgebraicParser = /** @class */ (function () {
6372
6438
  var left;
6373
6439
  if (isA_SymbolToken(firstToken)) {
6374
6440
  switch (firstToken[1]) {
6375
- case 'def':
6376
- return this.parseDef(firstToken);
6377
- case 'defn':
6378
- return this.parseDefn(firstToken);
6379
6441
  case 'let':
6380
6442
  return this.parseLet(firstToken);
6381
6443
  case 'if':
@@ -6403,6 +6465,12 @@ var AlgebraicParser = /** @class */ (function () {
6403
6465
  break;
6404
6466
  }
6405
6467
  }
6468
+ else if (isA_ReservedSymbolToken(firstToken, 'function')) {
6469
+ return this.parseFunction(firstToken);
6470
+ }
6471
+ else if (isA_ReservedSymbolToken(firstToken, 'export')) {
6472
+ return this.parseExport(firstToken);
6473
+ }
6406
6474
  left || (left = this.parseOperand());
6407
6475
  var operator = this.peek();
6408
6476
  while (!this.isAtExpressionEnd()) {
@@ -6534,10 +6602,18 @@ var AlgebraicParser = /** @class */ (function () {
6534
6602
  case 'String':
6535
6603
  return parseString(this.tokenStream, this.parseState);
6536
6604
  case 'A_Symbol': {
6605
+ var positionBefore = this.parseState.position;
6606
+ var lamdaFunction = this.parseLambdaFunction();
6607
+ if (lamdaFunction) {
6608
+ return lamdaFunction;
6609
+ }
6610
+ this.parseState.position = positionBefore;
6537
6611
  return parseSymbol(this.tokenStream, this.parseState);
6538
6612
  }
6539
6613
  case 'A_ReservedSymbol':
6540
6614
  return parseReservedSymbol(this.tokenStream, this.parseState);
6615
+ case 'RegexpShorthand':
6616
+ return parseRegexpShorthand(this.tokenStream, this.parseState);
6541
6617
  case 'PolNotation': {
6542
6618
  this.parseState.algebraic = false;
6543
6619
  var astNodes = [];
@@ -6671,11 +6747,9 @@ var AlgebraicParser = /** @class */ (function () {
6671
6747
  builtin.specialExpressions[node.n].validateParameterCount(node);
6672
6748
  return node;
6673
6749
  }
6674
- case 'defs':
6675
6750
  case 'fn':
6676
- case 'defns':
6677
- case 'try':
6678
- case 'doseq':
6751
+ case 'def':
6752
+ case 'defn':
6679
6753
  throw new Error("Special expression ".concat(name_2, " is not available in algebraic notation"));
6680
6754
  default:
6681
6755
  throw new Error("Unknown special expression: ".concat(name_2));
@@ -6694,6 +6768,11 @@ var AlgebraicParser = /** @class */ (function () {
6694
6768
  };
6695
6769
  AlgebraicParser.prototype.parseLambdaFunction = function () {
6696
6770
  var firstToken = this.peek();
6771
+ if (isLParenToken(firstToken)
6772
+ && isA_SymbolToken(this.peekAhead(1))
6773
+ && isA_OperatorToken(this.peekAhead(2), '=>')) {
6774
+ return null;
6775
+ }
6697
6776
  try {
6698
6777
  var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
6699
6778
  if (!isA_OperatorToken(this.peek(), '=>')) {
@@ -6719,6 +6798,18 @@ var AlgebraicParser = /** @class */ (function () {
6719
6798
  };
6720
6799
  AlgebraicParser.prototype.parseFunctionArguments = function () {
6721
6800
  var _a, _b, _c, _d, _e;
6801
+ var firstToken = this.peek();
6802
+ if (isA_SymbolToken(firstToken)) {
6803
+ this.advance();
6804
+ return {
6805
+ functionArguments: {
6806
+ m: [firstToken[1]],
6807
+ b: [],
6808
+ r: undefined,
6809
+ },
6810
+ arity: 1,
6811
+ };
6812
+ }
6722
6813
  this.advance();
6723
6814
  var rest = false;
6724
6815
  var letBindingObject;
@@ -6837,17 +6928,20 @@ var AlgebraicParser = /** @class */ (function () {
6837
6928
  };
6838
6929
  return node;
6839
6930
  };
6840
- AlgebraicParser.prototype.parseLet = function (token) {
6931
+ AlgebraicParser.prototype.parseLet = function (token, optionalSemicolon) {
6932
+ if (optionalSemicolon === void 0) { optionalSemicolon = false; }
6841
6933
  this.advance();
6842
6934
  var letSymbol = parseSymbol(this.tokenStream, this.parseState);
6843
6935
  assertA_OperatorToken(this.peek(), '=');
6844
6936
  this.advance();
6845
6937
  var value = this.parseExpression();
6938
+ if (!optionalSemicolon) {
6939
+ assertA_OperatorToken(this.peek(), ';');
6940
+ }
6846
6941
  return {
6847
6942
  t: AstNodeType.SpecialExpression,
6848
6943
  n: 'let',
6849
6944
  p: [],
6850
- token: getTokenDebugData(letSymbol.token) && letSymbol.token,
6851
6945
  bs: [{
6852
6946
  t: AstNodeType.Binding,
6853
6947
  n: letSymbol.v,
@@ -6855,6 +6949,7 @@ var AlgebraicParser = /** @class */ (function () {
6855
6949
  p: [],
6856
6950
  token: getTokenDebugData(token) && token,
6857
6951
  }],
6952
+ token: getTokenDebugData(letSymbol.token) && letSymbol.token,
6858
6953
  };
6859
6954
  };
6860
6955
  AlgebraicParser.prototype.parseDo = function (token) {
@@ -7022,7 +7117,7 @@ var AlgebraicParser = /** @class */ (function () {
7022
7117
  modifiers.push('&let');
7023
7118
  letBindings = [];
7024
7119
  while (isA_SymbolToken(token, 'let')) {
7025
- var letNode = this.parseLet(token);
7120
+ var letNode = this.parseLet(token, true);
7026
7121
  letBindings.push(letNode.bs[0]);
7027
7122
  token = this.peek();
7028
7123
  }
@@ -7209,20 +7304,7 @@ var AlgebraicParser = /** @class */ (function () {
7209
7304
  token: getTokenDebugData(token) && token,
7210
7305
  };
7211
7306
  };
7212
- AlgebraicParser.prototype.parseDef = function (token) {
7213
- this.advance();
7214
- var symbol = parseSymbol(this.tokenStream, this.parseState);
7215
- assertA_OperatorToken(this.peek(), '=');
7216
- this.advance();
7217
- var value = this.parseExpression();
7218
- return {
7219
- t: AstNodeType.SpecialExpression,
7220
- n: 'def',
7221
- p: [symbol, value],
7222
- token: getTokenDebugData(token) && token,
7223
- };
7224
- };
7225
- AlgebraicParser.prototype.parseDefn = function (token) {
7307
+ AlgebraicParser.prototype.parseFunction = function (token) {
7226
7308
  this.advance();
7227
7309
  var symbol = parseSymbol(this.tokenStream, this.parseState);
7228
7310
  var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
@@ -7235,10 +7317,9 @@ var AlgebraicParser = /** @class */ (function () {
7235
7317
  }
7236
7318
  assertA_ReservedSymbolToken(this.peek(), 'end');
7237
7319
  this.advance();
7238
- return {
7320
+ var fnNode = {
7239
7321
  t: AstNodeType.SpecialExpression,
7240
- n: 'defn',
7241
- f: symbol,
7322
+ n: 'fn',
7242
7323
  p: [],
7243
7324
  o: [{
7244
7325
  as: functionArguments,
@@ -7247,6 +7328,19 @@ var AlgebraicParser = /** @class */ (function () {
7247
7328
  }],
7248
7329
  token: getTokenDebugData(token) && token,
7249
7330
  };
7331
+ return {
7332
+ t: AstNodeType.SpecialExpression,
7333
+ n: 'let',
7334
+ p: [],
7335
+ bs: [{
7336
+ t: AstNodeType.Binding,
7337
+ n: symbol.v,
7338
+ v: fnNode,
7339
+ p: [],
7340
+ token: getTokenDebugData(symbol.token) && symbol.token,
7341
+ }],
7342
+ token: getTokenDebugData(token) && token,
7343
+ };
7250
7344
  };
7251
7345
  AlgebraicParser.prototype.isAtEnd = function () {
7252
7346
  return this.parseState.position >= this.tokenStream.tokens.length;
@@ -7267,8 +7361,30 @@ var AlgebraicParser = /** @class */ (function () {
7267
7361
  }
7268
7362
  return false;
7269
7363
  };
7270
- AlgebraicParser.prototype.peek = function () {
7271
- return this.tokenStream.tokens[this.parseState.position];
7364
+ AlgebraicParser.prototype.parseExport = function (token) {
7365
+ var _a;
7366
+ this.advance();
7367
+ var symbol = parseSymbol(this.tokenStream, this.parseState);
7368
+ if (isA_OperatorToken(this.peek(), ';')) {
7369
+ return {
7370
+ t: AstNodeType.SpecialExpression,
7371
+ n: 'def',
7372
+ p: [symbol, symbol],
7373
+ token: getTokenDebugData(token) && token,
7374
+ };
7375
+ }
7376
+ if (!isA_OperatorToken(this.peek(), '=')) {
7377
+ throw new LitsError('Expected = or ;', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
7378
+ }
7379
+ this.advance();
7380
+ var value = this.parseExpression();
7381
+ assertA_OperatorToken(this.peek(), ';');
7382
+ return {
7383
+ t: AstNodeType.SpecialExpression,
7384
+ n: 'def',
7385
+ p: [symbol, value],
7386
+ token: getTokenDebugData(token) && token,
7387
+ };
7272
7388
  };
7273
7389
  return AlgebraicParser;
7274
7390
  }());
@@ -7344,33 +7460,6 @@ function parseObjectLitteral(tokenStream, parseState) {
7344
7460
  assertEvenNumberOfParams(node);
7345
7461
  return node;
7346
7462
  }
7347
- function parseRegexpShorthand(tokenStream, parseState) {
7348
- var tkn = asP_RegexpShorthandToken(tokenStream.tokens[parseState.position++]);
7349
- var endStringPosition = tkn[1].lastIndexOf('"');
7350
- var regexpString = tkn[1].substring(2, endStringPosition);
7351
- var optionsString = tkn[1].substring(endStringPosition + 1);
7352
- var stringNode = {
7353
- t: AstNodeType.String,
7354
- v: regexpString,
7355
- p: [],
7356
- n: undefined,
7357
- token: getTokenDebugData(tkn) && tkn,
7358
- };
7359
- var optionsNode = {
7360
- t: AstNodeType.String,
7361
- v: optionsString,
7362
- p: [],
7363
- n: undefined,
7364
- token: getTokenDebugData(tkn) && tkn,
7365
- };
7366
- var node = {
7367
- t: AstNodeType.NormalExpression,
7368
- n: 'regexp',
7369
- p: [stringNode, optionsNode],
7370
- token: getTokenDebugData(tkn) && tkn,
7371
- };
7372
- return node;
7373
- }
7374
7463
  var placeholderRegexp = /^%([1-9]\d?)?$/;
7375
7464
  function parseFnShorthand(tokenStream, parseState) {
7376
7465
  var _a, _b, _c, _d;
@@ -7540,7 +7629,7 @@ function parsePolishToken(tokenStream, parseState) {
7540
7629
  return parseArrayLitteral(tokenStream, parseState);
7541
7630
  case 'LBrace':
7542
7631
  return parseObjectLitteral(tokenStream, parseState);
7543
- case 'P_RegexpShorthand':
7632
+ case 'RegexpShorthand':
7544
7633
  return parseRegexpShorthand(tokenStream, parseState);
7545
7634
  case 'P_FnShorthand':
7546
7635
  return parseFnShorthand(tokenStream, parseState);
@@ -7704,6 +7793,25 @@ var tokenizeString = function (input, position) {
7704
7793
  value += '"'; // closing quote
7705
7794
  return [length + 1, ['String', value]];
7706
7795
  };
7796
+ var tokenizeRegexpShorthand = function (input, position) {
7797
+ if (input[position] !== '#')
7798
+ return NO_MATCH;
7799
+ var _a = __read(tokenizeString(input, position + 1), 2), stringLength = _a[0], token = _a[1];
7800
+ if (!token)
7801
+ return NO_MATCH;
7802
+ position += stringLength + 1;
7803
+ var length = stringLength + 1;
7804
+ var options = '';
7805
+ while (input[position] === 'g' || input[position] === 'i') {
7806
+ if (options.includes(input[position])) {
7807
+ throw new LitsError("Duplicated regexp option \"".concat(input[position], "\" at position ").concat(position, "."), undefined);
7808
+ }
7809
+ options += input[position];
7810
+ length += 1;
7811
+ position += 1;
7812
+ }
7813
+ return [length, ['RegexpShorthand', "#".concat(token[1]).concat(options)]];
7814
+ };
7707
7815
  function tokenizeSimpleToken(type, value, input, position) {
7708
7816
  if (value === input.slice(position, position + value.length))
7709
7817
  return [value.length, [type]];
@@ -7721,6 +7829,7 @@ var commonTokenizers = [
7721
7829
  tokenizeLBrace,
7722
7830
  tokenizeRBrace,
7723
7831
  tokenizeString,
7832
+ tokenizeRegexpShorthand,
7724
7833
  ];
7725
7834
 
7726
7835
  var validAlgebraicReservedNamesRecord = {
@@ -7734,10 +7843,11 @@ var validAlgebraicReservedNamesRecord = {
7734
7843
  case: { value: null, forbidden: false },
7735
7844
  when: { value: null, forbidden: false },
7736
7845
  while: { value: null, forbidden: false },
7846
+ function: { value: null, forbidden: false },
7847
+ export: { value: null, forbidden: false },
7737
7848
  };
7738
7849
  var forbiddenAlgebraicReservedNamesRecord = {
7739
7850
  fn: { value: null, forbidden: true },
7740
- defns: { value: null, forbidden: true },
7741
7851
  };
7742
7852
  var algebraicReservedNamesRecord = __assign(__assign({}, validAlgebraicReservedNamesRecord), forbiddenAlgebraicReservedNamesRecord);
7743
7853
 
@@ -8122,25 +8232,6 @@ var tokenizeP_CollectionAccessor = function (input, position) {
8122
8232
  return NO_MATCH;
8123
8233
  return [1, ['P_CollectionAccessor', char]];
8124
8234
  };
8125
- var tokenizeP_RegexpShorthand = function (input, position) {
8126
- if (input[position] !== '#')
8127
- return NO_MATCH;
8128
- var _a = __read(tokenizeString(input, position + 1), 2), stringLength = _a[0], token = _a[1];
8129
- if (!token)
8130
- return NO_MATCH;
8131
- position += stringLength + 1;
8132
- var length = stringLength + 1;
8133
- var options = '';
8134
- while (input[position] === 'g' || input[position] === 'i') {
8135
- if (options.includes(input[position])) {
8136
- throw new LitsError("Duplicated regexp option \"".concat(input[position], "\" at position ").concat(position, "."), undefined);
8137
- }
8138
- options += input[position];
8139
- length += 1;
8140
- position += 1;
8141
- }
8142
- return [length, ['P_RegexpShorthand', "#".concat(token[1]).concat(options)]];
8143
- };
8144
8235
  // All tokenizers, order matters!
8145
8236
  var polishTokenizers = __spreadArray(__spreadArray([
8146
8237
  tokenizeP_Whitespace,
@@ -8151,7 +8242,6 @@ var polishTokenizers = __spreadArray(__spreadArray([
8151
8242
  tokenizeP_ReservedSymbol,
8152
8243
  tokenizeP_Modifier,
8153
8244
  tokenizeP_Symbol,
8154
- tokenizeP_RegexpShorthand,
8155
8245
  tokenizeP_FnShorthand,
8156
8246
  tokenizeP_CollectionAccessor,
8157
8247
  ], false);
@@ -9470,7 +9560,7 @@ var arrayReference = {
9470
9560
  };
9471
9561
 
9472
9562
  var sequenceReference = {
9473
- nth: {
9563
+ 'nth': {
9474
9564
  title: 'nth',
9475
9565
  category: 'Sequence',
9476
9566
  linkName: 'nth',
@@ -9506,7 +9596,7 @@ var sequenceReference = {
9506
9596
  '(nth nil 1 "Default value")',
9507
9597
  ],
9508
9598
  },
9509
- push: {
9599
+ 'push': {
9510
9600
  title: 'push',
9511
9601
  category: 'Sequence',
9512
9602
  linkName: 'push',
@@ -9536,7 +9626,7 @@ var sequenceReference = {
9536
9626
  '(def l [1 2 3]) (push l 4) l',
9537
9627
  ],
9538
9628
  },
9539
- pop: {
9629
+ 'pop': {
9540
9630
  title: 'pop',
9541
9631
  category: 'Sequence',
9542
9632
  linkName: 'pop',
@@ -9559,7 +9649,7 @@ var sequenceReference = {
9559
9649
  '(pop [])',
9560
9650
  ],
9561
9651
  },
9562
- unshift: {
9652
+ 'unshift': {
9563
9653
  title: 'unshift',
9564
9654
  category: 'Sequence',
9565
9655
  linkName: 'unshift',
@@ -9588,7 +9678,7 @@ var sequenceReference = {
9588
9678
  "\n(def l [1 2 3])\n(unshift l 4)\nl",
9589
9679
  ],
9590
9680
  },
9591
- shift: {
9681
+ 'shift': {
9592
9682
  title: 'shift',
9593
9683
  category: 'Sequence',
9594
9684
  linkName: 'shift',
@@ -9612,7 +9702,7 @@ var sequenceReference = {
9612
9702
  '(shift [])',
9613
9703
  ],
9614
9704
  },
9615
- slice: {
9705
+ 'slice': {
9616
9706
  title: 'slice',
9617
9707
  category: 'Sequence',
9618
9708
  linkName: 'slice',
@@ -9646,7 +9736,7 @@ var sequenceReference = {
9646
9736
  '(slice [1 2 3 4 5] 2)',
9647
9737
  ],
9648
9738
  },
9649
- reductions: {
9739
+ 'reductions': {
9650
9740
  title: 'reductions',
9651
9741
  category: 'Sequence',
9652
9742
  linkName: 'reductions',
@@ -9678,7 +9768,7 @@ var sequenceReference = {
9678
9768
  "\n(reductions\n (fn [result value] (+ result (if (even? value) value 0)))\n 0\n [1 2 3 4 5 6 7 8 9])",
9679
9769
  ],
9680
9770
  },
9681
- reduce: {
9771
+ 'reduce': {
9682
9772
  title: 'reduce',
9683
9773
  category: 'Sequence',
9684
9774
  linkName: 'reduce',
@@ -9708,7 +9798,7 @@ var sequenceReference = {
9708
9798
  "\n(reduce\n (fn [result value] (+ result (if (even? value) value 0)))\n 0\n [1 2 3 4 5 6 7 8 9])",
9709
9799
  ],
9710
9800
  },
9711
- reduce_right: {
9801
+ 'reduce_right': {
9712
9802
  title: 'reduce_right',
9713
9803
  category: 'Sequence',
9714
9804
  linkName: 'reduce_right',
@@ -9736,7 +9826,7 @@ var sequenceReference = {
9736
9826
  '(reduce_right str [:A :B :C] "")',
9737
9827
  ],
9738
9828
  },
9739
- map: {
9829
+ 'map': {
9740
9830
  title: 'map',
9741
9831
  category: 'Sequence',
9742
9832
  linkName: 'map',
@@ -9761,7 +9851,7 @@ var sequenceReference = {
9761
9851
  '(map [1 2 3] inc)',
9762
9852
  ],
9763
9853
  },
9764
- filter: {
9854
+ 'filter': {
9765
9855
  title: 'filter',
9766
9856
  category: 'Sequence',
9767
9857
  linkName: 'filter',
@@ -9785,7 +9875,7 @@ var sequenceReference = {
9785
9875
  "\n(filter\n[5 10 15 20]\n (fn [x] (> x 10)))",
9786
9876
  ],
9787
9877
  },
9788
- position: {
9878
+ 'position': {
9789
9879
  title: 'position',
9790
9880
  category: 'Sequence',
9791
9881
  linkName: 'position',
@@ -9812,7 +9902,7 @@ var sequenceReference = {
9812
9902
  "\n(position\n (fn [x] (> x 100))\n nil)",
9813
9903
  ],
9814
9904
  },
9815
- index_of: {
9905
+ 'index_of': {
9816
9906
  title: 'index_of',
9817
9907
  category: 'Sequence',
9818
9908
  linkName: 'index_of',
@@ -9839,7 +9929,34 @@ var sequenceReference = {
9839
9929
  '(index_of nil 1)',
9840
9930
  ],
9841
9931
  },
9842
- some: {
9932
+ 'last_index_of': {
9933
+ title: 'last_index_of',
9934
+ category: 'Sequence',
9935
+ linkName: 'last_index_of',
9936
+ clojureDocs: null,
9937
+ returns: {
9938
+ type: ['number', 'null'],
9939
+ },
9940
+ args: {
9941
+ seq: {
9942
+ type: ['sequence', 'null'],
9943
+ },
9944
+ x: {
9945
+ type: 'any',
9946
+ },
9947
+ },
9948
+ variants: [
9949
+ { argumentNames: ['seq', 'x'] },
9950
+ ],
9951
+ description: 'Returns the last index of $x in $seq. If element is not present in $seq `nil` is returned.',
9952
+ examples: [
9953
+ '(last_index_of ["Albert" "Mojir" 160 [1 2]] "Mojir")',
9954
+ '(last_index_of [5 10 15 20] 15)',
9955
+ '(last_index_of [5 10 15 20] 1)',
9956
+ '(last_index_of nil 1)',
9957
+ ],
9958
+ },
9959
+ 'some': {
9843
9960
  title: 'some',
9844
9961
  category: 'Sequence',
9845
9962
  linkName: 'some',
@@ -9866,7 +9983,7 @@ var sequenceReference = {
9866
9983
  "\n(some\n nil\n (fn [x] (> x 10)))",
9867
9984
  ],
9868
9985
  },
9869
- reverse: {
9986
+ 'reverse': {
9870
9987
  title: 'reverse',
9871
9988
  category: 'Sequence',
9872
9989
  linkName: 'reverse',
@@ -9889,7 +10006,7 @@ var sequenceReference = {
9889
10006
  '(reverse nil)',
9890
10007
  ],
9891
10008
  },
9892
- first: {
10009
+ 'first': {
9893
10010
  title: 'first',
9894
10011
  category: 'Sequence',
9895
10012
  linkName: 'first',
@@ -9911,7 +10028,7 @@ var sequenceReference = {
9911
10028
  '(first nil)',
9912
10029
  ],
9913
10030
  },
9914
- second: {
10031
+ 'second': {
9915
10032
  title: 'second',
9916
10033
  category: 'Sequence',
9917
10034
  linkName: 'second',
@@ -9934,7 +10051,7 @@ var sequenceReference = {
9934
10051
  '(second nil)',
9935
10052
  ],
9936
10053
  },
9937
- last: {
10054
+ 'last': {
9938
10055
  title: 'last',
9939
10056
  category: 'Sequence',
9940
10057
  linkName: 'last',
@@ -9958,7 +10075,7 @@ var sequenceReference = {
9958
10075
  '(last nil)',
9959
10076
  ],
9960
10077
  },
9961
- rest: {
10078
+ 'rest': {
9962
10079
  title: 'rest',
9963
10080
  category: 'Sequence',
9964
10081
  linkName: 'rest',
@@ -9983,7 +10100,7 @@ var sequenceReference = {
9983
10100
  '(rest "")',
9984
10101
  ],
9985
10102
  },
9986
- nthrest: {
10103
+ 'nthrest': {
9987
10104
  title: 'nthrest',
9988
10105
  category: 'Sequence',
9989
10106
  linkName: 'nthrest',
@@ -10011,7 +10128,7 @@ var sequenceReference = {
10011
10128
  '(nthrest "" 0)',
10012
10129
  ],
10013
10130
  },
10014
- next: {
10131
+ 'next': {
10015
10132
  title: 'next',
10016
10133
  category: 'Sequence',
10017
10134
  linkName: 'next',
@@ -10036,7 +10153,7 @@ var sequenceReference = {
10036
10153
  '(next "")',
10037
10154
  ],
10038
10155
  },
10039
- nthnext: {
10156
+ 'nthnext': {
10040
10157
  title: 'nthnext',
10041
10158
  category: 'Sequence',
10042
10159
  linkName: 'nthnext',
@@ -10064,7 +10181,7 @@ var sequenceReference = {
10064
10181
  '(nthnext "" 0)',
10065
10182
  ],
10066
10183
  },
10067
- take: {
10184
+ 'take': {
10068
10185
  title: 'take',
10069
10186
  category: 'Sequence',
10070
10187
  linkName: 'take',
@@ -10090,7 +10207,7 @@ var sequenceReference = {
10090
10207
  '(take 50 "Albert")',
10091
10208
  ],
10092
10209
  },
10093
- take_last: {
10210
+ 'take_last': {
10094
10211
  title: 'take_last',
10095
10212
  category: 'Sequence',
10096
10213
  linkName: 'take_last',
@@ -10114,7 +10231,7 @@ var sequenceReference = {
10114
10231
  '(take_last 0 [1 2 3 4 5])',
10115
10232
  ],
10116
10233
  },
10117
- take_while: {
10234
+ 'take_while': {
10118
10235
  title: 'take_while',
10119
10236
  category: 'Sequence',
10120
10237
  linkName: 'take_while',
@@ -10138,7 +10255,7 @@ var sequenceReference = {
10138
10255
  "\n(take_while\n [1 2 3 2 1]\n (fn [x] (> x 3)))",
10139
10256
  ],
10140
10257
  },
10141
- drop: {
10258
+ 'drop': {
10142
10259
  title: 'drop',
10143
10260
  category: 'Sequence',
10144
10261
  linkName: 'drop',
@@ -10164,7 +10281,7 @@ var sequenceReference = {
10164
10281
  '(drop "Albert" 50)',
10165
10282
  ],
10166
10283
  },
10167
- drop_last: {
10284
+ 'drop_last': {
10168
10285
  title: 'drop_last',
10169
10286
  category: 'Sequence',
10170
10287
  linkName: 'drop_last',
@@ -10188,7 +10305,7 @@ var sequenceReference = {
10188
10305
  '(drop_last [1 2 3 4 5] 0)',
10189
10306
  ],
10190
10307
  },
10191
- drop_while: {
10308
+ 'drop_while': {
10192
10309
  title: 'drop_while',
10193
10310
  category: 'Sequence',
10194
10311
  linkName: 'drop_while',
@@ -10212,7 +10329,7 @@ var sequenceReference = {
10212
10329
  "\n(drop_while\n [1 2 3 2 1]\n (fn [x] (> x 3)))",
10213
10330
  ],
10214
10331
  },
10215
- sort: {
10332
+ 'sort': {
10216
10333
  title: 'sort',
10217
10334
  category: 'Sequence',
10218
10335
  linkName: 'sort',
@@ -10239,7 +10356,7 @@ var sequenceReference = {
10239
10356
  "\n(sort\n [3 1 2]\n (fn [a b] (cond (> a b) -1 (< a b) 1 true -1)))",
10240
10357
  ],
10241
10358
  },
10242
- sort_by: {
10359
+ 'sort_by': {
10243
10360
  title: 'sort_by',
10244
10361
  category: 'Sequence',
10245
10362
  linkName: 'sort_by',
@@ -10268,7 +10385,7 @@ var sequenceReference = {
10268
10385
  '(sort_by "Albert" lower_case #(compare %2 %1))',
10269
10386
  ],
10270
10387
  },
10271
- distinct: {
10388
+ 'distinct': {
10272
10389
  title: 'distinct',
10273
10390
  category: 'Sequence',
10274
10391
  linkName: 'distinct',
@@ -10291,7 +10408,7 @@ var sequenceReference = {
10291
10408
  '(distinct "")',
10292
10409
  ],
10293
10410
  },
10294
- remove: {
10411
+ 'remove': {
10295
10412
  title: 'remove',
10296
10413
  category: 'Sequence',
10297
10414
  linkName: 'remove',
@@ -10315,7 +10432,7 @@ var sequenceReference = {
10315
10432
  '(remove "Albert Mojir" #(has? "aoueiyAOUEIY" %1))',
10316
10433
  ],
10317
10434
  },
10318
- remove_at: {
10435
+ 'remove_at': {
10319
10436
  title: 'remove_at',
10320
10437
  category: 'Sequence',
10321
10438
  linkName: 'remove_at',
@@ -10341,7 +10458,7 @@ var sequenceReference = {
10341
10458
  '(remove_at "Albert Mojir" 6)',
10342
10459
  ],
10343
10460
  },
10344
- split_at: {
10461
+ 'split_at': {
10345
10462
  title: 'split_at',
10346
10463
  category: 'Sequence',
10347
10464
  linkName: 'split_at',
@@ -10366,7 +10483,7 @@ var sequenceReference = {
10366
10483
  '(split_at "Albert" 2)',
10367
10484
  ],
10368
10485
  },
10369
- split_with: {
10486
+ 'split_with': {
10370
10487
  title: 'split_with',
10371
10488
  category: 'Sequence',
10372
10489
  linkName: 'split_with',
@@ -10391,7 +10508,7 @@ var sequenceReference = {
10391
10508
  '(split_with "Albert" #(<= %1 :Z))',
10392
10509
  ],
10393
10510
  },
10394
- frequencies: {
10511
+ 'frequencies': {
10395
10512
  title: 'frequencies',
10396
10513
  category: 'Sequence',
10397
10514
  linkName: 'frequencies',
@@ -10412,7 +10529,7 @@ var sequenceReference = {
10412
10529
  '(frequencies "Pneumonoultramicroscopicsilicovolcanoconiosis")',
10413
10530
  ],
10414
10531
  },
10415
- group_by: {
10532
+ 'group_by': {
10416
10533
  title: 'group_by',
10417
10534
  category: 'Sequence',
10418
10535
  linkName: 'group_by',
@@ -10436,7 +10553,7 @@ var sequenceReference = {
10436
10553
  '(group_by "Albert Mojir" (fn [char] (if (has? "aoueiAOUEI" char) "vowel" "other")))',
10437
10554
  ],
10438
10555
  },
10439
- partition: {
10556
+ 'partition': {
10440
10557
  title: 'partition',
10441
10558
  category: 'Sequence',
10442
10559
  linkName: 'partition',
@@ -10481,7 +10598,7 @@ var sequenceReference = {
10481
10598
  '(def foo [5 6 7 8]) (partition foo 2 1 foo)',
10482
10599
  ],
10483
10600
  },
10484
- partition_all: {
10601
+ 'partition_all': {
10485
10602
  title: 'partition_all',
10486
10603
  category: 'Sequence',
10487
10604
  linkName: 'partition_all',
@@ -10510,7 +10627,7 @@ var sequenceReference = {
10510
10627
  '(partition_all [0 1 2 3 4 5 6 7 8 9] 2 4)',
10511
10628
  ],
10512
10629
  },
10513
- partition_by: {
10630
+ 'partition_by': {
10514
10631
  title: 'partition_by',
10515
10632
  category: 'Sequence',
10516
10633
  linkName: 'partition_by',
@@ -10535,6 +10652,114 @@ var sequenceReference = {
10535
10652
  '(partition_by "Leeeeeerrroyyy" identity)',
10536
10653
  ],
10537
10654
  },
10655
+ 'starts_with?': {
10656
+ title: 'starts_with?',
10657
+ category: 'Sequence',
10658
+ linkName: 'starts_with-question',
10659
+ clojureDocs: null,
10660
+ returns: {
10661
+ type: 'boolean',
10662
+ },
10663
+ args: {
10664
+ seq: {
10665
+ type: 'sequence',
10666
+ },
10667
+ prefix: {
10668
+ type: 'sequence',
10669
+ },
10670
+ },
10671
+ variants: [
10672
+ { argumentNames: ['seq', 'prefix'] },
10673
+ ],
10674
+ description: 'Returns `true` if $seq starts with $prefix, otherwise `false`.',
10675
+ examples: [
10676
+ '(starts_with? [1 2 3 4 5] 1)',
10677
+ '(starts_with? [1 2 3 4 5] [1])',
10678
+ '(starts_with? "Albert" "Al")',
10679
+ '(starts_with? "Albert" "al")',
10680
+ ],
10681
+ },
10682
+ 'ends_with?': {
10683
+ title: 'ends_with?',
10684
+ category: 'Sequence',
10685
+ linkName: 'ends_with-question',
10686
+ clojureDocs: null,
10687
+ returns: {
10688
+ type: 'boolean',
10689
+ },
10690
+ args: {
10691
+ seq: {
10692
+ type: 'sequence',
10693
+ },
10694
+ suffix: {
10695
+ type: 'sequence',
10696
+ },
10697
+ },
10698
+ variants: [
10699
+ { argumentNames: ['seq', 'suffix'] },
10700
+ ],
10701
+ description: 'Returns `true` if $seq ends with $suffix, otherwise `false`.',
10702
+ examples: [
10703
+ '(ends_with? [1 2 3 4 5] 5)',
10704
+ '(ends_with? [1 2 3 4 5] [5])',
10705
+ '(ends_with? "Albert" "rt")',
10706
+ '(ends_with? "Albert" "RT")',
10707
+ ],
10708
+ },
10709
+ 'interleave': {
10710
+ title: 'interleave',
10711
+ category: 'Sequence',
10712
+ linkName: 'interleave',
10713
+ clojureDocs: null,
10714
+ returns: {
10715
+ type: 'sequence',
10716
+ },
10717
+ args: {
10718
+ seqs: {
10719
+ type: 'sequence',
10720
+ array: true,
10721
+ },
10722
+ },
10723
+ variants: [
10724
+ { argumentNames: ['seqs'] },
10725
+ ],
10726
+ description: 'Returns a sequence of the first item from each of the $seqs, then the second item from each of the $seqs, until all items from the shortest seq are exhausted.',
10727
+ examples: [
10728
+ '(interleave [1 2 3] [4 5 6])',
10729
+ '(interleave [1 2 3] [4 5 6] [7 8 9])',
10730
+ '(interleave [1 2 3] [4 5 6] [7 8])',
10731
+ '(interleave [1 2 3] [4 5 6] [7])',
10732
+ '(interleave [1 2 3] [4 5 6] [])',
10733
+ '(interleave [1 2 3] [])',
10734
+ '(interleave [])',
10735
+ ],
10736
+ },
10737
+ 'interpose': {
10738
+ title: 'interpose',
10739
+ category: 'Sequence',
10740
+ linkName: 'interpose',
10741
+ clojureDocs: null,
10742
+ returns: {
10743
+ type: 'sequence',
10744
+ },
10745
+ args: {
10746
+ seq: {
10747
+ type: 'sequence',
10748
+ },
10749
+ separator: {
10750
+ type: 'any',
10751
+ },
10752
+ },
10753
+ variants: [
10754
+ { argumentNames: ['seq', 'separator'] },
10755
+ ],
10756
+ description: 'Returns a sequence of the elements of $seq separated by $separator. If $seq is a string, the separator must be a string.',
10757
+ examples: [
10758
+ '(interpose :a [1 2 3 4 5])',
10759
+ '(interpose " " ["Albert" "Mojir" "Nina"])',
10760
+ '(interpose "." "Albert")',
10761
+ ],
10762
+ },
10538
10763
  };
10539
10764
 
10540
10765
  var mathReference = {
@@ -13129,12 +13354,12 @@ var regularExpressionReference = {
13129
13354
  ],
13130
13355
  description: "Matches $s against regular expression $r.\nIf $s is a string and matches the regular expression, a `match`-array is returned, otherwise `nil` is returned.",
13131
13356
  examples: [
13132
- '(match (regexp "^\\s*(.*)$") " A string")',
13133
- '(match #"albert"i "My name is Albert")',
13134
- '(match #"albert"i "My name is Ben")',
13135
- '(match #"albert"i nil)',
13136
- '(match #"albert"i 1)',
13137
- '(match #"albert"i {})',
13357
+ '(match " A string" (regexp "^\\s*(.*)$"))',
13358
+ '(match "My name is Albert" #"albert"i)',
13359
+ '(match "My name is Ben" #"albert"i)',
13360
+ '(match nil #"albert"i)',
13361
+ '(match 1 #"albert"i)',
13362
+ '(match {} #"albert"i)',
13138
13363
  ],
13139
13364
  },
13140
13365
  replace: {
@@ -13151,7 +13376,7 @@ var regularExpressionReference = {
13151
13376
  type: 'string',
13152
13377
  },
13153
13378
  r: {
13154
- type: 'regexp',
13379
+ type: ['regexp', 'string'],
13155
13380
  },
13156
13381
  x: {
13157
13382
  type: 'string',
@@ -13160,13 +13385,49 @@ var regularExpressionReference = {
13160
13385
  variants: [
13161
13386
  { argumentNames: ['s', 'r', 'x'] },
13162
13387
  ],
13163
- description: 'Returns a new string with some or all matches of regular expression $r replaced by $x.',
13388
+ description: 'Returns a new string with first match of regular expression $r replaced by $x.',
13164
13389
  examples: [
13165
- '(replace "Duck" (regexp :u) :i)',
13390
+ '(replace "Duck duck" "u" :i)',
13391
+ '(replace "Duck duck" (regexp :u) :i)',
13392
+ '(replace "abcABC" (regexp :a "i") "-")',
13166
13393
  '(replace "abcABC" (regexp :a "gi") "-")',
13394
+ '(replace "abcABC" #"a"i "-")',
13167
13395
  '(replace "abcABC" #"a"gi "-")',
13168
13396
  ],
13169
13397
  },
13398
+ replace_all: {
13399
+ title: 'replace_all',
13400
+ category: 'Regular expression',
13401
+ linkName: 'replace_all',
13402
+ clojureDocs: null,
13403
+ returns: {
13404
+ type: 'any',
13405
+ array: true,
13406
+ },
13407
+ args: {
13408
+ s: {
13409
+ type: 'string',
13410
+ },
13411
+ r: {
13412
+ type: ['regexp', 'string'],
13413
+ },
13414
+ x: {
13415
+ type: 'string',
13416
+ },
13417
+ },
13418
+ variants: [
13419
+ { argumentNames: ['s', 'r', 'x'] },
13420
+ ],
13421
+ description: 'Returns a new string with all matches of regular expression $r replaced by $x.',
13422
+ examples: [
13423
+ '(replace_all "Duck duck" "u" :i)',
13424
+ '(replace_all "Duck duck" (regexp :u) :i)',
13425
+ '(replace_all "abcABC" (regexp :a "i") "-")',
13426
+ '(replace_all "abcABC" (regexp :a "gi") "-")',
13427
+ '(replace_all "abcABC" #"a"i "-")',
13428
+ '(replace_all "abcABC" #"a"gi "-")',
13429
+ ],
13430
+ },
13170
13431
  };
13171
13432
 
13172
13433
  var specialExpressionsReference = {
@@ -13245,32 +13506,6 @@ var specialExpressionsReference = {
13245
13506
  '(def a (object :x 10 :y true :z "A string"))',
13246
13507
  ],
13247
13508
  },
13248
- 'defs': {
13249
- title: 'defs',
13250
- category: 'Special expression',
13251
- linkName: 'defs',
13252
- clojureDocs: null,
13253
- returns: {
13254
- type: 'any',
13255
- },
13256
- args: {
13257
- name: {
13258
- type: '*expression',
13259
- },
13260
- value: {
13261
- type: '*expression',
13262
- },
13263
- },
13264
- variants: [
13265
- { argumentNames: ['name', 'value'] },
13266
- ],
13267
- description: "\nCreates a variable with name set to $name evaluated and value set to $value.\n\nIf a variable with name $name is already defined, an error is thrown.",
13268
- examples: [
13269
- '(defs :a :b)',
13270
- "\n(defs (str :a :1) (object :x 10 :y true :z \"A string\"))\na1",
13271
- "\n(defs :a :b)\n(defs a :c)\nb",
13272
- ],
13273
- },
13274
13509
  'let': {
13275
13510
  title: 'let',
13276
13511
  category: 'Special expression',
@@ -13344,36 +13579,6 @@ var specialExpressionsReference = {
13344
13579
  "\n(defn sumOfSquares [& s]\n (apply\n +\n (map\n (fn [x] (* x x))\n s)))\n(sumOfSquares 1 2 3 4 5)",
13345
13580
  ],
13346
13581
  },
13347
- 'defns': {
13348
- title: 'defns',
13349
- category: 'Special expression',
13350
- linkName: 'defns',
13351
- clojureDocs: null,
13352
- returns: {
13353
- type: 'function',
13354
- },
13355
- args: {
13356
- name: {
13357
- type: '*expression',
13358
- },
13359
- args: {
13360
- type: '*arguments',
13361
- },
13362
- expressions: {
13363
- type: '*expression',
13364
- rest: true,
13365
- },
13366
- },
13367
- variants: [
13368
- { argumentNames: ['name', 'args', 'expressions'] },
13369
- ],
13370
- description: 'Creates a named global function with its name set to $name evaluated. When called, evaluation of the last expression in the body is returned.',
13371
- examples: [
13372
- "\n(defns \"hyp\" [a b]\n (sqrt\n (+\n (* a a)\n (* b b))))\nhyp",
13373
- "\n(defns\n (str :h :y :p)\n [a b]\n (sqrt\n (+\n (* a a)\n (* b b))))\n(hyp 3 4)",
13374
- "\n(defns \"sumOfSquares\" [& s]\n (apply\n +\n (map\n (fn [x] (* x x))\n s)))\n(sumOfSquares 1 2 3 4 5)",
13375
- ],
13376
- },
13377
13582
  'try': {
13378
13583
  title: 'try',
13379
13584
  category: 'Special expression',
@@ -14042,6 +14247,30 @@ var stringReference = {
14042
14247
  '(map number (split "0123456789" "" 5))',
14043
14248
  ],
14044
14249
  },
14250
+ 'split_lines': {
14251
+ title: 'split_lines',
14252
+ category: 'String',
14253
+ linkName: 'split_lines',
14254
+ clojureDocs: null,
14255
+ returns: {
14256
+ type: 'string',
14257
+ },
14258
+ args: {
14259
+ s: {
14260
+ type: 'string',
14261
+ },
14262
+ },
14263
+ variants: [
14264
+ { argumentNames: ['s'] },
14265
+ ],
14266
+ description: 'Divides $s into an array of substrings, each representing a line.',
14267
+ examples: [
14268
+ '(split_lines "Albert\nMojir\n")',
14269
+ '(split_lines "Albert\n\nMojir")',
14270
+ '(split_lines "Albert\nMojir\n\n")',
14271
+ '(split_lines "")',
14272
+ ],
14273
+ },
14045
14274
  'template': {
14046
14275
  title: 'template',
14047
14276
  category: 'String',
@@ -14258,6 +14487,55 @@ var stringReference = {
14258
14487
  '(++)',
14259
14488
  ],
14260
14489
  },
14490
+ 'capitalize': {
14491
+ title: 'capitalize',
14492
+ category: 'String',
14493
+ linkName: 'capitalize',
14494
+ clojureDocs: 'clojure.string/capitalize',
14495
+ returns: {
14496
+ type: 'string',
14497
+ },
14498
+ args: {
14499
+ s: {
14500
+ type: 'string',
14501
+ },
14502
+ },
14503
+ variants: [
14504
+ { argumentNames: ['s'] },
14505
+ ],
14506
+ description: 'Returns $s with the first character converted to uppercase and the rest to lowercase.',
14507
+ examples: [
14508
+ '(capitalize "albert")',
14509
+ '(capitalize "ALBERT")',
14510
+ '(capitalize "aLBERT")',
14511
+ '(capitalize "")',
14512
+ ],
14513
+ },
14514
+ 'blank?': {
14515
+ title: 'blank?',
14516
+ category: 'String',
14517
+ linkName: 'blank-question',
14518
+ clojureDocs: 'clojure.string/blank_q',
14519
+ returns: {
14520
+ type: 'boolean',
14521
+ },
14522
+ args: {
14523
+ s: {
14524
+ type: ['string', 'null'],
14525
+ },
14526
+ },
14527
+ variants: [
14528
+ { argumentNames: ['s'] },
14529
+ ],
14530
+ description: 'Returns true if $s is null or only contains whitespace characters.',
14531
+ examples: [
14532
+ '(blank? "")',
14533
+ '(blank? null)',
14534
+ '(blank? "\n")',
14535
+ '(blank? " ")',
14536
+ '(blank? ".")',
14537
+ ],
14538
+ },
14261
14539
  };
14262
14540
 
14263
14541
  var bitwiseReference = { '<<': {
@@ -14809,6 +15087,7 @@ var api = {
14809
15087
  'filter',
14810
15088
  'position',
14811
15089
  'index_of',
15090
+ 'last_index_of',
14812
15091
  'some',
14813
15092
  'reverse',
14814
15093
  'first',
@@ -14836,6 +15115,10 @@ var api = {
14836
15115
  'partition',
14837
15116
  'partition_all',
14838
15117
  'partition_by',
15118
+ 'starts_with?',
15119
+ 'ends_with?',
15120
+ 'interleave',
15121
+ 'interpose',
14839
15122
  ],
14840
15123
  math: [
14841
15124
  '+',
@@ -14956,16 +15239,15 @@ var api = {
14956
15239
  'regexp',
14957
15240
  'match',
14958
15241
  'replace',
15242
+ 'replace_all',
14959
15243
  ],
14960
15244
  specialExpressions: [
14961
15245
  '&&',
14962
15246
  '||',
14963
15247
  'def',
14964
- 'defs',
14965
15248
  'let',
14966
15249
  'fn',
14967
15250
  'defn',
14968
- 'defns',
14969
15251
  'try',
14970
15252
  'throw',
14971
15253
  'if',
@@ -14994,6 +15276,7 @@ var api = {
14994
15276
  'pad_left',
14995
15277
  'pad_right',
14996
15278
  'split',
15279
+ 'split_lines',
14997
15280
  'template',
14998
15281
  'to_char_code',
14999
15282
  'from_char_code',
@@ -15003,6 +15286,8 @@ var api = {
15003
15286
  'decode_uri_component',
15004
15287
  'join',
15005
15288
  '++',
15289
+ 'capitalize',
15290
+ 'blank?',
15006
15291
  ],
15007
15292
  bitwise: [
15008
15293
  '<<',
@@ -15508,7 +15793,9 @@ function getCliFunctionSignature(fmt, _a) {
15508
15793
  function getClojureDocsLink(functionName, clojureDocs) {
15509
15794
  var path = clojureDocs === null ? null : clojureDocs !== null && clojureDocs !== void 0 ? clojureDocs : functionName.replaceAll('_', '-').replace('?', '_q');
15510
15795
  return path
15511
- ? "https://clojuredocs.org/clojure.core/".concat(path)
15796
+ ? path.startsWith('clojure.')
15797
+ ? "https://clojuredocs.org/".concat(path)
15798
+ : "https://clojuredocs.org/clojure.core/".concat(path)
15512
15799
  : null;
15513
15800
  }
15514
15801