« first day (478 days earlier)      last day (2179 days later) » 

1:11 PM
Hey @Adám! I need your wizardry expertise. Is there a way to group equal elements of a matrix together? I guess that'd be like "sorting" the matrix? I'm still having some trouble using some operators/functions on higher-rank arrays >.>
 
1:30 PM
btw getting all the unique elements of a matrix would also be very nice. I can't seem to get the matrix to flatten though D:
 
2:09 PM
@J.Sallé If you don't care about the shape, just ravel the matrix:
⎕←{⊂⍺⍴⍨≢⍵}⌸,⎕←3 4⍴3 1 4 1 5
 
@Adám
3 1 4 1
5 3 1 4
1 5 3 1
┌─────┬─────────┬───┬───┐
│3 3 3│1 1 1 1 1│4 4│5 5│
└─────┴─────────┴───┴───┘
 
@J.Sallé Unique elements of the entire matrix:
⍞←∪,3 4⍴3 1 4 1 5
 
@Adám 3 1 4 5
 
@J.Sallé Unique rows:
⎕←↑∪↓5 2⍴3 1 4
 
@Adám
3 1
4 3
1 4
 
2:13 PM
Hi,
I just started learning APL. I have beginner to intermediate experienci with J.
Now I have the following question:
Is there a way to apply a primitive/train of functions to both left and right arguments and contunue to work with the result, something like this J code:
f=.+&*:
2 f 3
13
 
@Adám Huh... maybe I'm doing something wrong? I've tried raveling the matrix and it doesn't seem to work
I've tried doing this:
⎕←{{,⍺}⌸⍳⍵}6 6
 
@J.Sallé
┌───┬───┬───┬───┬───┬───┐
│1 1│1 2│1 3│1 4│1 5│1 6│
├───┼───┼───┼───┼───┼───┤
│2 1│2 2│2 3│2 4│2 5│2 6│
├───┼───┼───┼───┼───┼───┤
│3 1│3 2│3 3│3 4│3 5│3 6│
├───┼───┼───┼───┼───┼───┤
│4 1│4 2│4 3│4 4│4 5│4 6│
├───┼───┼───┼───┼───┼───┤
│5 1│5 2│5 3│5 4│5 5│5 6│
├───┼───┼───┼───┼───┼───┤
│6 1│6 2│6 3│6 4│6 5│6 6│
└───┴───┴───┴───┴───┴───┘
 
And I kinda have what I need to solve the problem with:
⎕←{{+/¨⍺}⌸⍳⍵}6 6
 
@J.Sallé
2 3 4  5  6  7
3 4 5  6  7  8
4 5 6  7  8  9
5 6 7  8  9 10
6 7 8  9 10 11
7 8 9 10 11 12
 
@J.Sallé You're ravelling the the left argument of Key's operand (which is already a vector).
 
2:18 PM
@Adám wait, that's not a matrix?
 
@J.Sallé No, the left argument of f in f⌸ is in turn each unique major cell of the right argument.
 
Ah, I see
 
@J.Sallé So what's happening here is that your inner dfn gets a row (because they're all unique) of your original matrix, sums each element of the row, and then everything is mixed together. Essentially, the whole Key part is a no-op:
⎕←{+/¨⍳⍵}6 6
 
@Adám
2 3 4  5  6  7
3 4 5  6  7  8
4 5 6  7  8  9
5 6 7  8  9 10
6 7 8  9 10 11
7 8 9 10 11 12
 
facepalm
I think I'm going to skip problem 3 for a while >.>
 
2:22 PM
@J.Sallé Well, now (with or without Key) you have all the sums, so only now should you group them.
 
@Adám yeah, that's what I was trying to do earlier
I'll leave the no-op as it is for now. I'm now getting:
⎕←{{(⊂(+/¨⍺)⍴⍨≢⍵)}⌸,⍳⍵}6 6
 
@J.Sallé
┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬──┬─┬─┬─┬─┬──┬──┬─┬─┬─┬──┬──┬──┐
│2│3│4│5│6│7│3│4│5│6│7│8│4│5│6│7│8│9│5│6│7│8│9│10│6│7│8│9│10│11│7│8│9│10│11│12│
└─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴──┴─┴─┴─┴─┴──┴──┴─┴─┴─┴──┴──┴──┘
 
Which honestly is closer than I've gotten for a while >.>
 
@GalenIvanov Not built-in, yet. Hopefully we'll add that operator (conjunction) in 18.0 (to be released in a year). Meanwhile, you can just define it yourself: Compose←{(⍵⍵ ⍺)⍺⍺(⍵⍵ ⍵)}:
⋄ Compose←{(⍵⍵ ⍺)⍺⍺(⍵⍵ ⍵)} ⋄ f←+Compose(×⍨) ⋄ ⎕←2 f 3
 
@Adám
13
 
2:28 PM
5 messages moved to trash
 
@Adám Thanks! So, for now I can repllicate the code for both sides if it's short :)
 
@GalenIvanov Yes. Since APL has been mainly explicit rather than tacit, we'd just assign the code a short name and apply it separately. However, now that APL allows tacit programming, we're slowly adding J's compositions.
@GalenIvanov Would you be interested in me starting my weekly APL lessons over from the beginning?
 
2:46 PM
@Adám why do I keep getting rank errors when I try to do stuff to this:
⎕←{{(+/¨⍺)}⌸,⍳⍵}6 6
 
@J.Sallé
2 3 4 5 6 7 3 4 5 6 7 8 4 5 6 7 8 9 5 6 7 8 9 10 6 7 8 9 10 11 7 8 9 10 11 12
 
Can't use bracket indexing on that, and I also get the error when trying to use ⍒⍋
 
@J.Sallé Can you give me a TIO link that errors?
@J.Sallé Why not? And TIO link please.
 
3:49 PM
@Adám hey sorry for the delay, my boss called me for a meeting >.>. Here's the link
I just figured it out btw, I was trying to do everything on the inner fn when I should be doing them on the outer one
 
@J.Sallé Yes, exactly.
 
My answer is getting more convoluted by the second >.>
I mean, look at this: {m[⍋m←{(+/¨⍺)}⌸,⍳⍵]}6 6
Pretty sure I'm mangling the language
 
@J.Sallé That looks fine, although personally I dislike inline assignments (just my personal opinion, nothing wrong per se). Did you see the TAO webinar?
@J.Sallé I just still don't understand why you're using Key as a no-op here; {m[⍋m←+/¨,⍳⍵]}6 6 is exactly the same.
 
@Adám I have not, I'll look it up later today.
@Adám and I'm using key there because Using the key operator ⌸, write an APL expression that, given an integer scalar or vector representing the number of sides on each of a set of dice, will return a histogram showing the distribution curve for the possible totals that can be rolled using those dice.
And I'm still experimenting with it
 
@J.Sallé It doesn't mean that you must force it in as a no-op, but that part of the problem will be easiest to solve with it.
 
4:04 PM
@Adám yeah, I know that. I'm still trying to figure it out >.>
 
@J.Sallé You're almost there.
 
I think I just can't see how it would apply to that problem yet
 
@J.Sallé Now you have all the possible sums, but you have duplicates.
 
@Adám Yes, I solved that with: {∪m[⍋m←{(+/¨⍺)}⌸,⍳⍵]}6 6
I think I can work it out from there, actually
 
@J.Sallé I knew you knew enough.
 
4:09 PM
What I'm thiking about now is that I need to put a dyadic somewhere in here: {∪m[⍋m←+/¨,⍳⍵]}6 6
But Key is kinda tricky to use in Dfns as it seems
 
Why is it ⊢∘⍳ here
not ⍳∘⊢
oh I see, ∘ is not atop
 
@FrownyFrog Exactly. I know, it is annoying, and there is no other built-in atop than (f g). I'm fairly certain we'll have an atop operator in 18.0.
 
Is it X ⊢ ⍳ Y?
or also affects X?
 
@Adám I DID IT
kind of
my result is actually coming up as:
 2 * 0 0 0 0 0
 3 * * 0 0 0 0
 4 * * * 0 0 0
 5 * * * * 0 0
 6 * * * * * 0
 7 * * * * * *
 8 * * * * * 0
 9 * * * * 0 0
10 * * * 0 0 0
11 * * 0 0 0 0
12 * 0 0 0 0 0
gotta remove them zeroes
 
@FrownyFrog Yes. The is to discard the left argument and use monadically.
@J.Sallé Looks like you're concatenating asterisks to the numbers instead of juxtaposing them.
 
4:25 PM
@Adám yup, that's exactly what I'm doing. I'll see if I can fix it
Now it works properly for all test cases
Holy shite that was hard
I kinda want to golf it now >.> but I won't
 
can you do sum of factorials for example? other than ⊢∘!+⊢∘!⍨
and no{}
I guess +/(!,)
oh, that’s the same question all over again
I didn’t notice Galen Ivanov’s message
 
4:43 PM
@FrownyFrog Yes, that should work, or (!⊣)+∘!.
@FrownyFrog Or +/∘!,
 
@J.Sallé hah that's where I'm at too
 
@Adám thank you
 
@Cowsquack the thing you need to remove the zeroes is really trivial actually
 
@Adám what should the box representation look like?
(for the result of 3)
 
1(,'
⎕←↑(1(,'*'))(2'**')(3'***')
 
4:47 PM
@Adám
┌─┬───┐
│1│*  │
├─┼───┤
│2│** │
├─┼───┤
│3│***│
└─┴───┘
 
@Cowsquack That style ^
 
thanks
it looks really different in atomic (IIRC) representation
┌→────────┐
↓   ┌→┐   │
│ 1 │*│   │
│   └─┘   │
│   ┌→─┐  │
│ 2 │**│  │
│   └──┘  │
│   ┌→──┐ │
│ 3 │***│ │
│   └───┘ │
└∊────────┘
 
@Adám Yes, I
 
@Cowsquack What is atomic representation? What you pasted looks like the same thing with ]box on -style=max or with ]display:
 
@Adám Yes, I'm interested in your APL lessons
 
4:52 PM
]display ↑(1(,'*'))(2'**')(3'***')
 
@Adám
DOMAIN ERROR
 
@DyalogAPL Stupid bot!
 
@Adám oh my, I'm getting confused with J terminology >_<
 
Problem 5 is giving me a headache D:
 
]display ↑(1(,''*''))(2''**'')(3''***'')
 
4:52 PM
@Adám
┌→────────┐
↓   ┌→┐   │
│ 1 │*│   │
│   └─┘   │
│   ┌→─┐  │
│ 2 │**│  │
│   └──┘  │
│   ┌→──┐ │
│ 3 │***│ │
│   └───┘ │
└∊────────┘
 
@J.Sallé Did you do number 4?
 
@Adám yeah, that was easy
 
@J.Sallé Obviously, I can't give you any specific hints, but I recommend going through the list of primitives (remember that each symbol is two!) and picking out those that do something related to (part of) the problem.
 
@Adám yeah, I'm currently trying to fiddle with and @
I'd love to have a "reverse key" though
 
@J.Sallé What would it do? Take a set of indices and their corresponding values, and constructs the array?
 
5:04 PM
@Adám yeah, that would be lovely
 
@J.Sallé Isn't that just {⍺@⍵⊢⍺}?
@J.Sallé Or ⌷⍨∘⊂∘⍋.
@J.Sallé Oh, those need one index for each value. You want a list of indices for each value?
⍞←'ABCD'{(⊂⍋∊⍵)⌷⍺/⍨≢¨⍵}(4 5) 2 (3 6) 1
 
@Adám DBCAAC
 
@J.Sallé Like this ^
 
@Adám well, what I was trying to do was to replicate each sign for each of that sign's days (30 or 31 times) and then work the result into a matrix I could index
I don't think that'd be very feasible though
I'll try your method
 
@J.Sallé Ah, yes, that'd work. So, what's the problem? They are already in their proper order, you just need to replicate them.
 
5:13 PM
@Adám well at the moment the problem is me being bad at date&time math >.>
 
@J.Sallé Ah you mean to convert a month,day into a dayOfYear?
 
also I think the code's gonna be gigantic that way >.>
@Adám yes
 
@J.Sallé Why don't you treat each month separately?
 
@Adám well I tried doing a 12 31⍴'signs' matrix but that didn't work out as I thought it would
Also I'd have to work that matrix out for 30-day months and then for february
Stuff of nightmares, basically
 
@J.Sallé You could do that too.
@J.Sallé Did you go through the primitives?
 
5:18 PM
@Adám yes, but I didn't find anything I thought would help much other than ⌷ and @
 
@J.Sallé OK, here is another general tip: Try to formulate in a single sentence of English (or Portuguese) what it is that you need to do.
 
@Adám well, I need to put each sign into a (very) ragged matrix so that I can index them >.>
That's kind of as far as I've got
 
@J.Sallé No, that's stating in English what your algorithm could be. Just say what you want to find out — what the question calls for.
 
@Adám I want to find out which sign corresponds to the given month,day pair
 
@J.Sallé Good. Now there's only one vague word in that sentence. Can you spot it?
 
5:25 PM
Corresponds?
 
@J.Sallé Exactly. Define it!
 
Huh... I'd define that as what the input coordinates would map to
but I think that's kinda broad?
 
@J.Sallé OK, fair enough. But you're still using one vague word. Which?
 
Map? I think
 
@J.Sallé Yes. See, you can do this! Now define it.
 
5:30 PM
This is hard. The input coordinates should return a single value from an array? idk
 
@J.Sallé OK, try this: If I give you a date, how would you go about finding its sign manually?
 
@Adám I'd look at the table the problem has given me, probably?
 
@J.Sallé And what if the date isn't in the table? E.g. today's date. It isn't mentioned.
 
Well it'd be between two dates that are in the table and I could figure it out
Oh god I'm gonna have to work with a bunch of guards, won't I?
I just realized that I can do it with logic operations instead of matrices
 
@J.Sallé Hey, you just defined what the mapping is!
 
5:37 PM
Okay I think I can do it now
I'll try something
 
@J.Sallé Great. Notice that I didn't actually give you any hints at all :-)
 
Yeah, you actually didn't. I like the way you teach because you kinda force me to be not-stupid about stuff >.>
 
@J.Sallé Thanks. I guess stupid does have a cure. Gotta go get a haircut. Good luck with it.
 
@Adám hah! Thanks a lot! I'll be going soon as well. Have a good weekend!
 
 
1 hour later…
6:55 PM
Problem five for what? Is this for the student competition?
 
@Zacharý Yes. Phase 1
 
Are you allowed to use ⎕R for phase 1 problems?
 
@Zacharý You can use anything that isn't clearly and explicitly prohibited.
 
Okay!
 

« first day (478 days earlier)      last day (2179 days later) »