« first day (1566 days earlier)      last day (1382 days later) » 

06:02
I want to hollow out a boolean array:
1 1 1 1 0 0 0 1 1 1 → 1 0 0 1 0 0 0 1 0 1
how do I do it?
@Razetime What is the expected output for 0 0 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 0?
0 0 1 0 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0
basically convert 1s between other 1s to zeroes
{(2⊥⍵)∊2 3 6}⌺3 should work
Basically tests if each 3-width window has 01x or x10 pattern
except that it doesn't work when the length is 1 or 0, because doesn't
06:12
@Bubbler behold
      'Buy24Beers'(({(2⊥⍵)∊2 3 6}⌺3)⍤∊⊂⊣)⎕A,⎕D
┌───┬──┬─────┐
│Buy│24│Beers│
└───┴──┴─────┘
06:35
@Razetime f⍢⌽∨f←2</0, in dzaima/APL (the equivalent vanilla Dyalog APL is ⌽⍤f⍤⌽∨f←2</0∘,)
Works for any input length and is probably a bit faster in general:
     ∇ ⌺ 3
      M←⌽⍤f⍤⌽∨f←2</0∘, ⋄ S←{(2⊥⍵)∊2 3 6}⌺3
      s←0 0 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 0
      l←2=?1e6⍴2
      ]runtime -c M⊢s S⊢s

  M⊢s → 7.3E¯7 |     0% ⎕
  S⊢s → 4.0E¯5 | +5414% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
      ]runtime -c M⊢l S⊢l

  M⊢l → 1.0E¯3 |       0%
  S⊢l → 3.1E0  | +308800% ⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕⎕
I think I've come up with another version of median, but I don't know how it differs from the one in APLcart {X←⍵[⍋⍵]⋄.5×(X+⌽X)[⌈.5×≢X]}
Aha, it's a train (for reference: (2÷⍨1⊥⊢⌷⍨∘⊂⍋⌷⍨∘⊂∘⌈2÷⍨0 1+≢))
@Sherlock9 Yours doesn't work on higher-rank arrays (though that could be fixed).
It also does a lot of unnecessary work, sorting the entire array, and adding all the values instead of only the two relevant ones.
Ah, I have not gotten the hang of higher rank arrays yet
What does the median of a higher-rank array look like? Flatten the whole array and then get the median value of all the elements?
06:53
@Adám very cool
sadly i realized my program would get too bloated with a non-regex approach
@Adám does the APLcart example work on higher rank?
Yes.
      {X←⍵[⍋⍵]⋄.5×(X+⌽X)[⌈.5×≢X]}3 3⍴⍳9
RANK ERROR
      {X←⍵[⍋⍵] ⋄ 0.5×(X+⌽X)[⌈0.5×≢X]}3 3⍴⍳9
@Sherlock9 No, that'd be f, for any f. It does the same as +⌿÷≢
am I using it wrong?
@Razetime No, it simply doesn't work on high-rank arguments.
RGS
RGS
07:04
@Adám Doesn't the one in APLCart also sort the entire array with X ← ⍵[⍋⍵]..?
@RGS @Razetime I think you're mixing up APLcart's median with Sherlock9's median.
RGS
RGS
@Adám Ah, maybe.
07:36
oh ok
      (2÷⍨1⊥⊢⌷⍨∘⊂⍋⌷⍨∘⊂∘⌈2÷⍨0 1+≢)3 3⍴9
9 9 9
i see
 
3 hours later…
RGS
RGS
10:20
The best way to find out the name of the current function is by looking at the stack?
10:34
@Adám What do you mean by f?
RGS
RGS
@Sherlock9 f is a function. What Adám means is that "flatten the whole array and then do something" is the same as writing the code f,
Where f is the function that does something.
Oh I see
Thanks
RGS
RGS
So if you have a function f that computes the median, then "flatten whole array and compute median" would be f,array.
Np. As far as my understanding goes, most functions look at high-dimensional arrays like "containers" of lower-dimensional things, in the sense that it is useful to compute some operation on those lower-dimensional subarrays separately.
So what this does is calculate the median ... element/row/plane along the first axis?
RGS
RGS
Yes, (2÷⍨1⊥⊢⌷⍨∘⊂⍋⌷⍨∘⊂∘⌈2÷⍨0 1+≢) calculates the median along the first axis.
for matrices, that means along the columns.
      3 3⍴1 2 3
1 2 3
1 2 3
1 2 3

      (2÷⍨1⊥⊢⌷⍨∘⊂⍋⌷⍨∘⊂∘⌈2÷⍨0 1+≢)3 3⍴1 2 3
1 2 3
for 3D things, the first axis "pierces through" the planes:
      3 3 3⍴1 2 3 4 5 6 7 8 9
1 2 3
4 5 6
7 8 9

1 2 3
4 5 6
7 8 9

1 2 3
4 5 6
7 8 9

      (2÷⍨1⊥⊢⌷⍨∘⊂⍋⌷⍨∘⊂∘⌈2÷⍨0 1+≢)3 3 3⍴1 2 3 4 5 6 7 8 9
1 2 3
4 5 6
7 8 9
11:12
@RGS They should. Dyadic is problematic!
11:31
Is there an array solution to this (I have a recursive one)? Given a boolean rank-2 array, on each row, wipe all 1s before or equal to the position of the first 1 on the row before, eg given
⊢m←3 12⍴0 0 1 0 0 0 1 0 1 0 0 1 0 1 0 1 0 0 0 1 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0 0
┌→──────────────────────┐
↓0 0 1 0 0 0 1 0 1 0 0 1│
│0 1 0 1 0 0 0 1 0 0 0 0│
│1 0 0 0 1 0 0 0 0 1 0 0│
└~──────────────────────┘

f m

┌→──────────────────────┐
↓0 0 1 0 0 0 1 0 1 0 0 1│
│0 0 0 1 0 0 0 1 0 0 0 0│
│0 0 0 0 1 0 0 0 0 1 0 0│
└~──────────────────────┘
i don't see a reason that should need any recursion?
current line and line above should be enough to know the new line
RGS
RGS
      <\0⍪2⊣⌿m
0 0 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0
@RGS that's just finding the first occurence
@dzaima I don't either :) -- hence my question -- feels like there should be a nice solution for this that I can't see.
RGS
RGS
@dzaima I know, I haven't finished typing :P
This shows the first 1 of the row above.
11:39
i think i have 25 as a dfn
RGS
RGS
      m×∨\1⍪0,1 ¯1↓<\0⍪2⊣⌿m
0 0 1 0 0 0 1 0 1 0 0 1
0 0 0 1 0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0 0 1 0 0
Then ∨\1⍪0,1 ¯1↓ builds a mask of all the 1s you want to keep.
And then you multiply that with m.
@RGS very neat
RGS
RGS
Can also do the ∨\ earlier to avoid a bit of unnecessary calculations: m×1⍪0,∨\1 ¯1↓<\0⍪2⊣⌿m
@RGS 2⊣⌿m is just an obscure way to write ¯1↓m right?
11:44
i had {⍵×(¯1↓0,⍵⍳⍤1⊢1)∘.<⍳2⊃⍴⍵}
RGS
RGS
@Adám Yes xD
@RGS Why add 0⍪ when you remove it later with 1 ¯1↓ ?
RGS
RGS
A bit shorter without adding and removing the same row for no reason at all: m×1⍪0,∨\0 ¯1↓<\¯1↓m
Ninja'd :(
@xpqz the hardest bits for me were in finding the first 1 row-wise, but RParks webinar on boolean scans reminded me of <\ , and then taking those first 1s and spreading them to the right, to create the mask, but that's just ∨\ .
I vaguely recall such matrices being called something, back from the days before I'd forgotten most of my maths.
RGS
RGS
11:49
What do you mean?
A matrix where there are no non-zero elements prior to the first non-zero element on the previous row -- don't they have a special name?
I may be wrong.
Kind of like triangular, but not really.
Yes. A KofT matrix. I like it.
If it doesn't have a name, then how about progressive matrix?
Works for me.
RGS
RGS
11:54
Yeah, can only think of triangular matrices, but their definition is not really the same as this one. Both KofT and progressive sound nice as names :P
Not all triangular matrices are KofT, but all KofT are upper triangular.
12:15
@xpqz this looks familiar...
@RGS try it on m←5 5⍴0 0 1 0 0 0 0 0 1 0 1 1 0 0 1 1 1 0 0 1 0 0 1 0 0 -- I realise I may have chosen an unfortunate example/unclear explanation earlier. Having each row reflect the one before -- including earlier changes -- presumably will require recurring. I had hoped for
┌→────────┐
↓0 0 1 0 0│
│0 0 0 1 0│
│0 0 0 0 1│
│0 0 0 0 0│
│0 0 0 0 0│
└~────────┘
@rak1507 Are you still looking to avoid exam revision?
@Adám What's the problem? And is it a problem that's likely to be fixed?
well considering I have one tomorrow, I probably shouldn't...
@Sherlock9 You win a price!
12:22
oh, I thought this was for a competition problem
that's because it is from a competition problem!
I forget which Rosalind problems double as Dyalog comp problems :/ -- good job no actual solution was posted.
RGS
RGS
@xpqz ah I see...
I've got a five-day weekend coming up and I don't plan to start Phase II of the competition until then
12:32
@RGS close enough to be a major spoiler :/
Relatedly, Ramadan Mubarak to all who celebrate it!
too late to remove now :P the entire chat is full
oh well, thanks for the nice solution guys
Eh, it's not how I'd do it and it'll continue to not be how I do it :D
Ah, nvm, doesn't quite work anyway like rgs said
RGS
RGS
@rak1507 yeah, I'm just full of empty promises
12:38
lol
I'll ... talk about other Rosalind problems instead :)
RGS
RGS
Let's talk about this one instead rosalind.info/problems/dna
I know how to do this the basic way
RGS
RGS
I keep forgetting that ⌸ is such a lovely primitive for these type of things.
@Sherlock9 What is "the basic way"?
nested dfns and an each
12:48
+/'ACGT'∘.=⊢
@RGS ⌸ isn't particularly nice here as it requires an order and stuff
      {⍵∘{+/⍺=⍵}¨'ACGT'}'AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC'
┌→──────────┐
│20 12 17 21│
└~──────────┘
RGS
RGS
@rak1507 You can prepend 'ACGT' and then subtract 1, but the ∘.= makes much more sense.
yeah
Oh ∘.=
Nuts
(≢⍤⊢-≢)⌸'ACTG',⊢ fun
RGS
RGS
12:53
Ok I'm so confused
(≢⍤⊢-≢)..?
I get ≢⍤⊢, I just don't understand why the -≢ works
To subtract 1, that is.
bc it subtracts ⍺≢⍵ which is always 1
RGS
RGS
Yeah that's nasty
:)
RGS
RGS
((¯1+≢⍤⊢)⌸'ACTG',⊢)
Much better.
12:55
an extra byte
RGS
RGS
But the readability increased by a factor of 24352623452345.6
This is my favourite so far: rosalind.info/problems/orf -- good opportunity for dyadic transposing
might as well use {1-⍨≢⍵}
@xpqz I've not done many of them but rosalind.info/problems/grph is quite fun
RGS
RGS
@rak1507 Graphs are fun, in general.
@rak1507 I think I did that one. Let's se
(key data) ← FASTA 'rosalind_grph-2.txt'
m ← ∘.{(¯3↑⍺)≡(3↑⍵)} ⍨data
(0 0⍉m) ← 0
r ← (2÷⍨≢pairs) 2⍴pairs ← key[∊⍸m]
12:58
looks similar to mine
although a lot simpler for some reason haha
rosalind.info/problems/hamm is just +/≠⌿ :D
RGS
RGS
@rak1507 or +/≠ if the two strings are the left and right args :P
true
1⊥≠ for extra obscurity
RGS
RGS
≢9/⍨≠ for extra⍣2⊢ obscurity
Although longer.
⍷⍨∘⊃⍨⍤0 1 lol
frustrating that the rank operator encloses the left argument or something
so ⍷⍤0 1 doesn't do what I expected
13:33
@rak1507 Say, what‽
13:44
@Adám i assume that's about this (which of course gets much more annoying dyadically). asks for ⍤-left and ⍤-right more than ¨ really
Oh, that it doesn't disclose then :-)
well, that's equivalent to effectively enclosing it
Except (2 3⍴⍳6)(≡⍤1) 4 5 6 surely doesn't enclose anything.
well yeah, it doesn't have 0 in ⍵⍵
14:07
(⍪(1 2)(3 4)) (∊⍤0 2) (⍪(2 1)(3 4)) surely doesn't enclose anything.
 
3 hours later…
16:48
So, I was hacking on the KAP UI, and figured it was time to render arrays in a nicer way. No need to use plain text-based rendering when I have an entire UI framework at my fingertips. Now, has anyone given any thought to a nice way to do this? I mean, I've experimented with using a JavaFX grid widget, which is nice enough (looks a bit like a HTML table). I've also tried using a regular table widget, which makes it look a lot more like a real table (think spreadhseet).
Surely someone has experimented with this? I've been thinking about using a grid for small tables, and moving to a scrollable table widget for larger ones. However, there is then the issue of a small table that contains a large one. That'll look weird.
What about rank>2?
@EliasMårtenson Yes, there is the array editor included with Dyalog.
@Adám I have some ideas, although none of them particularly great.
I do intend to implement a 3D array viewer using OpenGL. And yes, it will be just as useless as you imagine. I haven't written OpenGL code in a long time though, so I will just do it as a joke. :-)
@Adám How do I get to it?
@Adám Is it Windows only?
It is.
I've been wanting to write an array viewer/editor in HTML/JS for a while.
16:55
@Adám I was thinking of implementing something like that, but I felt it wouldn't be very useful.
I'm thinking about having a button next to a printed object in the output REPL. If you click on it, a spreadsheet-like editor can be opened up for browsing/editing the content.
 
2 hours later…
18:39
Does ⎕ not work for writing to stdout?
I am trying to use it with 'dyalog load=..' and no output is done
maybe i should try using ⎕sh
@rcabaco Are you sure you shouldn't be using LX=?
@Adám didn't know about LX=. I am trying to use ANSI escape control sequences in the terminal.
but ⎕SH'tput clear' does not work either.
@Adám maybe i didn't explain myself correctly. I was thinking that it was possible to load a .aplf with load= and have it print stuff to the terminal. But now I see that it does not work that way.
maybe when scripting is available.

« first day (1566 days earlier)      last day (1382 days later) »