funkr 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -107,5 +107,10 @@ class Array
107
107
  self.sliding_groups_of(seq.size).index(seq)
108
108
  end
109
109
 
110
+ # difference entre 2 tableaux, retourne le couple [ [missing] , [added] ]
111
+ def diff_with(other, &block)
112
+ [ self.inject([]){|a,e| other.find{|x| yield(e,x)} ? a : a + [e]},
113
+ other.inject([]){|a,e| self.find{|x| yield(e,x)} ? a : a + [e]} ]
114
+ end
110
115
 
111
116
  end
data/lib/funkr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Funkr
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/test/tests.rb CHANGED
@@ -87,3 +87,7 @@ puts((1..10).to_a.sliding_groups_of(3).inspect)
87
87
  puts "\n> seq_index (30)"
88
88
  puts((0..100).to_a.seq_index([30,31,32]))
89
89
 
90
+ puts "\n> diff_with"
91
+ a = [ {:v => 1}, {:v => 2}, {:v => 3} ]
92
+ b = [ {:v => 2}, {:v => 3}, {:v => 4} ]
93
+ puts(a.diff_with(b){|x,y| x[:v] == y[:v]}.inspect)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: funkr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 7
10
- version: 0.0.7
9
+ - 8
10
+ version: 0.0.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul Rivier
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-17 00:00:00 +01:00
18
+ date: 2011-03-21 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21