Naming Conventions

Scalar

Vector

Matrix

Any
rank

Non-
scalar

Boolean

BS

BV

BM

BA

BN

Integer

IS

IV

IM

IA

IN

Float

FS

FV

FM

FA

FN

Numeric

NS

NV

NM

NA

NN

Character

CS

CV

CM

CA

CN

Enclosed
vector

ES

EV

EM

EA

EN

enclosed
Text vector

TS

TV

TM

TA

TN

Simple

SS

SV

SM

SA

SN

Any

AS

AV

AM

AA

AN

phrase e.g.: .X...Y. ⍝ X←BS; Y←IV

combinations: use ISV for Integer scalarvector

B3, I4 &c. to specify higher ranks.

Open full technical reference

IsCharacter

This phrase returns a Boolean 1 depending on the type of the simple, non-mixed array.

      ' '=↑1↑0⍴SA

Examples

      ⎕FX ⍕2 1⍴'r←IsCharacter y' 'r←'' ''=↑1↑0⍴y'  
      IsCharacter¨'a' 1
1 0

How not to do it!

In Dyalog, there is a system function ⎕DR available which returns the data type of its argument. Albeit being useful on any non-char types, there is no reason to use it in order to determine whether a simple, non-mixed array is of type Char or not. In the Unicode version of Dyalog ⎕DR started to return 80 for a character variable rather than 82. The phrase returns a 1 in both, the Classic and the Unicode version.

Compatibility

Checked with: APL2, APLX, Dyalog, NARS2000

Test Cases

Show test cases

Test
 ⎕IO←0      ⍝ You may change this; however, zero IS the default in the Phrasebook
 ⎕FX'r←IsCharacter y' 'r←'' ''=↑1↑0⍴y'
⍝ ---- Start Test cases (do not delete this!)
 1 ≡ IsCharacter ''
 0 ≡ IsCharacter ⍳0
 1 ≡ IsCharacter 'abc'
 0 ≡ IsCharacter (1 2 3)

For details see the PhraseBook/TestCasesGuidelines.

Test my code, both Examples and Test Cases.

Mentor: KaiJaeger

Tags: <TypeCheck> <CheckType>


CategoryPhrasesAll

PhraseBook/IsCharacter (last edited 2011-12-26 10:36:00 by KaiJaeger)