July 15, 2006
Derek Parnell wrote:
> On Sat, 15 Jul 2006 02:46:24 +1000, Carlos Santander  <csantander619@gmail.com> wrote:
> 
> 
>>
>> It was possible some time ago, but it got forbidden. What I've been  doing (and I think others too) is:
>>
>> char [] [char []] whos;
>>
>> And set the element to both the key and the value. However, I admit I  liked void [T].
> 
> 
> Actually I use
> 
>   bool[ char[] ] whos;
> 
>   whos["Capone"] = true;
> 

You can also have a sort of poor-man's multiset with:

int[ char[] ] ms;

One could easily wrap this with a more multiset-ish interface, but to add an item you just say:

++ms["moo"];

And to remove:

if (--ms["moo"] <= 0) ms.remove("moo");

-- 
Kirk McDonald
Pyd: Wrapping Python with D
http://dsource.org/projects/pyd/wiki
July 15, 2006
Kirk McDonald wrote:
> Derek Parnell wrote:
> You can also have a sort of poor-man's multiset with:
> 
> int[ char[] ] ms;
> 
> One could easily wrap this with a more multiset-ish interface, but to add an item you just say:
> 
> ++ms["moo"];
> 
> And to remove:
> 
> if (--ms["moo"] <= 0) ms.remove("moo");
> 

That's what I liked from python... with dicts (aka AA) and lists (aka arrays) you can have basically every container you want.

And some newbie reading the code can grasp the meaning without loosing himself in a plethora of containers...

Now python users are complaining against too much features added in the language...

---
Paolo
1 2 3
Next ›   Last »