1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
[
  {
    "title": "Arithmetics",
    "functions": [
      {
        "name": "abs",
        "arguments": ["x"],
        "returns": "number",
        "help": "Return absolute value of number."
      },
      {
        "name": "add",
        "arguments": ["x", "y", "*n"],
        "returns": "number",
        "help": "Add two or more numbers."
      },
      {
        "name": "argmax",
        "arguments": ["numbers", "labels?"],
        "returns": "any",
        "help": "Return the index or label of the largest number in the list."
      },
      {
        "name": "argmin",
        "arguments": ["numbers", "labels?"],
        "returns": "any",
        "help": "Return the index or label of the smallest number in the list."
      },
      {
        "name": "ceil",
        "arguments": ["x"],
        "returns": "number",
        "help": "Return the smallest integer greater than or equal to x."
      },
      {
        "name": "div",
        "arguments": ["x", "y", "*n"],
        "returns": "number",
        "help": "Divide two or more numbers."
      },
      {
        "name": "idiv",
        "arguments": ["x", "y"],
        "returns": "number",
        "help": "Integer division of two numbers."
      },
      {
        "name": "floor",
        "arguments": ["x"],
        "returns": "number",
        "help": "Return the smallest integer lower than or equal to x."
      },
      {
        "name": "log",
        "arguments": ["x"],
        "returns": "number",
        "help": "Return the natural logarithm of x."
      },
      {
        "name": "max",
        "arguments": ["x", "y", "*n"],
        "alternatives": [
          ["list_of_numbers"]
        ],
        "returns": "number",
        "help": "Return the maximum number."
      },
      {
        "name": "min",
        "arguments": ["x", "y", "*n"],
        "alternatives": [
          ["list_of_numbers"]
        ],
        "returns": "number",
        "help": "Return the minimum number."
      },
      {
        "name": "mod",
        "arguments": ["x", "y"],
        "returns": "number",
        "help": "Return the remainder of x divided by y."
      },
      {
        "name": "mul",
        "arguments": ["x", "y", "*n"],
        "returns": "number",
        "help": "Multiply two or more numbers."
      },
      {
        "name": "neg",
        "arguments": ["x"],
        "returns": "number",
        "help": "Return -x."
      },
      {
        "name": "pow",
        "arguments": ["x", "y"],
        "returns": "number",
        "help": "Raise x to the power of y."
      },
      {
        "name": "round",
        "arguments": ["x"],
        "returns": "number",
        "help": "Return x rounded to the nearest integer."
      },
      {
        "name": "sqrt",
        "arguments": ["x"],
        "returns": "number",
        "help": "Return the square root of x."
      },
      {
        "name": "sub",
        "arguments": ["x", "y", "*n"],
        "returns": "number",
        "help": "Subtract two or more numbers."
      },
      {
        "name": "trunc",
        "arguments": ["x"],
        "returns": "number",
        "help": "Truncate the number by removing its decimal part."
      }
    ]
  },
  {
    "title": "Boolean operations & branching",
    "functions": [
      {
        "name": "and",
        "arguments": ["a", "b", "*n"],
        "returns": "T",
        "help": "Perform boolean AND operation on two or more values."
      },
      {
        "name": "if",
        "arguments": ["cond", "then", "else?"],
        "returns": "T",
        "help": "Evaluate condition and switch to correct branch."
      },
      {
        "name": "unless",
        "arguments": ["cond", "then", "else?"],
        "returns": "T",
        "help": "Shorthand for `if(not(cond), then, else?)`"
      },
      {
        "name": "not",
        "arguments": ["a"],
        "returns": "bool",
        "help": "Perform boolean NOT operation."
      },
      {
        "name": "or",
        "arguments": ["a", "b", "*n"],
        "returns": "T",
        "help": "Perform boolean OR operation on two or more values."
      }
    ]
  },
  {
    "title": "Comparison",
    "functions": [
      {
        "name": "eq",
        "arguments": ["s1", "s2"],
        "returns": "bool",
        "help": "Test string or sequence equality."
      },
      {
        "name": "ne",
        "arguments": ["s1", "s2"],
        "returns": "bool",
        "help": "Test string or sequence inequality."
      },
      {
        "name": "gt",
        "arguments": ["s1", "s2"],
        "returns": "bool",
        "help": "Test string or sequence s1 > s2."
      },
      {
        "name": "ge",
        "arguments": ["s1", "s2"],
        "returns": "bool",
        "help": "Test string or sequence s1 >= s2."
      },
      {
        "name": "lt",
        "arguments": ["s1", "s2"],
        "returns": "bool",
        "help": "Test string or sequence s1 < s2."
      },
      {
        "name": "le",
        "arguments": ["s1", "s2"],
        "returns": "bool",
        "help": "Test string or sequence s1 <= s2."
      }
    ]
  },
  {
    "title": "String & sequence helpers",
    "functions": [
      {
        "name": "compact",
        "arguments": ["list"],
        "returns": "list",
        "help": "Drop all falsey values from given list."
      },
      {
        "name": "concat",
        "arguments": ["string", "*strings"],
        "returns": "string",
        "help": "Concatenate given strings into a single one."
      },
      {
        "name": "contains",
        "arguments": ["seq", "subseq"],
        "returns": "bool",
        "help": "Find if subseq can be found in seq. Subseq can be a regular expression."
      },
      {
        "name": "count",
        "arguments": ["seq", "pattern"],
        "returns": "int",
        "help": "Count number of times pattern appear in seq. Pattern can be a regular expression."
      },
      {
        "name": "endswith",
        "arguments": ["string", "pattern"],
        "returns": "bool",
        "help": "Test if string ends with pattern."
      },
      {
        "name": "escape_regex",
        "arguments": ["string"],
        "returns": "string",
        "help": "Escape a string so it can be used safely in a regular expression."
      },
      {
        "name": "first",
        "arguments": ["seq"],
        "returns": "T",
        "help": "Get first element of sequence."
      },
      {
        "name": "fmt",
        "arguments": ["string", "*replacements"],
        "alternatives": [
          ["string", "map"]
        ],
        "returns": "string",
        "help": "Format a string by replacing \"{}\" occurrences by subsequent arguments.\n\nExample: `fmt(\"Hello {} {}\", name, surname)` will replace the first \"{}\" by the value of the name column, then the second one by the value of the surname column.\n\nCan also be given a substitution map like so:\n`fmt(\"Hello {name}\", {name: \"John\"})`."
      },
      {
        "name": "get",
        "arguments": ["target", "index_or_key", "default?"],
        "returns": "T",
        "help": "Get nth element of sequence (can use negative indexing), or key of mapping. Returns nothing if index or key is not found or alternatively the provided default value."
      },
      {
        "name": "join",
        "arguments": ["seq", "sep"],
        "returns": "string",
        "help": "Join sequence by separator."
      },
      {
        "name": "last",
        "arguments": ["seq"],
        "returns": "T",
        "help": "Get last element of sequence."
      },
      {
        "name": "len",
        "arguments": ["seq"],
        "returns": "int",
        "help": "Get length of sequence."
      },
      {
        "name": "ltrim",
        "arguments": ["string", "pattern?"],
        "returns": "string",
        "help": "Trim string of leading whitespace or provided characters."
      },
      {
        "name": "lower",
        "arguments": ["string"],
        "returns": "string",
        "help": "Lowercase string."
      },
      {
        "name": "match",
        "arguments": ["string", "pattern", "group"],
        "returns": "string",
        "help": "Return a regex pattern match on the string."
      },
      {
        "name": "numfmt",
        "arguments": ["number"],
        "returns": "string",
        "help": "Format a number with thousands separator and proper significance."
      },
      {
        "name": "replace",
        "arguments": ["string", "pattern", "replacement"],
        "returns": "string",
        "help": "Replace pattern in string. Can use a regex."
      },
      {
        "name": "rtrim",
        "arguments": ["string", "pattern?"],
        "returns": "string",
        "help": "Trim string of trailing whitespace or provided characters."
      },
      {
        "name": "slice",
        "arguments": ["seq", "start", "end?"],
        "returns": "seq",
        "help": "Return slice of sequence."
      },
      {
        "name": "split",
        "arguments": ["string", "sep", "max?"],
        "returns": "list",
        "help": "Split a string by separator."
      },
      {
        "name": "startswith",
        "arguments": ["string", "pattern"],
        "returns": "bool",
        "help": "Test if string starts with pattern."
      },
      {
        "name": "trim",
        "arguments": ["string", "pattern?"],
        "returns": "string",
        "help": "Trim string of leading & trailing whitespace or provided characters."
      },
      {
        "name": "upper",
        "arguments": ["string"],
        "returns": "string",
        "help": "Uppercase string."
      }
    ]
  },
  {
    "title": "Dates",
    "functions": [
      {
        "name": "datetime",
        "arguments": ["string", "format=?", "timezone=?"],
        "returns": "datetime",
        "help": "Parse a string as a datetime according to format and timezone. If no format is provided, string is parsed as ISO 8601 date format. Default timezone is the system timezone.\nhttps://docs.rs/jiff/latest/jiff/fmt/strtime/index.html#conversion-specifications"
      },
      {
        "name": "strftime",
        "arguments": ["target", "format"],
        "returns": "string",
        "help": "Format target (a time in ISO 8601 format, or the result of datetime() function) according to format."
      },
      {
        "name": "timestamp",
        "arguments": ["number"],
        "returns": "datetime",
        "help": "Parse a number as a POSIX timestamp in seconds (nb of seconds since 1970-01-01 00:00:00 UTC), and convert it to a datetime in local time."
      },
      {
        "name": "timestamp_ms",
        "arguments": ["number"],
        "returns": "datetime",
        "help": "Parse a number as a POSIX timestamp in milliseconds (nb of milliseconds since 1970-01-01 00:00:00 UTC), and convert it to a datetime in local time."
      },
      {
        "name": "to_timezone",
        "arguments": ["target", "timezone_in", "timezone_out"],
        "returns": "datetime",
        "help": "Parse target (a time in ISO 8601 format, or the result of datetime() function) in timezone_in, and convert it to timezone_out."
      },
      {
        "name": "to_local_timezone",
        "arguments": ["target"],
        "returns": "datetime",
        "help": "Parse target (a time in ISO 8601 format, or the result of datetime() function) in timezone_in, and convert it to the system's local timezone."
      },
      {
        "name": "year_month_day",
        "aliases": ["ymd"],
        "arguments": ["target"],
        "returns": "string",
        "help": "Extract the year, month and day of a datetime. If the input is a string, first parse it into datetime, and then extract the year, month and day.\nEquivalent to `strftime(string, format=\"%Y-%m-%d\")`."
      },
      {
        "name": "month_day",
        "arguments": ["target"],
        "returns": "string",
        "help": "Extract the month and day of a datetime. If the input is a string, first parse it into datetime, and then extract the month and day.\nEquivalent to `strftime(string, format=\"%m-%d\")`."
      },
      {
        "name": "month",
        "arguments": ["target"],
        "returns": "string",
        "help": "Extract the month of a datetime. If the input is a string, first parse it into datetime, and then extract the month.\nEquivalent to `strftime(string, format=\"%m\")`."
      },
      {
        "name": "year",
        "arguments": ["target"],
        "returns": "string",
        "help": "Extract the year of a datetime. If the input is a string, first parse it into datetime, and then extract the year.\nEquivalent to `strftime(string, format=\"%Y\")`."
      },
      {
        "name": "year_month",
        "aliases": ["ym"],
        "arguments": ["target"],
        "returns": "string",
        "help": "Extract the year and month of a datetime. If the input is a string, first parse it into datetime, and then extract the year and month.\nEquivalent to `strftime(string, format=\"%Y-%m\")`."
      }
    ]
  },
  {
    "title": "Higher-order functions",
    "functions": [
      {
        "name": "filter",
        "arguments": ["list", "lambda"],
        "returns": "list",
        "help": "Return a list containing only elements for which given lambda returned true."
      },
      {
        "name": "map",
        "arguments": ["list", "lambda"],
        "returns": "list",
        "help": "Return a list with elements transformed by given lambda."
      }
    ]
  },
  {
    "title": "Urls & web-related",
    "functions": [
      {
        "name": "html_unescape",
        "arguments": ["string"],
        "returns": "string",
        "help": "Unescape given HTML string by converting HTML entities back to normal text."
      },
      {
        "name": "lru",
        "arguments": ["string"],
        "returns": "string",
        "help": "Convert the given URL to LRU format.\nFor more info, read this: https://github.com/medialab/ural#about-lrus"
      },
      {
        "name": "parse_dataurl",
        "arguments": ["string"],
        "returns": "[string, bytes]",
        "help": "Parse the given data url and return its mime type and decoded binary data."
      },
      {
        "name": "urljoin",
        "arguments": ["string", "string"],
        "returns": "string",
        "help": "Join an url with the given addendum."
      }
    ]
  },
  {
    "title": "Collections (list of maps) functions",
    "functions": [
      {
        "name": "index_by",
        "arguments": ["collection", "key"],
        "returns": "map",
        "help": "Create a map from item key to collection item."
      }
    ]
  },
  {
    "title": "Map functions",
    "functions": [
      {
        "name": "keys",
        "arguments": ["map"],
        "returns": "[string]",
        "help": "Return a list of the map's keys."
      },
      {
        "name": "values",
        "arguments": ["map"],
        "returns": "[T]",
        "help": "Return a list of the map's values."
      }
    ]
  },
  {
    "title": "Aggregation functions",
    "functions": [
      {
        "name": "mean",
        "arguments": ["numbers"],
        "returns": "number?",
        "help": "Return the mean of the given numbers."
      },
      {
        "name": "sum",
        "arguments": ["numbers"],
        "returns": "number?",
        "help": "Return the sum of the given numbers, or nothing if the sum overflowed."
      }
    ]
  },
  {
    "title": "Fuzzy matching & information retrieval",
    "functions": [
      {
        "name": "fingerprint",
        "arguments": ["string"],
        "returns": "string",
        "help": "Fingerprint a string by normalizing characters, re-ordering and deduplicating its word tokens before re-joining them by spaces."
      },
      {
        "name": "carry_stemmer",
        "arguments": ["string"],
        "returns": "string",
        "help": "Apply the \"Carry\" stemmer targeting the French language."
      },
      {
        "name": "s_stemmer",
        "arguments": ["string"],
        "returns": "string",
        "help": "Apply a very simple stemmer removing common plural inflexions in some languages."
      },
      {
        "name": "unidecode",
        "arguments": ["string"],
        "returns": "string",
        "help": "Convert string to ascii as well as possible."
      }
    ]
  },
  {
    "title": "Utils",
    "functions": [
      {
        "name": "coalesce",
        "arguments": ["*args"],
        "returns": "T",
        "help": "Return first truthy value."
      },
      {
        "name": "col",
        "arguments": ["name_or_pos", "nth?"],
        "returns": "bytes",
        "help": "Return value of cell for given column, by name, by position or by name & nth, in case of duplicate header names."
      },
      {
        "name": "cols",
        "arguments": ["from_name_or_pos?", "to_name_or_pos?"],
        "returns": "list[bytes]",
        "help": "Return list of cell values from the given colum by name or position to another given column by name or position, inclusive. Can also be called with a single argument to take a slice from the given column to the end, or no argument at all to take all columns."
      },
      {
        "name": "err",
        "arguments": ["msg"],
        "returns": "error",
        "help": "Make the expression return a custom error."
      },
      {
        "name": "float",
        "arguments": ["any"],
        "returns": "float",
        "help": "Cast value as float and raise an error if impossible."
      },
      {
        "name": "headers",
        "arguments": ["from_name_or_pos?", "to_name_or_pos?"],
        "returns": "list[string]",
        "help": "Return list of header names from the given colum by name or position to another given column by name or position, inclusive. Can also be called with a single argument to take a slice from the given column to the end, or no argument at all to return all headers."
      },
      {
        "name": "index",
        "arguments": [],
        "returns": "int?",
        "help": "Return the row's index, if applicable."
      },
      {
        "name": "int",
        "arguments": ["any"],
        "returns": "int",
        "help": "Cast value as int and raise an error if impossible."
      },
      {
        "name": "mime_ext",
        "arguments": ["string"],
        "returns": "string",
        "help": "Return the extension related to given mime type."
      },
      {
        "name": "parse_json",
        "arguments": ["string"],
        "returns": "any",
        "help": "Parse the given string as JSON."
      },
      {
        "name": "try",
        "arguments": ["T"],
        "returns": "T",
        "help": "Attempt to evaluate given expression and return null if it raised an error."
      },
      {
        "name": "typeof",
        "arguments": ["value"],
        "returns": "string",
        "help": "Return type of value."
      }
    ]
  },
  {
    "title": "IO & path wrangling",
    "functions": [
      {
        "name": "abspath",
        "arguments": ["string"],
        "returns": "string",
        "help": "Return absolute & canonicalized path."
      },
      {
        "name": "bytesize",
        "arguments": ["string"],
        "returns": "string",
        "help": "Return a number of bytes in human-readable format (KB, MB, GB, etc.)."
      },
      {
        "name": "copy",
        "arguments": ["source_path", "target_path"],
        "returns": "string",
        "help": "Copy a source to target path. Will create necessary directories on the way. Returns target path as a convenience."
      },
      {
        "name": "ext",
        "arguments": ["path"],
        "returns": "string?",
        "help": "Return the path's extension, if any."
      },
      {
        "name": "filesize",
        "arguments": ["string"],
        "returns": "int",
        "help": "Return the size of given file in bytes."
      },
      {
        "name": "isfile",
        "arguments": ["string"],
        "returns": "bool",
        "help": "Return whether the given path is an existing file on disk."
      },
      {
        "name": "move",
        "arguments": ["source_path", "target_path"],
        "returns": "string",
        "help": "Move a source to target path. Will create necessary directories on the way. Returns target path as a convenience."
      },
      {
        "name": "pathjoin",
        "aliases": ["pjoin"],
        "arguments": ["string", "*strings"],
        "returns": "string",
        "help": "Join multiple paths correctly."
      },
      {
        "name": "read",
        "arguments": ["path", "encoding=?", "errors=?"],
        "returns": "string",
        "help": "Read file at path. Default encoding is \"utf-8\". Default error handling policy is \"replace\", and can be one of \"replace\", \"ignore\" or \"strict\"."
      },
      {
        "name": "read_csv",
        "arguments": ["path"],
        "returns": "list[map]",
        "help": "Read and parse CSV file at path, returning its rows as a list of maps with headers as keys."
      },
      {
        "name": "read_json",
        "arguments": ["path"],
        "returns": "any",
        "help": "Read and parse JSON file at path."
      },
      {
        "name": "write",
        "arguments": ["string", "path"],
        "returns": "string",
        "help": "Write string to path as utf-8 text. Will create necessary directories recursively before actually writing the file. Return the path that was written."
      }
    ]
  },
  {
    "title": "Random",
    "functions": [
      {
        "name": "md5",
        "arguments": ["string"],
        "returns": "string",
        "help": "Return the md5 hash of string in hexadecimal representation."
      },
      {
        "name": "random",
        "arguments": [],
        "returns": "float",
        "help": "Return a random float between 0 and 1."
      },
      {
        "name": "uuid",
        "arguments": [],
        "returns": "string",
        "help": "Return a uuid v4."
      }
    ]
  }
]