funkr 0.0.22 → 0.0.23

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,13 @@
2
2
  module Enumerable
3
3
 
4
4
  # enumerable extensions
5
+
6
+ # Folds an enumerable with an operator
7
+ def fold_with(sym)
8
+ self.inject{|a,e| a.public_send(sym,e)}
9
+ end
10
+
11
+ # Check if all elements in collection are differents
5
12
  def all_different?
6
13
  a = self.to_a.drop(1)
7
14
  self.each do |e|
data/lib/funkr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Funkr
2
- VERSION = "0.0.22"
2
+ VERSION = "0.0.23"
3
3
  end
@@ -47,6 +47,12 @@ class TestExtensions < Test::Unit::TestCase
47
47
  assert_equal(30, (0..100).to_a.seq_index([30,31,32]))
48
48
  end
49
49
 
50
+ def test_fold_with
51
+ assert_equal(15, [1,2,3,4,5].fold_with(:+))
52
+ assert_equal(6, [1,2,3].fold_with(:*))
53
+ assert_equal(1, [256,2,2,2,2,2,2,2,2].fold_with(:/))
54
+ end
55
+
50
56
  def test_diff_with
51
57
  a = [ {:v => 1}, {:v => 2}, {:v => 3}, {:v => 2}, {:v => 3} ]
52
58
  b = [ {:v => 2}, {:v => 3}, {:v => 4}, {:v => 3}, {:v => 4} ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funkr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-14 00:00:00.000000000Z
12
+ date: 2011-10-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &15155260 !ruby/object:Gem::Requirement
16
+ requirement: &18284740 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.9.2
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *15155260
24
+ version_requirements: *18284740
25
25
  description: ! '[EXPERIMENTAL] Some functionnal constructs for ruby, like ADT, functors,
26
26
  monads'
27
27
  email: