funkr 0.0.8 → 0.0.9
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.
- data/lib/funkr/extensions/array.rb +9 -3
- data/lib/funkr/version.rb +1 -1
- metadata +3 -3
@@ -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
|
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
|
-
|
113
|
-
|
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
|
data/lib/funkr/version.rb
CHANGED
metadata
CHANGED