funkr 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,6 +18,10 @@ module Funkr
18
18
  end
19
19
  end
20
20
  end
21
+
22
+ def lift_with(*args, &block)
23
+ full_lift_proc(&block).call(*args)
24
+ end
21
25
  end
22
26
 
23
27
 
@@ -89,5 +89,12 @@ class Array
89
89
  else [[], self]
90
90
  end
91
91
  end
92
+
93
+ # Constitue des groupes de n éléments
94
+ def groups_of(ar, n)
95
+ return [] if self.empty?
96
+ [self.take(n)] + groups_of(self.drop(n), n)
97
+ end
98
+
92
99
 
93
100
  end
data/lib/funkr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Funkr
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/test/tests.rb CHANGED
@@ -33,11 +33,16 @@ f = Maybe.full_lift_proc{|x,y| x + y}
33
33
  puts f.call(m,m)
34
34
  puts f.call(m,n)
35
35
 
36
+ puts "\n> Lift with"
37
+ puts Maybe.lift_with(m,m){|x,y| x + y}
38
+
39
+ puts "\n> mconcat"
36
40
  puts Maybe.mconcat([Maybe.just(10),
37
41
  Maybe.just(20),
38
42
  Maybe.nothing,
39
43
  Maybe.just(30)])
40
44
 
45
+ puts "\n> Comparisons"
41
46
  puts(m <=> m)
42
47
  puts(m <=> (m.map{|v| v+1}))
43
48
  puts(m < (m.map{|v| v+1}))
@@ -65,3 +70,6 @@ puts(a.bind do |x|
65
70
  end
66
71
  end.inspect)
67
72
 
73
+
74
+ puts "\n> group_seq_by"
75
+ puts([1,2,4,5,7,5,8,2,10].group_seq_by{|x| x % 2}.inspect)
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Paul Rivier
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-03-09 00:00:00 +01:00
17
+ date: 2011-03-11 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20