CharHist()

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()

Advertisements

2 responses to “CharHist()

  1. Pingback: Harbour String Functions | Viva Clipper !

  2. Pingback: Harbour All Functions – C | 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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s