« first day (1856 days earlier)      last day (791 days later) » 

2:19 AM
hey, i know this could be done with "if" but it feels like it might be able to be done with rank?

if ⍵ is rank 3: +⌿⍵
else: ⍵
 
2:33 AM
ok, i have a way (not using the rank operator though) but it isn't one i'm proud of
      m←3 3 ⍴ ⍳9
      {+⌿(⌽3↑(⌽⍴⍵),1)⍴⍵} m
1 2 3
4 5 6
7 8 9
      ⍝ it leaves m (a rank 2 array) alone
      m←2 3 3 ⍴ ⍳100
      {+⌿(⌽3↑(⌽⍴⍵),1)⍴⍵} m
11 13 15
17 19 21
23 25 27
      ⍝ it does +⌿ to the rank 3 array
 
3:15 AM
{(+⌿)⍣(3=≢⍴⍵)⊢⍵} works too, but maybe someone more experienced could come up with something better.
(My first attempt was (+⌿)⍣(3=≢∘⍴), which failed because 3=≢∘⍴ is a function, not a scalar.)
 
 
8 hours later…
11:05 AM
{⊃+⌿↓⍵} maybe.
 
11:21 AM
@rabbitgrowth @FawnLocke ⍸2=0+⌿⍤=∘.|⍨∘⍳
 
Aha, nice
 
@LdBeth Sure, it has a right-identity because n-0=n for all n.
@justin2004 I suppose your is always rank 3 or less, and non-empty: +⌿⊢⍴⍨1⌈¯3↑⍴
If can be empty: +⌿⊢⍴⍨¯3↑1 1 1,⍴
Oh, wait, these always return a rank 2 result, not if has rank 0 or 1.
 
11:56 AM
@rabbitgrowth that's what I'd do
 
 
3 hours later…
3:03 PM
Iverson wrote "PSQ:a=⌊a←⍵*.5" over 50 years ago, and it perfectly translates into the tacit example on the aplcart :)
 
AND the ⌊ symbol has been widely used outside APL
 
 
4 hours later…
6:48 PM
So, I'm just starting with APL. I was thinking, it's possible to use APL in shell as part of a pipeline receiving a stream?
We can write `awk 'program' file`, maybe there is any apl implementation that could work that way?
 
I've seen a paper suggesting an idea like this the other day, but i'm not sure if i can find it anymore.
 
18.2 features shell scripting and is due to release quite soon. You might be able to do this with some combination of hacks unknown to me.
 
@jacksonbenete With Dyalog 18.2 you can use "dyalogscript". See example here: xpqz.github.io/learnapl/workflow.html#dyalogscript
 
That's just great! Thanks for letting me know, I'll be waiting for it. I'm in 18.0.
 
notice that APL isn't really that useful for processing non-numeric data & friends, the APL glyphs won't render in the shell prompt unless you use an APL font for your terminal. for a lot of normal unix-y/awk-y problems, the traditional toolbox of sed/awk/perl does the job well because of how specialised these tools are, while APL is somewhat vague, general and more multipurpose than, say, AWK.
AWK automatically loops, splits you input into the chunks, figures out in a "smart" way where to take input from, has conveniently available regexes, ...
 
7:04 PM
Apart from rendering, typing the glyphs would be a problem, I can imagine prototyping something in a small dataset on the apl repl/editor session, and then copy the sentence for using in shell, or use a apl -f myscript file. In shell I would apply it to the complete dataset.
 
what matters at least to me is the convenience. i'd rather have quick awk/perl solution that does the job and move on to the rest of the problem than perfect this small and often insignificant bit. that's also the mindset of sysadmins i knew, etc...
 
 
3 hours later…
10:34 PM
You may try just forget about "shell" and think the APL session is your shell, and at least ⎕sh can call external programs via shell in the session. @jacksonbenete
 

« first day (1856 days earlier)      last day (791 days later) »