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 !" ) }
Compliance
CHARHIST() is only available in Harbour’s CT3 library.
Platforms
All
Files
Source is charlist.c, library is libct.
Seealso
CHARLIST(), CHARNOLIST(), CHARSLIST()
Pingback: Harbour String Functions | Viva Clipper !
Pingback: Harbour All Functions – C | Viva Clipper !