356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
|
# File 'lib/marty/xl.rb', line 356
def recalc_offsets(ops_pos)
new_ops1, new_ops2, new_ops = [], [], []
ops_pos.each do |d|
new_ops1 += d[2].select do |inner_ops|
inner_ops if inner_ops[0] == 'pos'
end.map do |inner|
[inner[0], d[1].zip(inner[1]).map { |x, y| x + y }, inner[2]]
end
end
new_ops2 = ops_pos.map do |d|
[d[0], d[1], d[2].select { |inner| inner if inner[0] != 'pos' }]
end
new_ops = new_ops1 + new_ops2
count = new_ops.count do |d|
d[2].count do |inner_ops|
inner_ops if inner_ops[0] == 'pos'
end > 0
end
count == 0 ? new_ops.sort : recalc_offsets(new_ops)
end
|