Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- SuperLib 3.50 - function aextract() http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 FUNCTION AEXTRACT()

  Short:
  ------
  AEXTRACT() Extract and return a conditional set from an array

  Returns:
  --------
  <aSubset> => subset of the array

  Syntax:
  -------
  AEXTRACT(aSource,bCondition,[nElement])

  Description:
  ------------
  Extracts elements meeting <bCondition> from <aSource>
  and returns them as in an array.

  <bCondition> is a code block that, for each element
  of <aSource> is passed the element and the position. So for
  element 3 the codeblock would be called with

    EVAL(bCondition,aSource[3],3)

  [nElement]  if passed signals that <aSource> is an
  array of arrays, and that [nElement] is to be extracted from
  each subarray where <bCondition> is true.

  Examples:
  ---------
   aNames    := {"Fred","Wilma","Barney","Betty"}
   aRubbels  := aextract(aNames,{|e|left(e,1)=="B"} )

   aDir := directory()
   // extract for size > 100,000
   aBig := aextract(aDir,{|e,n|aDir[n,2]> 100000})
   // extract only the name element for size > 100,000
   aBigNames := aextract(aDir,{|e,n|aDir[n,2]> 100000},1)

  Source:
  -------
  S_AEXTRA.PRG


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson