« first day (720 days earlier)      last day (1950 days later) » 

7:07 AM
This Haskell library sounds a lot like a backend data structure for APL
Time to build yet another APL derivative...
 
@Bubbler It does indeed, but interestingly, it is last-axis focused, as opposed to APL/J/K that are first-axis focused.
 
 
2 hours later…
9:19 AM
0
Q: Getting the type of a value in APL

August KarlstromI have a long vector which should be a character vector but when I print it using Dyalog's DISPLAY function it turns out to be a mixed vector. Now I need to find out which of the elements is not a character. How do I retrieve the type of a value in APL?

 
 
4 hours later…
1:43 PM
@jordancurve Welcome. Interested in APL?
 
 
2 hours later…
3:58 PM
oops
 
@nathanrogers
{(⍴⍵)⍴(((0<⍺)×|⍺)⍴0),(-⍺)↓⍵,((0>⍺)×|⍺)⍴0}
 
how do you do 2 left arguments with ¨?
I'm trying right f ⍨¨left doesn't seem to work in my case for some reaspon
and left¨ f right doesn't work either
 
4:14 PM
@nathanrogers you need to do each of f ?
If so, ⍺f¨⊂⍵ should work
 
4:27 PM
why is that?
⎕← 3 ¯3{(⍴⍵)⍴(((0<⍺)×|⍺)⍴0),(-⍺)↓⍵,((0>⍺)×|⍺)⍴0}¨⊂1 0 1 1 1 0 1 1
 
@nathanrogers
┌───────────────┬───────────────┐
│0 0 0 1 0 1 1 1│1 1 0 1 1 0 0 0│
└───────────────┴───────────────┘
 
for this I think I have a solution to problem 7 from 2018 challenge
but I'm not sure
 
@nathanrogers Sure, but I think you can make it much simpler.
 
it doesn't use a guard, like the question suggests
 
No, and it's flat, which is also good.
 
4:29 PM
@nathanrogers True, but it does a lot of extra work.
 
@H.PWiz flat?
@J.Sallé why does that ⍺f¨⊂⍵ work to each ⍺?
 
@nathanrogers No nested arrays
 
oh, hmm. do many solutions have that?
 
Yes
 
@nathanrogers @Adám can explain that a lot better than me :p
 
4:31 PM
@H.PWiz I can't imagine an example. could you show me?
I was thinking of trying this with ⊤⊥ but I couldn't seem to get it to work correctly
there's probably some kind of ...bits.../bits kind of solution
 
Oh, hang on, I misunderstood your question. I was thinking of a different "that". I don't know if there are solutions that use nested arrays.
 
Problem 7 - Unconditionally Shifty Logical bitwise shifting is a common operation where bits in a fixed width field are moved to the left or right by a specified amount, N, causing N bits to be "shifted out" at one end and N 0's to be filled in at the other end.
that's the problem from 2018
 
If ↓⍣¯1 worked, a cute solution would be {⍺↓⍣¯1⊢(-⍺)↓⍵}. (I think this is correct)
However:
⎕←0↓⍣¯1⍳5
 
@H.PWiz
 
4:40 PM
Drop elements from one end. Append 0s to the other end
Actually it doesn't work, when is bigger than ⍴⍵
 
⎕←3 ¯3{⍎(0>⍺)⊃'⌽(≢⍵)↑⍺↓⍵' '(≢⍵)↑⍺↓⍵'}¨⊂1 0 1 1 1 0 1 1
 
@J.Sallé
INDEX ERROR
 
oh IO
⋄←⎕IO←0⋄⎕←3 ¯3{⍎(0>⍺)⊃'⌽(≢⍵)↑⍺↓⍵' '(≢⍵)↑⍺↓⍵'}¨⊂1 0 1 1 1 0 1 1
 
@J.Sallé
SYNTAX ERROR
 
I have a 12-byte solution.
 
4:50 PM
I don't remember the correct syntax, mr bot.
 
@J.Sallé Hint: )about
 
something like ⊣⎕IO←0
 
⋄⎕IO←0⋄⎕←3 ¯3{⍎(0>⍺)⊃'⌽(≢⍵)↑⍺↓⍵' '(≢⍵)↑⍺↓⍵'}¨⊂1 0 1 1 1 0 1 1
 
@Adám I've been here a while, shouldn't need that D:
 
@Adám
┌───────────────┬───────────────┐
│0 0 0 1 1 0 1 1│1 0 1 1 1 0 0 0│
└───────────────┴───────────────┘
 
4:51 PM
Ah it doesn't have the first
Cheesy solution btw
 
It is just like a normal session, except you must begin with ⎕← or ⍞← or and you must use ⎕← for any further output.
 
Yeah, I just didn't remember it was just instead of ⋄←
 
let's see those 12 bytes
 
@J.Sallé ⋄← is never valid APL.
 
or at least give us a hint
 
4:53 PM
@nathanrogers @J.Sallé is well on the way. Just need to combine the two parts.
@nathanrogers Hint: A negative left argument to takes from the right and pads on the left.
 
5:17 PM
oops
⎕←3 ¯3{(-⍺)↓((-×⍺)×(≢⍵)+|⍺)↑⍵}¨⊂1 0 1 1 1 0 1 1
 
@nathanrogers
┌───────────────┬───────────────┐
│0 0 0 1 0 1 1 1│1 1 0 1 1 0 0 0│
└───────────────┴───────────────┘
 
@nathanrogers The bot doesn't understand edits.
 
⎕←3 {(-⍺)↓((-×⍺)×(≢⍵)+|⍺)↑⍵}1
 
@nathanrogers
0
 
⎕←5{(-⍺)↓((-×⍺)×(≢⍵)+|⍺)↑⍵}⍬
 
5:19 PM
@nathanrogers
 
is that more like what you had in mind @Adám
 
@nathanrogers A f¨B (by definition) pairs up each scalar of A with each scalar of B exactly like A+B. If any of A or B is a single scalar, then that scalar is paired up with all the scalars of the other side.
@nathanrogers Try first removing the unneeded bits, and only afterwards "over-taking" to restore original size.
 
⎕←3 ¯3{((-×⍺)×≢⍵)↑(-⍺)↓⍵}¨⊂1 0 1 1 1 0 1 1
 
@nathanrogers
┌───────────────┬───────────────┐
│0 0 0 1 0 1 1 1│1 1 0 1 1 0 0 0│
└───────────────┴───────────────┘
 
@nathanrogers Perfect!
And I just noticed that my solution needs 14 bytes, not 12. (Because the problem uses -⍺ for some reason.)
 
5:42 PM
:P
I guess you could just define it differently, for some reason I imagine ¯3 as shifting right not left
⎕←3 ¯3{((×⍺)×≢⍵)↑⍺↓⍵}¨⊂1 0 1 1 1 0 1 1
 
@nathanrogers
┌───────────────┬───────────────┐
│1 1 0 1 1 0 0 0│0 0 0 1 0 1 1 1│
└───────────────┴───────────────┘
 
@Adám that makes more sense to me, but the negatives shifting left for negative seem to be more APL-ish?
 
@nathanrogers Right, which is why I suggested the author to swap it. But he disagreed.
@nathanrogers That one lends itself well to become a 3-train: {(×⍺)×≢⍵}↑↓
 
5:57 PM
that doesn't work for me
 
Notice that you have (⍺ f ⍵) g ⍺ h ⍵. That's how trains work; it becomes f g h.
⎕←3 ¯3({(×⍺)×≢⍵}↑↓)¨⊂1 0 1 1 1 0 1 1
 
@Adám
┌───────────────┬───────────────┐
│1 1 0 1 1 0 0 0│0 0 0 1 0 1 1 1│
└───────────────┴───────────────┘
 
why are the parens necessary?
what does the expression mean without them?
 
3 ¯3{(×⍺)×≢⍵}↑↓¨⊂1 0 1 1 1 0 1 1 is simply evaluated as it looks. First ↓¨⊂1 0… then monadic then dyadic dfn.
@nathanrogers An expression is a function if the rightmost token is a (derived) function. So you must isolate trains by parenthesising or naming.
 
6:31 PM
@nathanrogers That doesn't work for 0 as a left argument
 
@H.PWiz Oh, I did't think of the edge case. It has been almost a year ¯\_(⍨)_/¯
 
sign of zero
is 0?
that's annoying
sign of zero or 1 I guess
 
⍞←¯1*¯3 0 4
 
@Adám ¯1 1 1
 
or that
 
6:36 PM
You could add 0.5
 
@H.PWiz Ah yes, that'd work.
 
{((1∨(×⍺))×≢⍵)↑⍺↓⍵}
why not that?
 
⍞←1∨¯3
 
@Adám 1
 
thinking in js
undefined || 1
-3 || 1
3 || 1
 
6:38 PM
What makes you think is or
⎕←∘.∨⍨⍳10
 
@H.PWiz
1 1 1 1 1 1 1 1 1  1
1 2 1 2 1 2 1 2 1  2
1 1 3 1 1 3 1 1 3  1
1 2 1 4 1 2 1 4 1  2
1 1 1 1 5 1 1 1 1  5
1 2 3 2 1 6 1 2 3  2
1 1 1 1 1 1 7 1 1  1
1 2 1 4 1 2 1 8 1  2
1 1 3 1 1 3 1 1 9  1
1 2 1 2 5 2 1 2 1 10
 
? because it is?
 
@nathanrogers It is indeed, but (unfortunately, imho) extended to GCD
 
@nathanrogers it is for booleans, but not beyond that
 
It behaves like or on 0/1 but so does , you wouldn't call or
@Adám I like having GCD, personally
 
6:40 PM
{(((×.5+⍺))×≢⍵)↑⍺↓⍵}
so that then
 
And since there wasn't another symbol for it already...
 
Me too, but I don't like it being paired with
@nathanrogers Other than the double-paren, yes.
 
oh, hah, I was adding on the wrong side
 
@H.PWiz I would have wanted to define ~ as 1+- and as × and all other Boolean functions based on those two.
However, I'd have used ¬ for NOT, as that shows the relationship with -.
@PaulMansour Long time no see. Welcome back!
 
@Adám in any case there really should be a this or that operator
I suppose (bool)/this that is ok
but this || that would be welcome for sure
 
6:47 PM
@nathanrogers imo that doesn't really fit the APL theme
 
@nathanrogers What does that do?
 
for one APL doesn't remotely allow short-circuit
 
@dzaima Uh, not true:
⋄ ⍎⎕FX'f' ':if 1' ':orif 1⊣⎕←''boo''' '⎕←''yay''' ':endif' ⋄ ⎕←⎕VR'f'
 
@Adám
yay
⍎VALUE ERROR
 
@Adám *not for regular functions
 
6:52 PM
⎕←⍎⎕FX'r←f' ':if 1' ':orif 1⊣⎕←''boo''' 'r←''yay''' ':endif' ⋄ ⎕←⎕VR'f'
 
@Adám
yay
     ∇ r←f
[1]    :If 1
[2]    :OrIf 1⊣⎕←'boo'
[3]        r←'yay'
[4]    :EndIf
     ∇
 
obviously it can with special syntax, but any language can do anything with special syntax for it
 
@dzaima Tradfns are regular.
 
@Adám I meant as making a regular function e.g. or that wouldn't evaluate ⎕←'hi' in 1 or ⎕←'hi..
 
⋄ or←{⊃⍺⍺⍬:1 ⋄ ⊃⍵⍵⍬} ⋄ ⎕←1 or {1⊣⎕←'hi'} ⍬ ⋄ ⎕←0 or {1⊣⎕←'hi'} ⍬
 
6:58 PM
@Adám
1
hi
1
 
You can use inline dfns as code blocks.
 
@Adám right, but that's again very annoyingly long, and doesn't pass //⍺⍺/⍵⍵//∇∇ down to the inner functions
 
@dzaima what doesn't?
 
@dzaima How is it long? You define it once, and then you have it. I'm not sure what the problem is with passing is, but sure, you can define or←{⍺←⊢ ⋄ ⍺ ⍺⍺ ⍵:1 ⋄ ⍺ ⍵⍵ ⍵} and then use it as ⍺ {cond1} or {cond2} ⍵`
 
@nathanrogers Adám's or, e.g. {0 or {1+⍵} ⍬}123 doesn't give the expected 124
@Adám that has 4 unnecessary chars in the calling of or - , {, }, that all could be avoided with a syntactical function (I'm not saying that a thing like that should exist though, quite the opposite)
 
7:11 PM
@dzaima Fair enough. Btw, we are considering allowing multiple guards, but that will be short-circuiting "andif". E.g. {0:1⊣⎕←'hi':'yay' ⋄ 'nay'} will not print hi.
 
 
4 hours later…
10:41 PM
https://tio.run/##PU@9bsIwEN79FLdhq@LHToasTEw8AWKwBIqqUjsi7YAQEwglQCRegS5UVbe0S8c@yr1IuHMQ0vm@u@@@@@Sz2aI7W9mFT5umM7Yvzy4FCyPvZzBcpu@vc/fWEVmC@/PaUcLyA6s/PO6kw/Ly1OemOGBVY/UT4ldhcZWSdcUXTRXJqLHMWjZgtsZT0Q9D3mW4ulbXemyEzUkrI9BgFEjzwCigBh1yqHuEECnQwmtaYk0cbGoTC2@IehDaCM/GXsM9zL3A6lss@UqyhkF4nEXTEFte1hIPW5tP6G9TBVkC1Pq23fx/8kF0Yn4D
This is a solution for problem 8
except for the case where the left argument is ⍬
when maxnum≡⌈/⍬
how do I avoid this?
1≡⍬ p8 1 is the expected resuilt
 

« first day (720 days earlier)      last day (1950 days later) »