SP_AMAVERAGE

AMAVERAGE()

  Short:
  ------
  AMAVERAGE() Average on a given element of multi-dim array

  Returns:
  --------
  <nAverage> => average of array element

  Syntax:
  -------
  AMAVERAGE(aMult,nElem,[bCondition])

  Description:
  ------------
  Returns average of array <aMult> element <nElem>.

  [bCondition] is an optional codeblock used to select
  a subset of the  array. This could be used to filter out 0's or
  non-numeric elements.  The block must accept a subarray as a
  parameter, and return  true or false <expL> to determine if this
  element is part of the desired  subset.

  Please not that the codeblock accepts the whole
  subarray, not  just subarray element <nElem>

  Examples:
  ---------

   ?"Average file size here is "
   ??amaverage(DIRECTORY(),2)

   ?"Average .EXE file size here is "
   ??amaverage(DIRECTORY(),2,{|e|".EXE"$e[1]}  )

   use customer
   ?"Average field size "
   ??amaverage(DBSTRUCT(),3)

  Notes:
  -------
  Presumes all sub-arrays are of equal length

  Coded by Matthew Maier.

  Source:
  -------
  S_AMSTAT.PRG

 

SP_AKOUNT

AKOUNT()

  Short:
  ------
  AKOUNT() Counts exact matches of value in array

  Returns:
  --------
  <nMatches>  => Number of matches

  Syntax:
  -------
  AKOUNT(aTarget,expWhatever)

  Description:
  ------------
  Counts # of exact matches of <expWhatever> in
  <aTarget>. <expWhatever> can be of any type.

  Examples:
  ---------

   AFIELDS(aFields,aTypes)
   nChar  := AKOUNT(aTypes,"C")  // count C fields
   nNum   := AKOUNT(aTypes,"N")  // count N fields
   nDate  := AKOUNT(aTypes,"D")  // count D fields

  Notes:
  -------
  See also AMATCHES() which allows a code block.

  Source:
  -------
  S_AKOUNT.PRG