« first day (1165 days earlier)      last day (1496 days later) » 

2:46 AM
I'm looking for a better solution to this simple J problem. If you just want to see the goal and my current solution: Try it online!. The problem is to take a list of boxed strings, and create duplicates of that list where each duplicate differs in one way: It has a fixed string appended to a different index.
 
 
4 hours later…
6:16 AM
@Jonah -5 bytes by returning the transpose of your result.
+2 bytes to transpose it back, so -3 bytes in total.
 
Great ty. And one more byte with [:=#\ for the identity matrix.
 
 
4 hours later…
10:12 AM
@Adám bugs probably, though i understand noone wanting to touch these horrifying ⍺-inverses (who's gonna use them anyway?)
also, pushed my ⍢ rework. Now to more simple things..
 
11:14 AM
@dzaima Feels to me yet another reason to use so-called "The Inverter" over other approaches.
 
@Bubbler i don't know what Dyalog uses, but that works just fine in dzaima/APL and it doesn't have a "The Inverter"
 
11:27 AM
implemented on vectors, don't feel like doing higher-rank logic right now..
 
@dzaima Oh, so it's a bug in Dyalog's...
 
@dzaima so mesh now is b⍢(u⌿)a⍀⍨~u
 
 
4 hours later…
3:30 PM
How can I write {⍵⍳a}¨b in tacit style?
for the arguments a and b?
 
Could you explain a bit how you came to that?
 
Anyone know if there is strong counterpoint (perhaps advanced by Iverson himself somewhere) to Djikstra's famous argument that indexing should start at 0?
 
@Evan firstly, {⍵ f A} is equal to - f∘A, which leads to another valid function - ⍳∘a¨ b, but it's not fully tacit. Then it's just noticing that is "left-each", for which the two common implementations are f∘A¨B which we have, and A f¨ ⊂B which can be converted to tacit with A f¨∘⊂ B
(as a side-note, dzaima/APL has a separate built-in for this - )
 
how long until this stuff feels a little more natural?
I've been programming for about 20 years and this feels completely new
lots to unlearn
 
3:49 PM
@Evan no clue - i took the unusual route of learning as i was writing my implementation, which is not applicable to most people
 
4:06 PM
@Evan Fwiw, I had similar experience and still found J to be the most challenging PL that I've ever learned, requiring a lot more effort even than Haskell. It was also the most mind-expanding.
 
Why does A f¨ ⊂B do what we expect?
I think that was my main sticking point
I might naively think to use A f¨ B but that requires that A and B have some kind of similar shape
 
@Evan when an argument of is a scalar (in our case, ⊂B), it extends it to be the same argument for all invocations of f - see 1 2 3 {'f'⍺⍵}¨ ⊂'ab'
 
oh so you box up B so it has rank one
or wait no
dim one
 
@Evan it has rank 0 actually, shape - so a scalar
 
right ok.
so then why does ⍳ do what we expect with the boxed argument?
 
4:15 PM
so A f¨ ⊂B effectively does A f¨ B B...B B, with the amount of Bs matching As size, which equals ((1⊃A) f B) ((2⊃A) f B) ((3⊃A) f B) ... where in this case f is
 
why is that?
I think i don't understand where B is implicitly enclosed and disclosed
and why
 
@Evan in the ¨ built-ins logic, it's just how it's defined
 
ah okay! I'll pour through the definition a bit.
thank you so much for the help!
 
(also B is never implicitly enclosed, we only explicitly enclose it with )
¨ follows the same logic as scalar built-ins, just only for 1 level of depth - 1 2 3+⊂10 20 is (1+10 20)(2+10 20)(3+10 20) (the simpler case being 1 2 3+⊂10 being (1+10)(2+10)(3+10), but the on 10 (and the implicit disclose) do nothing on plain scalar numbers) - A B C f¨ ⊂X is (A f X)(B f X)(C f X) by definition
 
That last bit is counterintuitive to me. I expect A B C f¨ ⊂X is (A f ⊂X)(B f ⊂X)(C f ⊂X)
because we see ok, ⊂X is a scalar, it will be extended to the shape of the left arg
why does it get disclosed?
 
4:28 PM
@Evan it's extension is a simple reshape, so 3⍴⊂X will be an array of 3 Xs, not an array of 3 enclosed Xs
 
so 3⍴⊂X = 3⍴X if X is scalar?
or sorry, ≡
that seems irregular but useful
 
@Evan no, there's nothing special about here - it does the thing it always has done - replace the shape of with
it's just that the shape of ⊂X is always (that's what a scalar is), which we replace with 3
 
then what about 3⍴3?
same thing?
I'm having a hard time with 3⍴⊂3 = 3⍴3
 
@Evan you've finally hit the weird part of APL - 3 ≡ ⊂3. (so yes, 3 ≡ ⊂⊂⊂3 and 3 ≡ ⊃⊃⊃3)
 
I bloody knew there was something weird here.
thank you
 
4:34 PM
@Evan though in the case of our ⍳¨∘⊂ that isn't required or used anywhere. It's your understanding of other cases that's changed
 
4:45 PM
at the risk of making this much more complicated, it may help to think of the shape & depth manipulations by looking at the shape, the shape of ⊃A, the shape of ⊃⊃A, etc. e.g. A←'abcd' 'efgh' has 2 = ⍴A, 4 = ⍴⊃A, ⍬ ≡ ⍴⊃⊃A, ⍬ ≡ ⍴⊃⊃⊃A, ...; this is a view of what's happening with this (imagine an infinite amount of |s following every line):
prepends an empty section, and replaces the numbers in the 1st section
 
4:58 PM
no no this is great... I always feel more comfortable once I know how things are implemented
if I know the underlying data structure I'm much happier
 
@Evan the underlying implementation is probably just that and are hard-coded to be identities on the given argument if it's a simple scalar, but i don't think that helps here at all
 
 
2 hours later…
7:04 PM
@dzaima inspired by your answer I came up w/ this:

1=0,∈{(~1⌊⍵)⊣⍣(1=1⊃⍵)⊢⍵}¨{⍵⊂⍨+\⍵} 0 1 0 1 0 2 0 0 1 0 0 2 1 0 0 1 0 2 0 0 2
0 0 1 0 1 0 0 0 0 1 1 0 0 1 1 0 1 0 0 0 0
 
@cannadayr yeah, that's the simpler (maybe better?) route. i'm gonna do some performance comparisons a bit later
 
hmm still might need some tweaks
hierarchical data is weird in apl
 
@xpqz right, A (⊣⍣c) B is also worth mentioning - still evaluates both, but ⎕IO-independent
@cannadayr hm, the rule of 1-to-anything is way simpler. i'll see what i can come up with
@dzaima this
 
7:21 PM
fixed padding:
f ← {⍵ {⍵,⍨0⍴⍨(≢⍺)-≢⍵} {1=∈⍵} {(~1⌊⍵)⊣⍣(1=1⊃⍵)⊢⍵}¨{⍵⊂⍨+\⍵} ⍵}
 
@dzaima - I see a lot of your comments are responses linked to your own comments... how do you do that? It doesn't seem to be an option when I'm doing it...
 
@JeffZeitlin go to message permalink (quick way is to middle-click the message arrow), and copy the message ID out of the link. Annoying, but i've gotten used to it and am too lazy to make a userscript
 
@dzaima - Ah. Interesting. The message ID is the number at the end, correct?
(I don't have a middle to click, but I can get the permalink.)
 
@JeffZeitlin yeah
@JeffZeitlin left+right-click? though it might be more comfortable to just get the thing by more usual means
@dzaima performance comparison. One definitely seems faster (at least in Dyalog)
 
@dzaima - Danke. No, L+R doesn't seem to work on my Surface Pro with Type Cover. I just click on the arrow, then right-click on the permalink link, copy the URI, paste-and-edit. Really, the hard way, but...
 
7:30 PM
¯\_(ツ)_/¯
 
No biggie; I was just curious.
 
new dzaima/APL release - this time i also added the regular jar
 
 
1 hour later…
8:40 PM
heh heres a fun new brain exercise (ill be needing some time to figure this out).
write a function to produce following for successive iterations:
1 2 3 ⍝ gen 1
1 (2 3 4) (5 6 7) ⍝ gen 2
1 (2 (3 4 5) (6 7 8)) (8 (9 10 11) (12 13 14)) ⍝ gen 3
 
what's the right way to select rows from a table? I have ⍴z is 221 5, and ⍴sel 221, and I wanna do sel/z.
 
@Evan use instead of /
@cannadayr does 8 intentionally repeat in gen 3?
 
like this? @Evan
x ← 2 3 ⍴⍳6
y ← x
{⍺/⍵}⌿(,/y),⍪,/x
4 5 5 6 6 6 4 5 5 6 6 6
@dzaima oops no thats a goof
 
thank ya!
 
should be: 1 (2 (3 4 5) (6 7 8)) (9 (10 11 12) (13 14 15))
 
8:55 PM
Any suggestions for how to simplify z⌿⍨(⊂fpath)≡¨((⍴fpath)↑¨z[;2])?
 
@RGS Known issue. Workaround:
f←f
f←⌊÷
 
and then also... how do you sort two columns in ascending order?
with priority given to one of them?
 
@Evan what's ⍴fpath? i'm trying to understand what that's supposed to do
 
oh sorry. It selects every row from a table where a particular column has elements that BEGIN with the variable fpath
 
@Evan z[wantedCol (⌷⍤1) z;]
 
9:02 PM
so I take the length of fpath from z[;2], then compare fpath to it, that gives me a mask that i use to take from z
 
@JeffZeitlin You can simply right-click the message arrow, then "Copy Link Location".
 
@dzaima z[⍋z[;2];] might be better/prettier
@Evan i don't have much to add, other than the pointless pair of parenthesis around (⍴fpath) ↑¨ z[;2]
 
@Evan z⌿⍨z[;2](fpath≡↑)¨⍨≢fpath
 
@Adám i wouldn't use there, but i guess it's a matter of style
 
hey that's not too far from what I wrote. Not too bad for 3 days of learning APL :D
 
9:18 PM
@Evan - Once you get past the initial reaction of "OMGLOOKATALLTHEHIEROGLYPHICS", APL is actually a pretty straightforward language. The hardest part is learning how to think in APL; I'm not there yet, I still think in Pascal and translate...
 
I've been using numpy for about 8 years... so I'm used to thinking in terms of array operations
numpy just doesn't feel like it goes far enough and feels too wordy
hence my interest in APL
plus I just don't like python lol
 
9:36 PM
ok ok here's another one... what's the right way to group table elements together where for each row, two of the cells are identical.
 
@evan could you provide a simple example?
 
(10 20 3 4)(11 21 3 4)(12 22 5 6)(13 23 5 6) to ((10 20 3 4)(11 21 3 4))((12 22 5 6)(13 23 5 6))
where I act on the last two columns
 
hm not exactly what you want yet
      fmt {⍵⊂⍨(⍳2)/⍨2÷⍨≢⍵}(1 2)(3 4)(5 6)(7 8)
┏→━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃┏→━━━━━━━━━━┓ ┏→━━━━━━━━━━┓┃
┃┃┏→━━┓ ┏→━━┓┃ ┃┏→━━┓ ┏→━━┓┃┃
┃┃┃1 2┃ ┃3 4┃┃ ┃┃5 6┃ ┃7 8┃┃┃
┃┃┗━━━┛ ┗━━━┛┃ ┃┗━━━┛ ┗━━━┛┃┃
┃┗∊━━━━━━━━━━┛ ┗∊━━━━━━━━━━┛┃
┗∊∊━━━━━━━━━━━━━━━━━━━━━━━━━┛
 
the challenge I think is to find the partitioning
oh also no worries about preserving order
if you wanna sort and then enclose that's cool
 
for reference I sometimes do this:

          fmt 1 1 2 2 ⊂ ⍳4
    ┏→━━━━━━━━━━┓
    ┃┏→━━┓ ┏→━━┓┃
    ┃┃1 2┃ ┃3 4┃┃
    ┃┗━━━┛ ┗━━━┛┃
    ┗∊━━━━━━━━━━┛
 
9:46 PM
@Evan (¯2∘↑¨{⊂⍵}⌸⊢)
@Evan Wait, do you know that they'll appear ordered? I.e. never (10 20 3 4)(12 22 5 6)(11 21 3 4)(13 23 5 6) ?
 
I've already ordered them, we'll say
I guess I could use unique and then partition.
 
@Evan Sure, but does all this for you. No need to order them first.
 
cool :D
 
RGS
10:04 PM
@Adám thanks!
 
 
1 hour later…
11:24 PM
{{⍺,⊂j[⍵;2 3 4]}⌸⍵[;0 1]} I feel like this could be improved upon
that's ultimately what I wanted, I think
is going two layers deep in dfns considered bad?
I managed to get this much of it ⊂(2↓j∘(⌷⍨)) but still need to attach the first argument somehow
or sorry, ⊂(2↓⍵∘(⌷⍨))
 
@Evan ⍵∘(⌷⍨) is the same as ⌷∘⍵
@Evan No, that's very common.
@Evan ⍵[;0 1] is the same as 2∘↑⍤1 should you want to go tacit.
 
11:40 PM
at some point I feel like I'm compromising the meaning of what i'm writing
but at the same time I don't know that an expert would feel the same
 
@Evan Proper names for variables and subfunctions plus comments go a long way.
 
I think I'm also having a hard time reading trains.
unfolding stuff into atops/forks I'm finding pretty tricky
 
@Evan That's common. You mentioned only having been doing APL for three days. I usually hold off even telling new students about trains until they feel comfortable with dfns.
@Evan Have you gone through some of the tutorials?
 
no! I'll definitely give that a whack
thank you!
 
When I was new to Dyalog APL and struggling with trains, I found ]box on -trains=tree extremely useful.
 
11:46 PM
I've been making use of that. It really is super helpful
 
Another trick is to replace the functions with dummy functions that "mark" their output so you can see the calling tree in the result. E.g dyadic + would become {⍺'+'⍵}.
If you are unsure whether a function will be called monadically or dyadically, insert ⍺←⊢ ⋄ at the beginning: {⍺←⊢ ⋄ ⍺'+'⍵}
 
@Adám - How do I enable the APL keyboard in Linux Mint 19.3? I'm running in a VMWare player on my Windows box.
 
@JeffZeitlin Have a look at this forum thread.
 

« first day (1165 days earlier)      last day (1496 days later) »