bug-apl
[Top][All Lists]
Advanced

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

Re: [Bug-apl] Element types in mixed arrays


From: Juergen Sauermann
Subject: Re: [Bug-apl] Element types in mixed arrays
Date: Fri, 23 May 2014 19:32:07 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5

Hi,

if M is mixed and possibly nested, then you can try this:

      M←3 3 'a' (4 'b') ⍝ M mixed and nested

      (∈Y)←{0=↑0⍴⍵}¨∈Y←M

      M ◊ Y
 3 3 a  4 b
 1 1 0  1 0

/// Jürgen


On 05/23/2014 06:30 PM, Elias Mårtenson wrote:
That one checks for numbers, of course. Compare to ' ' to check for characters.

Regards,
Elias


On 24 May 2014 00:28, Elias Mårtenson <address@hidden> wrote:
This is the best I can come up with:

      {0=↑1↓,⍵}¨m

Regards,
Elias


On 24 May 2014 00:26, Elias Mårtenson <address@hidden> wrote:
Well, it's not exactly what you're looking for. Consider if an element is a nested array. It'll come out as 0.

Regards,
Elias


On 23 May 2014 23:54, Blake McBride <address@hidden> wrote:
Greetings, and sorry about the basic question.

If I have a mixed array, i.e.:

m←5 5⍴⍳25
m[2;2]←'X'

What I am looking for is the correct way to tell which elements are character and which are numeric.

I know I can do:

m∊⎕AV

That gives me exactly what I am looking for.  It just seems like a lot of work for each element of m to get compared with each element of ⎕AV.  DialogAPL defines monadic ∊ to give this, but IBM APL2 uses it for something else.  I just thought there might be an efficient idiom for this in IBM APL2.

Thanks.

Blake






reply via email to

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