halunke 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/docs/array.md +13 -0
- data/lib/halunke/runtime/harray.rb +5 -0
- data/lib/halunke/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ba9ebbcb1186d006f78c38c14ab406969fe6b27
|
4
|
+
data.tar.gz: 0716253e97cc81ae7c99a1c845a79b3aa2899cde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ad48b695b918c2d8a93101b1fa802ccd7068a8a1198caba3a3e38fbd65a6f78fe22b739943e8fc4ecf246b4fedfe4ca40bcc42a5090fe8f8ad1120df3e33c5c
|
7
|
+
data.tar.gz: c3f657fbc36011b7026cac77a82e114e95404eaee7094a7911c46648416fdbbc0f27b441fca2c8fad502aa5f50b970904c5c874a976621c1d62369d737525569
|
data/Gemfile.lock
CHANGED
data/docs/array.md
CHANGED
@@ -56,6 +56,19 @@ length with the results of the function calls.
|
|
56
56
|
([0 1 2] map { |'x| (x + 1) }) /* => [1 2 3] */
|
57
57
|
```
|
58
58
|
|
59
|
+
## `reduce with`
|
60
|
+
|
61
|
+
Combines all elements of the array into a single element. The second argument
|
62
|
+
is the initial value of the memo variable. The function will be called once
|
63
|
+
for each of the elements. The first argument is the memo, the second the current
|
64
|
+
element. The result of each iteration will be the memo for the next call.
|
65
|
+
The final value of memo will be returned.
|
66
|
+
|
67
|
+
```
|
68
|
+
([1 2 3] reduce {|'memo 'el| (memo + el) } with 0)
|
69
|
+
/* => 6
|
70
|
+
```
|
71
|
+
|
59
72
|
## `find else`
|
60
73
|
|
61
74
|
Calls the provided function for each element. Returns the first element for
|
@@ -21,6 +21,11 @@ module Halunke
|
|
21
21
|
context["fn"].receive_message(context, "call", [HArray.create_instance([x])])
|
22
22
|
end)
|
23
23
|
}),
|
24
|
+
"reduce with" => HFunction.new([:self, :fn, :initial], lambda { |context|
|
25
|
+
context["self"].ruby_value.reduce(context["initial"]) do |memo, current|
|
26
|
+
context["fn"].receive_message(context, "call", [HArray.create_instance([memo, current])])
|
27
|
+
end
|
28
|
+
}),
|
24
29
|
"find else" => HFunction.new([:self, :search_fn, :fallback], lambda { |context|
|
25
30
|
context["self"].ruby_value.find(-> { context["fallback"] }) do |element|
|
26
31
|
context["search_fn"].receive_message(context, "call", [HArray.create_instance([element])]) == context["true"]
|
data/lib/halunke/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: halunke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lucas Dohmen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|