@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/index.js CHANGED
@@ -283,6 +283,7 @@ var commonSimpleTokenTypes = [
283
283
  ];
284
284
  var commomValueTokenTypes = [
285
285
  'String',
286
+ 'RegexpShorthand',
286
287
  ];
287
288
  function isLParenToken(token) {
288
289
  return (token === null || token === void 0 ? void 0 : token[0]) === 'LParen';
@@ -356,6 +357,18 @@ function asStringToken(token) {
356
357
  assertStringToken(token);
357
358
  return token;
358
359
  }
360
+ function isRegexpShorthandToken(token) {
361
+ return (token === null || token === void 0 ? void 0 : token[0]) === 'RegexpShorthand';
362
+ }
363
+ function assertRegexpShorthandToken(token) {
364
+ if (!isRegexpShorthandToken(token)) {
365
+ throwUnexpectedToken('RegexpShorthand', undefined, token);
366
+ }
367
+ }
368
+ function asRegexpShorthandToken(token) {
369
+ assertRegexpShorthandToken(token);
370
+ return token;
371
+ }
359
372
  function isAlgebraicNotationToken(token) {
360
373
  return (token === null || token === void 0 ? void 0 : token[0]) === 'AlgNotation';
361
374
  }
@@ -426,24 +439,22 @@ var symbolicOperators = __spreadArray(__spreadArray(__spreadArray([], __read(sym
426
439
  var nonFunctionOperators = [
427
440
  '??',
428
441
  '&&',
442
+ '||',
429
443
  'comment',
430
444
  'cond',
445
+ 'def',
431
446
  'defined?',
432
- 'if',
433
- 'unless',
434
- '||',
447
+ 'defn',
435
448
  'do',
436
- 'throw',
437
- 'let',
438
- 'def',
439
- 'defs',
449
+ 'doseq',
440
450
  'fn',
441
- 'defn',
442
- 'defns',
443
- 'try',
444
- 'recur',
451
+ 'if',
452
+ 'let',
445
453
  'loop',
446
- 'doseq',
454
+ 'recur',
455
+ 'throw',
456
+ 'try',
457
+ 'unless',
447
458
  'while',
448
459
  ];
449
460
  var nonFunctionOperatorSet = new Set(nonFunctionOperators);
@@ -514,9 +525,10 @@ function isA_OperatorToken(token, operatorName) {
514
525
  }
515
526
  function assertA_OperatorToken(token, operatorName) {
516
527
  if (!isA_OperatorToken(token, operatorName)) {
517
- {
528
+ if (operatorName) {
518
529
  throw new LitsError("Unexpected token: ".concat(token, ", expected operator ").concat(operatorName), undefined);
519
530
  }
531
+ throwUnexpectedToken('A_Operator', operatorName, token);
520
532
  }
521
533
  }
522
534
  function isA_WhitespaceToken(token) {
@@ -539,7 +551,6 @@ var polishOnlyValueTokenTypes = [
539
551
  'P_StringShorthand',
540
552
  'P_Symbol',
541
553
  'P_ReservedSymbol',
542
- 'P_RegexpShorthand',
543
554
  'P_CollectionAccessor',
544
555
  'P_Comment',
545
556
  'P_Whitespace',
@@ -577,18 +588,6 @@ function isP_ReservedSymbolToken(token) {
577
588
  function isP_ModifierToken(token) {
578
589
  return (token === null || token === void 0 ? void 0 : token[0]) === 'P_Modifier';
579
590
  }
580
- function isP_RegexpShorthandToken(token) {
581
- return (token === null || token === void 0 ? void 0 : token[0]) === 'P_RegexpShorthand';
582
- }
583
- function assertP_RegexpShorthandToken(token) {
584
- if (!isP_RegexpShorthandToken(token)) {
585
- throwUnexpectedToken('P_RegexpShorthand', undefined, token);
586
- }
587
- }
588
- function asP_RegexpShorthandToken(token) {
589
- assertP_RegexpShorthandToken(token);
590
- return token;
591
- }
592
591
  function isP_FnShorthandToken(token) {
593
592
  return (token === null || token === void 0 ? void 0 : token[0]) === 'P_FnShorthand';
594
593
  }
@@ -769,11 +768,6 @@ var specialExpressionCommentRemovers = {
769
768
  removeOptions.removeCommenNodesFromArray(node.p);
770
769
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
771
770
  },
772
- 'defns': function (_node, _removeOptions) { },
773
- 'defs': function (node, removeOptions) {
774
- removeOptions.removeCommenNodesFromArray(node.p);
775
- node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
776
- },
777
771
  'do': function (node, removeOptions) {
778
772
  removeOptions.removeCommenNodesFromArray(node.p);
779
773
  node.p.forEach(removeOptions.recursivelyRemoveCommentNodes);
@@ -1978,7 +1972,7 @@ var arrayNormalExpression = {
1978
1972
  };
1979
1973
 
1980
1974
  var sequenceNormalExpression = {
1981
- nth: {
1975
+ 'nth': {
1982
1976
  evaluate: function (params, sourceCodeInfo) {
1983
1977
  var _a = __read(params, 2), seq = _a[0], i = _a[1];
1984
1978
  var defaultValue = toAny(params[2]);
@@ -1990,7 +1984,7 @@ var sequenceNormalExpression = {
1990
1984
  },
1991
1985
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
1992
1986
  },
1993
- filter: {
1987
+ 'filter': {
1994
1988
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
1995
1989
  var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
1996
1990
  var executeFunction = _b.executeFunction;
@@ -2005,7 +1999,7 @@ var sequenceNormalExpression = {
2005
1999
  },
2006
2000
  validate: function (node) { return assertNumberOfParams(2, node); },
2007
2001
  },
2008
- first: {
2002
+ 'first': {
2009
2003
  evaluate: function (_a, sourceCodeInfo) {
2010
2004
  var _b = __read(_a, 1), array = _b[0];
2011
2005
  if (array === null)
@@ -2015,7 +2009,7 @@ var sequenceNormalExpression = {
2015
2009
  },
2016
2010
  validate: function (node) { return assertNumberOfParams(1, node); },
2017
2011
  },
2018
- last: {
2012
+ 'last': {
2019
2013
  evaluate: function (_a, sourceCodeInfo) {
2020
2014
  var _b = __read(_a, 1), array = _b[0];
2021
2015
  if (array === null)
@@ -2025,7 +2019,7 @@ var sequenceNormalExpression = {
2025
2019
  },
2026
2020
  validate: function (node) { return assertNumberOfParams(1, node); },
2027
2021
  },
2028
- map: {
2022
+ 'map': {
2029
2023
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2030
2024
  var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2031
2025
  var executeFunction = _b.executeFunction;
@@ -2047,7 +2041,7 @@ var sequenceNormalExpression = {
2047
2041
  },
2048
2042
  validate: function (node) { return assertNumberOfParams(2, node); },
2049
2043
  },
2050
- pop: {
2044
+ 'pop': {
2051
2045
  evaluate: function (_a, sourceCodeInfo) {
2052
2046
  var _b = __read(_a, 1), seq = _b[0];
2053
2047
  assertSeq(seq, sourceCodeInfo);
@@ -2058,7 +2052,7 @@ var sequenceNormalExpression = {
2058
2052
  },
2059
2053
  validate: function (node) { return assertNumberOfParams(1, node); },
2060
2054
  },
2061
- position: {
2055
+ 'position': {
2062
2056
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2063
2057
  var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2064
2058
  var executeFunction = _b.executeFunction;
@@ -2077,7 +2071,7 @@ var sequenceNormalExpression = {
2077
2071
  },
2078
2072
  validate: function (node) { return assertNumberOfParams(2, node); },
2079
2073
  },
2080
- index_of: {
2074
+ 'index_of': {
2081
2075
  evaluate: function (_a, sourceCodeInfo) {
2082
2076
  var _b = __read(_a, 2), seq = _b[0], value = _b[1];
2083
2077
  assertAny(value, sourceCodeInfo);
@@ -2096,7 +2090,26 @@ var sequenceNormalExpression = {
2096
2090
  },
2097
2091
  validate: function (node) { return assertNumberOfParams(2, node); },
2098
2092
  },
2099
- push: {
2093
+ 'last_index_of': {
2094
+ evaluate: function (_a, sourceCodeInfo) {
2095
+ var _b = __read(_a, 2), seq = _b[0], value = _b[1];
2096
+ assertAny(value, sourceCodeInfo);
2097
+ if (seq === null)
2098
+ return null;
2099
+ assertSeq(seq, sourceCodeInfo);
2100
+ if (typeof seq === 'string') {
2101
+ assertString(value, sourceCodeInfo);
2102
+ var index = seq.lastIndexOf(value);
2103
+ return index !== -1 ? index : null;
2104
+ }
2105
+ else {
2106
+ var index = seq.lastIndexOf(value);
2107
+ return index !== -1 ? index : null;
2108
+ }
2109
+ },
2110
+ validate: function (node) { return assertNumberOfParams(2, node); },
2111
+ },
2112
+ 'push': {
2100
2113
  evaluate: function (_a, sourceCodeInfo) {
2101
2114
  var _b = __read(_a), seq = _b[0], values = _b.slice(1);
2102
2115
  assertSeq(seq, sourceCodeInfo);
@@ -2110,7 +2123,7 @@ var sequenceNormalExpression = {
2110
2123
  },
2111
2124
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
2112
2125
  },
2113
- reductions: {
2126
+ 'reductions': {
2114
2127
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2115
2128
  var executeFunction = _a.executeFunction;
2116
2129
  var _b = __read(params, 2), seq = _b[0], fn = _b[1];
@@ -2171,7 +2184,7 @@ var sequenceNormalExpression = {
2171
2184
  },
2172
2185
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2173
2186
  },
2174
- reduce: {
2187
+ 'reduce': {
2175
2188
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2176
2189
  var executeFunction = _a.executeFunction;
2177
2190
  var _b = __read(params, 2), seq = _b[0], fn = _b[1];
@@ -2218,7 +2231,7 @@ var sequenceNormalExpression = {
2218
2231
  },
2219
2232
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2220
2233
  },
2221
- reduce_right: {
2234
+ 'reduce_right': {
2222
2235
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2223
2236
  var executeFunction = _a.executeFunction;
2224
2237
  var _b = __read(params, 2), seq = _b[0], fn = _b[1];
@@ -2266,7 +2279,7 @@ var sequenceNormalExpression = {
2266
2279
  },
2267
2280
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2268
2281
  },
2269
- rest: {
2282
+ 'rest': {
2270
2283
  evaluate: function (_a, sourceCodeInfo) {
2271
2284
  var _b = __read(_a, 1), seq = _b[0];
2272
2285
  assertSeq(seq, sourceCodeInfo);
@@ -2279,7 +2292,7 @@ var sequenceNormalExpression = {
2279
2292
  },
2280
2293
  validate: function (node) { return assertNumberOfParams(1, node); },
2281
2294
  },
2282
- nthrest: {
2295
+ 'nthrest': {
2283
2296
  evaluate: function (_a, sourceCodeInfo) {
2284
2297
  var _b = __read(_a, 2), seq = _b[0], count = _b[1];
2285
2298
  assertSeq(seq, sourceCodeInfo);
@@ -2291,7 +2304,7 @@ var sequenceNormalExpression = {
2291
2304
  },
2292
2305
  validate: function (node) { return assertNumberOfParams(2, node); },
2293
2306
  },
2294
- next: {
2307
+ 'next': {
2295
2308
  evaluate: function (_a, sourceCodeInfo) {
2296
2309
  var _b = __read(_a, 1), seq = _b[0];
2297
2310
  assertSeq(seq, sourceCodeInfo);
@@ -2306,7 +2319,7 @@ var sequenceNormalExpression = {
2306
2319
  },
2307
2320
  validate: function (node) { return assertNumberOfParams(1, node); },
2308
2321
  },
2309
- nthnext: {
2322
+ 'nthnext': {
2310
2323
  evaluate: function (_a, sourceCodeInfo) {
2311
2324
  var _b = __read(_a, 2), seq = _b[0], count = _b[1];
2312
2325
  assertSeq(seq, sourceCodeInfo);
@@ -2320,7 +2333,7 @@ var sequenceNormalExpression = {
2320
2333
  },
2321
2334
  validate: function (node) { return assertNumberOfParams(2, node); },
2322
2335
  },
2323
- reverse: {
2336
+ 'reverse': {
2324
2337
  evaluate: function (_a, sourceCodeInfo) {
2325
2338
  var _b = __read(_a, 1), seq = _b[0];
2326
2339
  if (seq === null)
@@ -2332,7 +2345,7 @@ var sequenceNormalExpression = {
2332
2345
  },
2333
2346
  validate: function (node) { return assertNumberOfParams(1, node); },
2334
2347
  },
2335
- second: {
2348
+ 'second': {
2336
2349
  evaluate: function (_a, sourceCodeInfo) {
2337
2350
  var _b = __read(_a, 1), seq = _b[0];
2338
2351
  if (seq === null)
@@ -2342,7 +2355,7 @@ var sequenceNormalExpression = {
2342
2355
  },
2343
2356
  validate: function (node) { return assertNumberOfParams(1, node); },
2344
2357
  },
2345
- shift: {
2358
+ 'shift': {
2346
2359
  evaluate: function (_a, sourceCodeInfo) {
2347
2360
  var _b = __read(_a, 1), seq = _b[0];
2348
2361
  assertSeq(seq, sourceCodeInfo);
@@ -2354,7 +2367,7 @@ var sequenceNormalExpression = {
2354
2367
  },
2355
2368
  validate: function (node) { return assertNumberOfParams(1, node); },
2356
2369
  },
2357
- slice: {
2370
+ 'slice': {
2358
2371
  evaluate: function (params, sourceCodeInfo) {
2359
2372
  var _a = __read(params, 3), seq = _a[0], from = _a[1], to = _a[2];
2360
2373
  assertSeq(seq, sourceCodeInfo);
@@ -2368,7 +2381,7 @@ var sequenceNormalExpression = {
2368
2381
  },
2369
2382
  validate: function (node) { return assertNumberOfParams({ min: 1, max: 3 }, node); },
2370
2383
  },
2371
- some: {
2384
+ 'some': {
2372
2385
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2373
2386
  var _c;
2374
2387
  var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
@@ -2385,7 +2398,7 @@ var sequenceNormalExpression = {
2385
2398
  },
2386
2399
  validate: function (node) { return assertNumberOfParams(2, node); },
2387
2400
  },
2388
- sort: {
2401
+ 'sort': {
2389
2402
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2390
2403
  var executeFunction = _a.executeFunction;
2391
2404
  var _b = __read(params, 1), seq = _b[0];
@@ -2423,7 +2436,7 @@ var sequenceNormalExpression = {
2423
2436
  },
2424
2437
  validate: function (node) { return assertNumberOfParams({ min: 1, max: 2 }, node); },
2425
2438
  },
2426
- sort_by: {
2439
+ 'sort_by': {
2427
2440
  evaluate: function (params, sourceCodeInfo, contextStack, _a) {
2428
2441
  var executeFunction = _a.executeFunction;
2429
2442
  var _b = __read(params, 2), seq = _b[0], keyfn = _b[1];
@@ -2474,7 +2487,7 @@ var sequenceNormalExpression = {
2474
2487
  },
2475
2488
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2476
2489
  },
2477
- take: {
2490
+ 'take': {
2478
2491
  evaluate: function (_a, sourceCodeInfo) {
2479
2492
  var _b = __read(_a, 2), input = _b[0], n = _b[1];
2480
2493
  assertNumber(n, sourceCodeInfo);
@@ -2484,7 +2497,7 @@ var sequenceNormalExpression = {
2484
2497
  },
2485
2498
  validate: function (node) { return assertNumberOfParams(2, node); },
2486
2499
  },
2487
- take_last: {
2500
+ 'take_last': {
2488
2501
  evaluate: function (_a, sourceCodeInfo) {
2489
2502
  var _b = __read(_a, 2), array = _b[0], n = _b[1];
2490
2503
  assertSeq(array, sourceCodeInfo);
@@ -2495,7 +2508,7 @@ var sequenceNormalExpression = {
2495
2508
  },
2496
2509
  validate: function (node) { return assertNumberOfParams(2, node); },
2497
2510
  },
2498
- take_while: {
2511
+ 'take_while': {
2499
2512
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2500
2513
  var e_1, _c;
2501
2514
  var _d = __read(_a, 2), seq = _d[0], fn = _d[1];
@@ -2523,7 +2536,7 @@ var sequenceNormalExpression = {
2523
2536
  },
2524
2537
  validate: function (node) { return assertNumberOfParams(2, node); },
2525
2538
  },
2526
- drop: {
2539
+ 'drop': {
2527
2540
  evaluate: function (_a, sourceCodeInfo) {
2528
2541
  var _b = __read(_a, 2), input = _b[0], n = _b[1];
2529
2542
  assertNumber(n, sourceCodeInfo);
@@ -2533,7 +2546,7 @@ var sequenceNormalExpression = {
2533
2546
  },
2534
2547
  validate: function (node) { return assertNumberOfParams(2, node); },
2535
2548
  },
2536
- drop_last: {
2549
+ 'drop_last': {
2537
2550
  evaluate: function (_a, sourceCodeInfo) {
2538
2551
  var _b = __read(_a, 2), array = _b[0], n = _b[1];
2539
2552
  assertSeq(array, sourceCodeInfo);
@@ -2544,7 +2557,7 @@ var sequenceNormalExpression = {
2544
2557
  },
2545
2558
  validate: function (node) { return assertNumberOfParams(2, node); },
2546
2559
  },
2547
- drop_while: {
2560
+ 'drop_while': {
2548
2561
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2549
2562
  var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2550
2563
  var executeFunction = _b.executeFunction;
@@ -2560,7 +2573,7 @@ var sequenceNormalExpression = {
2560
2573
  },
2561
2574
  validate: function (node) { return assertNumberOfParams(2, node); },
2562
2575
  },
2563
- unshift: {
2576
+ 'unshift': {
2564
2577
  evaluate: function (_a, sourceCodeInfo) {
2565
2578
  var _b = __read(_a), seq = _b[0], values = _b.slice(1);
2566
2579
  assertSeq(seq, sourceCodeInfo);
@@ -2574,7 +2587,7 @@ var sequenceNormalExpression = {
2574
2587
  },
2575
2588
  validate: function (node) { return assertNumberOfParams({ min: 2 }, node); },
2576
2589
  },
2577
- distinct: {
2590
+ 'distinct': {
2578
2591
  evaluate: function (_a, sourceCodeInfo) {
2579
2592
  var _b = __read(_a, 1), input = _b[0];
2580
2593
  assertSeq(input, sourceCodeInfo);
@@ -2584,9 +2597,9 @@ var sequenceNormalExpression = {
2584
2597
  },
2585
2598
  validate: function (node) { return assertNumberOfParams(1, node); },
2586
2599
  },
2587
- remove: {
2600
+ 'remove': {
2588
2601
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2589
- var _c = __read(_a, 2), fn = _c[0], input = _c[1];
2602
+ var _c = __read(_a, 2), input = _c[0], fn = _c[1];
2590
2603
  var executeFunction = _b.executeFunction;
2591
2604
  assertLitsFunction(fn, sourceCodeInfo);
2592
2605
  assertSeq(input, sourceCodeInfo);
@@ -2599,9 +2612,9 @@ var sequenceNormalExpression = {
2599
2612
  },
2600
2613
  validate: function (node) { return assertNumberOfParams(2, node); },
2601
2614
  },
2602
- remove_at: {
2615
+ 'remove_at': {
2603
2616
  evaluate: function (_a, sourceCodeInfo) {
2604
- var _b = __read(_a, 2), index = _b[0], input = _b[1];
2617
+ var _b = __read(_a, 2), input = _b[0], index = _b[1];
2605
2618
  assertNumber(index, sourceCodeInfo);
2606
2619
  assertSeq(input, sourceCodeInfo);
2607
2620
  var intIndex = Math.ceil(index);
@@ -2616,9 +2629,9 @@ var sequenceNormalExpression = {
2616
2629
  },
2617
2630
  validate: function (node) { return assertNumberOfParams(2, node); },
2618
2631
  },
2619
- split_at: {
2632
+ 'split_at': {
2620
2633
  evaluate: function (_a, sourceCodeInfo) {
2621
- var _b = __read(_a, 2), pos = _b[0], seq = _b[1];
2634
+ var _b = __read(_a, 2), seq = _b[0], pos = _b[1];
2622
2635
  assertNumber(pos, sourceCodeInfo, { finite: true });
2623
2636
  var intPos = toNonNegativeInteger(pos);
2624
2637
  assertSeq(seq, sourceCodeInfo);
@@ -2626,9 +2639,9 @@ var sequenceNormalExpression = {
2626
2639
  },
2627
2640
  validate: function (node) { return assertNumberOfParams(2, node); },
2628
2641
  },
2629
- split_with: {
2642
+ 'split_with': {
2630
2643
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2631
- var _c = __read(_a, 2), fn = _c[0], seq = _c[1];
2644
+ var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2632
2645
  var executeFunction = _b.executeFunction;
2633
2646
  assertLitsFunction(fn, sourceCodeInfo);
2634
2647
  assertSeq(seq, sourceCodeInfo);
@@ -2641,7 +2654,7 @@ var sequenceNormalExpression = {
2641
2654
  },
2642
2655
  validate: function (node) { return assertNumberOfParams(2, node); },
2643
2656
  },
2644
- frequencies: {
2657
+ 'frequencies': {
2645
2658
  evaluate: function (_a, sourceCodeInfo) {
2646
2659
  var _b = __read(_a, 1), seq = _b[0];
2647
2660
  assertSeq(seq, sourceCodeInfo);
@@ -2657,9 +2670,9 @@ var sequenceNormalExpression = {
2657
2670
  },
2658
2671
  validate: function (node) { return assertNumberOfParams(1, node); },
2659
2672
  },
2660
- group_by: {
2673
+ 'group_by': {
2661
2674
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2662
- var _c = __read(_a, 2), fn = _c[0], seq = _c[1];
2675
+ var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2663
2676
  var executeFunction = _b.executeFunction;
2664
2677
  assertAny(fn, sourceCodeInfo);
2665
2678
  assertSeq(seq, sourceCodeInfo);
@@ -2675,34 +2688,30 @@ var sequenceNormalExpression = {
2675
2688
  },
2676
2689
  validate: function (node) { return assertNumberOfParams(2, node); },
2677
2690
  },
2678
- partition: {
2691
+ 'partition': {
2679
2692
  evaluate: function (params, sourceCodeInfo) {
2680
- var len = params.length;
2681
- var n = toNonNegativeInteger(asNumber(params[0], sourceCodeInfo));
2682
- var seq = len === 2
2683
- ? asSeq(params[1], sourceCodeInfo)
2684
- : len === 3
2685
- ? asSeq(params[2], sourceCodeInfo)
2686
- : asSeq(params[3], sourceCodeInfo);
2687
- var step = len >= 3 ? toNonNegativeInteger(asNumber(params[1], sourceCodeInfo)) : n;
2688
- var pad = len === 4 ? (params[2] === null ? [] : asArray(params[2], sourceCodeInfo)) : undefined;
2693
+ var seq = asSeq(params[0], sourceCodeInfo);
2694
+ var n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo));
2695
+ var step = params.length >= 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n;
2696
+ var pad = params.length === 4
2697
+ ? params[3] === null ? [] : asArray(params[3], sourceCodeInfo)
2698
+ : undefined;
2689
2699
  return partition(n, step, seq, pad, sourceCodeInfo);
2690
2700
  },
2691
2701
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 4 }, node); },
2692
2702
  },
2693
- partition_all: {
2703
+ 'partition_all': {
2694
2704
  evaluate: function (params, sourceCodeInfo) {
2695
- var len = params.length;
2696
- var n = toNonNegativeInteger(asNumber(params[0], sourceCodeInfo));
2697
- var seq = len === 2 ? asSeq(params[1], sourceCodeInfo) : asSeq(params[2], sourceCodeInfo);
2698
- var step = len >= 3 ? toNonNegativeInteger(asNumber(params[1], sourceCodeInfo)) : n;
2705
+ var seq = asSeq(params[0], sourceCodeInfo);
2706
+ var n = toNonNegativeInteger(asNumber(params[1], sourceCodeInfo));
2707
+ var step = params.length === 3 ? toNonNegativeInteger(asNumber(params[2], sourceCodeInfo)) : n;
2699
2708
  return partition(n, step, seq, [], sourceCodeInfo);
2700
2709
  },
2701
2710
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2702
2711
  },
2703
- partition_by: {
2712
+ 'partition_by': {
2704
2713
  evaluate: function (_a, sourceCodeInfo, contextStack, _b) {
2705
- var _c = __read(_a, 2), fn = _c[0], seq = _c[1];
2714
+ var _c = __read(_a, 2), seq = _c[0], fn = _c[1];
2706
2715
  var executeFunction = _b.executeFunction;
2707
2716
  assertLitsFunction(fn, sourceCodeInfo);
2708
2717
  assertSeq(seq, sourceCodeInfo);
@@ -2719,7 +2728,88 @@ var sequenceNormalExpression = {
2719
2728
  }, []);
2720
2729
  return isStringSeq ? result.map(function (elem) { return elem.join(''); }) : result;
2721
2730
  },
2722
- validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
2731
+ validate: function (node) { return assertNumberOfParams(2, node); },
2732
+ },
2733
+ 'ends_with?': {
2734
+ evaluate: function (_a, sourceCodeInfo) {
2735
+ var _b = __read(_a, 2), str = _b[0], search = _b[1];
2736
+ assertSeq(str, sourceCodeInfo);
2737
+ if (typeof str === 'string') {
2738
+ assertString(search, sourceCodeInfo);
2739
+ return str.endsWith(search);
2740
+ }
2741
+ return str.at(-1) === search;
2742
+ },
2743
+ validate: function (node) { return assertNumberOfParams(2, node); },
2744
+ },
2745
+ 'starts_with?': {
2746
+ evaluate: function (_a, sourceCodeInfo) {
2747
+ var _b = __read(_a, 2), str = _b[0], search = _b[1];
2748
+ assertSeq(str, sourceCodeInfo);
2749
+ if (typeof str === 'string') {
2750
+ assertString(search, sourceCodeInfo);
2751
+ return str.startsWith(search);
2752
+ }
2753
+ return str[0] === search;
2754
+ },
2755
+ validate: function (node) { return assertNumberOfParams(2, node); },
2756
+ },
2757
+ 'interleave': {
2758
+ evaluate: function (_a, sourceCodeInfo) {
2759
+ var e_2, _b;
2760
+ var _c = __read(_a), seqs = _c.slice(0);
2761
+ var isStringSeq = typeof seqs[0] === 'string';
2762
+ var seqsArr = isStringSeq
2763
+ ? seqs.map(function (seq) {
2764
+ assertString(seq, sourceCodeInfo);
2765
+ if (typeof seq === 'string')
2766
+ return seq.split('');
2767
+ return seq;
2768
+ })
2769
+ : seqs.map(function (seq) {
2770
+ assertArray(seq, sourceCodeInfo);
2771
+ return seq;
2772
+ });
2773
+ var maxLength = Math.min.apply(Math, __spreadArray([], __read(seqsArr.map(function (seq) { return seq.length; })), false));
2774
+ var result = [];
2775
+ for (var i = 0; i < maxLength; i += 1) {
2776
+ try {
2777
+ 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()) {
2778
+ var seq = seqsArr_1_1.value;
2779
+ if (i < seq.length)
2780
+ result.push(seq[i]);
2781
+ }
2782
+ }
2783
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2784
+ finally {
2785
+ try {
2786
+ if (seqsArr_1_1 && !seqsArr_1_1.done && (_b = seqsArr_1.return)) _b.call(seqsArr_1);
2787
+ }
2788
+ finally { if (e_2) throw e_2.error; }
2789
+ }
2790
+ }
2791
+ return isStringSeq ? result.join('') : result;
2792
+ },
2793
+ validate: function (node) { return assertNumberOfParams({ min: 1 }, node); },
2794
+ },
2795
+ 'interpose': {
2796
+ evaluate: function (_a, sourceCodeInfo) {
2797
+ var _b = __read(_a, 2), seq = _b[0], separator = _b[1];
2798
+ assertSeq(seq, sourceCodeInfo);
2799
+ if (typeof seq === 'string') {
2800
+ assertString(separator, sourceCodeInfo);
2801
+ return seq.split('').join(separator);
2802
+ }
2803
+ if (seq.length === 0)
2804
+ return [];
2805
+ var result = [];
2806
+ for (var i = 0; i < seq.length - 1; i += 1) {
2807
+ result.push(seq[i], separator);
2808
+ }
2809
+ result.push(seq[seq.length - 1]);
2810
+ return result;
2811
+ },
2812
+ validate: function (node) { return assertNumberOfParams(2, node); },
2723
2813
  },
2724
2814
  };
2725
2815
  function partition(n, step, seq, pad, sourceCodeInfo) {
@@ -3882,7 +3972,7 @@ var regexpNormalExpression = {
3882
3972
  },
3883
3973
  match: {
3884
3974
  evaluate: function (_a, sourceCodeInfo) {
3885
- var _b = __read(_a, 2), regexp = _b[0], text = _b[1];
3975
+ var _b = __read(_a, 2), text = _b[0], regexp = _b[1];
3886
3976
  assertRegularExpression(regexp, sourceCodeInfo);
3887
3977
  if (!isString(text))
3888
3978
  return null;
@@ -3898,15 +3988,27 @@ var regexpNormalExpression = {
3898
3988
  evaluate: function (_a, sourceCodeInfo) {
3899
3989
  var _b = __read(_a, 3), str = _b[0], regexp = _b[1], value = _b[2];
3900
3990
  assertString(str, sourceCodeInfo);
3901
- assertRegularExpression(regexp, sourceCodeInfo);
3991
+ assertStringOrRegularExpression(regexp, sourceCodeInfo);
3902
3992
  assertString(value, sourceCodeInfo);
3903
- var regExp = new RegExp(regexp.s, regexp.f);
3904
- return str.replace(regExp, value);
3993
+ var matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, "".concat(regexp.f)) : regexp;
3994
+ return str.replace(matcher, value);
3995
+ },
3996
+ validate: function (node) { return assertNumberOfParams(3, node); },
3997
+ },
3998
+ replace_all: {
3999
+ evaluate: function (_a, sourceCodeInfo) {
4000
+ var _b = __read(_a, 3), str = _b[0], regexp = _b[1], value = _b[2];
4001
+ assertString(str, sourceCodeInfo);
4002
+ assertStringOrRegularExpression(regexp, sourceCodeInfo);
4003
+ assertString(value, sourceCodeInfo);
4004
+ var matcher = isRegularExpression(regexp) ? new RegExp(regexp.s, "".concat(regexp.f.includes('g') ? regexp.f : "".concat(regexp.f, "g"))) : regexp;
4005
+ return str.replaceAll(matcher, value);
3905
4006
  },
3906
4007
  validate: function (node) { return assertNumberOfParams(3, node); },
3907
4008
  },
3908
4009
  };
3909
4010
 
4011
+ var blankRegexp = /^\s*$/;
3910
4012
  var stringNormalExpression = {
3911
4013
  'subs': {
3912
4014
  evaluate: function (_a, sourceCodeInfo) {
@@ -4064,6 +4166,14 @@ var stringNormalExpression = {
4064
4166
  },
4065
4167
  validate: function (node) { return assertNumberOfParams({ min: 2, max: 3 }, node); },
4066
4168
  },
4169
+ 'split_lines': {
4170
+ evaluate: function (_a, sourceCodeInfo) {
4171
+ var _b = __read(_a, 1), str = _b[0];
4172
+ assertString(str, sourceCodeInfo);
4173
+ return str.split((/\r\n|\n|\r/)).filter(function (line) { return line !== ''; });
4174
+ },
4175
+ validate: function (node) { return assertNumberOfParams(1, node); },
4176
+ },
4067
4177
  'pad_left': {
4068
4178
  evaluate: function (_a, sourceCodeInfo) {
4069
4179
  var _b = __read(_a, 3), str = _b[0], length = _b[1], padString = _b[2];
@@ -4167,6 +4277,25 @@ var stringNormalExpression = {
4167
4277
  },
4168
4278
  validate: function (node) { return assertNumberOfParams(1, node); },
4169
4279
  },
4280
+ 'blank?': {
4281
+ evaluate: function (_a, sourceCodeInfo) {
4282
+ var _b = __read(_a, 1), value = _b[0];
4283
+ if (value === null) {
4284
+ return true;
4285
+ }
4286
+ assertString(value, sourceCodeInfo);
4287
+ return blankRegexp.test(value);
4288
+ },
4289
+ validate: function (node) { return assertNumberOfParams(1, node); },
4290
+ },
4291
+ 'capitalize': {
4292
+ evaluate: function (_a, sourceCodeInfo) {
4293
+ var _b = __read(_a, 1), str = _b[0];
4294
+ assertString(str, sourceCodeInfo);
4295
+ return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase();
4296
+ },
4297
+ validate: function (node) { return assertNumberOfParams(1, node); },
4298
+ },
4170
4299
  };
4171
4300
  var doubleDollarRegexp = /\$\$/g;
4172
4301
  function applyPlaceholders(templateString, placeholders, sourceCodeInfo) {
@@ -4512,44 +4641,6 @@ var defSpecialExpression = {
4512
4641
  },
4513
4642
  };
4514
4643
 
4515
- var defsSpecialExpression = {
4516
- polishParse: function (tokenStream, parseState, firstToken, _a) {
4517
- var parseTokensUntilClosingBracket = _a.parseTokensUntilClosingBracket;
4518
- var params = parseTokensUntilClosingBracket(tokenStream, parseState);
4519
- assertRParenToken(tokenStream.tokens[parseState.position++]);
4520
- var node = {
4521
- t: exports.AstNodeType.SpecialExpression,
4522
- n: 'defs',
4523
- p: params,
4524
- token: getTokenDebugData(firstToken) && firstToken,
4525
- };
4526
- return node;
4527
- },
4528
- validateParameterCount: function (node) { return assertNumberOfParams(2, node); },
4529
- evaluate: function (node, contextStack, _a) {
4530
- var _b, _c;
4531
- var evaluateAstNode = _a.evaluateAstNode, builtin = _a.builtin;
4532
- var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
4533
- var name = evaluateAstNode(node.p[0], contextStack);
4534
- assertString(name, sourceCodeInfo);
4535
- assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
4536
- contextStack.exportValue(name, evaluateAstNode(node.p[1], contextStack));
4537
- return null;
4538
- },
4539
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
4540
- var _b;
4541
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
4542
- var sourceCodeInfo = (_b = getTokenDebugData(node.token)) === null || _b === void 0 ? void 0 : _b.sourceCodeInfo;
4543
- var subNode = node.p[1];
4544
- var result = findUnresolvedIdentifiers([subNode], contextStack, builtin);
4545
- var name = evaluateAstNode(node.p[0], contextStack);
4546
- assertString(name, sourceCodeInfo);
4547
- assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
4548
- contextStack.exportValue(name, true);
4549
- return result;
4550
- },
4551
- };
4552
-
4553
4644
  var doSpecialExpression = {
4554
4645
  polishParse: getCommonPolishSpecialExpressionParser('do'),
4555
4646
  validateParameterCount: function () { return undefined; },
@@ -4629,7 +4720,7 @@ var defnSpecialExpression = {
4629
4720
  var _b;
4630
4721
  var _c, _d;
4631
4722
  var builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
4632
- var name = getFunctionName('defn', node, contextStack, evaluateAstNode);
4723
+ var name = node.f.v;
4633
4724
  assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
4634
4725
  var evaluatedFunctionOverloades = evaluateFunctionOverloades(node, contextStack, evaluateAstNode);
4635
4726
  var litsFunction = (_b = {},
@@ -4650,53 +4741,6 @@ var defnSpecialExpression = {
4650
4741
  return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
4651
4742
  },
4652
4743
  };
4653
- var defnsSpecialExpression = {
4654
- polishParse: function (tokenStream, parseState, firstToken, parsers) {
4655
- var parseToken = parsers.parseToken;
4656
- var functionName = parseToken(tokenStream, parseState);
4657
- var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
4658
- assertRParenToken(tokenStream.tokens[parseState.position++]);
4659
- var node = {
4660
- t: exports.AstNodeType.SpecialExpression,
4661
- n: 'defns',
4662
- p: [],
4663
- f: functionName,
4664
- o: functionOverloades,
4665
- token: getTokenDebugData(firstToken) && firstToken,
4666
- };
4667
- return node;
4668
- },
4669
- validateParameterCount: function () { return undefined; },
4670
- evaluate: function (node, contextStack, _a) {
4671
- var _b;
4672
- var _c, _d;
4673
- var builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
4674
- var name = getFunctionName('defns', node, contextStack, evaluateAstNode);
4675
- assertNameNotDefined(name, contextStack, builtin, (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo);
4676
- var evaluatedFunctionOverloades = evaluateFunctionOverloades(node, contextStack, evaluateAstNode);
4677
- var litsFunction = (_b = {},
4678
- _b[FUNCTION_SYMBOL] = true,
4679
- _b.sourceCodeInfo = (_d = getTokenDebugData(node.token)) === null || _d === void 0 ? void 0 : _d.sourceCodeInfo,
4680
- _b.t = exports.FunctionType.UserDefined,
4681
- _b.n = name,
4682
- _b.o = evaluatedFunctionOverloades,
4683
- _b);
4684
- contextStack.exportValue(name, litsFunction);
4685
- return null;
4686
- },
4687
- findUnresolvedIdentifiers: function (node, contextStack, _a) {
4688
- var _b;
4689
- var _c;
4690
- var findUnresolvedIdentifiers = _a.findUnresolvedIdentifiers, builtin = _a.builtin, evaluateAstNode = _a.evaluateAstNode;
4691
- var sourceCodeInfo = (_c = getTokenDebugData(node.token)) === null || _c === void 0 ? void 0 : _c.sourceCodeInfo;
4692
- var name = evaluateAstNode(asAstNode(node.f, sourceCodeInfo), contextStack);
4693
- assertString(name, sourceCodeInfo);
4694
- assertNameNotDefined(name, contextStack, builtin, sourceCodeInfo);
4695
- contextStack.exportValue(name, true);
4696
- var newContext = (_b = {}, _b[name] = { value: true }, _b);
4697
- return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin, newContext);
4698
- },
4699
- };
4700
4744
  var fnSpecialExpression = {
4701
4745
  polishParse: function (tokenStream, parseState, firstToken, parsers) {
4702
4746
  var functionOverloades = parseFunctionOverloades(tokenStream, parseState, parsers);
@@ -4730,14 +4774,6 @@ var fnSpecialExpression = {
4730
4774
  return addOverloadsUnresolvedIdentifiers(node.o, contextStack, findUnresolvedIdentifiers, builtin);
4731
4775
  },
4732
4776
  };
4733
- function getFunctionName(expressionName, node, contextStack, evaluateAstNode) {
4734
- var _a;
4735
- var sourceCodeInfo = (_a = getTokenDebugData(node.token)) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo;
4736
- if (expressionName === 'defn')
4737
- return (node.f).v;
4738
- var name = evaluateAstNode(node.f, contextStack);
4739
- return asString(name, sourceCodeInfo);
4740
- }
4741
4777
  function evaluateFunctionOverloades(node, contextStack, evaluateAstNode) {
4742
4778
  var e_1, _a, e_2, _b;
4743
4779
  var evaluatedFunctionOverloades = [];
@@ -5515,8 +5551,6 @@ var specialExpressions = {
5515
5551
  'switch': switchSpecialExpression,
5516
5552
  'def': defSpecialExpression,
5517
5553
  'defn': defnSpecialExpression,
5518
- 'defns': defnsSpecialExpression,
5519
- 'defs': defsSpecialExpression,
5520
5554
  'do': doSpecialExpression,
5521
5555
  'doseq': doseqSpecialExpression,
5522
5556
  'for': forSpecialExpression,
@@ -5578,7 +5612,6 @@ var ContextStackImpl = /** @class */ (function () {
5578
5612
  if (normalExpressionKeys.includes(name)) {
5579
5613
  throw new Error("Cannot shadow builtin function \"".concat(name, "\""));
5580
5614
  }
5581
- this.addValue(name, value);
5582
5615
  this.globalContext[name] = { value: value };
5583
5616
  };
5584
5617
  ContextStackImpl.prototype.addValue = function (name, value) {
@@ -6242,6 +6275,33 @@ function parseString(tokenStream, parseState) {
6242
6275
  token: getTokenDebugData(tkn) && tkn,
6243
6276
  };
6244
6277
  }
6278
+ function parseRegexpShorthand(tokenStream, parseState) {
6279
+ var tkn = asRegexpShorthandToken(tokenStream.tokens[parseState.position++]);
6280
+ var endStringPosition = tkn[1].lastIndexOf('"');
6281
+ var regexpString = tkn[1].substring(2, endStringPosition);
6282
+ var optionsString = tkn[1].substring(endStringPosition + 1);
6283
+ var stringNode = {
6284
+ t: exports.AstNodeType.String,
6285
+ v: regexpString,
6286
+ p: [],
6287
+ n: undefined,
6288
+ token: getTokenDebugData(tkn) && tkn,
6289
+ };
6290
+ var optionsNode = {
6291
+ t: exports.AstNodeType.String,
6292
+ v: optionsString,
6293
+ p: [],
6294
+ n: undefined,
6295
+ token: getTokenDebugData(tkn) && tkn,
6296
+ };
6297
+ var node = {
6298
+ t: exports.AstNodeType.NormalExpression,
6299
+ n: 'regexp',
6300
+ p: [stringNode, optionsNode],
6301
+ token: getTokenDebugData(tkn) && tkn,
6302
+ };
6303
+ return node;
6304
+ }
6245
6305
 
6246
6306
  var exponentiationPrecedence = 10;
6247
6307
  var binaryFunctionalOperatorPrecedence = 1;
@@ -6383,6 +6443,12 @@ var AlgebraicParser = /** @class */ (function () {
6383
6443
  this.tokenStream = tokenStream;
6384
6444
  this.parseState = parseState;
6385
6445
  }
6446
+ AlgebraicParser.prototype.peek = function () {
6447
+ return this.tokenStream.tokens[this.parseState.position];
6448
+ };
6449
+ AlgebraicParser.prototype.peekAhead = function (count) {
6450
+ return this.tokenStream.tokens[this.parseState.position + count];
6451
+ };
6386
6452
  AlgebraicParser.prototype.advance = function () {
6387
6453
  this.parseState.position += 1;
6388
6454
  };
@@ -6404,10 +6470,6 @@ var AlgebraicParser = /** @class */ (function () {
6404
6470
  var left;
6405
6471
  if (isA_SymbolToken(firstToken)) {
6406
6472
  switch (firstToken[1]) {
6407
- case 'def':
6408
- return this.parseDef(firstToken);
6409
- case 'defn':
6410
- return this.parseDefn(firstToken);
6411
6473
  case 'let':
6412
6474
  return this.parseLet(firstToken);
6413
6475
  case 'if':
@@ -6435,6 +6497,12 @@ var AlgebraicParser = /** @class */ (function () {
6435
6497
  break;
6436
6498
  }
6437
6499
  }
6500
+ else if (isA_ReservedSymbolToken(firstToken, 'function')) {
6501
+ return this.parseFunction(firstToken);
6502
+ }
6503
+ else if (isA_ReservedSymbolToken(firstToken, 'export')) {
6504
+ return this.parseExport(firstToken);
6505
+ }
6438
6506
  left || (left = this.parseOperand());
6439
6507
  var operator = this.peek();
6440
6508
  while (!this.isAtExpressionEnd()) {
@@ -6566,10 +6634,18 @@ var AlgebraicParser = /** @class */ (function () {
6566
6634
  case 'String':
6567
6635
  return parseString(this.tokenStream, this.parseState);
6568
6636
  case 'A_Symbol': {
6637
+ var positionBefore = this.parseState.position;
6638
+ var lamdaFunction = this.parseLambdaFunction();
6639
+ if (lamdaFunction) {
6640
+ return lamdaFunction;
6641
+ }
6642
+ this.parseState.position = positionBefore;
6569
6643
  return parseSymbol(this.tokenStream, this.parseState);
6570
6644
  }
6571
6645
  case 'A_ReservedSymbol':
6572
6646
  return parseReservedSymbol(this.tokenStream, this.parseState);
6647
+ case 'RegexpShorthand':
6648
+ return parseRegexpShorthand(this.tokenStream, this.parseState);
6573
6649
  case 'PolNotation': {
6574
6650
  this.parseState.algebraic = false;
6575
6651
  var astNodes = [];
@@ -6703,11 +6779,9 @@ var AlgebraicParser = /** @class */ (function () {
6703
6779
  builtin.specialExpressions[node.n].validateParameterCount(node);
6704
6780
  return node;
6705
6781
  }
6706
- case 'defs':
6707
6782
  case 'fn':
6708
- case 'defns':
6709
- case 'try':
6710
- case 'doseq':
6783
+ case 'def':
6784
+ case 'defn':
6711
6785
  throw new Error("Special expression ".concat(name_2, " is not available in algebraic notation"));
6712
6786
  default:
6713
6787
  throw new Error("Unknown special expression: ".concat(name_2));
@@ -6726,6 +6800,11 @@ var AlgebraicParser = /** @class */ (function () {
6726
6800
  };
6727
6801
  AlgebraicParser.prototype.parseLambdaFunction = function () {
6728
6802
  var firstToken = this.peek();
6803
+ if (isLParenToken(firstToken)
6804
+ && isA_SymbolToken(this.peekAhead(1))
6805
+ && isA_OperatorToken(this.peekAhead(2), '=>')) {
6806
+ return null;
6807
+ }
6729
6808
  try {
6730
6809
  var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
6731
6810
  if (!isA_OperatorToken(this.peek(), '=>')) {
@@ -6751,6 +6830,18 @@ var AlgebraicParser = /** @class */ (function () {
6751
6830
  };
6752
6831
  AlgebraicParser.prototype.parseFunctionArguments = function () {
6753
6832
  var _a, _b, _c, _d, _e;
6833
+ var firstToken = this.peek();
6834
+ if (isA_SymbolToken(firstToken)) {
6835
+ this.advance();
6836
+ return {
6837
+ functionArguments: {
6838
+ m: [firstToken[1]],
6839
+ b: [],
6840
+ r: undefined,
6841
+ },
6842
+ arity: 1,
6843
+ };
6844
+ }
6754
6845
  this.advance();
6755
6846
  var rest = false;
6756
6847
  var letBindingObject;
@@ -6869,17 +6960,20 @@ var AlgebraicParser = /** @class */ (function () {
6869
6960
  };
6870
6961
  return node;
6871
6962
  };
6872
- AlgebraicParser.prototype.parseLet = function (token) {
6963
+ AlgebraicParser.prototype.parseLet = function (token, optionalSemicolon) {
6964
+ if (optionalSemicolon === void 0) { optionalSemicolon = false; }
6873
6965
  this.advance();
6874
6966
  var letSymbol = parseSymbol(this.tokenStream, this.parseState);
6875
6967
  assertA_OperatorToken(this.peek(), '=');
6876
6968
  this.advance();
6877
6969
  var value = this.parseExpression();
6970
+ if (!optionalSemicolon) {
6971
+ assertA_OperatorToken(this.peek(), ';');
6972
+ }
6878
6973
  return {
6879
6974
  t: exports.AstNodeType.SpecialExpression,
6880
6975
  n: 'let',
6881
6976
  p: [],
6882
- token: getTokenDebugData(letSymbol.token) && letSymbol.token,
6883
6977
  bs: [{
6884
6978
  t: exports.AstNodeType.Binding,
6885
6979
  n: letSymbol.v,
@@ -6887,6 +6981,7 @@ var AlgebraicParser = /** @class */ (function () {
6887
6981
  p: [],
6888
6982
  token: getTokenDebugData(token) && token,
6889
6983
  }],
6984
+ token: getTokenDebugData(letSymbol.token) && letSymbol.token,
6890
6985
  };
6891
6986
  };
6892
6987
  AlgebraicParser.prototype.parseDo = function (token) {
@@ -7054,7 +7149,7 @@ var AlgebraicParser = /** @class */ (function () {
7054
7149
  modifiers.push('&let');
7055
7150
  letBindings = [];
7056
7151
  while (isA_SymbolToken(token, 'let')) {
7057
- var letNode = this.parseLet(token);
7152
+ var letNode = this.parseLet(token, true);
7058
7153
  letBindings.push(letNode.bs[0]);
7059
7154
  token = this.peek();
7060
7155
  }
@@ -7241,20 +7336,7 @@ var AlgebraicParser = /** @class */ (function () {
7241
7336
  token: getTokenDebugData(token) && token,
7242
7337
  };
7243
7338
  };
7244
- AlgebraicParser.prototype.parseDef = function (token) {
7245
- this.advance();
7246
- var symbol = parseSymbol(this.tokenStream, this.parseState);
7247
- assertA_OperatorToken(this.peek(), '=');
7248
- this.advance();
7249
- var value = this.parseExpression();
7250
- return {
7251
- t: exports.AstNodeType.SpecialExpression,
7252
- n: 'def',
7253
- p: [symbol, value],
7254
- token: getTokenDebugData(token) && token,
7255
- };
7256
- };
7257
- AlgebraicParser.prototype.parseDefn = function (token) {
7339
+ AlgebraicParser.prototype.parseFunction = function (token) {
7258
7340
  this.advance();
7259
7341
  var symbol = parseSymbol(this.tokenStream, this.parseState);
7260
7342
  var _a = this.parseFunctionArguments(), functionArguments = _a.functionArguments, arity = _a.arity;
@@ -7267,10 +7349,9 @@ var AlgebraicParser = /** @class */ (function () {
7267
7349
  }
7268
7350
  assertA_ReservedSymbolToken(this.peek(), 'end');
7269
7351
  this.advance();
7270
- return {
7352
+ var fnNode = {
7271
7353
  t: exports.AstNodeType.SpecialExpression,
7272
- n: 'defn',
7273
- f: symbol,
7354
+ n: 'fn',
7274
7355
  p: [],
7275
7356
  o: [{
7276
7357
  as: functionArguments,
@@ -7279,6 +7360,19 @@ var AlgebraicParser = /** @class */ (function () {
7279
7360
  }],
7280
7361
  token: getTokenDebugData(token) && token,
7281
7362
  };
7363
+ return {
7364
+ t: exports.AstNodeType.SpecialExpression,
7365
+ n: 'let',
7366
+ p: [],
7367
+ bs: [{
7368
+ t: exports.AstNodeType.Binding,
7369
+ n: symbol.v,
7370
+ v: fnNode,
7371
+ p: [],
7372
+ token: getTokenDebugData(symbol.token) && symbol.token,
7373
+ }],
7374
+ token: getTokenDebugData(token) && token,
7375
+ };
7282
7376
  };
7283
7377
  AlgebraicParser.prototype.isAtEnd = function () {
7284
7378
  return this.parseState.position >= this.tokenStream.tokens.length;
@@ -7299,8 +7393,30 @@ var AlgebraicParser = /** @class */ (function () {
7299
7393
  }
7300
7394
  return false;
7301
7395
  };
7302
- AlgebraicParser.prototype.peek = function () {
7303
- return this.tokenStream.tokens[this.parseState.position];
7396
+ AlgebraicParser.prototype.parseExport = function (token) {
7397
+ var _a;
7398
+ this.advance();
7399
+ var symbol = parseSymbol(this.tokenStream, this.parseState);
7400
+ if (isA_OperatorToken(this.peek(), ';')) {
7401
+ return {
7402
+ t: exports.AstNodeType.SpecialExpression,
7403
+ n: 'def',
7404
+ p: [symbol, symbol],
7405
+ token: getTokenDebugData(token) && token,
7406
+ };
7407
+ }
7408
+ if (!isA_OperatorToken(this.peek(), '=')) {
7409
+ throw new LitsError('Expected = or ;', (_a = getTokenDebugData(this.peek())) === null || _a === void 0 ? void 0 : _a.sourceCodeInfo);
7410
+ }
7411
+ this.advance();
7412
+ var value = this.parseExpression();
7413
+ assertA_OperatorToken(this.peek(), ';');
7414
+ return {
7415
+ t: exports.AstNodeType.SpecialExpression,
7416
+ n: 'def',
7417
+ p: [symbol, value],
7418
+ token: getTokenDebugData(token) && token,
7419
+ };
7304
7420
  };
7305
7421
  return AlgebraicParser;
7306
7422
  }());
@@ -7376,33 +7492,6 @@ function parseObjectLitteral(tokenStream, parseState) {
7376
7492
  assertEvenNumberOfParams(node);
7377
7493
  return node;
7378
7494
  }
7379
- function parseRegexpShorthand(tokenStream, parseState) {
7380
- var tkn = asP_RegexpShorthandToken(tokenStream.tokens[parseState.position++]);
7381
- var endStringPosition = tkn[1].lastIndexOf('"');
7382
- var regexpString = tkn[1].substring(2, endStringPosition);
7383
- var optionsString = tkn[1].substring(endStringPosition + 1);
7384
- var stringNode = {
7385
- t: exports.AstNodeType.String,
7386
- v: regexpString,
7387
- p: [],
7388
- n: undefined,
7389
- token: getTokenDebugData(tkn) && tkn,
7390
- };
7391
- var optionsNode = {
7392
- t: exports.AstNodeType.String,
7393
- v: optionsString,
7394
- p: [],
7395
- n: undefined,
7396
- token: getTokenDebugData(tkn) && tkn,
7397
- };
7398
- var node = {
7399
- t: exports.AstNodeType.NormalExpression,
7400
- n: 'regexp',
7401
- p: [stringNode, optionsNode],
7402
- token: getTokenDebugData(tkn) && tkn,
7403
- };
7404
- return node;
7405
- }
7406
7495
  var placeholderRegexp = /^%([1-9]\d?)?$/;
7407
7496
  function parseFnShorthand(tokenStream, parseState) {
7408
7497
  var _a, _b, _c, _d;
@@ -7572,7 +7661,7 @@ function parsePolishToken(tokenStream, parseState) {
7572
7661
  return parseArrayLitteral(tokenStream, parseState);
7573
7662
  case 'LBrace':
7574
7663
  return parseObjectLitteral(tokenStream, parseState);
7575
- case 'P_RegexpShorthand':
7664
+ case 'RegexpShorthand':
7576
7665
  return parseRegexpShorthand(tokenStream, parseState);
7577
7666
  case 'P_FnShorthand':
7578
7667
  return parseFnShorthand(tokenStream, parseState);
@@ -7736,6 +7825,25 @@ var tokenizeString = function (input, position) {
7736
7825
  value += '"'; // closing quote
7737
7826
  return [length + 1, ['String', value]];
7738
7827
  };
7828
+ var tokenizeRegexpShorthand = function (input, position) {
7829
+ if (input[position] !== '#')
7830
+ return NO_MATCH;
7831
+ var _a = __read(tokenizeString(input, position + 1), 2), stringLength = _a[0], token = _a[1];
7832
+ if (!token)
7833
+ return NO_MATCH;
7834
+ position += stringLength + 1;
7835
+ var length = stringLength + 1;
7836
+ var options = '';
7837
+ while (input[position] === 'g' || input[position] === 'i') {
7838
+ if (options.includes(input[position])) {
7839
+ throw new LitsError("Duplicated regexp option \"".concat(input[position], "\" at position ").concat(position, "."), undefined);
7840
+ }
7841
+ options += input[position];
7842
+ length += 1;
7843
+ position += 1;
7844
+ }
7845
+ return [length, ['RegexpShorthand', "#".concat(token[1]).concat(options)]];
7846
+ };
7739
7847
  function tokenizeSimpleToken(type, value, input, position) {
7740
7848
  if (value === input.slice(position, position + value.length))
7741
7849
  return [value.length, [type]];
@@ -7753,6 +7861,7 @@ var commonTokenizers = [
7753
7861
  tokenizeLBrace,
7754
7862
  tokenizeRBrace,
7755
7863
  tokenizeString,
7864
+ tokenizeRegexpShorthand,
7756
7865
  ];
7757
7866
 
7758
7867
  var validAlgebraicReservedNamesRecord = {
@@ -7766,10 +7875,11 @@ var validAlgebraicReservedNamesRecord = {
7766
7875
  case: { value: null, forbidden: false },
7767
7876
  when: { value: null, forbidden: false },
7768
7877
  while: { value: null, forbidden: false },
7878
+ function: { value: null, forbidden: false },
7879
+ export: { value: null, forbidden: false },
7769
7880
  };
7770
7881
  var forbiddenAlgebraicReservedNamesRecord = {
7771
7882
  fn: { value: null, forbidden: true },
7772
- defns: { value: null, forbidden: true },
7773
7883
  };
7774
7884
  var algebraicReservedNamesRecord = __assign(__assign({}, validAlgebraicReservedNamesRecord), forbiddenAlgebraicReservedNamesRecord);
7775
7885
 
@@ -8154,25 +8264,6 @@ var tokenizeP_CollectionAccessor = function (input, position) {
8154
8264
  return NO_MATCH;
8155
8265
  return [1, ['P_CollectionAccessor', char]];
8156
8266
  };
8157
- var tokenizeP_RegexpShorthand = function (input, position) {
8158
- if (input[position] !== '#')
8159
- return NO_MATCH;
8160
- var _a = __read(tokenizeString(input, position + 1), 2), stringLength = _a[0], token = _a[1];
8161
- if (!token)
8162
- return NO_MATCH;
8163
- position += stringLength + 1;
8164
- var length = stringLength + 1;
8165
- var options = '';
8166
- while (input[position] === 'g' || input[position] === 'i') {
8167
- if (options.includes(input[position])) {
8168
- throw new LitsError("Duplicated regexp option \"".concat(input[position], "\" at position ").concat(position, "."), undefined);
8169
- }
8170
- options += input[position];
8171
- length += 1;
8172
- position += 1;
8173
- }
8174
- return [length, ['P_RegexpShorthand', "#".concat(token[1]).concat(options)]];
8175
- };
8176
8267
  // All tokenizers, order matters!
8177
8268
  var polishTokenizers = __spreadArray(__spreadArray([
8178
8269
  tokenizeP_Whitespace,
@@ -8183,7 +8274,6 @@ var polishTokenizers = __spreadArray(__spreadArray([
8183
8274
  tokenizeP_ReservedSymbol,
8184
8275
  tokenizeP_Modifier,
8185
8276
  tokenizeP_Symbol,
8186
- tokenizeP_RegexpShorthand,
8187
8277
  tokenizeP_FnShorthand,
8188
8278
  tokenizeP_CollectionAccessor,
8189
8279
  ], false);
@@ -9502,7 +9592,7 @@ var arrayReference = {
9502
9592
  };
9503
9593
 
9504
9594
  var sequenceReference = {
9505
- nth: {
9595
+ 'nth': {
9506
9596
  title: 'nth',
9507
9597
  category: 'Sequence',
9508
9598
  linkName: 'nth',
@@ -9538,7 +9628,7 @@ var sequenceReference = {
9538
9628
  '(nth nil 1 "Default value")',
9539
9629
  ],
9540
9630
  },
9541
- push: {
9631
+ 'push': {
9542
9632
  title: 'push',
9543
9633
  category: 'Sequence',
9544
9634
  linkName: 'push',
@@ -9568,7 +9658,7 @@ var sequenceReference = {
9568
9658
  '(def l [1 2 3]) (push l 4) l',
9569
9659
  ],
9570
9660
  },
9571
- pop: {
9661
+ 'pop': {
9572
9662
  title: 'pop',
9573
9663
  category: 'Sequence',
9574
9664
  linkName: 'pop',
@@ -9591,7 +9681,7 @@ var sequenceReference = {
9591
9681
  '(pop [])',
9592
9682
  ],
9593
9683
  },
9594
- unshift: {
9684
+ 'unshift': {
9595
9685
  title: 'unshift',
9596
9686
  category: 'Sequence',
9597
9687
  linkName: 'unshift',
@@ -9620,7 +9710,7 @@ var sequenceReference = {
9620
9710
  "\n(def l [1 2 3])\n(unshift l 4)\nl",
9621
9711
  ],
9622
9712
  },
9623
- shift: {
9713
+ 'shift': {
9624
9714
  title: 'shift',
9625
9715
  category: 'Sequence',
9626
9716
  linkName: 'shift',
@@ -9644,7 +9734,7 @@ var sequenceReference = {
9644
9734
  '(shift [])',
9645
9735
  ],
9646
9736
  },
9647
- slice: {
9737
+ 'slice': {
9648
9738
  title: 'slice',
9649
9739
  category: 'Sequence',
9650
9740
  linkName: 'slice',
@@ -9678,7 +9768,7 @@ var sequenceReference = {
9678
9768
  '(slice [1 2 3 4 5] 2)',
9679
9769
  ],
9680
9770
  },
9681
- reductions: {
9771
+ 'reductions': {
9682
9772
  title: 'reductions',
9683
9773
  category: 'Sequence',
9684
9774
  linkName: 'reductions',
@@ -9710,7 +9800,7 @@ var sequenceReference = {
9710
9800
  "\n(reductions\n (fn [result value] (+ result (if (even? value) value 0)))\n 0\n [1 2 3 4 5 6 7 8 9])",
9711
9801
  ],
9712
9802
  },
9713
- reduce: {
9803
+ 'reduce': {
9714
9804
  title: 'reduce',
9715
9805
  category: 'Sequence',
9716
9806
  linkName: 'reduce',
@@ -9740,7 +9830,7 @@ var sequenceReference = {
9740
9830
  "\n(reduce\n (fn [result value] (+ result (if (even? value) value 0)))\n 0\n [1 2 3 4 5 6 7 8 9])",
9741
9831
  ],
9742
9832
  },
9743
- reduce_right: {
9833
+ 'reduce_right': {
9744
9834
  title: 'reduce_right',
9745
9835
  category: 'Sequence',
9746
9836
  linkName: 'reduce_right',
@@ -9768,7 +9858,7 @@ var sequenceReference = {
9768
9858
  '(reduce_right str [:A :B :C] "")',
9769
9859
  ],
9770
9860
  },
9771
- map: {
9861
+ 'map': {
9772
9862
  title: 'map',
9773
9863
  category: 'Sequence',
9774
9864
  linkName: 'map',
@@ -9793,7 +9883,7 @@ var sequenceReference = {
9793
9883
  '(map [1 2 3] inc)',
9794
9884
  ],
9795
9885
  },
9796
- filter: {
9886
+ 'filter': {
9797
9887
  title: 'filter',
9798
9888
  category: 'Sequence',
9799
9889
  linkName: 'filter',
@@ -9817,7 +9907,7 @@ var sequenceReference = {
9817
9907
  "\n(filter\n[5 10 15 20]\n (fn [x] (> x 10)))",
9818
9908
  ],
9819
9909
  },
9820
- position: {
9910
+ 'position': {
9821
9911
  title: 'position',
9822
9912
  category: 'Sequence',
9823
9913
  linkName: 'position',
@@ -9844,7 +9934,7 @@ var sequenceReference = {
9844
9934
  "\n(position\n (fn [x] (> x 100))\n nil)",
9845
9935
  ],
9846
9936
  },
9847
- index_of: {
9937
+ 'index_of': {
9848
9938
  title: 'index_of',
9849
9939
  category: 'Sequence',
9850
9940
  linkName: 'index_of',
@@ -9871,7 +9961,34 @@ var sequenceReference = {
9871
9961
  '(index_of nil 1)',
9872
9962
  ],
9873
9963
  },
9874
- some: {
9964
+ 'last_index_of': {
9965
+ title: 'last_index_of',
9966
+ category: 'Sequence',
9967
+ linkName: 'last_index_of',
9968
+ clojureDocs: null,
9969
+ returns: {
9970
+ type: ['number', 'null'],
9971
+ },
9972
+ args: {
9973
+ seq: {
9974
+ type: ['sequence', 'null'],
9975
+ },
9976
+ x: {
9977
+ type: 'any',
9978
+ },
9979
+ },
9980
+ variants: [
9981
+ { argumentNames: ['seq', 'x'] },
9982
+ ],
9983
+ description: 'Returns the last index of $x in $seq. If element is not present in $seq `nil` is returned.',
9984
+ examples: [
9985
+ '(last_index_of ["Albert" "Mojir" 160 [1 2]] "Mojir")',
9986
+ '(last_index_of [5 10 15 20] 15)',
9987
+ '(last_index_of [5 10 15 20] 1)',
9988
+ '(last_index_of nil 1)',
9989
+ ],
9990
+ },
9991
+ 'some': {
9875
9992
  title: 'some',
9876
9993
  category: 'Sequence',
9877
9994
  linkName: 'some',
@@ -9898,7 +10015,7 @@ var sequenceReference = {
9898
10015
  "\n(some\n nil\n (fn [x] (> x 10)))",
9899
10016
  ],
9900
10017
  },
9901
- reverse: {
10018
+ 'reverse': {
9902
10019
  title: 'reverse',
9903
10020
  category: 'Sequence',
9904
10021
  linkName: 'reverse',
@@ -9921,7 +10038,7 @@ var sequenceReference = {
9921
10038
  '(reverse nil)',
9922
10039
  ],
9923
10040
  },
9924
- first: {
10041
+ 'first': {
9925
10042
  title: 'first',
9926
10043
  category: 'Sequence',
9927
10044
  linkName: 'first',
@@ -9943,7 +10060,7 @@ var sequenceReference = {
9943
10060
  '(first nil)',
9944
10061
  ],
9945
10062
  },
9946
- second: {
10063
+ 'second': {
9947
10064
  title: 'second',
9948
10065
  category: 'Sequence',
9949
10066
  linkName: 'second',
@@ -9966,7 +10083,7 @@ var sequenceReference = {
9966
10083
  '(second nil)',
9967
10084
  ],
9968
10085
  },
9969
- last: {
10086
+ 'last': {
9970
10087
  title: 'last',
9971
10088
  category: 'Sequence',
9972
10089
  linkName: 'last',
@@ -9990,7 +10107,7 @@ var sequenceReference = {
9990
10107
  '(last nil)',
9991
10108
  ],
9992
10109
  },
9993
- rest: {
10110
+ 'rest': {
9994
10111
  title: 'rest',
9995
10112
  category: 'Sequence',
9996
10113
  linkName: 'rest',
@@ -10015,7 +10132,7 @@ var sequenceReference = {
10015
10132
  '(rest "")',
10016
10133
  ],
10017
10134
  },
10018
- nthrest: {
10135
+ 'nthrest': {
10019
10136
  title: 'nthrest',
10020
10137
  category: 'Sequence',
10021
10138
  linkName: 'nthrest',
@@ -10043,7 +10160,7 @@ var sequenceReference = {
10043
10160
  '(nthrest "" 0)',
10044
10161
  ],
10045
10162
  },
10046
- next: {
10163
+ 'next': {
10047
10164
  title: 'next',
10048
10165
  category: 'Sequence',
10049
10166
  linkName: 'next',
@@ -10068,7 +10185,7 @@ var sequenceReference = {
10068
10185
  '(next "")',
10069
10186
  ],
10070
10187
  },
10071
- nthnext: {
10188
+ 'nthnext': {
10072
10189
  title: 'nthnext',
10073
10190
  category: 'Sequence',
10074
10191
  linkName: 'nthnext',
@@ -10096,7 +10213,7 @@ var sequenceReference = {
10096
10213
  '(nthnext "" 0)',
10097
10214
  ],
10098
10215
  },
10099
- take: {
10216
+ 'take': {
10100
10217
  title: 'take',
10101
10218
  category: 'Sequence',
10102
10219
  linkName: 'take',
@@ -10122,7 +10239,7 @@ var sequenceReference = {
10122
10239
  '(take 50 "Albert")',
10123
10240
  ],
10124
10241
  },
10125
- take_last: {
10242
+ 'take_last': {
10126
10243
  title: 'take_last',
10127
10244
  category: 'Sequence',
10128
10245
  linkName: 'take_last',
@@ -10146,7 +10263,7 @@ var sequenceReference = {
10146
10263
  '(take_last 0 [1 2 3 4 5])',
10147
10264
  ],
10148
10265
  },
10149
- take_while: {
10266
+ 'take_while': {
10150
10267
  title: 'take_while',
10151
10268
  category: 'Sequence',
10152
10269
  linkName: 'take_while',
@@ -10170,7 +10287,7 @@ var sequenceReference = {
10170
10287
  "\n(take_while\n [1 2 3 2 1]\n (fn [x] (> x 3)))",
10171
10288
  ],
10172
10289
  },
10173
- drop: {
10290
+ 'drop': {
10174
10291
  title: 'drop',
10175
10292
  category: 'Sequence',
10176
10293
  linkName: 'drop',
@@ -10196,7 +10313,7 @@ var sequenceReference = {
10196
10313
  '(drop "Albert" 50)',
10197
10314
  ],
10198
10315
  },
10199
- drop_last: {
10316
+ 'drop_last': {
10200
10317
  title: 'drop_last',
10201
10318
  category: 'Sequence',
10202
10319
  linkName: 'drop_last',
@@ -10220,7 +10337,7 @@ var sequenceReference = {
10220
10337
  '(drop_last [1 2 3 4 5] 0)',
10221
10338
  ],
10222
10339
  },
10223
- drop_while: {
10340
+ 'drop_while': {
10224
10341
  title: 'drop_while',
10225
10342
  category: 'Sequence',
10226
10343
  linkName: 'drop_while',
@@ -10244,7 +10361,7 @@ var sequenceReference = {
10244
10361
  "\n(drop_while\n [1 2 3 2 1]\n (fn [x] (> x 3)))",
10245
10362
  ],
10246
10363
  },
10247
- sort: {
10364
+ 'sort': {
10248
10365
  title: 'sort',
10249
10366
  category: 'Sequence',
10250
10367
  linkName: 'sort',
@@ -10271,7 +10388,7 @@ var sequenceReference = {
10271
10388
  "\n(sort\n [3 1 2]\n (fn [a b] (cond (> a b) -1 (< a b) 1 true -1)))",
10272
10389
  ],
10273
10390
  },
10274
- sort_by: {
10391
+ 'sort_by': {
10275
10392
  title: 'sort_by',
10276
10393
  category: 'Sequence',
10277
10394
  linkName: 'sort_by',
@@ -10300,7 +10417,7 @@ var sequenceReference = {
10300
10417
  '(sort_by "Albert" lower_case #(compare %2 %1))',
10301
10418
  ],
10302
10419
  },
10303
- distinct: {
10420
+ 'distinct': {
10304
10421
  title: 'distinct',
10305
10422
  category: 'Sequence',
10306
10423
  linkName: 'distinct',
@@ -10323,7 +10440,7 @@ var sequenceReference = {
10323
10440
  '(distinct "")',
10324
10441
  ],
10325
10442
  },
10326
- remove: {
10443
+ 'remove': {
10327
10444
  title: 'remove',
10328
10445
  category: 'Sequence',
10329
10446
  linkName: 'remove',
@@ -10347,7 +10464,7 @@ var sequenceReference = {
10347
10464
  '(remove "Albert Mojir" #(has? "aoueiyAOUEIY" %1))',
10348
10465
  ],
10349
10466
  },
10350
- remove_at: {
10467
+ 'remove_at': {
10351
10468
  title: 'remove_at',
10352
10469
  category: 'Sequence',
10353
10470
  linkName: 'remove_at',
@@ -10373,7 +10490,7 @@ var sequenceReference = {
10373
10490
  '(remove_at "Albert Mojir" 6)',
10374
10491
  ],
10375
10492
  },
10376
- split_at: {
10493
+ 'split_at': {
10377
10494
  title: 'split_at',
10378
10495
  category: 'Sequence',
10379
10496
  linkName: 'split_at',
@@ -10398,7 +10515,7 @@ var sequenceReference = {
10398
10515
  '(split_at "Albert" 2)',
10399
10516
  ],
10400
10517
  },
10401
- split_with: {
10518
+ 'split_with': {
10402
10519
  title: 'split_with',
10403
10520
  category: 'Sequence',
10404
10521
  linkName: 'split_with',
@@ -10423,7 +10540,7 @@ var sequenceReference = {
10423
10540
  '(split_with "Albert" #(<= %1 :Z))',
10424
10541
  ],
10425
10542
  },
10426
- frequencies: {
10543
+ 'frequencies': {
10427
10544
  title: 'frequencies',
10428
10545
  category: 'Sequence',
10429
10546
  linkName: 'frequencies',
@@ -10444,7 +10561,7 @@ var sequenceReference = {
10444
10561
  '(frequencies "Pneumonoultramicroscopicsilicovolcanoconiosis")',
10445
10562
  ],
10446
10563
  },
10447
- group_by: {
10564
+ 'group_by': {
10448
10565
  title: 'group_by',
10449
10566
  category: 'Sequence',
10450
10567
  linkName: 'group_by',
@@ -10468,7 +10585,7 @@ var sequenceReference = {
10468
10585
  '(group_by "Albert Mojir" (fn [char] (if (has? "aoueiAOUEI" char) "vowel" "other")))',
10469
10586
  ],
10470
10587
  },
10471
- partition: {
10588
+ 'partition': {
10472
10589
  title: 'partition',
10473
10590
  category: 'Sequence',
10474
10591
  linkName: 'partition',
@@ -10513,7 +10630,7 @@ var sequenceReference = {
10513
10630
  '(def foo [5 6 7 8]) (partition foo 2 1 foo)',
10514
10631
  ],
10515
10632
  },
10516
- partition_all: {
10633
+ 'partition_all': {
10517
10634
  title: 'partition_all',
10518
10635
  category: 'Sequence',
10519
10636
  linkName: 'partition_all',
@@ -10542,7 +10659,7 @@ var sequenceReference = {
10542
10659
  '(partition_all [0 1 2 3 4 5 6 7 8 9] 2 4)',
10543
10660
  ],
10544
10661
  },
10545
- partition_by: {
10662
+ 'partition_by': {
10546
10663
  title: 'partition_by',
10547
10664
  category: 'Sequence',
10548
10665
  linkName: 'partition_by',
@@ -10567,6 +10684,114 @@ var sequenceReference = {
10567
10684
  '(partition_by "Leeeeeerrroyyy" identity)',
10568
10685
  ],
10569
10686
  },
10687
+ 'starts_with?': {
10688
+ title: 'starts_with?',
10689
+ category: 'Sequence',
10690
+ linkName: 'starts_with-question',
10691
+ clojureDocs: null,
10692
+ returns: {
10693
+ type: 'boolean',
10694
+ },
10695
+ args: {
10696
+ seq: {
10697
+ type: 'sequence',
10698
+ },
10699
+ prefix: {
10700
+ type: 'sequence',
10701
+ },
10702
+ },
10703
+ variants: [
10704
+ { argumentNames: ['seq', 'prefix'] },
10705
+ ],
10706
+ description: 'Returns `true` if $seq starts with $prefix, otherwise `false`.',
10707
+ examples: [
10708
+ '(starts_with? [1 2 3 4 5] 1)',
10709
+ '(starts_with? [1 2 3 4 5] [1])',
10710
+ '(starts_with? "Albert" "Al")',
10711
+ '(starts_with? "Albert" "al")',
10712
+ ],
10713
+ },
10714
+ 'ends_with?': {
10715
+ title: 'ends_with?',
10716
+ category: 'Sequence',
10717
+ linkName: 'ends_with-question',
10718
+ clojureDocs: null,
10719
+ returns: {
10720
+ type: 'boolean',
10721
+ },
10722
+ args: {
10723
+ seq: {
10724
+ type: 'sequence',
10725
+ },
10726
+ suffix: {
10727
+ type: 'sequence',
10728
+ },
10729
+ },
10730
+ variants: [
10731
+ { argumentNames: ['seq', 'suffix'] },
10732
+ ],
10733
+ description: 'Returns `true` if $seq ends with $suffix, otherwise `false`.',
10734
+ examples: [
10735
+ '(ends_with? [1 2 3 4 5] 5)',
10736
+ '(ends_with? [1 2 3 4 5] [5])',
10737
+ '(ends_with? "Albert" "rt")',
10738
+ '(ends_with? "Albert" "RT")',
10739
+ ],
10740
+ },
10741
+ 'interleave': {
10742
+ title: 'interleave',
10743
+ category: 'Sequence',
10744
+ linkName: 'interleave',
10745
+ clojureDocs: null,
10746
+ returns: {
10747
+ type: 'sequence',
10748
+ },
10749
+ args: {
10750
+ seqs: {
10751
+ type: 'sequence',
10752
+ array: true,
10753
+ },
10754
+ },
10755
+ variants: [
10756
+ { argumentNames: ['seqs'] },
10757
+ ],
10758
+ 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.',
10759
+ examples: [
10760
+ '(interleave [1 2 3] [4 5 6])',
10761
+ '(interleave [1 2 3] [4 5 6] [7 8 9])',
10762
+ '(interleave [1 2 3] [4 5 6] [7 8])',
10763
+ '(interleave [1 2 3] [4 5 6] [7])',
10764
+ '(interleave [1 2 3] [4 5 6] [])',
10765
+ '(interleave [1 2 3] [])',
10766
+ '(interleave [])',
10767
+ ],
10768
+ },
10769
+ 'interpose': {
10770
+ title: 'interpose',
10771
+ category: 'Sequence',
10772
+ linkName: 'interpose',
10773
+ clojureDocs: null,
10774
+ returns: {
10775
+ type: 'sequence',
10776
+ },
10777
+ args: {
10778
+ seq: {
10779
+ type: 'sequence',
10780
+ },
10781
+ separator: {
10782
+ type: 'any',
10783
+ },
10784
+ },
10785
+ variants: [
10786
+ { argumentNames: ['seq', 'separator'] },
10787
+ ],
10788
+ description: 'Returns a sequence of the elements of $seq separated by $separator. If $seq is a string, the separator must be a string.',
10789
+ examples: [
10790
+ '(interpose :a [1 2 3 4 5])',
10791
+ '(interpose " " ["Albert" "Mojir" "Nina"])',
10792
+ '(interpose "." "Albert")',
10793
+ ],
10794
+ },
10570
10795
  };
10571
10796
 
10572
10797
  var mathReference = {
@@ -13161,12 +13386,12 @@ var regularExpressionReference = {
13161
13386
  ],
13162
13387
  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.",
13163
13388
  examples: [
13164
- '(match (regexp "^\\s*(.*)$") " A string")',
13165
- '(match #"albert"i "My name is Albert")',
13166
- '(match #"albert"i "My name is Ben")',
13167
- '(match #"albert"i nil)',
13168
- '(match #"albert"i 1)',
13169
- '(match #"albert"i {})',
13389
+ '(match " A string" (regexp "^\\s*(.*)$"))',
13390
+ '(match "My name is Albert" #"albert"i)',
13391
+ '(match "My name is Ben" #"albert"i)',
13392
+ '(match nil #"albert"i)',
13393
+ '(match 1 #"albert"i)',
13394
+ '(match {} #"albert"i)',
13170
13395
  ],
13171
13396
  },
13172
13397
  replace: {
@@ -13183,7 +13408,7 @@ var regularExpressionReference = {
13183
13408
  type: 'string',
13184
13409
  },
13185
13410
  r: {
13186
- type: 'regexp',
13411
+ type: ['regexp', 'string'],
13187
13412
  },
13188
13413
  x: {
13189
13414
  type: 'string',
@@ -13192,13 +13417,49 @@ var regularExpressionReference = {
13192
13417
  variants: [
13193
13418
  { argumentNames: ['s', 'r', 'x'] },
13194
13419
  ],
13195
- description: 'Returns a new string with some or all matches of regular expression $r replaced by $x.',
13420
+ description: 'Returns a new string with first match of regular expression $r replaced by $x.',
13196
13421
  examples: [
13197
- '(replace "Duck" (regexp :u) :i)',
13422
+ '(replace "Duck duck" "u" :i)',
13423
+ '(replace "Duck duck" (regexp :u) :i)',
13424
+ '(replace "abcABC" (regexp :a "i") "-")',
13198
13425
  '(replace "abcABC" (regexp :a "gi") "-")',
13426
+ '(replace "abcABC" #"a"i "-")',
13199
13427
  '(replace "abcABC" #"a"gi "-")',
13200
13428
  ],
13201
13429
  },
13430
+ replace_all: {
13431
+ title: 'replace_all',
13432
+ category: 'Regular expression',
13433
+ linkName: 'replace_all',
13434
+ clojureDocs: null,
13435
+ returns: {
13436
+ type: 'any',
13437
+ array: true,
13438
+ },
13439
+ args: {
13440
+ s: {
13441
+ type: 'string',
13442
+ },
13443
+ r: {
13444
+ type: ['regexp', 'string'],
13445
+ },
13446
+ x: {
13447
+ type: 'string',
13448
+ },
13449
+ },
13450
+ variants: [
13451
+ { argumentNames: ['s', 'r', 'x'] },
13452
+ ],
13453
+ description: 'Returns a new string with all matches of regular expression $r replaced by $x.',
13454
+ examples: [
13455
+ '(replace_all "Duck duck" "u" :i)',
13456
+ '(replace_all "Duck duck" (regexp :u) :i)',
13457
+ '(replace_all "abcABC" (regexp :a "i") "-")',
13458
+ '(replace_all "abcABC" (regexp :a "gi") "-")',
13459
+ '(replace_all "abcABC" #"a"i "-")',
13460
+ '(replace_all "abcABC" #"a"gi "-")',
13461
+ ],
13462
+ },
13202
13463
  };
13203
13464
 
13204
13465
  var specialExpressionsReference = {
@@ -13277,32 +13538,6 @@ var specialExpressionsReference = {
13277
13538
  '(def a (object :x 10 :y true :z "A string"))',
13278
13539
  ],
13279
13540
  },
13280
- 'defs': {
13281
- title: 'defs',
13282
- category: 'Special expression',
13283
- linkName: 'defs',
13284
- clojureDocs: null,
13285
- returns: {
13286
- type: 'any',
13287
- },
13288
- args: {
13289
- name: {
13290
- type: '*expression',
13291
- },
13292
- value: {
13293
- type: '*expression',
13294
- },
13295
- },
13296
- variants: [
13297
- { argumentNames: ['name', 'value'] },
13298
- ],
13299
- 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.",
13300
- examples: [
13301
- '(defs :a :b)',
13302
- "\n(defs (str :a :1) (object :x 10 :y true :z \"A string\"))\na1",
13303
- "\n(defs :a :b)\n(defs a :c)\nb",
13304
- ],
13305
- },
13306
13541
  'let': {
13307
13542
  title: 'let',
13308
13543
  category: 'Special expression',
@@ -13376,36 +13611,6 @@ var specialExpressionsReference = {
13376
13611
  "\n(defn sumOfSquares [& s]\n (apply\n +\n (map\n (fn [x] (* x x))\n s)))\n(sumOfSquares 1 2 3 4 5)",
13377
13612
  ],
13378
13613
  },
13379
- 'defns': {
13380
- title: 'defns',
13381
- category: 'Special expression',
13382
- linkName: 'defns',
13383
- clojureDocs: null,
13384
- returns: {
13385
- type: 'function',
13386
- },
13387
- args: {
13388
- name: {
13389
- type: '*expression',
13390
- },
13391
- args: {
13392
- type: '*arguments',
13393
- },
13394
- expressions: {
13395
- type: '*expression',
13396
- rest: true,
13397
- },
13398
- },
13399
- variants: [
13400
- { argumentNames: ['name', 'args', 'expressions'] },
13401
- ],
13402
- 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.',
13403
- examples: [
13404
- "\n(defns \"hyp\" [a b]\n (sqrt\n (+\n (* a a)\n (* b b))))\nhyp",
13405
- "\n(defns\n (str :h :y :p)\n [a b]\n (sqrt\n (+\n (* a a)\n (* b b))))\n(hyp 3 4)",
13406
- "\n(defns \"sumOfSquares\" [& s]\n (apply\n +\n (map\n (fn [x] (* x x))\n s)))\n(sumOfSquares 1 2 3 4 5)",
13407
- ],
13408
- },
13409
13614
  'try': {
13410
13615
  title: 'try',
13411
13616
  category: 'Special expression',
@@ -14074,6 +14279,30 @@ var stringReference = {
14074
14279
  '(map number (split "0123456789" "" 5))',
14075
14280
  ],
14076
14281
  },
14282
+ 'split_lines': {
14283
+ title: 'split_lines',
14284
+ category: 'String',
14285
+ linkName: 'split_lines',
14286
+ clojureDocs: null,
14287
+ returns: {
14288
+ type: 'string',
14289
+ },
14290
+ args: {
14291
+ s: {
14292
+ type: 'string',
14293
+ },
14294
+ },
14295
+ variants: [
14296
+ { argumentNames: ['s'] },
14297
+ ],
14298
+ description: 'Divides $s into an array of substrings, each representing a line.',
14299
+ examples: [
14300
+ '(split_lines "Albert\nMojir\n")',
14301
+ '(split_lines "Albert\n\nMojir")',
14302
+ '(split_lines "Albert\nMojir\n\n")',
14303
+ '(split_lines "")',
14304
+ ],
14305
+ },
14077
14306
  'template': {
14078
14307
  title: 'template',
14079
14308
  category: 'String',
@@ -14290,6 +14519,55 @@ var stringReference = {
14290
14519
  '(++)',
14291
14520
  ],
14292
14521
  },
14522
+ 'capitalize': {
14523
+ title: 'capitalize',
14524
+ category: 'String',
14525
+ linkName: 'capitalize',
14526
+ clojureDocs: 'clojure.string/capitalize',
14527
+ returns: {
14528
+ type: 'string',
14529
+ },
14530
+ args: {
14531
+ s: {
14532
+ type: 'string',
14533
+ },
14534
+ },
14535
+ variants: [
14536
+ { argumentNames: ['s'] },
14537
+ ],
14538
+ description: 'Returns $s with the first character converted to uppercase and the rest to lowercase.',
14539
+ examples: [
14540
+ '(capitalize "albert")',
14541
+ '(capitalize "ALBERT")',
14542
+ '(capitalize "aLBERT")',
14543
+ '(capitalize "")',
14544
+ ],
14545
+ },
14546
+ 'blank?': {
14547
+ title: 'blank?',
14548
+ category: 'String',
14549
+ linkName: 'blank-question',
14550
+ clojureDocs: 'clojure.string/blank_q',
14551
+ returns: {
14552
+ type: 'boolean',
14553
+ },
14554
+ args: {
14555
+ s: {
14556
+ type: ['string', 'null'],
14557
+ },
14558
+ },
14559
+ variants: [
14560
+ { argumentNames: ['s'] },
14561
+ ],
14562
+ description: 'Returns true if $s is null or only contains whitespace characters.',
14563
+ examples: [
14564
+ '(blank? "")',
14565
+ '(blank? null)',
14566
+ '(blank? "\n")',
14567
+ '(blank? " ")',
14568
+ '(blank? ".")',
14569
+ ],
14570
+ },
14293
14571
  };
14294
14572
 
14295
14573
  var bitwiseReference = { '<<': {
@@ -14853,6 +15131,7 @@ var api = {
14853
15131
  'filter',
14854
15132
  'position',
14855
15133
  'index_of',
15134
+ 'last_index_of',
14856
15135
  'some',
14857
15136
  'reverse',
14858
15137
  'first',
@@ -14880,6 +15159,10 @@ var api = {
14880
15159
  'partition',
14881
15160
  'partition_all',
14882
15161
  'partition_by',
15162
+ 'starts_with?',
15163
+ 'ends_with?',
15164
+ 'interleave',
15165
+ 'interpose',
14883
15166
  ],
14884
15167
  math: [
14885
15168
  '+',
@@ -15000,16 +15283,15 @@ var api = {
15000
15283
  'regexp',
15001
15284
  'match',
15002
15285
  'replace',
15286
+ 'replace_all',
15003
15287
  ],
15004
15288
  specialExpressions: [
15005
15289
  '&&',
15006
15290
  '||',
15007
15291
  'def',
15008
- 'defs',
15009
15292
  'let',
15010
15293
  'fn',
15011
15294
  'defn',
15012
- 'defns',
15013
15295
  'try',
15014
15296
  'throw',
15015
15297
  'if',
@@ -15038,6 +15320,7 @@ var api = {
15038
15320
  'pad_left',
15039
15321
  'pad_right',
15040
15322
  'split',
15323
+ 'split_lines',
15041
15324
  'template',
15042
15325
  'to_char_code',
15043
15326
  'from_char_code',
@@ -15047,6 +15330,8 @@ var api = {
15047
15330
  'decode_uri_component',
15048
15331
  'join',
15049
15332
  '++',
15333
+ 'capitalize',
15334
+ 'blank?',
15050
15335
  ],
15051
15336
  bitwise: [
15052
15337
  '<<',