bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Determining data type...


From: Kacper Gutowski
Subject: Re: [Bug-apl] Determining data type...
Date: Fri, 1 Aug 2014 01:12:57 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

On 2014-07-31 15:54:44, Peter Teeson wrote:
> Looked in the APL2 IBM manual but do not understand how to determine the data 
> type of a variable.
> Neither the primitives nor the Quads sparked the answer in my brain. 
> It must be something pretty obvious but not to me right now.
> 
> So if I have a function FOO X how do I determine if X is character, integer, 
> float, or imaginary?
> Assuming that it is not a nested array of course.


      ischar←{''≡0⍴⍵}
      isnumeric←{⍬≡0⍴⍵}
      ⍝ otherwise it's mixed or nested; examine elements

As for distinguishing integers, floats, and imaginary numbers, the
standard explicitly requests that there be no difference in behaviour of
numbers of different representations.  You should not need to check what
kind of number they are, instead check explicitly whether their
complex/fractional part is zero.

      isint←{0=1|⍵}
      isreal←{⍵=|⍵}

Of course, there could be some kind of quad function to tell the internal
representation, but to my best knowledge there isn't one.
Though, in GNU APL, you can also distinguish complex number using ⎕TF.


-k



reply via email to

[Prev in Thread] Current Thread [Next in Thread]