Re: sets

From: Date: Sat, 06 May 2000 15:46:00 +0000
Subject: Re: sets
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-18481@lists.php.net to get a copy of this message
Submit a Feature Request at bugs.php.net/version4. On Sat, 06 May 2000, Stig Venaas wrote: > Hi > > I'm writing an PHP4 application where I use sets a lot. The sets are > arrays, but I only care what values I have in them, not about indices > and ordering. I use the set operations union, intersection, subtraction > a lot. I also need to check whether something is an element, that's > easily done with array_in. I could do union with the array_merge > function sort of, but I don't want duplicate values. It would help if > had a function to remove duplicates though, but a specialised union > would help. > > > Would the following functions be accepted if I wrote them? > > array array_union(array array1, array array2) > Creates an array that contains all values from array1 and array2 without > any duplicates provided array1 and array2 don't have dups. > > array array_intersection(array array1, array array2) > Creates an array that contains all values that exists both in array1 and > array2. > > array array_subtraction(array array1, array array2) > Creates an array that contains all values from array1 that is not in > array2. > > The ordering will mostly be preserved, then they are also useful for > "lists". > > > Should they be named set_ rather than array_? > > So what do you say, is this useful? > > Stig > > -- > Stig Venaas > UNINETT > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net > For additional commands, e-mail: php-dev-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > -Andrei "Man, if you gotta ask you'll never know." - Louis Armstrong, when asked "What is jazz?"

« previous php.dev (#18481) next »