halunke 0.6.1 → 0.6.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a30ac31cb1f6c2532016bf0d0df8b675e14cb4c4
4
- data.tar.gz: 92aad694be55cf366ef8cfa4246392439aeda9fe
3
+ metadata.gz: 7ba9ebbcb1186d006f78c38c14ab406969fe6b27
4
+ data.tar.gz: 0716253e97cc81ae7c99a1c845a79b3aa2899cde
5
5
  SHA512:
6
- metadata.gz: 3088efc5a96653967c9011a10576f31501430cd4f71712db677cbca40bad57de4219a2cc7066c524f4af379af23433e03f8ac976955819591a98b64c838a24d6
7
- data.tar.gz: a32c0fe5da4eee3a5d6fc4cf2b3e0e9233fa5036c9abfc25b2486848b429bd82182f4bfa96edb92cf074caa58ea636d1af252a46f4038c91841df9117ef58aac
6
+ metadata.gz: 9ad48b695b918c2d8a93101b1fa802ccd7068a8a1198caba3a3e38fbd65a6f78fe22b739943e8fc4ecf246b4fedfe4ca40bcc42a5090fe8f8ad1120df3e33c5c
7
+ data.tar.gz: c3f657fbc36011b7026cac77a82e114e95404eaee7094a7911c46648416fdbbc0f27b441fca2c8fad502aa5f50b970904c5c874a976621c1d62369d737525569
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- halunke (0.6.1)
4
+ halunke (0.6.2)
5
5
  rack (~> 2.0.4)
6
6
 
7
7
  GEM
@@ -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"]
@@ -1,3 +1,3 @@
1
1
  module Halunke
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
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.1
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-12 00:00:00.000000000 Z
11
+ date: 2018-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack