bug-apl
[Top][All Lists]
Advanced

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

Re: APL2 Compatibility


From: Jay Foad
Subject: Re: APL2 Compatibility
Date: Fri, 27 Nov 2020 12:39:18 +0000

No problem!

Your (⊂ 1 2) (/¨)¨(,¨)'ab' can of course be golfed:

      (⊂1 2)/¨¨'ab'
  a  aa    b  bb

Or, in Dyalog:

      1 2∘(/¨)¨'ab'
  a  aa    b  bb

Jay.

On Fri, 27 Nov 2020 at 11:47, Hans-Peter Sorge
<hanspetersorge@netscape.net> wrote:
>
> Hi,
>
> In my mind I mostly think in "elements" - not rank or shape.
>
> That is  "L-element OP R-element" . Where elements have an empty rank
> (scalar, ⊂..). And APL takes care of ranks, shapes and depth.
>
> ⍝ as you mentioned (and I had to remember):  'a' 'b' ≡ 'ab'
> ⍝ that is a vector of single chars is a char vector.
>
>         (⊂ 1 2) /¨'a' 'b'  ⍝  (1 2/'a') (1 2/'b')
>   aaa bbb
>
> what I want:
>          (1 2/¨'a') (1 2/¨'b')
>    a aa    b bb
>
> My initial puzle was ( and as you pointed out) a scalar and a one
> element vector are being treated equally.
>
> in my expression
>           (⊂1 2) (/¨) (,¨) 'ab'
> I ignored that  (,¨) operates on 'ab' and that it does not return 'ab'
> element-wise
>
>
> so this does the job:
>        (⊂ 1 2) (/¨)¨(,¨)'ab'
>    a aa    b bb
>
> Thank you for your patience
>
> Best regards
> Hans-Peter
>
>
> Am 27.11.20 um 10:26 schrieb Jay Foad:
> > I'm not sure what you're saying. Replicate does tolerate a scalar on
> > the right and treat it like a 1-element vector:
> >
> >        (,6)/'a'
> > aaaaaa
> >        (,6)/,'a'
> > aaaaaa
> >
> > Your examples are showing something different, where you're
> > introducing an extra level of nesting to the right argument but
> > without changing its rank or shape.
> >
> > Jay.
> >
> > On Thu, 26 Nov 2020 at 23:56, Hans-Peter Sorge
> > <hanspetersorge@netscape.net> wrote:
> >> Hi Jay,
> >>
> >> .. not quite:
> >>
> >>         (,6)/'a'
> >> aaaaaa
> >>
> >>         (,6)/,¨'a'
> >>    a a a a a a
> >>
> >>         (,6)/'abc'
> >> aaaaaabbbbbbcccccc
> >>
> >>        (,6)/,¨'abc'
> >>    a a a a a a b b b b b b c c c c c c
> >>
> >>         (,6)/¨,¨'abc'
> >>    aaaaaa bbbbbb cccccc
> >>
> >> Hans-Peter
> >>
> >> Am 26.11.20 um 16:24 schrieb Jay Foad:
> >>> Hi,
> >>>
> >>>> Here comes my irritation. Or some missing knowledge ....
> >>>> ⍝ 11 - if this is true ( from ⍝3 )
> >>>>        (⊂1 2 3)/¨'ABC'
> >>>>    AAAAAA BBBBBB CCCCCC
> >>>>
> >>>> ⍝ 12 - then this schould be different
> >>>>         (⊂1 2 3)/¨,¨'ABC'
> >>>>    AAAAAA BBBBBB CCCCCC
> >>>> ⍝ expected
> >>>>     A AA AAA  B BB BBB  C CC CCC
> >>> I think they are the same because:
> >>> 6/¨'abc'
> >>> 6/¨,¨'abc'
> >>> are the same, because:
> >>> 6/'a'
> >>> 6/,'a'
> >>> are the same, because Replicate tolerates a scalar on the right and
> >>> treats it like a 1-element vector.
> >>>
> >>> Jay.
>
>



reply via email to

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