funkr 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -107,10 +107,16 @@ 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] ]
110
+ # difference entre 2 tableaux, retourne le triplet [ [missing] , [intersection], [added] ]
111
+ # codé en impératif parce que inject est trop lent :(
111
112
  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]} ]
113
+ m, i, a = [], [], []
114
+ self.each do |e|
115
+ if other.find{|x| yield(e,x)} then i.push(e) # intersection
116
+ else m.push(e) end # missing
117
+ end
118
+ other.each { |e| a.push(e) unless self.find{|x| yield(e,x)} } # added
119
+ [ m, i, a ]
114
120
  end
115
121
 
116
122
  end
@@ -1,3 +1,3 @@
1
1
  module Funkr
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
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: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul Rivier