Re: What's the purpose of CountTable?

2017-12-27 Thread Udiknedormin
No, you're wrong. Iterable is ANY container that can be iterated over (including lists, sets etc) while openArray is anything that has an array-like memory layout, i.e. array or seq. Your code fails for containers which with non-linear memory layout: import lists var li =

Re: What's the purpose of CountTable?

2017-12-27 Thread moigagoo
PR submitted: [https://github.com/nim-lang/Nim/pull/6977](https://github.com/nim-lang/Nim/pull/6977)

Re: What's the purpose of CountTable?

2017-12-27 Thread moigagoo
> I can't see any proc to create a CountTable from any iterable so I think > you're wrong with assigning ones [toCountTable](https://nim-lang.org/docs/tables.html#toCountTable,openArray\[A\]) does that. > Also, it's not just like any table, as it provides inc proc Well, yes, but you actually h

Re: What's the purpose of CountTable?

2017-12-26 Thread Udiknedormin
I can't see any proc to create a CountTable from any iterable so I think you're wrong with assigning ones, it seems it's defined only for openArray`s. Also, it's not just like any table, as it provides `inc proc. Please notice this method works even if the table does NOT contain the key yet!

What's the purpose of CountTable?

2017-12-26 Thread moigagoo
As far as I can see from the docs, it's just a regular table where values are of type `int`. It doesn't actually count things for you, rather you have to increase the counter yourself. If you create a CountTable from an iterable, it doesn't count how many times each key is included in it, just a