On Fri, Jan 29, 2016 at 7:04 PM, Scotty C <costo...@hotmail.com> wrote:

> > > question for you all. right now i use modulo on my bignums. i know i
> > > can't do that to a byte string. i'll figure something out. if any of
> > > you know how to do this, can you post a method?
> > >
> >
> > I'm not sure what your asking exactly.
>
> i'm talking about getting the hash index of a key. see my key is a bignum
> and i get the hash index with (modulo key 6000011). so i either need to
> turn the key (which will be a byte string) into a number. stuff that right
> in where i have key. or i replace modulo.



Sorry -- I haven't been following this thread closely, so I apologize if
this question was already answered:

Did you implement your own hash tables, or are you using Racket's built-in
hashes? Because if you're using the built-in ones, there's no reason to do
this. You just use your object (a bignum, a byte string, or anything else)
as the key. (The hash code is generated by `equal-hash-code`, but you don't
have to call it yourself. The hash implementation does that.)

However, if you have implemented your own, you can still call
`equal-hash-code` on your byte string. That will give you an exact integer,
and you can then call modulo (or remainder) on that.

-Jon

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to