# CHARHIST()

Generates a character histogram of a string

Syntax

  CHARHIST ([<cString>]) -> aCharacterCount

Arguments

  [<cString>] is the string for whom the function generates a character histogram Default: "" (empty string)

Returns

  <aCharacterCount> an array with 256 elements where the nth element contains the count of character #(n-1) in cString

Description

  The CHARHIST() function generates a character histogram of those characters that are contained in <cString>. This histogram is stored in an 256-element array where the nth element contains the count of ASCII character #(n-1) in <cString>.

Examples

          ? charhist ("Hello World !")[109] --> 3  // chr(108)=="l"
    Tests
          charhist ("Hello World !")[109] == 3
          eval ({||aeval (charhist ("Hello World !"),{|x|nTotal+=x}),nTotal==len("Hello World !")}

Status

  Ready

Compliance

  CHARHIST() is only available in Harbour's CT3 library.

Platforms

  All

Files

  Source is charlist.c, library is libct.

See Also

- CHARLIST()
- CHARNOLIST()
- CHARSLIST()