bug-apl
[Top][All Lists]
Advanced

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

Re: Question on scalar extension of left arg


From: Dr . Jürgen Sauermann
Subject: Re: Question on scalar extension of left arg
Date: Fri, 30 Jul 2021 17:56:23 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

Hi Kacpar,

thanks, fixed in SVN 1478.

Best Regards,
Jürgen


On 7/30/21 8:14 AM, Kacper Gutowski wrote:
Looking at this post I think there is a tiny bug in the implementation of each:

      (⍳6) {⍺,⍵}¨ ⍳5
 1 1  2 2  3 3  4 4  5 5
      (⍳5) {⍺,⍵}¨ ⍳6
INDEX ERROR
μ-Z__vA_LO_EACH_vB[2]  (μ-N⊃μ-Z)←(μ-N⊃μ-A)μ-LO                                   ^            ^

I think both should give a LENGTH ERROR.


On Thu, Jul 29, 2021 at 10:48:52PM -0700, Russtopia wrote:
      w
┌→─────┐
│listen│
└──────┘
      cl
┌→────────────────────────────────────────────┐
│┌→──────┐ ┌→─────┐ ┌→─────┐ ┌→─────┐ ┌→─────┐│
││enlists│ │google│ │inlets│ │banana│ │tinsel││
│└───────┘ └──────┘ └──────┘ └──────┘ └──────┘│
└∊────────────────────────────────────────────┘

      w is_anagram_of ¨ cl    ⍝ <-- Should this not implicitly expand left arg?

Look at the shapes, w is not a scalar but a vector of length 6 and cl is a vector of length 5. No scalar extension is possible, but a length error.

What you wanted is simply:

      (⊂w) is_anagram_of¨ cl
0 0 1 0 1

      (∊1 (⍴cl))⍴⊂w
┌→───────────────────────────────────────────┐
↓┌→─────┐ ┌→─────┐ ┌→─────┐ ┌→─────┐ ┌→─────┐│
││listen│ │listen│ │listen│ │listen│ │listen││
│└──────┘ └──────┘ └──────┘ └──────┘ └──────┘│
└∊───────────────────────────────────────────┘
      w w w w w
┌→───────────────────────────────────────────┐
│┌→─────┐ ┌→─────┐ ┌→─────┐ ┌→─────┐ ┌→─────┐│
││listen│ │listen│ │listen│ │listen│ │listen││
│└──────┘ └──────┘ └──────┘ └──────┘ └──────┘│
└∊───────────────────────────────────────────┘

These are not the same. See that arrow on the left border of boxed representation?

      ((∊1 (⍴cl))⍴⊂w) is_anagram_of ¨ cl   ⍝ <-- ?? Why does this not work as (w w w w w)?
RANK ERROR
      ((∈1(⍴cl))⍴⊂w)is_anagram_of¨cl
      ^                           ^

w w w w w       ←→   5⍴⊂w   ⍝ a 5-element vector
((∊1 (⍴cl))⍴⊂w) ←→ 1 5⍴⊂w   ⍝ a 1-by-5 matrix

-k



reply via email to

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