FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

mango.utils.Array?

 
Post new topic   Reply to topic     Forum Index -> Mango
View previous topic :: View next topic  
Author Message
csauls



Joined: 27 Mar 2004
Posts: 278

PostPosted: Thu May 25, 2006 1:47 am    Post subject: mango.utils.Array? Reply with quote

As just came up on the NG, basic common array functions are a must, so maybe Mango could have a mango.utils.Array module, analogous to mango.utils.Text and that in Cashew:
http://www.codemeu.com:81/~pontiff/projects/cashew/docs/ArrayUtils.html

Just some essentials for when you do a lot of array handling, but don't need the elaboration of mango.containers. Smile

The Cashew code is, of course and as always, available for a launchpad to the Mango version, if it happens.
_________________
Chris Nicholson-Sauls
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
qbert



Joined: 30 Mar 2004
Posts: 209
Location: Dallas, Texas

PostPosted: Thu May 25, 2006 9:05 am    Post subject: Reply with quote

Seconded.

These really should be provided by the language but untill then some good array templates are needed.

I'd also suggest 'bool contains' to search an array, 'T[] unique' , given two arrays would return a unique result set.

Charlie
Back to top
View user's profile Send private message MSN Messenger
csauls



Joined: 27 Mar 2004
Posts: 278

PostPosted: Thu May 25, 2006 12:13 pm    Post subject: Reply with quote

qbert wrote:
'T[] unique' , given two arrays would return a unique result set.

It may be that I just got out of bed, but I'm not sure I quite grasp what you mean. Is it to be something along the lines of PHP's array_diff() function?
http://us2.php.net/manual/en/function.array-diff.php


And also let me add a couple more suggestions myself: .intersect(T[], ...) and, if someone can come up with a good way to pull it off, a .filter(T[], ?) and .map(T{}, ?) ... my ColdC background just won't let me live without the looping expressions (map, hash, find, and filter).
_________________
Chris Nicholson-Sauls
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
qbert



Joined: 30 Mar 2004
Posts: 209
Location: Dallas, Texas

PostPosted: Thu May 25, 2006 12:22 pm    Post subject: Reply with quote

csauls wrote:

It may be that I just got out of bed, but I'm not sure I quite grasp what you mean. Is it to be something along the lines of PHP's array_diff() function?
http://us2.php.net/manual/en/function.array-diff.php


Almost , i mean like php's array_unique http://us2.php.net/manual/en/function.array-unique.php . I said it wrong earlier, it operates on just one array.

filter and intersect sound good.

I actually tried to implement most of those array_* php functions with templates , but ran into trouble when it got up to about 50+ templates. I can't remember exactly what the error was, I still have the code Ill try to dig it up.

Charlie
Back to top
View user's profile Send private message MSN Messenger
csauls



Joined: 27 Mar 2004
Posts: 278

PostPosted: Thu May 25, 2006 10:32 pm    Post subject: Reply with quote

Ahh, I get you then. Although, maybe .diff() would be good too, although it should probably return a new array rather than modify the source inline, since it'd act on more than one array.

--------------------------------------------------
Edit: I just added some of this to Cashew's utils. New functions:
bool contains (haystack, needle)
T[] diff (alpha, beta)
T[] intersect (alpha, beta)
void unique (haystack)
_________________
Chris Nicholson-Sauls
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
csauls



Joined: 27 Mar 2004
Posts: 278

PostPosted: Wed Sep 13, 2006 12:14 am    Post subject: Reply with quote

As posted on the NG, cashew's array utils have been expanded, and also refactored to take out the wrapper class. IFTI and the new imports system make it seem unneccessary.

http://www.codemeu.com:81/~pontiff/projects/cashew/doc/array.html
_________________
Chris Nicholson-Sauls
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Mango All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group