View Single Post
Old Jan 28th, 2008, 10:09 AM   #6
grimpirate
King of Portal
 
grimpirate's Avatar
 
Join Date: Sep 2005
Posts: 431
Rep Power: 4 grimpirate is on a distinguished road
Send a message via Yahoo to grimpirate
Re: Function too convoluted?

Attenuate is the filtering function. It doesn't make much sense to me to write another function that would aid this one. I'd still have to know how they want to filter the results so I don't understand how the GT/LT/EQ is debilitating. I can explain algorithmically what the function is doing.
  1. If 0 arguments are passed return an error
  2. If 1 argument is passed return the array or return error
  3. If more than one argument is passed assume the first argument is an array, if not return error
  4. If remaining arguments were passed as an array pop them from the passed arguments array
  5. Take the first argument of the remaining args and assume it is the key to filter by
  6. Take the second argument of the remaining args and assume it is the operation to be performed
  7. If the operation is LT|GT|EQ|LTEQ|GTEQ then only take one argument as the filter value
  8. If the the operation is LTGT|GTLT|LTEQGT|GTEQLT|LTGTEQ|GTLTEQ|LTEQGTEQ|GTEQLTEQ then take the next two arguments as the filtering value
  9. Repeat until there are no more arguments left
  10. Look at each value of the array, if it's an array then recurse the function
  11. If the returned result is different from the value then unset that portion of the array
  12. If the value is not an array then proceed to filter results only if the key passed through parameters is the same as the current key of the data
  13. If an i was present in the filtering operation then assume we want case insensitivity of strings
  14. Check the actual value to determine if it is a string or not
  15. Irrelevant of the type of checking denote that a value greater results in 1 a value less than results in -1 and equality results in 0
  16. Based on the previous results and the operation type determine the range of values which satisfy the filtering operation and unset any that do not
  17. Return the filtered array
__________________
Lo, there do I see my father. 'Lo, there do I see My mother, and my sisters, and my brothers. 'Lo, there do I see The line of my people... Back to the beginning. 'Lo, they do call to me. They bid me take my place among them. In the halls of Valhalla... Where the brave... May live... ...forever.. GrimBB | Mimesis
grimpirate is offline   Reply With Quote