Sha256: b6d3782b301a0260b241fcd0b8bd22e3f139df3be801145bff7e1d60dc1b65a6

Contents?: true

Size: 421 Bytes

Versions: 4

Compression:

Stored size: 421 Bytes

Contents

# Return a value from the supplied range by searching the first column for the
# supplied value, and then reading the result from the matching row.
Soroban::define :VLOOKUP => lambda { |value, range, col, inexact|
  fc, fr, tc, tr = Soroban::getRange(range)
  i = walk("#{fc}#{fr}:#{fc}#{tr}").find_index(value)
  return nil if i.nil?
  (0...i).each { fr.next! }
  (1...col).each { fc.next! }
  eval("@#{fc}#{fr}.get")
}

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
soroban-0.2.0 lib/soroban/functions/vlookup.rb
soroban-0.1.1 lib/soroban/functions/vlookup.rb
soroban-0.1.0 lib/soroban/functions/vlookup.rb
Soroban-0.1.0 lib/soroban/functions/vlookup.rb