Re: [Haskell-cafe] Bloom Filter

2007-05-02 Thread tom
Hi Andrew, Thanks for the comments, it really helps to have someone else's opinion on my code. I'll be applying what you've said as soon as I get a chance and I'm sure I'll have some more questions then. I'll certainly look more closely at the Set interface and try and duplicate all the parts

Re: [Haskell-cafe] Bloom Filter

2007-05-01 Thread Josef Svenningsson
Hi, Just a small comment on one of the comments. On 5/1/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Also, rather than this: add :: Bloom a - a - Bloom a a better argument order is this: insert :: a - Bloom a - Bloom a That way, you can use it with foldr. Hmmm. If you want to

[Haskell-cafe] Bloom Filter

2007-05-01 Thread Dom
Reminds me of this code from Data.Binary: unroll :: Integer - [Word8] unroll = unfoldr step where step 0 = Nothing step i = Just (fromIntegral i, i `shiftR` 8) roll :: [Word8] - Integer roll = foldr unstep 0 where unstep b a = a

Re: [Haskell-cafe] Bloom Filter

2007-05-01 Thread ajb
G'day all. Quoting Dom [EMAIL PROTECTED]: But better than what is in Codec.Utils: [deletia] It seems a shame that everyone has to roll their own. That and integer log base 2. Cheers, Andrew Bromage ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Bloom Filter

2007-05-01 Thread ajb
G'day all. I wrote: insert :: a - Bloom a - Bloom a That way, you can use it with foldr. Quoting Josef Svenningsson [EMAIL PROTECTED]: Hmmm. If you want to create a Bloom using a fold wouldn't it make more sense to use foldl'? I think the argument order is fine. You're right that

[Haskell-cafe] Bloom Filter

2007-04-30 Thread tom
Hi all, I'm pretty new to Haskell, I've been working on a Bloom filter[1] implementation as a learning exercise. I'd really appreciate it if someone more experienced would comment on the code. I'm sure there's plenty of places where I'm doing things in silly or overly complex ways. I've

Re: [Haskell-cafe] Bloom Filter

2007-04-30 Thread ajb
G'day. Quoting tom [EMAIL PROTECTED]: I'm pretty new to Haskell, I've been working on a Bloom filter[1] implementation as a learning exercise. Excellent! Sounds like a fun test. I'd really appreciate it if someone more experienced would comment on the code. I'm sure there's plenty of

Re: [Haskell-cafe] Bloom Filter

2007-04-30 Thread Donald Bruce Stewart
ajb: Quoting tom [EMAIL PROTECTED]: This looks cool: bytes2int = foldr ((. (256 *)) . (+)) 0 . (map toInteger) but I'm not smart enough to parse it. This is both more readable and shorter: bytes2int = foldr (\x r - r*256 + fromInteger x) 0 Integer log2's are probably better