Re: [Haskell-cafe] Pure hashtable library

2008-08-28 Thread Richard A. O'Keefe
On 28 Aug 2008, at 9:07 pm, Jules Bean wrote: Insert for Data.Sequence is log(i) where i is the position of the insertion; clearly bounded by log(n). toList is O(n) and index is (at worst) log(i). I think the corresponding operations with tries are log(n), Let the key you want to insert h

Re: [Haskell-cafe] Pure hashtable library

2008-08-28 Thread Jason Dusek
Well, sure, that could work too. -- _jsn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Pure hashtable library

2008-08-28 Thread Jules Bean
Jason Dusek wrote: Jules Bean <[EMAIL PROTECTED]> wrote: Jason Dusek wrote: Jules Bean <[EMAIL PROTECTED]> wrote: Jason Dusek wrote: I would much rather have a pure Trie that is foldable. If we have a Trie, we get a space efficient sorted list, too. Well, Data.Sequence can be used as a space

Re: [Haskell-cafe] Pure hashtable library

2008-08-28 Thread Jason Dusek
Jules Bean <[EMAIL PROTECTED]> wrote: > Jason Dusek wrote: > > Jules Bean <[EMAIL PROTECTED]> wrote: > > > Jason Dusek wrote: > > > > I would much rather have a pure Trie that is foldable. > > > > If we have a Trie, we get a space efficient sorted list, > > > > too. > > > > > > Well, Data.Sequence

Re: Re[2]: [Haskell-cafe] Pure hashtable library

2008-08-28 Thread Jan-Willem Maessen
On Aug 27, 2008, at 4:31 PM, Bulat Ziganshin wrote: Hello Jan-Willem, Wednesday, August 27, 2008, 4:06:11 PM, you wrote: One obvious way to make non-modifiable hash tables useful is to "eat your own tail" non-strictly--- aggregate a set of hash table entries, construct a hash table from them

Re: [Haskell-cafe] Pure hashtable library

2008-08-28 Thread Jules Bean
Jason Dusek wrote: > Jules Bean <[EMAIL PROTECTED]> wrote: >> Jason Dusek wrote: >>> I would much rather have a pure Trie that is foldable. If we >>> have a Trie, we get a space efficient sorted list, too. >> Well, Data.Sequence can be used as a space efficient sorted >> list which is Foldable - i

Re: [Haskell-cafe] Pure hashtable library

2008-08-28 Thread Jason Dusek
Jules Bean <[EMAIL PROTECTED]> wrote: > Jason Dusek wrote: > > I would much rather have a pure Trie that is foldable. If we > > have a Trie, we get a space efficient sorted list, too. > > Well, Data.Sequence can be used as a space efficient sorted > list which is Foldable - if you make the decision

Re[2]: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Bulat Ziganshin
Hello Don, Thursday, August 28, 2008, 10:32:43 AM, you wrote: > Seems like you can make a pure hashtable by unsafePerformIO on the > impure one, and exporting only 'lookup'.. probably yes, but it will lose a bit of performance due to incremental building of hashtable. actually, writing HT module

Re: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Don Stewart
bulat.ziganshin: > Hello Richard, > > Thursday, August 28, 2008, 5:28:46 AM, you wrote: > > >>> trie: O(len)*O(width) > >>> hashed trie: O(len) > >>> hash: O(len) > > > If "width" here refers to the branching factor of the trie, > > it's actually O(len.lg(width)), and the width that matters > >

Re[2]: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Bulat Ziganshin
Hello Richard, Thursday, August 28, 2008, 5:28:46 AM, you wrote: >>> trie: O(len)*O(width) >>> hashed trie: O(len) >>> hash: O(len) > If "width" here refers to the branching factor of the trie, > it's actually O(len.lg(width)), and the width that matters > is not the *possible* number of choices

Re: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Jules Bean
Jason Dusek wrote: I would much rather have a pure Trie that is foldable. If we have a Trie, we get a space efficient sorted list, too. Well, Data.Sequence can be used as a space efficient sorted list which is Foldable - if you make the decision to insert elements into it in a sorted way

Re: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Jason Dusek
I would much rather have a pure Trie that is foldable. If we have a Trie, we get a space efficient sorted list, too. -- _jsn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Richard A. O'Keefe
Someone wrote: trie: O(len)*O(width) hashed trie: O(len) hash: O(len) If "width" here refers to the branching factor of the trie, it's actually O(len.lg(width)), and the width that matters is not the *possible* number of choices but the *actual* number. The great problem with hash tables is d

Re[2]: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Bulat Ziganshin
Hello Jules, Wednesday, August 27, 2008, 7:59:55 PM, you wrote: >>> To get "much better efficient" than a trie, the hash function has to be >>> so fast that it is faster than following (log n) pointers >> >> afaiu, trie search follows n pointers > No. > "n" is the number of strings in my data

Re[2]: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Bulat Ziganshin
Hello Jan-Willem, Wednesday, August 27, 2008, 4:06:11 PM, you wrote: > One obvious way to make non-modifiable hash tables useful is to "eat > your own tail" non-strictly--- aggregate a set of hash table entries, > construct a hash table from them, and plumb the resulting hash table > into the o

Re[2]: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Bulat Ziganshin
Hello Stephan, Wednesday, August 27, 2008, 1:52:23 PM, you wrote: > and on the other and, its implementation uses hash functions and arrays > as well. IIRC it does that in a state monad that keeps the array mutable > and finally freezes it before usage, which might be a good idea for pure > hash t

Re[2]: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Bulat Ziganshin
Hello Daniel, Wednesday, August 27, 2008, 8:01:24 PM, you wrote: >> trie: O(len)*O(width) >> hashed trie: O(len) >> hash: O(len) > Wouldn't the hashtable have lookup time O(len+bucketsize)? i suppose that bucketsize=O(1): constructor should get [approximate] size of hashed assoclist and it will

Re: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Jules Bean
Bulat Ziganshin wrote: Hello Jules, Wednesday, August 27, 2008, 7:21:46 PM, you wrote: given these constraints, it should be just a 10-20 lines of code, and provide much better efficiency than any tree/trie implementations Prove it. To get "much better efficient" than a trie, the hash f

Re: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Daniel Fischer
Am Mittwoch, 27. August 2008 17:36 schrieb Bulat Ziganshin: > Hello Jules, > > Wednesday, August 27, 2008, 7:21:46 PM, you wrote: > >> given these constraints, it should be just a 10-20 lines of code, and > >> provide much better efficiency than any tree/trie implementations > > > > Prove it. > > >

Re: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Jed Brown
On Wed 2008-08-27 16:21, Jules Bean wrote: > Bulat Ziganshin wrote: >> Hello haskell-cafe, >> >> solving one more task that uses English dictionary, i've thought: why we >> don't yet have pure hashtable library? There is imperative hashtables, >> pretty complex as they need to rebuild entire tabl

Re[2]: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Bulat Ziganshin
Hello Jules, Wednesday, August 27, 2008, 7:21:46 PM, you wrote: >> given these constraints, it should be just a 10-20 lines of code, and >> provide much better efficiency than any tree/trie implementations > Prove it. > To get "much better efficient" than a trie, the hash function has to be >

Re: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Jules Bean
Bulat Ziganshin wrote: Hello haskell-cafe, solving one more task that uses English dictionary, i've thought: why we don't yet have pure hashtable library? There is imperative hashtables, pretty complex as they need to rebuild entire table as it grows. There is also simple assoc lists and tree

Re: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Jan-Willem Maessen
On Aug 27, 2008, at 3:41 AM, Bulat Ziganshin wrote: Hello haskell-cafe, solving one more task that uses English dictionary, i've thought: why we don't yet have pure hashtable library? There is imperative hashtables, pretty complex as they need to rebuild entire table as it grows. There is

Re: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Johannes Waldmann
>> * hashtable is represented as an array of assoc lists: Array Int [(a,b)] > > Don't immutable arrays get rather inefficient when modified? Bulat was specifically asking for "simple *non-modifiable* hashes" http://article.gmane.org/gmane.comp.lang.haskell.cafe/43612 J.W. signature.asc Descr

Re: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Stephan Friedrichs
Bulat Ziganshin wrote: > solving one more task that uses English dictionary, i've thought: why we > don't yet have pure hashtable library? There is imperative hashtables, > [...] > how should it look: > > * hashtable is represented as an array of assoc lists: Array Int [(a,b)] Don't immutable arr

Re: Re[2]: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Thomas Davie
On 27 Aug 2008, at 10:39, Bayley, Alistair wrote: From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Thomas Davie > Much better efficiency in what way? instead of going through many levels of tree/trie, lookup function will just select array element by hash value

RE: Re[2]: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Bayley, Alistair
> From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Thomas Davie > > > Much better efficiency in what way? > > instead of going through many levels of tree/trie, > lookup function will just select array element by hash value > and look through a few elements in ass

Re: Re[2]: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Thomas Davie
On 27 Aug 2008, at 10:09, Bulat Ziganshin wrote: Hello Jason, Wednesday, August 27, 2008, 11:55:31 AM, you wrote: >> given these constraints, it should be just a 10-20 lines of >> code, and provide much better efficiency than any tree/trie >> implementations > Much better efficiency in wha

Re[2]: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Bulat Ziganshin
Hello Jason, Wednesday, August 27, 2008, 11:55:31 AM, you wrote: >> given these constraints, it should be just a 10-20 lines of >> code, and provide much better efficiency than any tree/trie >> implementations > Much better efficiency in what way? instead of going through many levels of tree/

Re: [Haskell-cafe] Pure hashtable library

2008-08-27 Thread Jason Dusek
Bulat Ziganshin <[EMAIL PROTECTED]>: > given these constraints, it should be just a 10-20 lines of > code, and provide much better efficiency than any tree/trie > implementations Much better efficiency in what way? -- _jsn ___ Haskell-Cafe mailing lis

[Haskell-cafe] Pure hashtable library

2008-08-27 Thread Bulat Ziganshin
Hello haskell-cafe, solving one more task that uses English dictionary, i've thought: why we don't yet have pure hashtable library? There is imperative hashtables, pretty complex as they need to rebuild entire table as it grows. There is also simple assoc lists and tree/trie implementations, bu