SP_AEXTRACT

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

 

2 responses to “SP_AEXTRACT

  1. Pingback: SP Array Functions | Viva Clipper !

  2. Pingback: SP Functions | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.