Method: RubyLabs::HashLab#h0
- Defined in:
- lib/hashlab.rb
#h0(s, n) ⇒ Object
Trival hash function that uses only the first letter in the input string. s is the string to hash, n is the size of the hash table.
Example:
>> ?b.ord
=> 1
>> h0("beer", 10)
=> 1
– :begin :h0
74 75 76 |
# File 'lib/hashlab.rb', line 74 def h0(s, n) return s[0].ord % n end |