Dear David, Thanks for the idiom reference!
With a lot of respect, I think you missed my point. The APL 1 idiom works as you want and expect in APL 1, APL 2, and GNU APL. Look closely at my example. On the other hand, if it is I who is missing the point (quite possible), please explain. Thanks. Blake On Wed, May 28, 2014 at 5:57 PM, David B. Lamkins <dlamk...@gmail.com>wrote: > Yes, it is interesting. > > I now understand that ⍎BS/'expr' is an APL 1 idiom that became obsolete > with APL 2. > > The APL 2 IDIOMS Library[*] offers this instead: > fn¨BS/⊂A ⍝ Conditional execution of monadic function. > > As-is, this is not as general as APL 1's ⍎BS/'expr', but it's still > useful. > > With a helper function, one can get the behavior of the APL 1 idiom as > interpreted by APL 2: > > ⎕cr 'ex' > z←ex v > z←⍎v > ex¨0/⊂'⍳5' > > ex¨1/⊂'⍳5' > 1 2 3 4 5 > > Finally, to get the original effect of APL 1's 0⍴⍎BS/'expr' : > > ⎕cr 'qx' > qx v > v > qx¨0/⊂'⍳5' > qx¨1/⊂'⍳5' > ⍳5 > > I guess I have some APL 1 habits to unlearn... :\ > > Thanks, Blake, for bringing this up. > > > [*] APL 2 IDIOMS Library, Stan Cason, IBM, Endicott NY > ftp://ftp.software.ibm.com/ps/products/apl2/info/APL2IDIOMS.pdf > > > On Wed, 2014-05-28 at 13:34 -0500, Blake McBride wrote: > > Dear David, > > > > > > Interesting observation. More interesting is how GNU APL correctly > > handles it. i.e.: > > > > > > ∇test[⎕]∇ > > ∇ > > [0] test > > [1] '1' > > [2] ⍎0/'test2' > > [3] '2' > > [4] '' > > [5] '3' > > [6] ⍎1/'test2' > > [7] '4' > > ∇ > > ∇test2[⎕]∇ > > ∇ > > [0] test2 > > [1] 'test2' > > ∇ > > test > > 1 > > 2 > > > > > > 3 > > test2 > > 4 > > > > > > The problem you bring up, which would be very significant, isn't a > > problem. I'm uncertain of the logic used, but GNU APL (correctly) > > produces the expected and standard behavior - a behavior that doesn't > > have the problem you mention. > > > > > > Am I missing something? > > > > > > Thanks. > > > > > > Blake > > > > > > > > > > On Wed, May 28, 2014 at 1:19 PM, David B. Lamkins <dlamk...@gmail.com> > > wrote: > > Now that I can see how printing '' as CR affects a larger > > program, I've > > gotta say that I'm stumped as to how this behavior can be > > considered > > usable. > > > > Specifically, it's now (unless there's a trick I haven't yet > > discovered) > > difficult (see below) to silently (i.e. without affecting the > > display) > > execute an arbitrary expression that may, depending upon the > > expression, > > return either '' or nothing at all. > > > > I dunno... maybe that's not something that anyone else has > > ever done. > > > > But here's an extremely common idiom that breaks badly under > > the new > > print behavior: > > > > ⍎test/'expression' > > > > This is just a conditional execution of an expression. The > > problem with > > the new print behavior is that this line will print a CR > > whenever the > > test is false. Not OK... > > > > If we're going to stick with this new behavior, I can adapt. > > I've even > > discovered a (rather tortured-looking) solution to the > > use-case I posed > > in the second paragraph: > > > > ∇sink v > > ⍝ Consume value; no display > > ∇ > > > > sink '0' ⎕ea ',⍎l' > > > > On the other hand, it's surprising to me how this new behavior > > affects > > so much else. > > > > > > > > > > >