@mojir/lits 2.0.16 → 2.0.18

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