kumi 0.0.26 → 0.0.27
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/CLAUDE.md +4 -0
- data/README.md +17 -8
- data/data/functions/core/conversion.yaml +32 -0
- data/data/kernels/javascript/core/coercion.yaml +20 -0
- data/data/kernels/ruby/core/coercion.yaml +20 -0
- data/docs/ARCHITECTURE.md +277 -0
- data/docs/DEVELOPMENT.md +62 -0
- data/docs/FUNCTIONS.md +955 -0
- data/docs/SYNTAX.md +8 -0
- data/docs/VSCODE_EXTENSION.md +114 -0
- data/docs/functions-reference.json +1821 -0
- data/golden/array_element/expected/schema_ruby.rb +1 -1
- data/golden/array_index/expected/schema_ruby.rb +1 -1
- data/golden/array_operations/expected/schema_ruby.rb +1 -1
- data/golden/cascade_logic/expected/schema_ruby.rb +1 -1
- data/golden/chained_fusion/expected/schema_ruby.rb +1 -1
- data/golden/decimal_explicit/expected/ast.txt +38 -0
- data/golden/decimal_explicit/expected/input_plan.txt +3 -0
- data/golden/decimal_explicit/expected/lir_00_unoptimized.txt +30 -0
- data/golden/decimal_explicit/expected/lir_01_hoist_scalar_references.txt +30 -0
- data/golden/decimal_explicit/expected/lir_02_inlined.txt +44 -0
- data/golden/decimal_explicit/expected/lir_03_cse.txt +40 -0
- data/golden/decimal_explicit/expected/lir_04_1_loop_fusion.txt +40 -0
- data/golden/decimal_explicit/expected/lir_04_loop_invcm.txt +40 -0
- data/golden/decimal_explicit/expected/lir_06_const_prop.txt +40 -0
- data/golden/decimal_explicit/expected/nast.txt +30 -0
- data/golden/decimal_explicit/expected/schema_javascript.mjs +31 -0
- data/golden/decimal_explicit/expected/schema_ruby.rb +57 -0
- data/golden/decimal_explicit/expected/snast.txt +30 -0
- data/golden/decimal_explicit/expected.json +1 -0
- data/golden/decimal_explicit/input.json +5 -0
- data/golden/decimal_explicit/schema.kumi +14 -0
- data/golden/element_arrays/expected/schema_ruby.rb +1 -1
- data/golden/empty_and_null_inputs/expected/schema_ruby.rb +1 -1
- data/golden/function_overload/expected/schema_ruby.rb +1 -1
- data/golden/game_of_life/expected/schema_ruby.rb +1 -1
- data/golden/hash_keys/expected/schema_ruby.rb +1 -1
- data/golden/hash_value/expected/schema_ruby.rb +1 -1
- data/golden/hierarchical_complex/expected/schema_ruby.rb +1 -1
- data/golden/inline_rename_scope_leak/expected/schema_ruby.rb +1 -1
- data/golden/input_reference/expected/schema_ruby.rb +1 -1
- data/golden/interleaved_fusion/expected/schema_ruby.rb +1 -1
- data/golden/let_inline/expected/schema_ruby.rb +1 -1
- data/golden/loop_fusion/expected/schema_ruby.rb +1 -1
- data/golden/min_reduce_scope/expected/schema_ruby.rb +1 -1
- data/golden/mixed_dimensions/expected/schema_ruby.rb +1 -1
- data/golden/multirank_hoisting/expected/schema_ruby.rb +1 -1
- data/golden/nested_hash/expected/schema_ruby.rb +1 -1
- data/golden/reduction_broadcast/expected/schema_ruby.rb +1 -1
- data/golden/roll/expected/schema_ruby.rb +1 -1
- data/golden/shift/expected/schema_ruby.rb +1 -1
- data/golden/shift_2d/expected/schema_ruby.rb +1 -1
- data/golden/simple_math/expected/schema_ruby.rb +1 -1
- data/golden/streaming_basics/expected/schema_ruby.rb +1 -1
- data/golden/tuples/expected/schema_ruby.rb +1 -1
- data/golden/tuples_and_arrays/expected/schema_ruby.rb +1 -1
- data/golden/us_tax_2024/expected/schema_ruby.rb +1 -1
- data/golden/with_constants/expected/schema_ruby.rb +1 -1
- data/lib/kumi/configuration.rb +6 -0
- data/lib/kumi/core/input/type_matcher.rb +8 -1
- data/lib/kumi/core/ruby_parser/input_builder.rb +2 -2
- data/lib/kumi/core/types/normalizer.rb +1 -0
- data/lib/kumi/core/types/validator.rb +2 -2
- data/lib/kumi/core/types.rb +2 -2
- data/lib/kumi/dev/golden/reporter.rb +9 -0
- data/lib/kumi/dev/golden/result.rb +3 -1
- data/lib/kumi/dev/golden/runtime_test.rb +25 -0
- data/lib/kumi/dev/golden/suite.rb +4 -4
- data/lib/kumi/dev/golden/value_normalizer.rb +80 -0
- data/lib/kumi/dev/golden.rb +21 -12
- data/lib/kumi/doc_generator/formatters/json.rb +39 -0
- data/lib/kumi/doc_generator/formatters/markdown.rb +175 -0
- data/lib/kumi/doc_generator/loader.rb +37 -0
- data/lib/kumi/doc_generator/merger.rb +54 -0
- data/lib/kumi/doc_generator.rb +4 -0
- data/lib/kumi/version.rb +1 -1
- data/vscode-extension/.gitignore +4 -0
- data/vscode-extension/README.md +59 -0
- data/vscode-extension/TESTING.md +151 -0
- data/vscode-extension/package.json +51 -0
- data/vscode-extension/src/extension.ts +295 -0
- data/vscode-extension/tsconfig.json +15 -0
- metadata +37 -1
data/docs/FUNCTIONS.md
ADDED
@@ -0,0 +1,955 @@
|
|
1
|
+
# Kumi Function Reference
|
2
|
+
|
3
|
+
Auto-generated documentation for Kumi functions and their kernels.
|
4
|
+
|
5
|
+
## `__select__`
|
6
|
+
|
7
|
+
**Aliases:** `if`, `select`
|
8
|
+
|
9
|
+
- **Arity:** 3
|
10
|
+
- **Type:** same as `value_when_true`
|
11
|
+
|
12
|
+
### Parameters
|
13
|
+
|
14
|
+
- `condition_mask`
|
15
|
+
- `value_when_true`
|
16
|
+
- `value_when_false`
|
17
|
+
|
18
|
+
## `agg.all`
|
19
|
+
|
20
|
+
**Aliases:** `all`, `all?`
|
21
|
+
|
22
|
+
- **Arity:** 1
|
23
|
+
- **Type:** boolean
|
24
|
+
- **Behavior:** Reduces a dimension `[D] -> T`
|
25
|
+
|
26
|
+
### Parameters
|
27
|
+
|
28
|
+
- `source_value`
|
29
|
+
|
30
|
+
### Implementations
|
31
|
+
|
32
|
+
#### Ruby
|
33
|
+
|
34
|
+
`all:ruby:v1`
|
35
|
+
|
36
|
+
**Inline:** `= $0 && $1` (`$0` = accumulator, `$1` = element)
|
37
|
+
|
38
|
+
**Implementation:**
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
(a, b)
|
42
|
+
a && b
|
43
|
+
```
|
44
|
+
|
45
|
+
**Identity:**
|
46
|
+
- boolean: `true`
|
47
|
+
|
48
|
+
## `agg.any`
|
49
|
+
|
50
|
+
**Aliases:** `any`, `any?`
|
51
|
+
|
52
|
+
- **Arity:** 1
|
53
|
+
- **Type:** boolean
|
54
|
+
- **Behavior:** Reduces a dimension `[D] -> T`
|
55
|
+
|
56
|
+
### Parameters
|
57
|
+
|
58
|
+
- `source_value`
|
59
|
+
|
60
|
+
### Implementations
|
61
|
+
|
62
|
+
#### Ruby
|
63
|
+
|
64
|
+
`any:ruby:v1`
|
65
|
+
|
66
|
+
**Inline:** `= $0 || $1` (`$0` = accumulator, `$1` = element)
|
67
|
+
|
68
|
+
**Implementation:**
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
(a, b)
|
72
|
+
a || b
|
73
|
+
```
|
74
|
+
|
75
|
+
**Identity:**
|
76
|
+
- boolean: `false`
|
77
|
+
|
78
|
+
## `agg.count`
|
79
|
+
|
80
|
+
- **Arity:** 1
|
81
|
+
- **Type:** integer
|
82
|
+
- **Behavior:** Reduces a dimension `[D] -> T`
|
83
|
+
|
84
|
+
### Parameters
|
85
|
+
|
86
|
+
- `source_value`
|
87
|
+
|
88
|
+
### Implementations
|
89
|
+
|
90
|
+
#### Ruby
|
91
|
+
|
92
|
+
`agg.count:ruby:v1`
|
93
|
+
|
94
|
+
**Inline:** `+= 1` (`$0` = accumulator, `$1` = element)
|
95
|
+
|
96
|
+
**Implementation:**
|
97
|
+
|
98
|
+
```ruby
|
99
|
+
(a,_b)
|
100
|
+
a + 1
|
101
|
+
```
|
102
|
+
|
103
|
+
**Fold:** `= $0.count`
|
104
|
+
|
105
|
+
**Identity:**
|
106
|
+
- any: `0`
|
107
|
+
|
108
|
+
**Reduction:** Monoid operation with identity element
|
109
|
+
|
110
|
+
## `agg.count_if`
|
111
|
+
|
112
|
+
- **Arity:** 2
|
113
|
+
- **Type:** integer
|
114
|
+
- **Behavior:** Reduces a dimension `[D] -> T`
|
115
|
+
|
116
|
+
### Parameters
|
117
|
+
|
118
|
+
- `condition`
|
119
|
+
- `source_value`
|
120
|
+
|
121
|
+
## `agg.join`
|
122
|
+
|
123
|
+
- **Arity:** 1
|
124
|
+
- **Type:** string
|
125
|
+
- **Behavior:** Reduces a dimension `[D] -> T`
|
126
|
+
|
127
|
+
### Parameters
|
128
|
+
|
129
|
+
- `source_value`
|
130
|
+
|
131
|
+
### Implementations
|
132
|
+
|
133
|
+
#### Ruby
|
134
|
+
|
135
|
+
`agg.join:ruby:v1`
|
136
|
+
|
137
|
+
**Fold:** `= $0.join`
|
138
|
+
|
139
|
+
_Note: No identity value. First element initializes accumulator._
|
140
|
+
|
141
|
+
**Reduction:** First element is initial value (no identity)
|
142
|
+
|
143
|
+
## `agg.max`
|
144
|
+
|
145
|
+
- **Arity:** 1
|
146
|
+
- **Type:** element of `source_value`
|
147
|
+
- **Behavior:** Reduces a dimension `[D] -> T`
|
148
|
+
|
149
|
+
### Parameters
|
150
|
+
|
151
|
+
- `source_value`
|
152
|
+
|
153
|
+
### Implementations
|
154
|
+
|
155
|
+
#### Ruby
|
156
|
+
|
157
|
+
`agg.max:ruby:v1`
|
158
|
+
|
159
|
+
**Implementation:**
|
160
|
+
|
161
|
+
```ruby
|
162
|
+
(a, b)
|
163
|
+
a > b ? a : b
|
164
|
+
```
|
165
|
+
|
166
|
+
**Fold:** `= $0.max`
|
167
|
+
|
168
|
+
_Note: No identity value. First element initializes accumulator._
|
169
|
+
|
170
|
+
**Reduction:** First element is initial value (no identity)
|
171
|
+
|
172
|
+
## `agg.mean`
|
173
|
+
|
174
|
+
**Aliases:** `avg`, `mean`
|
175
|
+
|
176
|
+
- **Arity:** 1
|
177
|
+
- **Type:** float
|
178
|
+
- **Behavior:** Reduces a dimension `[D] -> T`
|
179
|
+
|
180
|
+
### Parameters
|
181
|
+
|
182
|
+
- `source_value`
|
183
|
+
|
184
|
+
## `agg.mean_if`
|
185
|
+
|
186
|
+
**Aliases:** `avg_if`, `mean_if`
|
187
|
+
|
188
|
+
- **Arity:** 2
|
189
|
+
- **Type:** float
|
190
|
+
- **Behavior:** Reduces a dimension `[D] -> T`
|
191
|
+
|
192
|
+
### Parameters
|
193
|
+
|
194
|
+
- `source_value`
|
195
|
+
- `condition`
|
196
|
+
|
197
|
+
## `agg.min`
|
198
|
+
|
199
|
+
- **Arity:** 1
|
200
|
+
- **Type:** element of `source_value`
|
201
|
+
- **Behavior:** Reduces a dimension `[D] -> T`
|
202
|
+
|
203
|
+
### Parameters
|
204
|
+
|
205
|
+
- `source_value`
|
206
|
+
|
207
|
+
### Implementations
|
208
|
+
|
209
|
+
#### Ruby
|
210
|
+
|
211
|
+
`agg.min:ruby:v1`
|
212
|
+
|
213
|
+
**Implementation:**
|
214
|
+
|
215
|
+
```ruby
|
216
|
+
(a, b)
|
217
|
+
a < b ? a : b
|
218
|
+
```
|
219
|
+
|
220
|
+
**Fold:** `= $0.min`
|
221
|
+
|
222
|
+
_Note: No identity value. First element initializes accumulator._
|
223
|
+
|
224
|
+
**Reduction:** First element is initial value (no identity)
|
225
|
+
|
226
|
+
## `agg.sum`
|
227
|
+
|
228
|
+
- **Arity:** 1
|
229
|
+
- **Type:** same as `source_value`
|
230
|
+
- **Behavior:** Reduces a dimension `[D] -> T`
|
231
|
+
|
232
|
+
### Parameters
|
233
|
+
|
234
|
+
- `source_value`
|
235
|
+
|
236
|
+
### Implementations
|
237
|
+
|
238
|
+
#### Ruby
|
239
|
+
|
240
|
+
`agg.sum:ruby:v1`
|
241
|
+
|
242
|
+
**Inline:** `+= $1` (`$0` = accumulator, `$1` = element)
|
243
|
+
|
244
|
+
**Implementation:**
|
245
|
+
|
246
|
+
```ruby
|
247
|
+
(a,b)
|
248
|
+
a + b
|
249
|
+
```
|
250
|
+
|
251
|
+
**Fold:** `= $0.sum`
|
252
|
+
|
253
|
+
**Identity:**
|
254
|
+
- float: `0.0`
|
255
|
+
- integer: `0`
|
256
|
+
|
257
|
+
**Reduction:** Monoid operation with identity element
|
258
|
+
|
259
|
+
## `agg.sum_if`
|
260
|
+
|
261
|
+
- **Arity:** 2
|
262
|
+
- **Type:** same as `source_value`
|
263
|
+
- **Behavior:** Reduces a dimension `[D] -> T`
|
264
|
+
|
265
|
+
### Parameters
|
266
|
+
|
267
|
+
- `source_value`
|
268
|
+
- `condition`
|
269
|
+
|
270
|
+
## `core.abs`
|
271
|
+
|
272
|
+
- **Arity:** 1
|
273
|
+
- **Type:** same as `number`
|
274
|
+
|
275
|
+
### Parameters
|
276
|
+
|
277
|
+
- `number`
|
278
|
+
|
279
|
+
### Implementations
|
280
|
+
|
281
|
+
#### Ruby
|
282
|
+
|
283
|
+
`abs:ruby:v1`
|
284
|
+
|
285
|
+
_Note: No identity value. First element initializes accumulator._
|
286
|
+
|
287
|
+
## `core.add`
|
288
|
+
|
289
|
+
- **Arity:** 2
|
290
|
+
- **Type:** promoted from `left_operand`, `right_operand`
|
291
|
+
|
292
|
+
### Parameters
|
293
|
+
|
294
|
+
- `left_operand`
|
295
|
+
- `right_operand`
|
296
|
+
|
297
|
+
### Implementations
|
298
|
+
|
299
|
+
#### Ruby
|
300
|
+
|
301
|
+
`add:ruby:v1`
|
302
|
+
|
303
|
+
**Implementation:**
|
304
|
+
|
305
|
+
```ruby
|
306
|
+
(a, b)
|
307
|
+
a + b
|
308
|
+
```
|
309
|
+
|
310
|
+
_Note: No identity value. First element initializes accumulator._
|
311
|
+
|
312
|
+
## `core.and`
|
313
|
+
|
314
|
+
**Aliases:** `&`, `and`
|
315
|
+
|
316
|
+
- **Arity:** 2
|
317
|
+
- **Type:** boolean
|
318
|
+
|
319
|
+
### Parameters
|
320
|
+
|
321
|
+
- `left_operand`
|
322
|
+
- `right_operand`
|
323
|
+
|
324
|
+
### Implementations
|
325
|
+
|
326
|
+
#### Ruby
|
327
|
+
|
328
|
+
`and:ruby:v1`
|
329
|
+
|
330
|
+
**Implementation:**
|
331
|
+
|
332
|
+
```ruby
|
333
|
+
(a, b)
|
334
|
+
a && b
|
335
|
+
```
|
336
|
+
|
337
|
+
_Note: No identity value. First element initializes accumulator._
|
338
|
+
|
339
|
+
## `core.array_size`
|
340
|
+
|
341
|
+
**Aliases:** `array_size`, `size`
|
342
|
+
|
343
|
+
- **Arity:** 1
|
344
|
+
- **Type:** integer
|
345
|
+
|
346
|
+
### Parameters
|
347
|
+
|
348
|
+
- `collection`
|
349
|
+
|
350
|
+
### Implementations
|
351
|
+
|
352
|
+
#### Ruby
|
353
|
+
|
354
|
+
`size:ruby:v1`
|
355
|
+
|
356
|
+
**Implementation:**
|
357
|
+
|
358
|
+
```ruby
|
359
|
+
(collection)
|
360
|
+
collection.size
|
361
|
+
```
|
362
|
+
|
363
|
+
**Fold:** `= $0.length`
|
364
|
+
|
365
|
+
_Note: No identity value. First element initializes accumulator._
|
366
|
+
|
367
|
+
## `core.at`
|
368
|
+
|
369
|
+
**Aliases:** `[]`, `at`, `get`
|
370
|
+
|
371
|
+
- **Arity:** 2
|
372
|
+
- **Type:** element of `collection`
|
373
|
+
|
374
|
+
### Parameters
|
375
|
+
|
376
|
+
- `collection`
|
377
|
+
- `index`
|
378
|
+
|
379
|
+
### Implementations
|
380
|
+
|
381
|
+
#### Ruby
|
382
|
+
|
383
|
+
`at:ruby:v1`
|
384
|
+
|
385
|
+
_Note: No identity value. First element initializes accumulator._
|
386
|
+
|
387
|
+
## `core.clamp`
|
388
|
+
|
389
|
+
- **Arity:** 3
|
390
|
+
- **Type:** same as `x`
|
391
|
+
|
392
|
+
### Parameters
|
393
|
+
|
394
|
+
- `x`
|
395
|
+
- `lo`
|
396
|
+
- `hi`
|
397
|
+
|
398
|
+
### Implementations
|
399
|
+
|
400
|
+
#### Ruby
|
401
|
+
|
402
|
+
`clamp:ruby:v1`
|
403
|
+
|
404
|
+
**Implementation:**
|
405
|
+
|
406
|
+
```ruby
|
407
|
+
(x, lo, hi)
|
408
|
+
[[x, lo].max, hi].min
|
409
|
+
```
|
410
|
+
|
411
|
+
_Note: No identity value. First element initializes accumulator._
|
412
|
+
|
413
|
+
## `core.concat`
|
414
|
+
|
415
|
+
- **Arity:** 2
|
416
|
+
- **Type:** string
|
417
|
+
|
418
|
+
### Parameters
|
419
|
+
|
420
|
+
- `left_string`
|
421
|
+
- `right_string`
|
422
|
+
|
423
|
+
### Implementations
|
424
|
+
|
425
|
+
#### Ruby
|
426
|
+
|
427
|
+
`concat:ruby:v1`
|
428
|
+
|
429
|
+
**Implementation:**
|
430
|
+
|
431
|
+
```ruby
|
432
|
+
(a, b)
|
433
|
+
a.to_s + b.to_s
|
434
|
+
```
|
435
|
+
|
436
|
+
_Note: No identity value. First element initializes accumulator._
|
437
|
+
|
438
|
+
## `core.div`
|
439
|
+
|
440
|
+
**Aliases:** `div`, `divide`
|
441
|
+
|
442
|
+
- **Arity:** 2
|
443
|
+
- **Type:** float
|
444
|
+
|
445
|
+
### Parameters
|
446
|
+
|
447
|
+
- `left_operand`
|
448
|
+
- `right_operand`
|
449
|
+
|
450
|
+
### Implementations
|
451
|
+
|
452
|
+
#### Ruby
|
453
|
+
|
454
|
+
`div:ruby:v1`
|
455
|
+
|
456
|
+
**Implementation:**
|
457
|
+
|
458
|
+
```ruby
|
459
|
+
(a, b)
|
460
|
+
a / b.to_f
|
461
|
+
```
|
462
|
+
|
463
|
+
_Note: No identity value. First element initializes accumulator._
|
464
|
+
|
465
|
+
## `core.downcase`
|
466
|
+
|
467
|
+
- **Arity:** 1
|
468
|
+
- **Type:** string
|
469
|
+
|
470
|
+
### Parameters
|
471
|
+
|
472
|
+
- `string`
|
473
|
+
|
474
|
+
### Implementations
|
475
|
+
|
476
|
+
#### Ruby
|
477
|
+
|
478
|
+
`downcase:ruby:v1`
|
479
|
+
|
480
|
+
_Note: No identity value. First element initializes accumulator._
|
481
|
+
|
482
|
+
## `core.eq`
|
483
|
+
|
484
|
+
**Aliases:** `==`, `eq`, `equal`
|
485
|
+
|
486
|
+
- **Arity:** 2
|
487
|
+
- **Type:** boolean
|
488
|
+
|
489
|
+
### Parameters
|
490
|
+
|
491
|
+
- `left_operand`
|
492
|
+
- `right_operand`
|
493
|
+
|
494
|
+
### Implementations
|
495
|
+
|
496
|
+
#### Ruby
|
497
|
+
|
498
|
+
`eq:ruby:v1`
|
499
|
+
|
500
|
+
**Implementation:**
|
501
|
+
|
502
|
+
```ruby
|
503
|
+
(a, b)
|
504
|
+
a == b
|
505
|
+
```
|
506
|
+
|
507
|
+
_Note: No identity value. First element initializes accumulator._
|
508
|
+
|
509
|
+
## `core.gt`
|
510
|
+
|
511
|
+
**Aliases:** `>`, `greater_than`, `gt`
|
512
|
+
|
513
|
+
- **Arity:** 2
|
514
|
+
- **Type:** boolean
|
515
|
+
|
516
|
+
### Parameters
|
517
|
+
|
518
|
+
- `left_operand`
|
519
|
+
- `right_operand`
|
520
|
+
|
521
|
+
### Implementations
|
522
|
+
|
523
|
+
#### Ruby
|
524
|
+
|
525
|
+
`gt:ruby:v1`
|
526
|
+
|
527
|
+
**Implementation:**
|
528
|
+
|
529
|
+
```ruby
|
530
|
+
(a, b)
|
531
|
+
a > b
|
532
|
+
```
|
533
|
+
|
534
|
+
_Note: No identity value. First element initializes accumulator._
|
535
|
+
|
536
|
+
## `core.gte`
|
537
|
+
|
538
|
+
**Aliases:** `>=`, `ge`, `greater_than_or_equal`, `gte`
|
539
|
+
|
540
|
+
- **Arity:** 2
|
541
|
+
- **Type:** boolean
|
542
|
+
|
543
|
+
### Parameters
|
544
|
+
|
545
|
+
- `left_operand`
|
546
|
+
- `right_operand`
|
547
|
+
|
548
|
+
### Implementations
|
549
|
+
|
550
|
+
#### Ruby
|
551
|
+
|
552
|
+
`gte:ruby:v1`
|
553
|
+
|
554
|
+
**Implementation:**
|
555
|
+
|
556
|
+
```ruby
|
557
|
+
(a, b)
|
558
|
+
a >= b
|
559
|
+
```
|
560
|
+
|
561
|
+
_Note: No identity value. First element initializes accumulator._
|
562
|
+
|
563
|
+
## `core.hash_fetch`
|
564
|
+
|
565
|
+
- **Arity:** 1
|
566
|
+
- **Type:** any
|
567
|
+
|
568
|
+
### Parameters
|
569
|
+
|
570
|
+
- `key`
|
571
|
+
|
572
|
+
## `core.length`
|
573
|
+
|
574
|
+
**Aliases:** `len`, `length`
|
575
|
+
|
576
|
+
- **Arity:** 1
|
577
|
+
- **Type:** integer
|
578
|
+
|
579
|
+
### Parameters
|
580
|
+
|
581
|
+
- `collection`
|
582
|
+
|
583
|
+
### Implementations
|
584
|
+
|
585
|
+
#### Ruby
|
586
|
+
|
587
|
+
`length:ruby:v1`
|
588
|
+
|
589
|
+
**Implementation:**
|
590
|
+
|
591
|
+
```ruby
|
592
|
+
(collection)
|
593
|
+
collection.size
|
594
|
+
```
|
595
|
+
|
596
|
+
**Fold:** `= $0.length`
|
597
|
+
|
598
|
+
_Note: No identity value. First element initializes accumulator._
|
599
|
+
|
600
|
+
## `core.lt`
|
601
|
+
|
602
|
+
**Aliases:** `<`, `less_than`, `lt`
|
603
|
+
|
604
|
+
- **Arity:** 2
|
605
|
+
- **Type:** boolean
|
606
|
+
|
607
|
+
### Parameters
|
608
|
+
|
609
|
+
- `left_operand`
|
610
|
+
- `right_operand`
|
611
|
+
|
612
|
+
### Implementations
|
613
|
+
|
614
|
+
#### Ruby
|
615
|
+
|
616
|
+
`lt:ruby:v1`
|
617
|
+
|
618
|
+
**Implementation:**
|
619
|
+
|
620
|
+
```ruby
|
621
|
+
(a, b)
|
622
|
+
a < b
|
623
|
+
```
|
624
|
+
|
625
|
+
_Note: No identity value. First element initializes accumulator._
|
626
|
+
|
627
|
+
## `core.lte`
|
628
|
+
|
629
|
+
**Aliases:** `<=`, `le`, `less_than_or_equal`, `lte`
|
630
|
+
|
631
|
+
- **Arity:** 2
|
632
|
+
- **Type:** boolean
|
633
|
+
|
634
|
+
### Parameters
|
635
|
+
|
636
|
+
- `left_operand`
|
637
|
+
- `right_operand`
|
638
|
+
|
639
|
+
### Implementations
|
640
|
+
|
641
|
+
#### Ruby
|
642
|
+
|
643
|
+
`lte:ruby:v1`
|
644
|
+
|
645
|
+
**Implementation:**
|
646
|
+
|
647
|
+
```ruby
|
648
|
+
(a, b)
|
649
|
+
a <= b
|
650
|
+
```
|
651
|
+
|
652
|
+
_Note: No identity value. First element initializes accumulator._
|
653
|
+
|
654
|
+
## `core.mod`
|
655
|
+
|
656
|
+
**Aliases:** `%`, `mod`, `modulo`
|
657
|
+
|
658
|
+
- **Arity:** 2
|
659
|
+
- **Type:** promoted from `left_operand`, `right_operand`
|
660
|
+
|
661
|
+
### Parameters
|
662
|
+
|
663
|
+
- `left_operand`
|
664
|
+
- `right_operand`
|
665
|
+
|
666
|
+
### Implementations
|
667
|
+
|
668
|
+
#### V1
|
669
|
+
|
670
|
+
`mod.ruby:v1`
|
671
|
+
|
672
|
+
_Note: No identity value. First element initializes accumulator._
|
673
|
+
|
674
|
+
## `core.mul`
|
675
|
+
|
676
|
+
**Aliases:** `mul`, `multiply`
|
677
|
+
|
678
|
+
- **Arity:** 2
|
679
|
+
- **Type:** promoted from `left_operand`, `right_operand`
|
680
|
+
|
681
|
+
### Parameters
|
682
|
+
|
683
|
+
- `left_operand`
|
684
|
+
- `right_operand`
|
685
|
+
|
686
|
+
### Implementations
|
687
|
+
|
688
|
+
#### Ruby
|
689
|
+
|
690
|
+
`mul:ruby:v1`
|
691
|
+
|
692
|
+
**Implementation:**
|
693
|
+
|
694
|
+
```ruby
|
695
|
+
(a, b)
|
696
|
+
a * b
|
697
|
+
```
|
698
|
+
|
699
|
+
_Note: No identity value. First element initializes accumulator._
|
700
|
+
|
701
|
+
## `core.neq`
|
702
|
+
|
703
|
+
**Aliases:** `!=`, `neq`, `not_equal`
|
704
|
+
|
705
|
+
- **Arity:** 2
|
706
|
+
- **Type:** boolean
|
707
|
+
|
708
|
+
### Parameters
|
709
|
+
|
710
|
+
- `left_operand`
|
711
|
+
- `right_operand`
|
712
|
+
|
713
|
+
### Implementations
|
714
|
+
|
715
|
+
#### Ruby
|
716
|
+
|
717
|
+
`neq:ruby:v1`
|
718
|
+
|
719
|
+
**Implementation:**
|
720
|
+
|
721
|
+
```ruby
|
722
|
+
(a, b)
|
723
|
+
a != b
|
724
|
+
```
|
725
|
+
|
726
|
+
_Note: No identity value. First element initializes accumulator._
|
727
|
+
|
728
|
+
## `core.not`
|
729
|
+
|
730
|
+
**Aliases:** `!`, `not`
|
731
|
+
|
732
|
+
- **Arity:** 1
|
733
|
+
- **Type:** boolean
|
734
|
+
|
735
|
+
### Parameters
|
736
|
+
|
737
|
+
- `operand`
|
738
|
+
|
739
|
+
### Implementations
|
740
|
+
|
741
|
+
#### Ruby
|
742
|
+
|
743
|
+
`not:ruby:v1`
|
744
|
+
|
745
|
+
**Implementation:**
|
746
|
+
|
747
|
+
```ruby
|
748
|
+
(a)
|
749
|
+
!a
|
750
|
+
```
|
751
|
+
|
752
|
+
_Note: No identity value. First element initializes accumulator._
|
753
|
+
|
754
|
+
## `core.or`
|
755
|
+
|
756
|
+
**Aliases:** `or`, `|`
|
757
|
+
|
758
|
+
- **Arity:** 2
|
759
|
+
- **Type:** boolean
|
760
|
+
|
761
|
+
### Parameters
|
762
|
+
|
763
|
+
- `left_operand`
|
764
|
+
- `right_operand`
|
765
|
+
|
766
|
+
### Implementations
|
767
|
+
|
768
|
+
#### Ruby
|
769
|
+
|
770
|
+
`or:ruby:v1`
|
771
|
+
|
772
|
+
**Implementation:**
|
773
|
+
|
774
|
+
```ruby
|
775
|
+
(a, b)
|
776
|
+
a || b
|
777
|
+
```
|
778
|
+
|
779
|
+
_Note: No identity value. First element initializes accumulator._
|
780
|
+
|
781
|
+
## `core.pow`
|
782
|
+
|
783
|
+
**Aliases:** `pow`, `power`
|
784
|
+
|
785
|
+
- **Arity:** 2
|
786
|
+
- **Type:** promoted from `base`, `exponent`
|
787
|
+
|
788
|
+
### Parameters
|
789
|
+
|
790
|
+
- `base`
|
791
|
+
- `exponent`
|
792
|
+
|
793
|
+
### Implementations
|
794
|
+
|
795
|
+
#### Ruby
|
796
|
+
|
797
|
+
`pow:ruby:v1`
|
798
|
+
|
799
|
+
**Implementation:**
|
800
|
+
|
801
|
+
```ruby
|
802
|
+
(a, b)
|
803
|
+
a ** b
|
804
|
+
```
|
805
|
+
|
806
|
+
_Note: No identity value. First element initializes accumulator._
|
807
|
+
|
808
|
+
## `core.sub`
|
809
|
+
|
810
|
+
**Aliases:** `sub`, `subtract`
|
811
|
+
|
812
|
+
- **Arity:** 2
|
813
|
+
- **Type:** promoted from `left_operand`, `right_operand`
|
814
|
+
|
815
|
+
### Parameters
|
816
|
+
|
817
|
+
- `left_operand`
|
818
|
+
- `right_operand`
|
819
|
+
|
820
|
+
### Implementations
|
821
|
+
|
822
|
+
#### Ruby
|
823
|
+
|
824
|
+
`sub:ruby:v1`
|
825
|
+
|
826
|
+
**Implementation:**
|
827
|
+
|
828
|
+
```ruby
|
829
|
+
(a, b)
|
830
|
+
a - b
|
831
|
+
```
|
832
|
+
|
833
|
+
_Note: No identity value. First element initializes accumulator._
|
834
|
+
|
835
|
+
## `core.to_decimal`
|
836
|
+
|
837
|
+
- **Arity:** 1
|
838
|
+
- **Type:** decimal
|
839
|
+
|
840
|
+
### Parameters
|
841
|
+
|
842
|
+
- `value`
|
843
|
+
|
844
|
+
### Implementations
|
845
|
+
|
846
|
+
#### Ruby
|
847
|
+
|
848
|
+
`to_decimal:ruby:v1`
|
849
|
+
|
850
|
+
**Implementation:**
|
851
|
+
|
852
|
+
```ruby
|
853
|
+
(value)
|
854
|
+
case value
|
855
|
+
when BigDecimal then value
|
856
|
+
when String then BigDecimal(value)
|
857
|
+
when Numeric then BigDecimal(value.to_s)
|
858
|
+
else raise TypeError, "Cannot coerce #{value.class} to Decimal"
|
859
|
+
end
|
860
|
+
```
|
861
|
+
|
862
|
+
_Note: No identity value. First element initializes accumulator._
|
863
|
+
|
864
|
+
## `core.to_float`
|
865
|
+
|
866
|
+
- **Arity:** 1
|
867
|
+
- **Type:** float
|
868
|
+
|
869
|
+
### Parameters
|
870
|
+
|
871
|
+
- `value`
|
872
|
+
|
873
|
+
### Implementations
|
874
|
+
|
875
|
+
#### Ruby
|
876
|
+
|
877
|
+
`to_float:ruby:v1`
|
878
|
+
|
879
|
+
**Implementation:**
|
880
|
+
|
881
|
+
```ruby
|
882
|
+
(value)
|
883
|
+
value.to_f
|
884
|
+
```
|
885
|
+
|
886
|
+
_Note: No identity value. First element initializes accumulator._
|
887
|
+
|
888
|
+
## `core.to_integer`
|
889
|
+
|
890
|
+
**Aliases:** `to_int`, `to_integer`
|
891
|
+
|
892
|
+
- **Arity:** 1
|
893
|
+
- **Type:** integer
|
894
|
+
|
895
|
+
### Parameters
|
896
|
+
|
897
|
+
- `value`
|
898
|
+
|
899
|
+
### Implementations
|
900
|
+
|
901
|
+
#### Ruby
|
902
|
+
|
903
|
+
`to_integer:ruby:v1`
|
904
|
+
|
905
|
+
**Implementation:**
|
906
|
+
|
907
|
+
```ruby
|
908
|
+
(value)
|
909
|
+
value.to_i
|
910
|
+
```
|
911
|
+
|
912
|
+
_Note: No identity value. First element initializes accumulator._
|
913
|
+
|
914
|
+
## `core.to_string`
|
915
|
+
|
916
|
+
**Aliases:** `to_str`, `to_string`
|
917
|
+
|
918
|
+
- **Arity:** 1
|
919
|
+
- **Type:** string
|
920
|
+
|
921
|
+
### Parameters
|
922
|
+
|
923
|
+
- `value`
|
924
|
+
|
925
|
+
### Implementations
|
926
|
+
|
927
|
+
#### Ruby
|
928
|
+
|
929
|
+
`to_string:ruby:v1`
|
930
|
+
|
931
|
+
**Implementation:**
|
932
|
+
|
933
|
+
```ruby
|
934
|
+
(value)
|
935
|
+
value.to_s
|
936
|
+
```
|
937
|
+
|
938
|
+
_Note: No identity value. First element initializes accumulator._
|
939
|
+
|
940
|
+
## `core.upcase`
|
941
|
+
|
942
|
+
- **Arity:** 1
|
943
|
+
- **Type:** string
|
944
|
+
|
945
|
+
### Parameters
|
946
|
+
|
947
|
+
- `string`
|
948
|
+
|
949
|
+
### Implementations
|
950
|
+
|
951
|
+
#### Ruby
|
952
|
+
|
953
|
+
`upcase:ruby:v1`
|
954
|
+
|
955
|
+
_Note: No identity value. First element initializes accumulator._
|